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;
}
Exemple #2
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 #3
0
void TTValue::test()
{
    // Test == operator (was broken prior to 2009-12-03)
    // TODO: replace with test-assertions

    TTValue a = TTValue(2);
    TTValue c = TTValue(2);
    TTValue b = TTValue(33);

    TT_ASSERT("== comparison for the same value", bool(a == c));
    TT_ASSERT("== comparison for different values", !bool(a == b));
}
Exemple #4
0
TTAttribute::TTAttribute(TTAttributePtr extendedAttribute, const TTObjectBasePtr extendedObject)
: TTObjectBase(TTValue()), name(extendedAttribute->name), type(extendedAttribute->type), getterObject(extendedObject), setterObject(extendedObject), getterFlags(kTTAttrPassObject), setterFlags(kTTAttrPassObject),
readOnly(extendedAttribute->readOnly), rangeLowBound(extendedAttribute->rangeLowBound), rangeHighBound(extendedAttribute->rangeHighBound), rangeChecking(extendedAttribute->rangeChecking), description(kTTSymEmpty), mDefaultValue(0)
{
	getter = (TTGetterMethod)&TTAttribute::extendedGetter;
	setter = (TTSetterMethod)&TTAttribute::extendedSetter;
}
Exemple #5
0
TTAttribute::TTAttribute(const TTSymbol& newName, const TTObjectBasePtr newGetterObject, const TTObjectBasePtr newSetterObject)
: TTObjectBase(TTValue()), name(newName), type(kTypeNone), getterObject(newGetterObject), setterObject(newSetterObject), getterFlags(kTTAttrPassObject), setterFlags(kTTAttrPassObject),
  readOnly(NO), rangeLowBound(0.0), rangeHighBound(1.0), rangeChecking(kTTSym_none), hidden(NO), description(kTTSymEmpty), mDefaultValue(0)
{
	getter = (TTGetterMethod)&TTAttribute::callbackGetter;
	setter = (TTSetterMethod)&TTAttribute::callbackSetter;
}
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_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;
}
void model_preset_amenities(TTPtr self)
{
	WrappedModularInstancePtr	x = (WrappedModularInstancePtr)self;
    TTAddress                   modelAdrs;
	TTValue						v, a, args, none;
    TTAddress                   presetAddress;

    // get model:address
    EXTRA->modelInfo->get(kTTSym_address, v);
    modelAdrs = v[0];

    // create the preset manager
	jamoma_presetManager_create((t_object*)x, *EXTRA->presetManager);

    // suscribe it under a preset node
    presetAddress = modelAdrs.appendAddress(TTAddress("preset"));

    args = TTValue(presetAddress, *EXTRA->presetManager, x->patcherPtr);

    if (!MaxApplication.send("ObjectRegister", args, none)) {

        EXTRA->presetManager->set(kTTSym_address, modelAdrs);

        defer_low(x, (method)model_preset_default, 0, 0, 0L);
    }
}
Exemple #9
0
TTErr TTDictionaryBase::clear()
{
//	mList->clear();
	mMap.clear();
	sendNotification("change", TTValue());
	return kTTErrNone;
}
TTErr TukeyWindow::test(TTValue& returnedTestInfo)
{
	int					errorCount = 0;
	int					testAssertionCount = 0;
	int					badSampleCount = 0;
	TTAudioObjectBasePtr	windowObject = NULL;
	TTAudioSignalPtr	input = NULL;
	TTAudioSignalPtr	output = NULL;
	int					N = 128;
	TTValue				v;
	TTFloat64			testAlpha = 0.5;
	
	// setup windowObject
	TTObjectBaseInstantiate(TT("WindowFunction"), &windowObject, TTValue(1));
	windowObject->setAttributeValue(TT("function"), TT("tukey"));
	windowObject->setAttributeValue(TT("mode"), TT("apply"));
	
	// set the value for alpha
	windowObject->setAttributeValue(TT("alpha"), testAlpha);
	TTTestLog("alpha was set to %.10f for test", testAlpha);
	
	// create 1 channel audio signal objects
	TTObjectBaseInstantiate(kTTSym_audiosignal, &input, 1);
	TTObjectBaseInstantiate(kTTSym_audiosignal, &output, 1);
	input->allocWithVectorSize(N);
	output->allocWithVectorSize(N);
									
	// create a signal to be transformed and then process it)
	input->fill(1.0);
	windowObject->process(input, output);
	
	// now test the output
	for (int n=0; n<N; n++)
	{
		TTBoolean result = !TTTestFloatEquivalence(output->mSampleVectors[0][n], sTukeyWindowCoefficients128[n]);
		badSampleCount += result;
		if (result) 
			TTTestLog("BAD SAMPLE @ n=%i ( value=%.10f	expected=%.10f )", n, output->mSampleVectors[0][n], sTukeyWindowCoefficients128[n]);
	}
	
	TTTestAssertion("Produces correct window coefficients", 
					badSampleCount == 0,
					testAssertionCount, 
					errorCount);
	if (badSampleCount)
		TTTestLog("badSampleCount is %i", badSampleCount);
	
	
	TTObjectBaseRelease(&input);
	TTObjectBaseRelease(&output);
	TTObjectBaseRelease(&windowObject);

	
	// wrap up test results and pass back to whoever called test
	return TTTestFinish(testAssertionCount, errorCount, returnedTestInfo);

}
Exemple #11
0
TTObject::TTObject(const TTSymbol aClassName) :
mObjectInstance(NULL)
{
	TTErr err = ttEnvironment->createInstance(aClassName, &mObjectInstance, TTValue());
	
	if (err) {
		TTLogError("TTObject -- error %i instantiating %s\n", err, aClassName.c_str());
		throw TTException("object instantiation failed");
	}
}
Exemple #12
0
TTMessage::TTMessage(const TTSymbol newName, TTMethod newMethod, TTMessageFlags newFlags) :
	TTObjectBase(TTValue()),
	name(newName), 
	flags(newFlags),
	method(newMethod),
	hidden(NO),
	description(kTTSymEmpty)
{
	;
}
Exemple #13
0
TTErr TTProtocol::isRegistered(const TTValue& inputValue, TTValue& outputValue)
{
	TTSymbol	applicationName;
	TTValue		v;
	
	applicationName = inputValue[0];
	
    outputValue = TTValue(mApplicationParameters.lookup(applicationName, v) == kTTErrNone);
	
	return kTTErrNone;
}
void model_preset_dorecall(TTPtr self, t_symbol *msg, long argc, t_atom *argv)
{
	WrappedModularInstancePtr	x = (WrappedModularInstancePtr)self;
	TTValue		v, none;

	if (argc && argv)
		if (atom_gettype(argv) == A_SYM)
			v = TTValue(TTSymbol(atom_getsym(argv)->s_name));

	// recall the preset
	EXTRA->presetManager->send(kTTSym_Recall, v, none);
}
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 #16
0
TTErr TTDictionaryBase::remove(const TTSymbol key)
{
//	TTValue	v;
//	TTErr	err;

//	err = mList->find(TTDictionaryBaseFindKeyInList, key.rawpointer(), v);
//	if (!err)
//		mList->remove(v);
//	return mHashTable->remove(key);
//	mMap.erase(key.getSymbolId());
	mMap.erase((TTPtrSizedInt)key.rawpointer());
	sendNotification("change", TTValue());
	return kTTErrNone;
}
Exemple #17
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;
}
Exemple #18
0
TTErr TTDictionaryBase::append(const TTSymbol key, const TTValue& value)
{
//	TTValue v = new TTKeyVal(TTPtrSizedInt(&key), value);
//	lock();
	remove(key);
//	mMap.insert(TTDictionaryBasePair(key.getSymbolId(), value));
	mMap.insert(TTDictionaryBasePair((TTPtrSizedInt)key.rawpointer(), value));
//	unlock();
	sendNotification("change", TTValue());
	return kTTErrNone;

//	mList->append(v);
//	return mMap->append(key, value);
//	return kTTErrNone;
}
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 #20
0
TTAttribute::TTAttribute(const TTSymbol& newName, TTDataType newType, void* newAddress) :
	TTObjectBase(TTValue()),
	name(newName), 
	type(newType), 
	address(newAddress), 
	getterObject(NULL), 
	setterObject(NULL), 
	getterFlags(kTTAttrDefaultFlags), 
	setterFlags(kTTAttrDefaultFlags),
  	readOnly(NO), 
	rangeLowBound(0.0), 
	rangeHighBound(1.0), 
	rangeChecking(kTTSym_none),
	hidden(NO),
	description(kTTSymEmpty),
	mDefaultValue(0)
{
	getter = (TTGetterMethod)&TTAttribute::defaultGetter;
	setter = (TTSetterMethod)&TTAttribute::defaultSetter;
}
TTErr RosenbergGlottalPulseWindow::test(TTValue& returnedTestInfo)
{
	int					errorCount = 0;
	int					testAssertionCount = 0;
	
	TTAudioObjectBasePtr	windowObject = NULL;
	
	TTAudioSignalPtr	input = NULL;
	TTAudioSignalPtr	output = NULL;
	
	int					N = 101;
	TTValue				v, aReturnWeDontCareAbout;
	
	// create the object, keep the default ratio parameter
	TTObjectBaseInstantiate(TT("WindowFunction"), &windowObject, TTValue(1));
	windowObject->setAttributeValue(TT("function"), TT("rosenbergGlottalPulse"));
	windowObject->setAttributeValue(TT("mode"), TT("apply"));
	
	// create 1 channel audio signal objects
	TTObjectBaseInstantiate(kTTSym_audiosignal, &input, 1);
	TTObjectBaseInstantiate(kTTSym_audiosignal, &output, 1);
	input->allocWithVectorSize(N);
	output->allocWithVectorSize(N);
	
	// create a signal to be transformed, and then process it
	input->fill(1.0);
	windowObject->process(input, output);
		
	// now test the output
	int	badSampleCount = 0;
	for (int n=0; n<N; n++) {
		TTBoolean result = !TTTestFloatEquivalence(output->mSampleVectors[0][n], expectedResult1[n]);
		badSampleCount += result;
		if (result)
			TTTestLog("BAD SAMPLE @ n=%i  ( value=%.10f   expected=%.10f )", n, output->mSampleVectors[0][n], expectedResult1[n]);
	}

	TTTestAssertion("Produces correct window shape for with default ratio attribute", 
					badSampleCount == 0, 
					testAssertionCount, 
					errorCount);
	if (badSampleCount)
		TTTestLog("badSampleCount is %i", badSampleCount);
	
	v.resize(2);
	v.set(0, TT("ratio"));
	v.set(1, 0.8);
	windowObject->sendMessage(TT("setParameter"), v, aReturnWeDontCareAbout);
	
	// Again create a signal to be transformed, and then process it
	input->fill(1.0);
	windowObject->process(input, output);
	
	// now test the output
	badSampleCount = 0;
	for (int n=0; n<N; n++) {
		TTBoolean result = !TTTestFloatEquivalence(output->mSampleVectors[0][n], expectedResult2[n]);
		badSampleCount += result;
		if (result)
			TTTestLog("BAD SAMPLE @ n=%i  ( value=%.10f   expected=%.10f )", n, output->mSampleVectors[0][n], expectedResult2[n]);
	}
	
	TTTestAssertion("Produces correct window shape for with ratio set to 0.8",
					badSampleCount == 0,
					testAssertionCount,
					errorCount);
	if (badSampleCount)
		TTTestLog("badSampleCount is %i", badSampleCount);
	
	
	TTObjectBaseRelease(&input);
	TTObjectBaseRelease(&output);
	TTObjectBaseRelease(&windowObject);
	
	// Wrap up the test results to pass back to whoever called this test
	return TTTestFinish(testAssertionCount, errorCount, returnedTestInfo);
}
Exemple #22
0
void TTDictionaryTestBasic(int& errorCount, int& testAssertionCount)
{
    TTTestLog("\n");
	TTTestLog("Testing dictionary basic operations");
    
	TTTestLog("\n");
	TTTestLog("Testing dictionary creation");
    
    // creation using a random name
    TTDictionary d1;

	TTTestAssertion("TTDictionary random name : Test fails if the dictionary have no name",
					d1.name() != kTTSymEmpty,
					testAssertionCount,
					errorCount);
    
    // creation using a specific string name
    TTDictionary   d2("dictionary2");
    
    TTTestAssertion("TTDictionary string name : Test fails if the dictionary name is not \"dictionary2\"",
					d2.name() == TTSymbol("dictionary2"),
					testAssertionCount,
					errorCount);
    
    // creation using a specific symbol name
    TTDictionary   d3(kTTSym_symbol);
    
    TTTestAssertion("TTDictionary symbol name : Test fails if the dictionary name is not \"symbol\"",
					d3.name() == kTTSym_symbol,
					testAssertionCount,
					errorCount);
    
    
    
    TTTestLog("\n");
	TTTestLog("Testing dictionary schema");
    
    TTTestAssertion("TTDictionary schema : dictionary schema should default to 'none' ",
					d1.getSchema() == "none",
					testAssertionCount,
					errorCount);
    
    d1.setSchema(TTSymbol("aSchemaName"));
    
    TTTestAssertion("TTDictionary schema : Test fails if the dictionary schema is not \"aSchemaName\"",
					d1.getSchema() == TTSymbol("aSchemaName"),
					testAssertionCount,
					errorCount);
    
    

    TTTestLog("\n");
	TTTestLog("Testing dictionary value");
    
    TTValue v;
    d1.getValue(v);
    
    TTTestAssertion("TTDictionary value : Test fails if the dictionary value is not empty",
					v == TTValue(),
					testAssertionCount,
					errorCount);
    
    d1.setValue(1);
    d1.getValue(v);
    
    TTTestAssertion("TTDictionary value : Test fails if the dictionary value is not kTTVal1",
					v == 1,
					testAssertionCount,
					errorCount);
    
    
    
    TTTestLog("\n");
	TTTestLog("Testing dictionary keys");
    
    d1.append(kTTSym_gain, 1);
    TTErr err = d1.lookup(kTTSym_gain, v);
    
    TTTestAssertion("TTDictionary append key : Test fails if the dictionary key \"gain\" doesn't exist or its value is not kTTVal1",
                    err == kTTErrNone &&
					v == 1,
					testAssertionCount,
					errorCount);
    
    d1.getKeys(v);
    TTSymbol k1 = v[2];
    TTSymbol k2 = v[1];
    TTSymbol k3 = v[0];
    
    TTTestAssertion("TTDictionary get keys : Test fails if the dictionary keys are not \"schema\", \"value\" and \"gain\" or the size is not 3",
                    k1 == kTTSym_schema &&
                    k2 == kTTSym_value &&
                    k3 == kTTSym_gain &&
                    d1.size() == 3,
					testAssertionCount,
					errorCount);
    
    d1.remove(kTTSym_gain);
    d1.getKeys(v);
    k1 = v[1];
    k2 = v[0];
    
    TTTestAssertion("TTDictionary remove key : Test fails if the dictionary keys are not \"schema\" and \"value\" or the size is not 2",
                    k1 == kTTSym_schema &&
                    k2 == kTTSym_value  &&
                    d1.size() == 2,
					testAssertionCount,
					errorCount);
    
    d1.clear();
    
    TTTestAssertion("TTDictionary clear keys : Test fails if the dictionary keys are not empty or the size is not 0",
                    d1.empty() &&
                    d1.size() == 0,
					testAssertionCount,
					errorCount);
}
Exemple #23
0
void
DemoApp::SetupModular()
{
    TTValue     args, v, out, none;
    TTAddress   address;
    TTErr       err;
    
    TTLogMessage("\n*** Initialisation of Modular environnement ***\n");
    /////////////////////////////////////////////////////////////////////
    
    // Init the Modular library (passing the folder path where all the dylibs are)
    TTModularInit("/usr/local/jamoma");
    
    // Create an application manager
    mApplicationManager = TTObject("ApplicationManager");
    
    
    TTLogMessage("\n*** Creation of mApplicationDemo application ***\n");
    /////////////////////////////////////////////////////////////////////
    
    // Create a local application called "demo" and get it back
    err = mApplicationManager.send("ApplicationInstantiateLocal", "demo", out);
    
    if (err) {
        TTLogError("Error : can't create demo application \n");
        return;
    }
    else
        mApplicationDemo = out[0];
    
    
	TTLogMessage("\n*** Creation of mApplicationDemo datas ***\n");
    /////////////////////////////////////////////////////////////////////
    
    // Create a parameter data and set its callback function and baton and some attributes
    mDataDemoParameter = TTObject("Data", "parameter");
    
    // Setup the callback mechanism to get the value back
    args = TTValue(TTPtr(this), mDataDemoParameter);
    mDataDemoParameter.set("baton", args);
    mDataDemoParameter.set("function", TTPtr(&DemoAppDataReturnValueCallback));

    // Setup the data attributes depending of its use inside the application
    mDataDemoParameter.set("type", "decimal");
    mDataDemoParameter.set("rangeBounds", TTValue(0., 1.));
    mDataDemoParameter.set("rangeClipmode", "low");
    mDataDemoParameter.set("description", "any information relative to the state of the application");
    
    // Register the parameter data into mApplicationDemo at an address
    args = TTValue("/myParameter", mDataDemoParameter);
    mApplicationDemo.send("ObjectRegister", args, out);
    
    
    // Create a message data and set its callback function and baton and some attributes
    mDataDemoMessage = TTObject("Data", "message");
    
    // Setup the callback mechanism to get the value back
    args = TTValue(TTPtr(this), mDataDemoMessage);
    mDataDemoMessage.set("baton", args);
    mDataDemoMessage.set("function", TTPtr(&DemoAppDataReturnValueCallback));
    
    // Setup the data attributes depending of its use inside the application
    mDataDemoMessage.set("type", "string");
    mDataDemoMessage.set("description", "any information to provide to the application");
    
    // Register the message data into mApplicationDemo at an address
    args = TTValue("/myMessage", mDataDemoMessage);
    mApplicationDemo.send("ObjectRegister", args, out);
    
    
    // Create a return data and set its callback function and baton and some attributes
    mDataDemoReturn = TTObject("Data", "return");
    
    // Setup the callback mechanism to get the value back
    args = TTValue(TTPtr(this), mDataDemoReturn);
    mDataDemoReturn.set("baton", args);
    mDataDemoReturn.set("function", TTPtr(&DemoAppDataReturnValueCallback));

    // Setup the data attributes depending of its use inside the application
    mDataDemoReturn.set("type", "integer");
    mDataDemoReturn.set("defaultValue", 0);
    mDataDemoReturn.set("description", "any information the application returns back");
    
    // Register the return data into mApplicationDemo at an address
    args = TTValue("/myReturn", mDataDemoReturn);
    mApplicationDemo.send("ObjectRegister", args, out);
    
    // Initialise the application and all datas inside (using defaultValue attribute)
    mApplicationDemo.send("Init");
}
#include "TTOverdrive.h"
#include "TTEnvironment.h"

