Exemplo n.º 1
0
void out_subscribe(TTPtr self)
{
    WrappedModularInstancePtr	x = (WrappedModularInstancePtr)self;
    TTAddress   signalAddress;
    TTAddress	outputAddress;
    TTAddress	inputAddress;
    TTValue		v, args;
    TTNodePtr	returnedNode = NULL;
    TTNodePtr   returnedContextNode = NULL;
    TTAddress	returnedAddress, parentAddress;
    TTString	formatDescription, sInstance;
    t_object    *modelOrView = NULL;

#ifdef J_OUT_TILDE
    signalAddress = TTAddress("audio");
#endif

#ifdef J_OUT_MULTI
    signalAddress = TTAddress("audio");
#endif

#ifndef J_OUT_TILDE
#ifndef J_OUT_MULTI
    signalAddress = TTAddress("data");
#endif
#endif

    // edit "signal/out.instance" address
    outputAddress = signalAddress.appendAddress(TTAddress("out")).appendInstance(EXTRA->instance);

    // if the subscription is successful
    if (!jamoma_subscriber_create((t_eobj*)x, x->wrappedObject, outputAddress, x->subscriberObject, returnedAddress, &returnedNode, &returnedContextNode)) {

        // get patcher
        x->patcherPtr = ((t_eobj*)x)->o_canvas;

        // update instance symbol in case of duplicate instance
        EXTRA->instance = returnedAddress.getInstance();

        // observe /parent/in address in order to link/unlink with an Input object below
        returnedNode->getParent()->getAddress(parentAddress);
        inputAddress = parentAddress.appendAddress(TTAddress("in")).appendInstance(EXTRA->instance);
        x->wrappedObject.set("inputAddress", inputAddress);

        // get model or view object
        jamoma_patcher_get_model_or_view(x->patcherPtr, &modelOrView);

        // notify the model there is something new concerning signal processing
        if (modelOrView)
            object_method_typed(modelOrView, gensym("output_created"), 0, NULL, NULL);
    }
}
Exemplo n.º 2
0
void in_subscribe(TTPtr self)
{
	WrappedModularInstancePtr x = (WrappedModularInstancePtr)self;
	TTAddress   inputAddress;
	TTAddress   outputAddress;
	TTValue		v, args;
	TTNodePtr	returnedNode = NULL;
    TTNodePtr   returnedContextNode = NULL;
	TTAddress   returnedAddress, parentAddress;
	TTDataPtr	aData;
	TTString	formatDescription, sInstance;
	SymbolPtr	inDescription;
	
	inputAddress = TTAddress("in").appendInstance(EXTRA->instance);
	
	// if the subscription is successful
	if (!jamoma_subscriber_create((ObjectPtr)x, x->wrappedObject, inputAddress, &x->subscriberObject, returnedAddress, &returnedNode, &returnedContextNode)) {
		
		// get patcher
		x->patcherPtr = jamoma_patcher_get((ObjectPtr)x);
		
		// update instance symbol in case of duplicate instance
		EXTRA->instance = returnedAddress.getInstance();
		
		// observe /parent/out address in order to link/unlink with an Input object below
		returnedNode->getParent()->getAddress(parentAddress);
		outputAddress = parentAddress.appendAddress(TTAddress("out")).appendInstance(EXTRA->instance);
		x->wrappedObject->setAttributeValue(TTSymbol("outputAddress"), outputAddress);
		
#ifdef JCOM_IN_TILDE
		
		// make internal data to return amplitude
		v = TTValue(0., 1.);
		formatDescription = "instant amplitude of %s input";
		
		sInstance = EXTRA->instance.c_str();
		jamoma_edit_string_instance(formatDescription, &inDescription, sInstance);
			
		makeInternals_data(x, returnedAddress, TTSymbol("amplitude"), NULL, x->patcherPtr, kTTSym_return, (TTObjectBasePtr*)&aData);
		aData->setAttributeValue(kTTSym_type, kTTSym_decimal);
		aData->setAttributeValue(kTTSym_tag, kTTSym_generic);
		aData->setAttributeValue(kTTSym_rangeBounds, v);
		aData->setAttributeValue(kTTSym_description, TTSymbol(inDescription->s_name));
		aData->setAttributeValue(kTTSym_dataspace, TTSymbol("gain"));
		aData->setAttributeValue(kTTSym_dataspaceUnit, TTSymbol("linear"));
		
		// make internal data to parameter in/amplitude/active
		makeInternals_data(x, returnedAddress, TTSymbol("amplitude/active"), gensym("return_amplitude_active"), x->patcherPtr, kTTSym_parameter, (TTObjectBasePtr*)&aData);
		aData->setAttributeValue(kTTSym_type, kTTSym_integer);
		aData->setAttributeValue(kTTSym_tag, kTTSym_generic);
		v = TTValue((int)EXTRA->pollInterval);
		aData->setAttributeValue(kTTSym_valueDefault, v);
		v = TTValue(0, 1000);
		aData->setAttributeValue(kTTSym_rangeBounds, v);
		aData->setAttributeValue(kTTSym_rangeClipmode, kTTSym_low);
		aData->setAttributeValue(kTTSym_description, TTSymbol("set the sample rate of the amplitude follower"));
		
		// launch the clock to update amplitude regulary
		EXTRA->clock = clock_new(x, (method)in_update_amplitude);
		if (EXTRA->pollInterval)
			clock_delay(EXTRA->clock, EXTRA->pollInterval);
		
#endif
		
		// expose bypass and mute attributes of TTInput as TTData in the tree structure
		x->subscriberObject->exposeAttribute(x->wrappedObject, kTTSym_bypass, kTTSym_parameter, &aData);
		aData->setAttributeValue(kTTSym_type, kTTSym_boolean);
		aData->setAttributeValue(kTTSym_tag, kTTSym_generic);
		aData->setAttributeValue(kTTSym_description, TTSymbol("When active, this attribute bypasses the model's processing algtorithm, letting incoming signal pass through unaffected"));
		v = TTValue(0);
		aData->setAttributeValue(kTTSym_valueDefault, v);			
		
		x->subscriberObject->exposeAttribute(x->wrappedObject, kTTSym_mute, kTTSym_parameter, &aData);
		aData->setAttributeValue(kTTSym_type, kTTSym_boolean);
		aData->setAttributeValue(kTTSym_tag, kTTSym_generic);
		aData->setAttributeValue(kTTSym_description, TTSymbol("When active, this attribute turns off model's inputs."));
		v = TTValue(0);
		aData->setAttributeValue(kTTSym_valueDefault, v);
	}
}