TTErr TTScoreTimeProcessEndCallbackCreate(TTTimeProcessPtr timeProcess, TTObjectBasePtr *endCallback, TTScoreTimeProcessEndCallbackPtr endCallbackFunction)
{
    TTValue        v, none;
    TTValuePtr     endMessageBaton;
    TTMessagePtr   aMessage;
    TTErr          err;
    
    *endCallback = NULL;
    
    // create a TTCallback to observe when time process starts (using internal_TTScoreTimeProcessEndCallback)
    TTObjectBaseInstantiate(TTSymbol("callback"), endCallback, none);
    
    // store the function to call and the time process to pass
    endMessageBaton = new TTValue(TTPtr(timeProcess));    // endMessageBaton will be deleted during the callback destruction
    endMessageBaton->append(TTPtr(endCallbackFunction));
    
    (*endCallback)->setAttributeValue(kTTSym_baton, TTPtr(endMessageBaton));
    (*endCallback)->setAttributeValue(kTTSym_function, TTPtr(&internal_TTScoreTimeProcessEndCallback));
    
    // register for ProcessEnd message observation
    err = timeProcess->findMessage(kTTSym_ProcessEnd, &aMessage);
    
    if (!err)
        aMessage->registerObserverForNotifications(**endCallback);
    
    return err;
}
Exemple #2
0
TTObjectBase::~TTObjectBase()
{
	TTValue	v, u;

	// Delete message objects, then delete the hash that maintains them.
	messages->getKeys(v);
	for (TTUInt16 i=0; i<v.size(); i++) {
		TTSymbol	name(kTTSymEmpty);
		TTMessage*	message = NULL;

		name = v[i];
		messages->lookup(name, u);
		message = TTMessagePtr(TTPtr(u));
		delete message;
	}
	delete messages;

	// Delete attribute objects, then delete the hash that maintains them.
	attributes->getKeys(v);
	for (TTUInt16 i=0; i<v.size(); i++) {
		TTSymbol		name(kTTSymEmpty);
		TTAttribute*	attribute = NULL;

		name = v[i];
		attributes->lookup(name, u);
		attribute = TTAttributePtr(TTPtr(u));
		delete attribute;
	}
	delete attributes;
}
TTErr makeInternals_viewer(TTPtr self, TTAddress address, TTSymbol name, t_symbol *callbackMethod, TTObject& returnedViewer, TTBoolean deferlow)
{
	WrappedModularInstancePtr	x = (WrappedModularInstancePtr)self;
	TTValue			v, baton;
	TTAddress       adrs;
    
    // check the internals do not exist yet
    if (!x->internals->lookup(name, v)) {
        returnedViewer = v[0];
        JamomaDebug object_post((t_object*)x, "makeInternals_viewer : \"%s\" internal already exists", name.c_str());
        return kTTErrNone;
    }
	
	returnedViewer = TTObject(kTTSym_Viewer);
    
    baton = TTValue(TTPtr(x), TTPtr(callbackMethod), deferlow);
    returnedViewer.set(kTTSym_baton, baton);
	returnedViewer.set(kTTSym_function, TTPtr(&jamoma_callback_return_value));
	
	// edit address
	adrs = address.appendAddress(TTAddress(name));
	
	// default registration case : store object only (see in unregister method)
	x->internals->append(name, returnedViewer);
    
    // set address attribute (after registration as the value can be updated in the same time)
	returnedViewer.set(kTTSym_address, adrs);
    
    JamomaDebug object_post((t_object*)x, "makes internal \"%s\" viewer to bind on : %s", name.c_str(), adrs.c_str());
    
	return kTTErrNone;
}
TTErr makeInternals_explorer(TTPtr self, TTSymbol name, t_symbol *callbackMethod, TTObject& returnedExplorer, TTBoolean deferlow)
{
	WrappedModularInstancePtr	x = (WrappedModularInstancePtr)self;
	TTValue		v, args, baton;
	TTObject    returnValueCallback;
    
    // check the internals do not exist yet
    if (!x->internals->lookup(name, v)) {
        returnedExplorer = v[0];
        JamomaDebug object_post((t_object*)x, "makeInternals_explorer : \"%s\" internal already exists", name.c_str());
        return kTTErrNone;
    }
	
	// prepare arguments
	returnValueCallback = TTObject("callback");
    
	baton = TTValue(TTPtr(x), TTPtr(callbackMethod), deferlow);
    
	returnValueCallback.set(kTTSym_baton, baton);
	returnValueCallback.set(kTTSym_function, TTPtr(&jamoma_callback_return_value));
	args.append(returnValueCallback);
	
	args.append((TTPtr)jamoma_explorer_default_filter_bank());
	
	returnedExplorer = TTObject(kTTSym_Explorer, args);
	
	// default registration case : store object only (see in unregister method)
	x->internals->append(name, returnedExplorer);
    
    JamomaDebug object_post((t_object*)x, "makes internal \"%s\" explorer", name.c_str());
    
	return kTTErrNone;
}
TTErr makeInternals_data(TTPtr self, TTAddress address, TTSymbol name, t_symbol *callbackMethod, TTPtr context, TTSymbol service, TTObject& returnedData, TTBoolean deferlow)
{
	WrappedModularInstancePtr	x = (WrappedModularInstancePtr)self;
	TTValue			baton, v, out;
	TTAddress       dataAddress, dataRelativeAddress;
    TTNodePtr       dataNode;
    
	returnedData = TTObject(kTTSym_Data, service);
    
    baton = TTValue(TTPtr(x), TTPtr(callbackMethod), deferlow);
	
    returnedData.set(kTTSym_baton, baton);
	returnedData.set(kTTSym_function, TTPtr(&jamoma_callback_return_value));
	
	// absolute registration
	dataAddress = address.appendAddress(TTAddress(name));
    v = TTValue(dataAddress, returnedData, context);
	out = MaxApplication.send("ObjectRegister", v);
	
    // retreive relative effective address
	dataAddress = out[0];
    dataNode = TTNodePtr((TTPtr)out[1]);
    dataNode->getAddress(dataRelativeAddress, address);
    
	// absolute registration case : set the address in second position (see in unregister method)
	v = TTValue(returnedData, dataAddress);
	x->internals->append(dataRelativeAddress, v);
	
	JamomaDebug object_post((t_object*)x, "makes internal \"%s\" %s at : %s", dataRelativeAddress.c_str(), service.c_str(), dataAddress.c_str());
	
	return kTTErrNone;
}
void TTAudioGraphSource::create()
{
	TTObjectBaseInstantiate(TT("callback"), &mCallbackHandler, kTTValNONE);
	
	mCallbackHandler->setAttributeValue(TT("function"), TTPtr(&TTAudioGraphSourceObserverCallback));
	mCallbackHandler->setAttributeValue(TT("baton"), TTPtr(this));	
}
TTErr TTScoreTimeEventStatusCallbackCreate(TTTimeEventPtr timeEvent, TTObjectBasePtr *statusCallback, TTScoreTimeEventStatusCallbackPtr statusCallbackFunction)
{
    TTValue         v, none;
    TTValuePtr      statusAttributeBaton;
    TTAttributePtr  anAttribute;
    TTErr           err;
    
    statusCallback = NULL;
    
    // Create a TTCallback to observe time event status attribute (using internal_TTScoreTimeEventStatusCallback)
    TTObjectBaseInstantiate(TTSymbol("callback"), statusCallback, none);
    
    statusAttributeBaton = new TTValue(TTPtr(timeEvent)); // statusAttributeBaton will be deleted during the callback destruction
    statusAttributeBaton->append(TTPtr(statusCallbackFunction));
    
    (*statusCallback)->setAttributeValue(kTTSym_baton, TTPtr(statusAttributeBaton));
    (*statusCallback)->setAttributeValue(kTTSym_function, TTPtr(&internal_TTScoreTimeEventStatusCallback));
    
    // register for status attribute observation
    err = timeEvent->findAttribute(kTTSym_status, &anAttribute);
    
    if (!err)
        anAttribute->registerObserverForNotifications(**statusCallback);
    
    return err;
}
Exemple #8
0
UnpackPtr UnpackNew(SymbolPtr msg, AtomCount argc, AtomPtr argv)
{
    UnpackPtr	self;
	TTValue	v;
	TTErr	err;
	
    self = UnpackPtr(object_alloc(sUnpackClass));
    if (self) {
    	object_obex_store((void*)self, _sym_dumpout, (ObjectPtr)outlet_new(self, NULL));	// dumpout	
		self->graphOutlets[0] = outlet_new(self, NULL);
		
		v.setSize(2);
		v.set(0, TT("graph.output"));
		v.set(1, TTUInt32(1));
		err = TTObjectInstantiate(TT("graph.object"), (TTObjectPtr*)&self->graphObject, v);
		
		if (!self->graphObject->mKernel) {
			object_error(SELF, "cannot load Jamoma object");
			return NULL;
		}
		
		err = TTObjectInstantiate(TT("Callback"), (TTObjectPtr*)&self->callback, kTTValNONE);
		self->callback->setAttributeValue(TT("Function"), TTPtr(&UnpackGraphCallback));
		self->callback->setAttributeValue(TT("Baton"), TTPtr(self));	
		// dynamically add a message to the callback object so that it can handle the 'dictionaryReceived' notification
		self->callback->registerMessage(TT("dictionaryReceived"), (TTMethod)&TTCallback::notify, kTTMessagePassValue);
		// tell the graph object that we want to watch it
		self->graphObject->mKernel->registerObserverForNotifications(*self->callback);
		
		attr_args_process(self, argc, argv);
	}
	return self;
}
Exemple #9
0
UnpackPtr UnpackNew(t_symbol *msg, long argc, t_atom* argv)
{
    UnpackPtr	self;
	TTValue		v, none;
	TTErr		err;
	
    self = UnpackPtr(object_alloc(sUnpackClass));
    if (self) {
    	object_obex_store((void*)self, _sym_dumpout, (t_object*)outlet_new(self, NULL));	// dumpout	
		self->graphOutlets[0] = outlet_new(self, NULL);
		
		v.resize(2);
		v[0] = "graph.output";
		v[1] = 1;
		err = TTObjectBaseInstantiate(TT("graph.object"), (TTObjectBasePtr*)&self->graphObject, v);
		
		if (!self->graphObject->mKernel.valid()) {
			object_error(SELF, "cannot load Jamoma object");
			return NULL;
		}
		
		self->callback = new TTObject("callback");
		self->callback->set(TT("function"), TTPtr(&UnpackGraphCallback));
		self->callback->set(TT("baton"), TTPtr(self));
		
		// Dynamically add a message to the callback object so that it can handle the 'dictionaryReceived' notification
		self->callback->instance()->registerMessage(TT("dictionaryReceived"), (TTMethod)&TTCallback::notify, kTTMessagePassValue);
		// Tell the graph object that we want to watch it
		self->graphObject->mKernel.registerObserverForNotifications(*self->callback);
		
		attr_args_process(self, argc, argv);
	}
	return self;
}
JamomaError RampLib::createUnit(const TTSymbol* unitName, RampUnit **unit, RampUnitCallback callback, void* baton)
{
	TTValue v;
	
	v.setSize(2);
	v.set(0, TTPtr(callback));
	v.set(1, TTPtr(baton));
	
	// These should be alphabetized
	if (unitName == TT("async"))
		TTObjectInstantiate(TT("AsyncRamp"), (TTObjectPtr*)unit, v);
		//*unit = (RampUnit*) new AsyncRamp(callback, baton);
	else if (unitName == TT("none"))
		TTObjectInstantiate(TT("NoneRamp"), (TTObjectPtr*)unit, v);
//		*unit = (RampUnit*) new NoneRamp(callback, baton);
	else if (unitName == TT("queue"))
		TTObjectInstantiate(TT("QueueRamp"), (TTObjectPtr*)unit, v);
//		*unit = (RampUnit*) new QueueRamp(callback, baton);
	else if (unitName == TT("scheduler"))
		TTObjectInstantiate(TT("SchedulerRamp"), (TTObjectPtr*)unit, v);
//		*unit = (RampUnit*) new SchedulerRamp(callback, baton);
	else {
		// Invalid function specified default to linear
		error("Jamoma RampLib: Invalid RampUnit ( %s ) specified", (char*)unitName);
		TTObjectInstantiate(TT("NoneRamp"), (TTObjectPtr*)unit, v);
//		*unit = (RampUnit*) new NoneRamp(callback, baton);
	}
	return JAMOMA_ERR_NONE;
}
void TTGraphDestination::create()
{
	TTObjectBaseInstantiate(TT("callback"), &mCallbackHandler, kTTValNONE);
	
	mCallbackHandler->setAttributeValue(TT("owner"), TT("TTGraphDestination"));
	mCallbackHandler->setAttributeValue(TT("function"), TTPtr(&TTGraphDestinationObserverCallback));
	mCallbackHandler->setAttributeValue(TT("baton"), TTPtr(this));	
}
Exemple #12
0
void init_subscribe(t_init *x)
{
	TTValue     v, args, none;
	TTAddress   contextAddress = kTTAdrsEmpty;
    TTAddress   returnedAddress;
    TTNodePtr   returnedNode = NULL;
    TTNodePtr   returnedContextNode = NULL;
	TTObject    returnAddressCallback, returnValueCallback, empty;
	
	// for relative address
	if (x->address.getType() == kAddressRelative) {

		if (!jamoma_subscriber_create((t_object*)x, empty, x->address, x->subscriberObject, returnedAddress, &returnedNode, &returnedContextNode)) {
            
			// get the context address to make
			// a receiver on the contextAddress:initialized attribute
			x->subscriberObject.get("contextAddress", v);
			contextAddress = v[0];
		}
		
		// bind on the /model:address parameter (view patch) or return (model patch)
		if (contextAddress != kTTAdrsEmpty) {
			
			// Make a TTReceiver object
			returnAddressCallback = TTObject("callback");
			returnAddressCallback.set(kTTSym_baton, TTPtr(x));
			returnAddressCallback.set(kTTSym_function, TTPtr(&jamoma_callback_return_address));
			args.append(returnAddressCallback);
			
			returnValueCallback = TTObject("callback");
			returnValueCallback.set(kTTSym_baton, TTPtr(x));
			returnValueCallback.set(kTTSym_function, TTPtr(&jamoma_callback_return_value));
			args.append(returnValueCallback);
			
			x->initReceiver = TTObject(kTTSym_Receiver, args);
			
			x->initReceiver.set(kTTSym_address, contextAddress.appendAttribute(kTTSym_initialized));
		}
		
		// while the context node is not registered : try to binds again :(
		// (to -- this is not a good way todo. For binding we should make a subscription 
		// to a notification mechanism and each time an TTObjet subscribes to the namespace
		// using jamoma_subscriber_create we notify all the externals which have used 
		// jamoma_subscriber_create with NULL object to bind)
		else {
			
			// release the subscriber
			x->subscriberObject = TTObject();
			
			// The following must be deferred because we have to interrogate our box,
			// and our box is not yet valid until we have finished instantiating the object.
			// Trying to use a loadbang method instead is also not fully successful (as of Max 5.0.6)
			defer_low((t_object*)x, (method)init_subscribe, NULL, 0, 0);
		}
	}
	else
		object_error((t_object*)x, "can't bind because %s is not a relative address", x->address.c_str());
}
Exemple #13
0
TTErr TTEnvironment::registerClass(const TTSymbolPtr className, const TTString& tagString, const TTObjectInstantiationMethod anInstantiationMethod)
{
	TTValue		v((TTString&)tagString);	// The tags to be associated with the class we are registering.
	TTValue		tagObjects;					// Contains a TTList of objects in the environment with the given tag.
	TTClassPtr	theClass;
	TTErr		err;
	TTList*		classNamesForTag;			// The TTList contained by tagObjects
	TTUInt16	size;
	TTSymbolPtr	tag;
	TTValue		result;

	err = classes->lookup(className, result);
	
	// If a class is already registered with this name, then we do not want to register another class with the same name!
	if (err == kTTErrValueNotFound) {
		
		// 1. Turn the string into an array of symbols
		v.transformCSVStringToSymbolArray();
		
		// 2. Create the class and associate it with its name
		theClass = new TTClass(className, v, anInstantiationMethod);
		
		// 3. For each symbol in the TTValue array...
		size = v.getSize();
		for (TTUInt16 i=0; i<size; i++) {
			v.get(i, &tag);
			
			// 4. Look to see if this tag exists yet
			err = tags->lookup(tag, tagObjects);
			if (!err) {
				classNamesForTag = (TTList*)(TTPtr(tagObjects));
				
				// TODO: The following code demonstrates so extreme lameness that we need to evaluate.
				//	First, we should probably just do this section of code with TTValue instead of TTList (but we needed code to test TTList)
				//	Second, TTList is taking references but keeping things internally as pointers, which leads to lots of confusion
				//	Third, we have to pass objects that are permanent - so no temporaries are allowed unless we make TTList do a copy
				//	etc.

				// TODO: We need to factor out a function to add a tag for a named class (or a given class ptr)
				
				//classNamesForTag->append(className);
				classNamesForTag->append(*new TTValue(className));
			}
			else {
				classNamesForTag = new TTList;
				tagObjects = TTPtr(classNamesForTag);
				tags->append(tag ,tagObjects);
				classNamesForTag->append(*new TTValue(className));
			}
		}	
		
		// 4. Register it
		err = registerClass(theClass);
	}
	return err;
}
Exemple #14
0
void
DemoApp::SetupScore()
{
    TTValue     args, out;
    TTObject    xmlHandler("XmlHandler");
    
    TTLogMessage("\n*** Initialisation of Score environnement ***\n");
    /////////////////////////////////////////////////////////////////////
    
    // Init the Score library (passing the folder path where all the dylibs are)
    TTScoreInit("/usr/local/jamoma");
    
    
    TTLogMessage("\n*** Reading of an interactive scenario file ***\n");
    /////////////////////////////////////////////////////////////////////
    
    // Create an empty Scenario
    mScenario = TTObject("Scenario");
    
    // Read DemoScenario1.score file to fill mScenario
    xmlHandler.set("object", mScenario);
    xmlHandler.send("Read", "../DemoScenario.score", out);
    
    
    TTLogMessage("\n*** Prepare scenario observation ***\n");
    /////////////////////////////////////////////////////////////////////
    
    // Create a callback for the "EventStatusChanged" notification sent by each event
    mEventStatusChangedCallback = TTObject("callback");
    mEventStatusChangedCallback.set("baton", TTPtr(this));
    mEventStatusChangedCallback.set("function", TTPtr(&DemoAppEventStatusChangedCallback));
    mEventStatusChangedCallback.set("notification", TTSymbol("EventStatusChanged"));
    
    // Get all events of the scenario and attach a callback to them
    TTValue timeEvents;
    mScenario.get("timeEvents", timeEvents);
    
    for (TTElementIter it = timeEvents.begin() ; it != timeEvents.end() ; it++) {
        TTObject event = TTElement(*it);
        event.registerObserverForNotifications(mEventStatusChangedCallback);
    }
    
    
    TTLogMessage("\n*** Start scenario execution ***\n");
    /////////////////////////////////////////////////////////////////////
    
    // Set the execution speed of the scenario
    mScenario.set("speed", 2.);
    
    // Start the scenario
    mScenario.send("Start");
    
    // Poll Scenario information
    mPollingThread = new TTThread(TTThreadCallbackType(DemoAppScenarioPollingThread), this);
}
Exemple #15
0
TTErr TTObjectBase::registerAttribute(const TTSymbol name, const TTObjectBasePtr newGetterObject, const TTObjectBasePtr newSetterObject)
{
	TTAttribute* newAttribute = new TTAttribute(name, newGetterObject, newSetterObject);

	attributes->append(name, TTPtr(newAttribute));
	return kTTErrNone;
}
Exemple #16
0
TTErr TTObjectBase::registerAttribute(const TTSymbol name, const TTDataType type, void* address, TTGetterMethod getter, TTSetterMethod setter)
{
	TTAttribute* newAttribute = new TTAttribute(name, type, address, getter, setter);

	attributes->append(name, TTPtr(newAttribute));
	return kTTErrNone;
}
Exemple #17
0
PlugOutPtr PlugOutNew(SymbolPtr msg, AtomCount argc, AtomPtr argv)
{
    PlugOutPtr	self = PlugOutPtr(object_alloc(sPlugOutClass));
	TTValue		v;
	TTErr		err;

    if (self) {
		v.setSize(2);
		v.set(0, TT("plugtastic.output"));
		v.set(1, 2);
		err = TTObjectBaseInstantiate(TT("audio.object"), (TTObjectBasePtr*)&self->audioGraphObject, v);

		v = TTPtr(self->audioGraphObject);

		object_obex_store((void*)self, _sym_dumpout, (object*)outlet_new(self, NULL));
		self->audioGraphOutlet = outlet_new(self, "audio.connect");
		self->qelem = qelem_new(self, (method)PlugOutQFn);
		
		object_obex_lookup(self, GENSYM("#P"), &self->patcher);
		self->pluginName = object_attr_getsym(self->patcher, _sym_name);
		self->pluginVersion = GENSYM("1.0");
		self->pluginVersionHex = GENSYM("0x00010000");
		self->pluginManufacturer = GENSYM("Plugtastic");
		self->pluginManufacturerCode = GENSYM("74Ob");
		self->pluginID = GENSYM("ftmp");
		
		attr_args_process(self, argc, argv);
	}
	return self;
}
Exemple #18
0
TTErr TTSampleMatrix::load(const TTValue& input, TTValue& unusedOutput)
{
    /* * * 
     Beware this method is still in progress
     It will eventually work with the TTSoundfileLoader class
     * * */
    
    TTValue			inputWithPointerPrepended = input;
    TTObjectBase*	objectBasePtrToSampleMatrix = (TTObjectBase*)(TTPtr(this));
	
    inputWithPointerPrepended.prepend(objectBasePtrToSampleMatrix);
    
    try {
        
        // first instantiate the SoundfileLoader object
        TTAudioObject fileToLoad("soundfile.loader");
		
		if (fileToLoad.valid())
			// then pass along the updated TTValue to its load() method
			return fileToLoad.send("load", inputWithPointerPrepended);
        else
			return kTTErrInstantiateFailed;
    }
	catch (...) {
        return kTTErrInstantiateFailed;
    }

}
Exemple #19
0
TTErr
DemoAppDataReturnValueCallback(const TTValue& baton, const TTValue& value)
{
    DemoApp*    demoApp = (DemoApp*)TTPtr(baton[0]);
    TTObject    anObject = baton[1];
    
	// Reteive which data has been updated
    if (anObject.instance() == demoApp->mDataDemoParameter.instance()) {
        
        // print the returned value
        TTLogMessage("/myParameter has been updated to %s \n", value.toString().data());
        return kTTErrNone;
    }
    
    if (anObject.instance() == demoApp->mDataDemoMessage.instance()) {
        
        // print the returned value
        TTLogMessage("/myMessage has been updated to %s \n", value.toString().data());
        return kTTErrNone;
    }
    
    if (anObject.instance() == demoApp->mDataDemoReturn.instance()) {
        
        // print the returned value
        TTLogMessage("/myReturn has been updated to %s \n", value.toString().data());
        return kTTErrNone;
    }
    
    return kTTErrGeneric;
}
TTErr makeInternals_receiver(TTPtr self, TTAddress address, TTSymbol name, t_symbol *callbackMethod, TTObject& returnedReceiver, TTBoolean deferlow, TTBoolean appendNameAsAttribute)
{
	WrappedModularInstancePtr	x = (WrappedModularInstancePtr)self;
	TTValue			v, args, baton;
	TTObject        returnValueCallback, empty;
	TTAddress       adrs;
    
    // check the internals do not exist yet
    if (!x->internals->lookup(name, v)) {
        returnedReceiver = v[0];
        JamomaDebug object_post((t_object*)x, "makeInternals_receiver : \"%s\" internal already exists", name.c_str());
        returnedReceiver.send("Get");
        return kTTErrNone;
    }
	
	// prepare arguments
	
	// we don't want the address back
	args.append(empty);
	
	returnValueCallback = TTObject("callback");
    
	baton = TTValue(TTPtr(x), TTPtr(callbackMethod), deferlow);
    
	returnValueCallback.set(kTTSym_baton, baton);
	returnValueCallback.set(kTTSym_function, TTPtr(&jamoma_callback_return_value));
	args.append(returnValueCallback);
	
	returnedReceiver = TTObject(kTTSym_Receiver, args);
	
	// edit address
	if (appendNameAsAttribute)
        adrs = address.appendAttribute(name);
    else
        adrs = address.appendAddress(TTAddress(name.c_str()));
	
	// default registration case : store object only (see in unregister method)
	x->internals->append(name, returnedReceiver);
    
    // set address attribute (after registration as the value can be updated in the same time)
    returnedReceiver.set(kTTSym_address, adrs);
    
    JamomaDebug object_post((t_object*)x, "makes internal \"%s\" receiver to bind on : %s", name.c_str(), adrs.c_str());
    
	return kTTErrNone;
}
Exemple #21
0
NSPStatus 
Namespace::namespacePresetsLoadFromXml(std::string filepath)
{
	TTValue				args, v, attr;
//	TTPresetManagerPtr	returnedPresetManager	= NULL;
	TTXmlHandlerPtr		aXmlHandler				= NULL;
	TTHashPtr			toStore					= new TTHash();
	TTObjectPtr			testObjectCallback;
//	TTValuePtr			testObjectBaton;
	
	// Instanciate a PresetManager
	args.append(GalamusApplication);	// add application arg
	
	testObjectCallback = NULL;			// without this, TTObjectInstantiate try to release an oldObject that doesn't exist ... Is it good ?
	TTObjectInstantiate(TTSymbol("callback"),			&testObjectCallback,					kTTValNONE);
//	testObjectBaton = new TTValue(TTPtr(x));
//	testObjectCallback->setAttributeValue(kTTSym_baton, TTPtr(testObjectBaton));
//	testObjectCallback->setAttributeValue(kTTSym_function, TTPtr(&jamoma_presetManager_test_object_callback));
	args.append(testObjectCallback);	// add callback method arg (we don't need here)
	
	// Here we decide to store only Value and Priority attributes for Data object
	attr = TTValue(kTTSym_value);
	attr.append(kTTSym_priority);
	//toStore->append(TTSymbol("Data"), attr);
	
	args.append((TTPtr)toStore);		// add storing hash table arg
	
	m_presetManager = NULL;
	TTObjectInstantiate(TTSymbol("PresetManager"),	TTObjectHandle(&m_presetManager), args);
	
	// Instanciate a XmlHandler
	args.clear();
	TTObjectInstantiate(TTSymbol("XmlHandler"),		TTObjectHandle(&aXmlHandler),			args);
	
	// Set XmlHandler being used by PresetManager
	v = TTValue(TTPtr(m_presetManager));
	aXmlHandler->setAttributeValue(kTTSym_object, v);
	aXmlHandler->setAttributeValue(TTSymbol("headerNodeName"),	TT(XML_PRESET_HEADER_NODE_NAME));
	aXmlHandler->setAttributeValue(TTSymbol("version"),			TT(XML_PRESET_VERSION));
	aXmlHandler->setAttributeValue(TTSymbol("xmlSchemaLocation"), TT(XML_PRESET_SCHEMA_LOCATION));
	
	v.clear();
	v.append(TT(filepath));
	aXmlHandler->sendMessage(TTSymbol("Read"), v);//TODO : return an error code if fail
	
//	TTValue tmp;
//	m_presetManager->getAttributeValue(TTSymbol("names"), tmp);
//	
//	for (int i = 0; i < tmp.getSize(); i++) {
//		TTString s;
//		tmp.toString();
//		tmp.get(i, s);
//		
//		std::cout << s << std::endl;
//	}
	
	return NSP_NO_ERROR;
}
Exemple #22
0
TTErr TTObjectBase::registerAttribute(const TTSymbol name, const TTDataType type, void* address)
{
	TTAttribute* newAttribute = new TTAttribute(name, type, address);

	newAttribute->setGetterFlags(kTTAttrPassObject);
	newAttribute->setSetterFlags(kTTAttrPassObject);
	attributes->append(name, TTPtr(newAttribute));
	return kTTErrNone;
}
Exemple #23
0
TTErr TTObjectBase::registerMessage(const TTSymbol name, TTMethod method, TTMessageFlags flags)
{
	TTMessagePtr newMessage = new TTMessage(name, method, flags);

	if (ttEnvironment->mDebugMessaging)
		logMessage("Registering Message '%s' with flags = %ld, message count for this object is now %ld\n", name.c_str(), kTTMessageDefaultFlags, messages->getSize());

	messages->append(name, TTPtr(newMessage));
	return kTTErrNone;
}
Exemple #24
0
TTErr TTObjectBase::findAttribute(const TTSymbol name, TTAttribute** attr)
{
	TTValue v;
	TTErr	err = kTTErrNone;

	err = attributes->lookup(name, v);
	if (err == kTTErrNone)
		*attr = TTAttributePtr(TTPtr(v));
	else
		err = kTTErrInvalidAttribute;
	return err;
}
Exemple #25
0
TTErr TTObjectBase::findMessage(const TTSymbol name, TTMessage** message)
{
	TTValue v;
	TTErr	err = kTTErrNone;

	err = messages->lookup(TTSymbol(name), v);
	if (!err) {
		*message = TTMessagePtr(TTPtr(v));
		return kTTErrNone;
	}
	else
		return kTTErrInvalidAttribute;
}
Exemple #26
0
TTErr TTObjectBase::registerAttributeProperty(const TTSymbol attributeName, const TTSymbol propertyName, const TTValue& initialValue, TTGetterMethod getter, TTSetterMethod setter)
{
	TTAttributePtr	theAttr = NULL;
	TTValue			v;
	TTErr			err;

	err = attributes->lookup(attributeName, v);
	if (!err) {
		theAttr = TTAttributePtr(TTPtr(v));
		err = theAttr->registerAttribute(propertyName, kTypeLocalValue, NULL, getter, setter);
		theAttr->setAttributeValue(propertyName, (TTValue&)initialValue);
	}
	return err;
}
Exemple #27
0
TTErr TTObjectBase::extendAttribute(const TTSymbol name, const TTObjectBasePtr extendedObject, const TTSymbol extendedName)
{
	TTAttributePtr	extendedAttribute = NULL;
	TTAttributePtr	newAttribute;
	TTErr			err = extendedObject->findAttribute(extendedName, &extendedAttribute);

	if (!err) {
		newAttribute = new TTAttribute(extendedAttribute, extendedObject);
		attributes->append(name, TTPtr(newAttribute));
		return kTTErrNone;
	}
	else
		return err;
}
void data_array_create(TTPtr self, TTObject& returnedData, TTSymbol service, TTUInt32 index)
{
    WrappedModularInstancePtr	x = (WrappedModularInstancePtr)self;
    t_symbol    *iAdrs;
	TTValue     baton;

	returnedData = TTObject(kTTSym_Data, service);
    
    jamoma_edit_numeric_instance(x->arrayFormatInteger, &iAdrs, index);
    
    baton = TTValue(self, index, TTSymbol(iAdrs->s_name));
	returnedData.set(kTTSym_baton, baton);
	returnedData.set(kTTSym_function, TTPtr(&data_array_return_value));
}
Exemple #29
0
TTErr TTObjectBase::registerMessageProperty(const TTSymbol messageName, const TTSymbol propertyName, const TTValue& initialValue, TTGetterMethod getter, TTSetterMethod setter)
{
	TTMessagePtr	theMessage = NULL;
	TTValue			v;
	TTErr			err;

	err = messages->lookup(messageName, v);
	if (err == kTTErrNone) {
		theMessage = TTMessagePtr(TTPtr(v));
		err = theMessage->registerAttribute(propertyName, kTypeLocalValue, NULL, getter, setter);
		theMessage->setAttributeValue(propertyName, (TTValue&)initialValue);
	}
	return err;
}
Exemple #30
0
NSPStatus 
Namespace::namespaceMappingLoadFromXml(std::string filepath)
{
	// Parse xml file to instantiate TTData for each input 
	XMLNode xMainNode;
	XMLError err = XMLNode::openFileHelper(&xMainNode, filepath.c_str(), XML_MAPPING_HEADER_NODE_NAME);
	
	if (err == eXMLErrorFileNotFound)
		return NSP_FILE_NOTFOUND;
	if (err == eXMLErrorFirstTagNotFound)
		return NSP_XMLPARSING_ERROR;
	
	int nChild = xMainNode.nChildNode();
	
	// For each child of the node create a mapping parameter according to the input attribute
	for (int i = 0; i < nChild; i++) {
		XMLNode child = xMainNode.getChildNode(i);
		namespaceParameterCreate(child.getAttribute("input"), NULL);
	}
	
	// Instanciate a MapperManager
	TTValue				args, v;
	TTMapperManagerPtr	returnedMapperManager	= NULL;
	TTXmlHandlerPtr		aXmlHandler				= NULL;
	
	args.append(GalamusApplication);
	TTObjectInstantiate(TTSymbol("MapperManager"),	TTObjectHandle(&returnedMapperManager), args);
	
	// Instanciate a XmlHandler
	args.clear();
	TTObjectInstantiate(TTSymbol("XmlHandler"),		TTObjectHandle(&aXmlHandler),			args);
	
	// Set XmlHandler being used by MapperManager
	v = TTValue(TTPtr(returnedMapperManager));
	aXmlHandler->setAttributeValue(kTTSym_object, v);
	aXmlHandler->setAttributeValue(TTSymbol("headerNodeName"),	TT(XML_MAPPING_HEADER_NODE_NAME));
	aXmlHandler->setAttributeValue(TTSymbol("version"),			TT(XML_MAPPING_VERSION));
	aXmlHandler->setAttributeValue(TTSymbol("xmlSchemaLocation"), TT(XML_MAPPING_SCHEMA_LOCATION));
	
	v.clear();
	v.append(TT(filepath));
	aXmlHandler->sendMessage(TTSymbol("Read"), v);//TODO : return an error code if fail
	
//	v.clear();
//	v.append(TTSymbol("writtenMapping.xml"));
//	aXmlHandler->sendMessage(TTSymbol("Write"), v);
	
	return NSP_NO_ERROR;
}