#define thisTTClass			TTOverdrive
#define thisTTClassName		"overdrive"
#define thisTTClassTags		"dspEffectsLib, audio, processor, distortion"


TT_AUDIO_CONSTRUCTOR,
	dcBlockerUnit(kTTSym_dcblock)
{
	TTUInt16	initialMaxNumChannels = arguments;
	
	// Register Attributes
	addAttributeWithSetter(Drive,				kTypeFloat64);
		addAttributeProperty(Drive,				range,			TTValue(1.0, 10.0));
		addAttributeProperty(Drive,				rangeChecking,	TT("clip")); // options are "clip" "cliphigh" "cliplow"
	addAttributeWithSetter(DcBlocker,			kTypeBoolean);
	addAttributeWithSetter(Mode,				kTypeBoolean);// IMPORTANT: if we have more modes, the datatype need to change here
	addAttributeWithGetterAndSetter(Preamp,		kTypeFloat64);
	
	// Register Messages
	addMessage(clear);
	addUpdates(MaxNumChannels);
	
	// Set Defaults
	setAttributeValue(kTTSym_maxNumChannels,	initialMaxNumChannels);
	setAttributeValue("mode",		1);
	setAttributeValue("preamp",		0.0);
	setAttributeValue("drive",		3.0);
	setAttributeValue("dcBlocker",	YES);
Exemple #25
0

TT_AUDIO_CONSTRUCTOR,
#ifndef USE_MERSENNE_TWISTER_ALGORITHM
accum(0),
#endif
mNumChannels(0)
{
	addAttributeWithSetter(Mode,			kTypeSymbol); 
	addAttributeWithGetterAndSetter(Gain,	kTypeFloat64);	
	setAttributeValue(TT("mode"), TT("white"));    
	setAttributeValue(TT("gain"), 0.0);			// 0 dB 
#ifdef USE_MERSENNE_TWISTER_ALGORITHM	
	addAttribute(Mean,						kTypeFloat64); 
	addAttribute(Std,						kTypeFloat64); 
	addAttributeProperty(Std,			range,			TTValue(0.0, 1.0));
	addAttributeProperty(Std,			rangeChecking,	TT("low"));	
	setAttributeValue(TT("mean"), 0.0);	
	setAttributeValue(TT("std"), 1.0);	
#endif	
}


TTNoise::~TTNoise()
{
	;
}


TTErr TTNoise::setNumChannels(const TTChannelCount newNumChannels)
{  
TTErr KaiserWindow::test(TTValue& returnedTestInfo)
{
	int					errorCount = 0;
	int					testAssertionCount = 0;
	int					badSampleCount = 0;
	TTAudioObjectBasePtr	windowObject = NULL;
	TTAudioSignalPtr	input = NULL;
	TTAudioSignalPtr	output = NULL;
	int					N = 128;
	TTValue				v, aReturnWeDontCareAbout;
	
	// create the object and set the beta parameter
	TTObjectBaseInstantiate(TT("WindowFunction"), &windowObject, TTValue(1));
	windowObject->setAttributeValue(TT("function"), TT("kaiser"));
	windowObject->setAttributeValue(TT("mode"), TT("apply"));
	
	v.resize(2);
	v[0] = TT("beta");
	v[1] = 6.0;
	windowObject->sendMessage(TT("setParameter"), v, aReturnWeDontCareAbout);
	
	TTTestAssertion("Internal intermediate value 1 (zeroth-order bessel fn of the first kind, taken of beta = 6.0) is correct.",
					TTTestFloatEquivalence(((KaiserWindow*)((WindowFunction*)windowObject)->mFunctionObject)->mBesselIOofBeta, 67.2344069764780),
					testAssertionCount,
					errorCount);
	
	// change the alpha parameter and test Bessel function again
	v.resize(2);
	v[0] = TT("alpha");
	v[1] = 2.0;
	windowObject->sendMessage(TT("setParameter"), v, aReturnWeDontCareAbout);
	
	TTTestAssertion("Internal intermediate value 2 (zeroth-order bessel fn of the first kind, taken of alpha = 2) is correct.",
					TTTestFloatEquivalence(((KaiserWindow*)((WindowFunction*)windowObject)->mFunctionObject)->mBesselIOofBeta, 87.10851065339077),
					testAssertionCount,
					errorCount);  // added 4/26 by Wolek
	
	// change the beta parameter and try applying the window
	v.resize(2);
	v[0] = TT("beta");
	v[1] = 3.0 * kTTPi;
	windowObject->sendMessage(TT("setParameter"), v, aReturnWeDontCareAbout);
	
	TTTestAssertion("Internal intermediate value 2 (zeroth-order bessel fn of the first kind, taken of beta = 3 * pi) is correct.",
					TTTestFloatEquivalence(((KaiserWindow*)((WindowFunction*)windowObject)->mFunctionObject)->mBesselIOofBeta, 1633.090522058824),
					testAssertionCount,
					errorCount);  // added 4/26 by Wolek
	
	// create 1 channel audio signal objects
	TTObjectBaseInstantiate(kTTSym_audiosignal, &input, 1);
	TTObjectBaseInstantiate(kTTSym_audiosignal, &output, 1);
	input->allocWithVectorSize(N);
	output->allocWithVectorSize(N);
	
	// create a signal to be transformed, and then process it
	input->fill(1.0);
	windowObject->process(input, output);
		
	// now test the output
	for (int n=0; n<N; n++) {
		TTBoolean result = !TTTestFloatEquivalence(output->mSampleVectors[0][n], sKaiserB3PiWindowCoefficients128[n]);
		badSampleCount += result;
		if (result)
			TTTestLog("BAD SAMPLE @ n=%i  ( value=%.10f   expected=%.10f )", n, output->mSampleVectors[0][n], sKaiserB3PiWindowCoefficients128[n]);
	}

	TTTestAssertion("Produces correct window shape for beta = 3 pi", 
					badSampleCount == 0, 
					testAssertionCount, 
					errorCount);
	if (badSampleCount)
		TTTestLog("badSampleCount is %i", badSampleCount);
	
	
	TTObjectBaseRelease(&input);
	TTObjectBaseRelease(&output);
	TTObjectBaseRelease(&windowObject);
	
	// Wrap up the test results to pass back to whoever called this test
	return TTTestFinish(testAssertionCount, errorCount, returnedTestInfo);
}
Exemple #27
0
void TTAddressItem::unregisterHandler(TTObjectBase& anObject)
{
	TTValue v = TTValue(anObject);
	this->handlers.remove(v);
}
Exemple #28
0
TTErr TTProtocol::ApplicationRegister(const TTValue& inputValue, TTValue& outputValue)
{
    TTObject    application;
	TTSymbol	parameterName;
	TTHashPtr	applicationParameters;
	TTValue		v, parameterNames, out, none;
	TTErr		err;
    
    // update local application name
    mApplicationManager.get("applicationLocalName", v);
    mLocalApplicationName = v[0];
    
    if (inputValue.size() == 1) {
        
        if (inputValue[0].type() == kTypeSymbol) {
            
            mSelectedApplication = inputValue[0];
            
            // Check the application is not already registered
            err = mApplicationParameters.lookup(mSelectedApplication, v);
                
            if (err) {
                
                applicationParameters = new TTHash();
                
                // prepare parameters table
                this->getParameterNames(parameterNames);
                for (TTUInt32 i = 0; i < parameterNames.size(); i++) {
                    parameterName = parameterNames[i];
                    applicationParameters->append(parameterName, none);
                }
                
                // add the parameters table into mApplicationParameters
                v = TTValue((TTPtr)applicationParameters);
                mApplicationParameters.append(mSelectedApplication, v);
                
                // optionnaly format the application type depending on the protocol features
                // (if the application is already registered into the application manager)
                err = mApplicationManager.send("ApplicationFind", mSelectedApplication, out);
                
                if (!err) {
                        
                    application = out[0];
                    
                    // for none local application
                    if (mSelectedApplication != mLocalApplicationName) {
                        
                        // setup the application type depending of the discovering feature of the protocol
                        if (mDiscover || mDiscoverAll)
                            application.set("type", kTTSym_mirror);
                        else
                            application.set("type", kTTSym_proxy);
                    }
                }
                
                return kTTErrNone;
            }
        }
    }
	
	return kTTErrGeneric;
}
Exemple #29
0
TTData::TTData(const TTValue& arguments) :
TTCallback(arguments),
mValue(TTValue(0.0)),
mValueDefault(TTValue(0.0)),
mValueStepsize(TTValue(0.1)),       // this default value is expected in #TTData::setType method
mType(kTTSym_generic),
mTags(TTValue(kTTSym_none)),
mPriority(0),
mDescription(kTTSym_none),
mRepetitionsFilter(NO),
mActive(YES),
mInitialized(NO),
mRangeBounds(0.0, 1.0),             // this default value is expected in #TTData::setType method
mRangeClipmode(kTTSym_none),
mDynamicInstances(NO),
mInstanceBounds(0, -1),
mRampDrive(kTTSym_none),
mRampDriveDefault(TTSymbol("system")),
#ifndef TT_NO_DSP
mRampFunction(kTTSym_none),         // this default value is expected in #TTData::setType method
#endif
mRampStatus(NO),
mDataspace(kTTSym_none),
mDataspaceUnit(kTTSym_none),
mService(kTTSymEmpty)
{
	if (arguments.size() == 1)
		mService = arguments[0];
	
    registerAttribute(kTTSym_value, kTypeNone, NULL, (TTGetterMethod)&TTData::getValue, (TTSetterMethod)&TTData::setGenericValue);
	addAttributeWithGetterAndSetter(ValueDefault, kTypeNone);
	addAttributeWithGetterAndSetter(ValueStepsize, kTypeNone);
	
	addAttributeWithSetter(Type, kTypeSymbol);
	addAttributeWithSetter(Tags, kTypeLocalValue);
	addAttributeWithSetter(Priority, kTypeInt32);
	addAttributeWithSetter(Description, kTypeSymbol);
	addAttributeWithSetter(RepetitionsFilter, kTypeBoolean);
	
	addAttributeWithSetter(Active, kTypeBoolean);
	
	addAttribute(Initialized, kTypeBoolean);
	addAttributeProperty(Initialized, readOnly, YES);
	addAttributeProperty(Initialized, hidden, YES);
	
	addAttributeWithSetter(RangeBounds, kTypeLocalValue);
	addAttributeWithSetter(RangeClipmode, kTypeSymbol);
	
    // this is a temporary solution for Blue Yéti
	addAttribute(DynamicInstances, kTypeBoolean);
	addAttributeProperty(DynamicInstances, hidden, YES);
	addAttributeWithSetter(InstanceBounds, kTypeLocalValue);
	addAttributeProperty(InstanceBounds, hidden, YES);
	
	addAttributeWithSetter(RampDrive, kTypeSymbol);
    addAttribute(RampDriveDefault, kTypeSymbol);
    addAttributeProperty(RampDriveDefault, hidden, YES);
#ifndef TT_NO_DSP    
	addAttributeWithSetter(RampFunction, kTypeSymbol);
#endif
	
	addAttribute(RampFunctionParameters, kTypeLocalValue);
	addAttributeProperty(RampFunctionParameters, readOnly, YES);
	
	addAttribute(RampStatus, kTypeBoolean);
	addAttributeProperty(RampStatus, readOnly, YES);
    addAttributeProperty(RampStatus, hidden, YES);          // hidden for Max
	
	addAttributeWithSetter(Dataspace, kTypeSymbol);
	addAttributeWithSetter(DataspaceUnit, kTypeSymbol);
	
	addAttribute(Service, kTypeSymbol);
    //addAttributeProperty(Service, hidden, YES);           // we don't hide this attribute to mirror it (even if we want to hide it for Max)
	
    registerMessage(kTTSym_Init, (TTMethod)&TTData::GenericInit, kTTMessagePassNone);
	addMessageWithArguments(Inc);
	addMessageWithArguments(Dec);
    
    addMessageWithArguments(Command);
	addMessageProperty(Command, hidden, YES);
    
    addMessageWithArguments(RampSet);
    addMessageProperty(RampSet, hidden, YES);
    addMessageWithArguments(RampTarget);
    addMessageProperty(RampTarget, hidden, YES);
    addMessageWithArguments(RampGo);
    addMessageProperty(RampGo, hidden, YES);
    addMessageWithArguments(RampSlide);
    addMessageProperty(RampSlide, hidden, YES);
	
	// needed to be handled by a TTTextHandler
	addMessageWithArguments(WriteAsText);
	addMessageProperty(WriteAsText, hidden, YES);
	
	mIsSending = NO;
	mIsOverridingDataspaceUnit = NO;
    
    commandMethod = (TTMethodValue)&TTData::GenericCommand;
    
    // cache some message and attribute for observer notification
    this->findAttribute(kTTSym_value, &valueAttribute);
    this->findAttribute(kTTSym_initialized, &initializedAttribute);
    
    // set no time for external ramp drive
    externalRampTime = 0;
}
Exemple #30
0
void TTAddressItem::registerHandler(TTObjectBase& anObject)
{
	TTValue v = TTValue(anObject);
	this->handlers.appendUnique(v);
}