Beispiel #1
0
void TTNodeLibTestAddressComparison(int& errorCount, int& testAssertionCount)
{
	TTAddressComparisonFlag result;
	TTInt8 depthDifference;
	
	TTTestLog("\n");
	TTTestLog("Testing Address Comparison");
	
	TTAddress testAddressA("/gran/parent/name.instance");
	TTAddress testAddressB("/gran");
	TTAddress testAddressC("gran/parent/name.instance");
	TTAddress testAddressD("gran");
	
	result = testAddressA.compare(testAddressA, depthDifference);
	TTTestAssertion("TTAddressComparison: Test fails if comparison returns anything else than equality",
					result == kAddressEqual &&
					depthDifference == 0,
					testAssertionCount,
					errorCount);
	
	result = testAddressA.compare(testAddressB, depthDifference);
	TTTestAssertion("TTAddressComparison: Test passes if comparison returns the address is lower with 2 levels of difference",
					result == kAddressLower &&
					depthDifference == 2,
					testAssertionCount,
					errorCount);
	
	result = testAddressB.compare(testAddressA, depthDifference);
	TTTestAssertion("TTAddressComparison: Test passes if comparison returns the address is upper with 2 levels of difference",
					result == kAddressUpper &&
					depthDifference == -2,
					testAssertionCount,
					errorCount);
	
	result = testAddressC.compare(testAddressD, depthDifference);
	TTTestAssertion("TTAddressComparison: Test passes if comparison returns the address is lower with 2 levels of difference",
					result == kAddressLower &&
					depthDifference == 2,
					testAssertionCount,
					errorCount);
	
	result = testAddressD.compare(testAddressC, depthDifference);
	TTTestAssertion("TTAddressComparison: Test passes if comparison returns the address is upper with 2 levels of difference",
					result == kAddressUpper &&
					depthDifference == -2,
					testAssertionCount,
					errorCount);
	
	result = testAddressA.compare(testAddressD, depthDifference);
	TTTestAssertion("TTAddressComparison: Test passes if comparison returns the address is lower with 2 levels of difference",
					result == kAddressDifferent,
					testAssertionCount,
					errorCount);
	
	result = testAddressC.compare(testAddressB, depthDifference);
	TTTestAssertion("TTAddressComparison: Test passes if comparison returns the address is upper with 2 levels of difference",
					result == kAddressDifferent,
					testAssertionCount,
					errorCount);
}
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);

}
Beispiel #3
0
/** Test for correct cubic interpolations performance.
 @param anErrorCount			The number of asserts that failed
 @param aTestAssertionCount		The numebr of asserts carried out
 */
void TestCubic(int& anErrorCount, int& aTestAssertionCount)
{
    /* We perform the interpolation on four values of the following function:
     g(delta) = cos (PI*delta) + delta + 1

     This gives the following input values to the interpolating function:

     g(-1) = -1
     g( 0) =  2
     g( 1) =  1
     g( 2) =  4

     The difference is calculated as
     ∆g(delta) = (g(delta+1)-g(delta-1)) / 2

     This leads to:

     ∆g(0) = ( 1 -(-1) )/2 = 1
     ∆g(1) = ( 4 - 2)/2 = 1

     The cubic interpolation function f(delta) is then required to fullfil the following four conditions:

     (A) f( 0) =  2
     (B) f( 1) =  1
     (C) f'(0) = 1
     (D) f'(1) = 1

     Analytically, when solved, these four conditions are fulfilled by the following 3rd order polynomial:
     f(delta) = 4 delta^3 - 6 delta^2 + delta + 2

     The following test compares interpolated values to expected values for this function.
     */

    int badSampleCount = 0;

    TTFloat64 x0 = -1.0;
    TTFloat64 x1 =  2.0;
    TTFloat64 x2 =  1.0;
    TTFloat64 x3 =  4.0;

    TTTestLog("");
    TTTestLog("Testing cubic interpolation");

    // Test for delta = -1 => f(delta) = -9
    badSampleCount += !InterpolateAndTestCubic(x0, x1, x2, x3, -1.00, -9.0);
    // Test for delta = 0 => f(delta) = 2
    badSampleCount += !InterpolateAndTestCubic(x0, x1, x2, x3,  0.00,  2.0);
    // Test for delta = 1 => f(delta) = 1
    badSampleCount += !InterpolateAndTestCubic(x0, x1, x2, x3,  1.00,  1.0);
    // Test for delta = 2 => f(delta) = 12
    badSampleCount += !InterpolateAndTestCubic(x0, x1, x2, x3,  2.00, 12.0);

    TTTestAssertion("Produces expected results with cubic interpolation",
                    badSampleCount == 0,
                    aTestAssertionCount,
                    anErrorCount);
}
Beispiel #4
0
void TTScoreTestMain(int& errorCount, int& testAssertionCount)
{
	TTTestLog("\n");
	TTTestLog("Testing Score");
	
    TTTestAssertion("TTScoreTest",
                    YES,
					testAssertionCount,
					errorCount);
}
Beispiel #5
0
void TTStringTestStream(int& errorCount, int&testAssertionCount)
{
	TTTestLog("\n");
	TTTestLog("Testing string stream");
	TTTestLog("(there will be no assertions, look for stdout output)");
	
	TTString hi("Hello World!");
	
	std::cout << "	Passing TTString to stdout: " << hi << " (hooray)" << std::endl;
}
Beispiel #6
0
/** Perform one cosine interpolation and compare the outcome to expected value.
 @param x0				Sample value at prior integer index
 @param x1				Sample value at next integer index
 @param aDelta			The fractional value for which we want to perform the interpolation.
 aDelta=0 => x0 @n
 aDelta=1 => x1
 @param expectedValue	The expected outcome of the interpolation
 @return				TRUE if the interpolat returnes the expected value, else FALSE
 */
TTFloat64 InterpolateAndTestCosine(const TTFloat64 x0, const TTFloat64 x1, const TTFloat64& aDelta, TTFloat64 anExpectedValue)
{
    TTFloat64 interpolatedValue = TTInterpolateCosine(x0, x1, aDelta);
    TTBoolean result = TTTestFloatEquivalence(interpolatedValue , anExpectedValue);
    if (!result)
        TTTestLog("BAD INTERPOLATION @ delta=%.5f  ( value=%.10f   expected=%.10f )", aDelta, interpolatedValue, anExpectedValue);
    return result;
}
Beispiel #7
0
TTErr TTTestFinish(int testAssertionCount, int errorCount, TTValue& returnedTestInfo)
{
	TTDictionary d;

	d.setSchema("TestInfo");
	d.append("testAssertionCount", testAssertionCount);
	d.append("errorCount", errorCount);
	returnedTestInfo = d;
	
	TTTestLog("\n");
	TTTestLog("Number of assertions: %ld", testAssertionCount);
	TTTestLog("Number of failed assertions: %ld", errorCount);
	TTTestLog("\n");
	
	if (errorCount)
		return kTTErrGeneric;
	else
		return kTTErrNone;
}
Beispiel #8
0
void TTDictionaryTestValue(int& errorCount, int& testAssertionCount)
{
	TTTestLog("\n");
	TTTestLog("Testing dictionary inside value");
    
    TTDictionary d1("dictionary1");
    TTValue v = d1;
    
    TTTestAssertion("TTDictionary value assignement : Test fails if the value type is not dictionary",
                    v[0].type() == kTypeDictionary,
					testAssertionCount,
					errorCount);
    
    TTDictionary d2 = v[0];
    
    TTTestAssertion("TTDictionary value assignement : Test fails if two dictionaries haven't the same name",
                    d2.name() == d1.name(),
					testAssertionCount,
					errorCount);
}
Beispiel #9
0
/** Test for correct linear interpolations performance.
 @param anErrorCount			The number of asserts that failed
 @param aTestAssertionCount		The numebr of asserts carried out
 */
void TestLinear(int& anErrorCount, int& aTestAssertionCount)
{
    int			badSampleCount = 0;

    TTFloat64	x0 =  3.0;
    TTFloat64	x1 = -1.0;

    TTTestLog("");
    TTTestLog("Testing linear interpolation");

    badSampleCount += !InterpolateAndTestLinear(x0, x1, 0.00,  3.0);
    badSampleCount += !InterpolateAndTestLinear(x0, x1, 0.25,  2.0);
    badSampleCount += !InterpolateAndTestLinear(x0, x1, 0.50,  1.0);
    badSampleCount += !InterpolateAndTestLinear(x0, x1, 0.75,  0.0);
    badSampleCount += !InterpolateAndTestLinear(x0, x1, 1.00, -1.0);

    TTTestAssertion("Produces expected results with linear interpolation",
                    badSampleCount == 0,
                    aTestAssertionCount,
                    anErrorCount);
}
Beispiel #10
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);
}
Beispiel #11
0
TTErr TTSpatSnap::testSinkPositionSetterAndGetter(int& aTestAssertionCount, int& anErrorCount, TTValue& aReturnedTestInfo)
{	
	// Set the location of five sinks:
	
	TTValue anEntity;
	TTValue unused;
	anEntity.resize(4);
	
	// Sink 1: Default = (0., 0., 0.) so we don't set it.
	
	// Sink 2: (2.2, 0., 0.)
	
	anEntity[0] = 2;
	anEntity[1] = 2.2;
	anEntity[2] = 0.;
	anEntity[3] = 0.;
	this->sendMessage("setSinkPosition", anEntity, unused);
	
	// Sink 3: (0., 3.3, 0.)
	
	anEntity[0] = 3;
	anEntity[1] = 0.;
	anEntity[2] = 3.3;
	anEntity[3] = 0.;
	this->sendMessage("setSinkPosition", anEntity, unused);
	
	// Sink 4: (0., 0., 4.4)
	
	anEntity[0] = 4;
	anEntity[1] = 0.;
	anEntity[2] = 0.;
	anEntity[3] = 4.4;
	this->sendMessage("setSinkPosition", anEntity, unused);
	
	// Sink 5: (-2., -3.14, -4.)
	
	anEntity[0] = 5;
	anEntity[1] = -2.;
	anEntity[2] = -3.14;
	anEntity[3] = -4.;
	this->sendMessage("setSinkPosition", anEntity, unused);
	
	// Now we test five sink positions:
	
	TTValue getChannel;
	TTFloat64 x, y, z;
	TTInt16 channelNumber;
	
	getChannel.resize(1);
	
	// Get and test sink 1:
	
	TTTestLog(" ");
	TTTestLog("Getting default position of sink 1");
	TTTestLog(" ");
	
	anEntity.clear();
	getChannel[0] = 1;
	
	this->sendMessage("getSinkPosition", getChannel, anEntity);
	
	TTTestAssertion("getSinkPosition[1]: Returning TTValue array with four members",
					(anEntity.size() == 4),
					aTestAssertionCount,
					anErrorCount);
	
	channelNumber = anEntity[0];
	x = anEntity[1];
	y = anEntity[2];
	z = anEntity[3];
	
	TTTestAssertion("getSinkPosition[1]: Returning position for correct channel",
					(channelNumber==1),
					aTestAssertionCount,
					anErrorCount);
	
	TTTestAssertion("getSinkPosition[1]: Returning correct default x-position",
					TTTestFloatEquivalence(x, 0.),
					aTestAssertionCount,
					anErrorCount);
	
	TTTestAssertion("getSinkPosition[1]: Returning correct default y-position",
					TTTestFloatEquivalence(y, 0.),
					aTestAssertionCount,
					anErrorCount);
	
	TTTestAssertion("getSinkPosition[1]: Returning correct default z-position",
					TTTestFloatEquivalence(z, 0.),
					aTestAssertionCount,
					anErrorCount);
	
	
	// Get and test sink 2:
	
	TTTestLog(" ");
	TTTestLog("Setting and getting position of sink 2");
	TTTestLog(" ");
	
	anEntity.clear();
	getChannel[0] = 2;
	
	this->sendMessage("getSinkPosition", getChannel, anEntity);
	
	TTTestAssertion("getSinkPosition[2]: Returning TTValue array with four members",
					(anEntity.size() == 4),
					aTestAssertionCount,
					anErrorCount);
	
	channelNumber = anEntity[0];
	x = anEntity[1];
	y = anEntity[2];
	z = anEntity[3];
	
	TTTestAssertion("getSinkPosition[2]: Returning position for correct channel",
					(channelNumber==2),
					aTestAssertionCount,
					anErrorCount);
	
	TTTestAssertion("getSinkPosition[2]: Returning correct x-position",
					TTTestFloatEquivalence(x, 2.2),
					aTestAssertionCount,
					anErrorCount);
	
	TTTestAssertion("getSinkPosition[2]: Returning correct y-position",
					TTTestFloatEquivalence(y, 0.),
					aTestAssertionCount,
					anErrorCount);
	
	TTTestAssertion("getSinkPosition[2]: Returning correct z-position",
					TTTestFloatEquivalence(z, 0.),
					aTestAssertionCount,
					anErrorCount);
	
	
	// Get and test sink 3:
	
	TTTestLog(" ");
	TTTestLog("Setting and getting position of sink 3");
	TTTestLog(" ");
	
	anEntity.clear();
	getChannel[0] = 3;
	
	this->sendMessage("getSinkPosition", getChannel, anEntity);
	
	TTTestAssertion("getSinkPosition[3]: Returning TTValue array with four members",
					(anEntity.size() == 4),
					aTestAssertionCount,
					anErrorCount);
	
	channelNumber = anEntity[0];
	x = anEntity[1];
	y = anEntity[2];
	z = anEntity[3];
	
	TTTestAssertion("getSinkPosition[3]: Returning position for correct channel",
					(channelNumber==3),
					aTestAssertionCount,
					anErrorCount);
	
	TTTestAssertion("getSinkPosition[3]: Returning correct x-position",
					TTTestFloatEquivalence(x, 0.),
					aTestAssertionCount,
					anErrorCount);
	
	TTTestAssertion("getSinkPosition[3]: Returning correct y-position",
					TTTestFloatEquivalence(y, 3.3),
					aTestAssertionCount,
					anErrorCount);
	
	TTTestAssertion("getSinkPosition[3]: Returning correct z-position",
					TTTestFloatEquivalence(z, 0.),
					aTestAssertionCount,
					anErrorCount);
	
	
	// Get and test sink 4:
	
	TTTestLog(" ");
	TTTestLog("Setting and getting position of sink 4");
	TTTestLog(" ");
	
	anEntity.clear();
	getChannel[0] = 4;
	
	this->sendMessage("getSinkPosition", getChannel, anEntity);
	
	TTTestAssertion("getSinkPosition[4]: Returning TTValue array with four members",
					(anEntity.size() == 4),
					aTestAssertionCount,
					anErrorCount);
	
	channelNumber = anEntity[0];
	x = anEntity[1];
	y = anEntity[2];
	z = anEntity[3];
	
	TTTestAssertion("getSinkPosition[4]: Returning position for correct channel",
					(channelNumber==4),
					aTestAssertionCount,
					anErrorCount);
	
	TTTestAssertion("getSinkPosition[4]: Returning correct x-position",
					TTTestFloatEquivalence(x, 0.),
					aTestAssertionCount,
					anErrorCount);
	
	TTTestAssertion("getSinkPosition[4]: Returning correct y-position",
					TTTestFloatEquivalence(y, 0.),
					aTestAssertionCount,
					anErrorCount);
	
	TTTestAssertion("getSinkPosition[4]: Returning correct z-position",
					TTTestFloatEquivalence(z, 4.4),
					aTestAssertionCount,
					anErrorCount);
	
	
	// Get and test sink 5:
	
	TTTestLog(" ");
	TTTestLog("Setting and getting position of sink 5");
	TTTestLog(" ");
	
	anEntity.clear();
	getChannel[0] = 5;
	
	this->sendMessage("getSinkPosition", getChannel, anEntity);
	
	TTTestAssertion("getSinkPosition[5]: Returning TTValue array with four members",
					(anEntity.size() == 4),
					aTestAssertionCount,
					anErrorCount);
	
	channelNumber = anEntity[0];
	x = anEntity[1];
	y = anEntity[2];
	z = anEntity[3];
	
	TTTestAssertion("getSinkPosition[5]: Returning position for correct channel",
					(channelNumber==5),
					aTestAssertionCount,
					anErrorCount);
	
	TTTestAssertion("getSinkPosition[5]: Returning correct x-position",
					TTTestFloatEquivalence(x, -2.),
					aTestAssertionCount,
					anErrorCount);
	
	TTTestAssertion("getSinkPosition[5]: Returning correct y-position",
					TTTestFloatEquivalence(y, -3.14),
					aTestAssertionCount,
					anErrorCount);
	
	TTTestAssertion("getSinkPosition[5]: Returning correct z-position",
					TTTestFloatEquivalence(z, -4.),
					aTestAssertionCount,
					anErrorCount);
	
	return kTTErrNone;
}
Beispiel #12
0
void TTNodeLibTestMiscellaneous(int& errorCount, int& testAssertionCount)
{
	TTTestLog("\n");
	TTTestLog("Miscellaneous Tests");
	
	// test convertUpperCasedName global method
	TTSymbol testSymbolA = "TestSymbolName";
	TTSymbol testSymbolB = "testSymbolName";
	TTSymbol testSymbolC = "testsymbolname";
	TTAddress result;
   

	convertUpperCasedNameInAddress(testSymbolA, result);
	TTTestAssertion("convertUpperCasedName: Test passes if \"TestSymbolName\" is converted in \"test/symbol/name\"",
					result == TTAddress("test/symbol/name"),
					testAssertionCount,
					errorCount);
	
	convertUpperCasedNameInAddress(testSymbolB, result);
	TTTestAssertion("convertUpperCasedName: Test passes if \"testSymbolName\" is converted in \"test/symbol/name\"",
					result == TTAddress("test/symbol/name"),
					testAssertionCount,
					errorCount);
	
	convertUpperCasedNameInAddress(testSymbolC, result);
	TTTestAssertion("convertUpperCasedName: Test passes if \"testsymbolname\" is not converted",
					result == testSymbolC,
					testAssertionCount,
					errorCount);
    
    // test TTSymbol to TTAdress casting
    TTValue     testValue = TTValue(TTSymbol("directory:/gran/parent/name.instance:attribute"));
    TTAddress   testAddress;
    
    testAddress = testValue[0];
    
    TTSymbol		directory	= testAddress.getDirectory();
	TTAddress		parent		= testAddress.getParent();
	TTSymbol		name		= testAddress.getName();
	TTSymbol		instance	= testAddress.getInstance();
	TTSymbol		attribute	= testAddress.getAttribute();
	TTAddressType	type		= testAddress.getType();
    
    TTBoolean t1 = directory == TTSymbol("directory");
    TTBoolean t2 = parent == TTAddress("/gran/parent");
    TTBoolean t3 = name == TTSymbol("name");
    TTBoolean t4 = instance == TTSymbol("instance");
    TTBoolean t5 = attribute == TTSymbol("attribute");
    TTBoolean t6 = type == kAddressAbsolute;

    TTTestAssertion("TTValue::get : Test2 fails if a TTSymbol contained into a value is not casted into a TTAddress during a get method",
					directory == TTSymbol("directory") &&
					parent == TTAddress("/gran/parent") &&
					name == TTSymbol("name") &&
					instance == TTSymbol("instance") &&
					attribute == TTSymbol("attribute") &&
					type == kAddressAbsolute,
					testAssertionCount,
					errorCount);

    // test TTSymbol for TTHash access when a key is stored using a TTAddress
    TTHash      testTable;
    TTAddress   keyAddress = TTAddress("testKeyAddress");
    TTValue     keyValue;
    TTErr       err;
    
    testTable.append(keyAddress, keyValue);             // store a value into the table using "testKeyAddress" address
    testValue = TTValue(TTSymbol("testKeyAddress"));    // store a "testKeyAddress" symbol into a value
    testAddress = testValue[0];                         // get it as an address
    err = testTable.lookup(testAddress, keyValue);      // use the address to lookup the table
    
    TTTestAssertion("TTHash::lookup : Test fails if a TTSymbol cannot be used as storage key for TTHash table when the lookup key is a TTAddress",
					err == kTTErrNone,
					testAssertionCount,
					errorCount);
    
    // The test below fails but it have been added only to check the opposite operation.
    // For instant we don't need this test to pass so it is commented out until we need this feature.
    
    /* test TTAddress for TTHash access when a key is stored using a TTSymbol
    TTSymbol    keySymbol = TTSymbol("testKeySymbol");
    TTSymbol    testSymbol;
    
    testTable.append(keySymbol, keyValue);              // store a value into the table using "testKeySymbol" symbol
    testValue = TTValue(TTAddress("testKeySymbol"));    // store a "testKeySymbol" address into a value
    testSymbol = testValue[0];                          // get it as an symbol
    err = testTable.lookup(testSymbol, keyValue);       // use the symbol to lookup the table
    
    TTTestAssertion("TTHash::lookup : Test fails if a TTAddress cannot be used as storage key for TTHash table when the lookup key is a TTSymbol",
					err == kTTErrNone,
					testAssertionCount,
					errorCount);
     */
}
Beispiel #13
0
void TTNodeLibTestAddressMethods(int& errorCount, int& testAssertionCount)
{
	TTAddress testAddressA("directory:/gran/parent/name.instance:attribute");
	TTAddress testAddressB("/parent/name");
	TTAddress testAddressC("name");
	
	TTAddress testAddressD("/gran/parent");
	TTAddress testAddressE("directory:/gran/parent");
	
	TTAddress testAddressF("name.instance:attribute");
	TTAddress testAddressG("/name.instance:attribute");
    
    TTSymbol  testSymbolA("");
    
	TTSymbol  resultSymbol;
    TTAddress resultAddress;
	TTAddress part1, part2;

	// the first set of tests checks the getNameInstance method
	TTTestLog("\n");
	TTTestLog("Testing Address getNameInstance Method");
	
	resultSymbol = testAddressA.getNameInstance();
	TTTestAssertion("TTAddress: Test passes if the getNameInstance() method returns \"name.instance\"",
					resultSymbol == TTSymbol("name.instance"),
					testAssertionCount,
					errorCount);

	resultSymbol = testAddressB.getNameInstance();
	TTTestAssertion("TTAddress: Test passes if the getNameInstance() method returns \"name\"",
					resultSymbol == TTSymbol("name"),
					testAssertionCount,
					errorCount);

	resultSymbol = testAddressC.getNameInstance();
	TTTestAssertion("TTAddress: Test passes if the getNameInstance() method returns \"name\"",
					resultSymbol == TTSymbol("name"),
					testAssertionCount,
					errorCount);

	resultSymbol = kTTAdrsEmpty.getNameInstance();
	TTTestAssertion("TTAddress: Test passes if the getNameInstance() method returns kTTSymEmpty",
					resultSymbol == kTTSymEmpty,
					testAssertionCount,
					errorCount);
	
	// the second set of tests checks the appendAddress method
	TTTestLog("\n");
	TTTestLog("Testing Address appendAddress Method");
	
	resultAddress = testAddressD.appendAddress(kTTAdrsEmpty);
	TTTestAssertion("TTAddress: Test passes if the appendAddress() method returns the same address",
					resultAddress == testAddressD,
					testAssertionCount,
					errorCount);
	
	resultAddress = kTTAdrsEmpty.appendAddress(testAddressD);
	TTTestAssertion("TTAddress: Test passes if the appendAddress() method returns the same address",
					resultAddress == testAddressD,
					testAssertionCount,
					errorCount);
	
	resultAddress = kTTAdrsRoot.appendAddress(testAddressD);
	TTTestAssertion("TTAddress: Test passes if the appendAddress() method returns the same address",
					resultAddress == testAddressD,
					testAssertionCount,
					errorCount);
	
	resultAddress = kTTAdrsEmpty.appendAddress(testAddressE);
	TTTestAssertion("TTAddress: Test passes if the appendAddress() method returns the same address",
					resultAddress == testAddressE,
					testAssertionCount,
					errorCount);
	
	resultAddress = kTTAdrsRoot.appendAddress(testAddressE);
	TTTestAssertion("TTAddress: Test passes if the appendAddress() method returns the same address",
					resultAddress == testAddressE,
					testAssertionCount,
					errorCount);
	
	resultAddress = testAddressD.appendAddress(testAddressF);
	TTTestAssertion("TTAddress: Test passes if the appendAddress() method returns \"/gran/parent/name.instance:attribute\"",
					resultAddress == TTAddress("/gran/parent/name.instance:attribute"),
					testAssertionCount,
					errorCount);
	
	resultAddress = testAddressD.appendAddress(testAddressG);
	TTTestAssertion("TTAddress: Test passes if the appendAddress() method returns \"/gran/parent/name.instance:attribute\"",
					resultAddress == TTAddress("/gran/parent/name.instance:attribute"),
					testAssertionCount,
					errorCount);
	
	// This test checks appendInstance() and appendAttribute() methods
	resultAddress = kTTAdrsRoot.appendAddress(TTAddress("name")).appendInstance(TTAddress("instance")).appendAttribute(TTAddress("attribute"));
	TTTestAssertion("TTAddress: Test passes if appendAddress + appendInstance + appendAttribute methods returns \"/name.instance:attribute\"",
					resultAddress == TTAddress("/name.instance:attribute"),
					testAssertionCount,
					errorCount);

	// the third set of tests checks the splitAt method
	TTTestLog("\n");
	TTTestLog("Testing Address splitAt Method");
	
	testAddressA.splitAt(0, part1, part2);
	TTTestAssertion("TTAddress: Test passes if splitAt method returns \"directory:/\" and \"gran/parent/name.instance:attribute\"",
					part1 == TTAddress("directory:/") &&
					part2 == TTAddress("gran/parent/name.instance:attribute"),
					testAssertionCount,
					errorCount);
	
	testAddressA.splitAt(1, part1, part2);
	TTTestAssertion("TTAddress: Test passes if splitAt method returns \"directory:/gran\" and \"parent/name.instance:attribute\"",
					part1 == TTAddress("directory:/gran") &&
					part2 == TTAddress("parent/name.instance:attribute"),
					testAssertionCount,
					errorCount);
	
	testAddressA.splitAt(2, part1, part2);
	TTTestAssertion("TTAddress: Test passes if splitAt method returns \"directory:/gran/parent\" and \"name.instance:attribute\"",
					part1 == TTAddress("directory:/gran/parent") &&
					part2 == TTAddress("name.instance:attribute"),
					testAssertionCount,
					errorCount);
	
	
	// the fourth set of tests checks the countSeparator method
	TTTestLog("\n");
	TTTestLog("Testing Address countSeparator Method");
	
	/*	
	// the fift set of tests checks the listNameInstance method
	TTTestLog("\n");
	TTTestLog("Testing Address listNameInstance Method");
	 */
	
}
Beispiel #14
0
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);
}
TTErr TTRamp::test(TTValue& returnedTestInfo)
{
	int					errorCount = 0;
	int					testAssertionCount = 0;
	int					badSampleCount = 0;
	int					badSampleCountTotal = 0;
	TTAudioSignalPtr	output = NULL;
	
	// create 1 channel audio signal objects
	TTObjectBaseInstantiate(kTTSym_audiosignal, &output, 1);
	output->allocWithVectorSize(64);
	
	// setup the generator
	this->setAttributeValue(TT("destinationValue"), 1.0);
	this->setAttributeValue(TT("startValue"), 0.0);
	this->setAttributeValue(TT("mode"), TT("sample"));
	this->setAttributeValue(TT("rampTime"), 64000.0/sr);
	this->process(output);
	

	// created with Octave: sig = linspace(0,1,64) 
	TTFloat64 expectedSignalTest1[64] = {
		0.0000000000000000e+00,
		1.5873015873015872e-02,
		3.1746031746031744e-02,
		4.7619047619047616e-02,
		6.3492063492063489e-02,
		7.9365079365079361e-02,
		9.5238095238095233e-02,
		1.1111111111111110e-01,
		1.2698412698412698e-01,
		1.4285714285714285e-01,
		1.5873015873015872e-01,
		1.7460317460317459e-01,
		1.9047619047619047e-01,
		2.0634920634920634e-01,
		2.2222222222222221e-01,
		2.3809523809523808e-01,
		2.5396825396825395e-01,
		2.6984126984126983e-01,
		2.8571428571428570e-01,
		3.0158730158730157e-01,
		3.1746031746031744e-01,
		3.3333333333333331e-01,
		3.4920634920634919e-01,
		3.6507936507936506e-01,
		3.8095238095238093e-01,
		3.9682539682539680e-01,
		4.1269841269841268e-01,
		4.2857142857142855e-01,
		4.4444444444444442e-01,
		4.6031746031746029e-01,
		4.7619047619047616e-01,
		4.9206349206349204e-01,
		5.0793650793650791e-01,
		5.2380952380952384e-01,
		5.3968253968253965e-01,
		5.5555555555555558e-01,
		5.7142857142857140e-01,
		5.8730158730158732e-01,
		6.0317460317460314e-01,
		6.1904761904761907e-01,
		6.3492063492063489e-01,
		6.5079365079365081e-01,
		6.6666666666666663e-01,
		6.8253968253968256e-01,
		6.9841269841269837e-01,
		7.1428571428571430e-01,
		7.3015873015873012e-01,
		7.4603174603174605e-01,
		7.6190476190476186e-01,
		7.7777777777777779e-01,
		7.9365079365079361e-01,
		8.0952380952380953e-01,
		8.2539682539682535e-01,
		8.4126984126984128e-01,
		8.5714285714285710e-01,
		8.7301587301587302e-01,
		8.8888888888888884e-01,
		9.0476190476190477e-01,
		9.2063492063492058e-01,
		9.3650793650793651e-01,
		9.5238095238095233e-01,
		9.6825396825396826e-01,
		9.8412698412698407e-01,
		1.0000000000000000e+00		
	};
	
	for (int i=0; i<64; i++) {
		TTBoolean result = !TTTestFloatEquivalence(output->mSampleVectors[0][i], expectedSignalTest1[i]);
		badSampleCount += result;
		if (result)
			//TTTestLog("BAD SAMPLE @ i=%i  ( value=%.10f   expected=%.10f )", i, output->mSampleVectors[0][i], expectedSignalTest1[i]);
            std::cout << "BAD SAMPLE @ n=" << i << " ( value=" << output->mSampleVectors[0][i] << " expected=" << expectedSignalTest1[i] << " )\n";
	}
    
	TTTestAssertion("Test 1: Produces correct ramp from 0 to 1 when a positive Frequency is defined", 
					badSampleCount == 0, 
					testAssertionCount, 
					errorCount);
    
	if (badSampleCount)
		//TTTestLog("badSampleCount is %i", badSampleCount);
        std::cout << "badSampleCount is " << badSampleCount << "\n";
	
	badSampleCountTotal += badSampleCount;
	//reinitializing for next test
	badSampleCount = 0;
	
	// Second test: now the ramp goes from 1 to 0
	
	// setup the generator
	
	this->setAttributeValue(TT("startValue"), 1.0);
	this->setAttributeValue(TT("destinationValue"), 0.0);
	this->setAttributeValue(TT("mode"), TT("sample"));
	this->setAttributeValue(TT("rampTime"), 64000.0/sr); 
	this->process(output);
	// created with Octave: linspace(1,0,64) 
	TTFloat64 expectedSignalTest2[64] = {
		1.0000000000000000e+00,
		9.8412698412698418e-01,
		9.6825396825396826e-01,
		9.5238095238095233e-01,
		9.3650793650793651e-01,
		9.2063492063492069e-01,
		9.0476190476190477e-01,
		8.8888888888888884e-01,
		8.7301587301587302e-01,
		8.5714285714285721e-01,
		8.4126984126984128e-01,
		8.2539682539682535e-01,
		8.0952380952380953e-01,
		7.9365079365079372e-01,
		7.7777777777777779e-01,
		7.6190476190476186e-01,
		7.4603174603174605e-01,
		7.3015873015873023e-01,
		7.1428571428571430e-01,
		6.9841269841269837e-01,
		6.8253968253968256e-01,
		6.6666666666666674e-01,
		6.5079365079365081e-01,
		6.3492063492063489e-01,
		6.1904761904761907e-01,
		6.0317460317460325e-01,
		5.8730158730158732e-01,
		5.7142857142857140e-01,
		5.5555555555555558e-01,
		5.3968253968253976e-01,
		5.2380952380952384e-01,
		5.0793650793650791e-01,
		4.9206349206349209e-01,
		4.7619047619047616e-01,
		4.6031746031746035e-01,
		4.4444444444444442e-01,
		4.2857142857142860e-01,
		4.1269841269841268e-01,
		3.9682539682539686e-01,
		3.8095238095238093e-01,
		3.6507936507936511e-01,
		3.4920634920634919e-01,
		3.3333333333333337e-01,
		3.1746031746031744e-01,
		3.0158730158730163e-01,
		2.8571428571428570e-01,
		2.6984126984126988e-01,
		2.5396825396825395e-01,
		2.3809523809523814e-01,
		2.2222222222222221e-01,
		2.0634920634920639e-01,
		1.9047619047619047e-01,
		1.7460317460317465e-01,
		1.5873015873015872e-01,
		1.4285714285714290e-01,
		1.2698412698412698e-01,
		1.1111111111111116e-01,
		9.5238095238095233e-02,
		7.9365079365079416e-02,
		6.3492063492063489e-02,
		4.7619047619047672e-02,
		3.1746031746031744e-02,
		1.5873015873015928e-02,
		0.0000000000000000e+00
	};
	
	for (int i=0; i<64; i++) {
		TTBoolean result = !TTTestFloatEquivalence(output->mSampleVectors[0][i], expectedSignalTest2[i]);
		badSampleCount += result;
		if (result)
			//TTTestLog("BAD SAMPLE @ i=%i  ( value=%.10f   expected=%.10f )", i, output->mSampleVectors[0][i], expectedSignalTest2[i]);
            std::cout << "BAD SAMPLE @ n=" << i << " ( value=" << output->mSampleVectors[0][i] << " expected=" << expectedSignalTest2[i] << " )\n";
	}
	
	TTTestAssertion("Test 2: Produces correct ramp from 1 to 0 when a negative Frequency is defined", 
					badSampleCount == 0,
					testAssertionCount, 
					errorCount);
    
	if (badSampleCount)
		//TTTestLog("badSampleCount is %i", badSampleCount);
        std::cout << "badSampleCount is " << badSampleCount << "\n";
	
	badSampleCountTotal += badSampleCount;
	//reinitializing for next test
	badSampleCount = 0;
	
	
	// Finish //
	
	// Total number of bad samples:
	if (badSampleCountTotal)
		TTTestLog("badSampleCountTotal is %i", badSampleCountTotal);
	
	TTObjectBaseRelease(&output);
	
	
	// Wrap up the test results to pass back to whoever called this test
	return TTTestFinish(testAssertionCount, errorCount, returnedTestInfo);
}
TTErr TTSmoothPolynomialFunction::test(TTValue& returnedTestInfo)
{
	int					errorCount = 0;
	int					testAssertionCount = 0;
	int					badSampleCount = 0;
	TTAudioSignalPtr	input = NULL;
	TTAudioSignalPtr	output = NULL;
	int					N = 128;
	TTValue				v;
	

TTFloat64 inputSignal1[128] = {
	0.0000000000000000e+00, 
	7.8740157480314960e-03, 
	1.5748031496062992e-02, 
	2.3622047244094488e-02, 
	3.1496062992125984e-02, 
	3.9370078740157480e-02, 
	4.7244094488188976e-02, 
	5.5118110236220472e-02, 
	6.2992125984251968e-02, 
	7.0866141732283464e-02, 
	7.8740157480314960e-02, 
	8.6614173228346455e-02, 
	9.4488188976377951e-02, 
	1.0236220472440945e-01, 
	1.1023622047244094e-01, 
	1.1811023622047244e-01, 
	1.2598425196850394e-01, 
	1.3385826771653545e-01, 
	1.4173228346456693e-01, 
	1.4960629921259844e-01, 
	1.5748031496062992e-01, 
	1.6535433070866143e-01, 
	1.7322834645669291e-01, 
	1.8110236220472442e-01, 
	1.8897637795275590e-01, 
	1.9685039370078741e-01, 
	2.0472440944881889e-01, 
	2.1259842519685040e-01, 
	2.2047244094488189e-01, 
	2.2834645669291340e-01, 
	2.3622047244094488e-01, 
	2.4409448818897639e-01, 
	2.5196850393700787e-01, 
	2.5984251968503935e-01, 
	2.6771653543307089e-01, 
	2.7559055118110237e-01, 
	2.8346456692913385e-01, 
	2.9133858267716534e-01, 
	2.9921259842519687e-01, 
	3.0708661417322836e-01, 
	3.1496062992125984e-01, 
	3.2283464566929132e-01, 
	3.3070866141732286e-01, 
	3.3858267716535434e-01, 
	3.4645669291338582e-01, 
	3.5433070866141730e-01, 
	3.6220472440944884e-01, 
	3.7007874015748032e-01, 
	3.7795275590551181e-01, 
	3.8582677165354329e-01, 
	3.9370078740157483e-01, 
	4.0157480314960631e-01, 
	4.0944881889763779e-01, 
	4.1732283464566927e-01, 
	4.2519685039370081e-01, 
	4.3307086614173229e-01, 
	4.4094488188976377e-01, 
	4.4881889763779526e-01, 
	4.5669291338582679e-01, 
	4.6456692913385828e-01, 
	4.7244094488188976e-01, 
	4.8031496062992124e-01, 
	4.8818897637795278e-01, 
	4.9606299212598426e-01, 
	5.0393700787401574e-01, 
	5.1181102362204722e-01, 
	5.1968503937007871e-01, 
	5.2755905511811019e-01, 
	5.3543307086614178e-01, 
	5.4330708661417326e-01, 
	5.5118110236220474e-01, 
	5.5905511811023623e-01, 
	5.6692913385826771e-01, 
	5.7480314960629919e-01, 
	5.8267716535433067e-01, 
	5.9055118110236215e-01, 
	5.9842519685039375e-01, 
	6.0629921259842523e-01, 
	6.1417322834645671e-01, 
	6.2204724409448819e-01, 
	6.2992125984251968e-01, 
	6.3779527559055116e-01, 
	6.4566929133858264e-01, 
	6.5354330708661412e-01, 
	6.6141732283464572e-01, 
	6.6929133858267720e-01, 
	6.7716535433070868e-01, 
	6.8503937007874016e-01, 
	6.9291338582677164e-01, 
	7.0078740157480313e-01, 
	7.0866141732283461e-01, 
	7.1653543307086609e-01, 
	7.2440944881889768e-01, 
	7.3228346456692917e-01, 
	7.4015748031496065e-01, 
	7.4803149606299213e-01, 
	7.5590551181102361e-01, 
	7.6377952755905509e-01, 
	7.7165354330708658e-01, 
	7.7952755905511806e-01, 
	7.8740157480314965e-01, 
	7.9527559055118113e-01, 
	8.0314960629921262e-01, 
	8.1102362204724410e-01, 
	8.1889763779527558e-01, 
	8.2677165354330706e-01, 
	8.3464566929133854e-01, 
	8.4251968503937003e-01, 
	8.5039370078740162e-01, 
	8.5826771653543310e-01, 
	8.6614173228346458e-01, 
	8.7401574803149606e-01, 
	8.8188976377952755e-01, 
	8.8976377952755903e-01, 
	8.9763779527559051e-01, 
	9.0551181102362199e-01, 
	9.1338582677165359e-01, 
	9.2125984251968507e-01, 
	9.2913385826771655e-01, 
	9.3700787401574803e-01, 
	9.4488188976377951e-01, 
	9.5275590551181100e-01, 
	9.6062992125984248e-01, 
	9.6850393700787396e-01, 
	9.7637795275590555e-01, 
	9.8425196850393704e-01, 
	9.9212598425196852e-01, 
	1.0000000000000000e+00	
};

	
TTFloat64 expectedSignal1[128] = { 
		0.0000000000000000e+00, 
		4.8244209039635314e-06, 
		3.8138443955198070e-05, 
		1.2718493906995618e-04, 
		2.9786651631526754e-04, 
		5.7476731875201535e-04, 
		9.8117481527801352e-04, 
		1.5391015934710839e-03, 
		2.2693071524321311e-03, 
		3.1913196956282223e-03, 
		4.3234579237356610e-03, 
		5.6828528274830668e-03, 
		7.2854694804944482e-03, 
		9.1461288321322883e-03, 
		1.1278529500340605e-02, 
		1.3695269564488044e-02, 
		1.6407868358210953e-02, 
		1.9426788262256446e-02, 
		2.2761456497325496e-02, 
		2.6420286916916010e-02, 
		3.0410701800165873e-02, 
		3.4739153644696097e-02, 
		3.9411146959453816e-02, 
		4.4431260057555426e-02, 
		4.9803166849129596e-02, 
		5.5529658634160470e-02, 
		6.1612665895330529e-02, 
		6.8053280090863921e-02, 
		7.4851775447369331e-02, 
		8.2007630752683164e-02, 
		8.9519551148712656e-02, 
		9.7385489924278826e-02, 
		1.0560267030795963e-01, 
		1.1416760726093299e-01, 
		1.2307612926982006e-01, 
		1.3232340013952798e-01, 
		1.4190394078609317e-01, 
		1.5181165102952443e-01, 
		1.6203983138664596e-01, 
		1.7258120486394016e-01, 
		1.8342793875039137e-01, 
		1.9457166641032828e-01, 
		2.0600350907626741e-01, 
		2.1771409764175598e-01, 
		2.2969359445421497e-01, 
		2.4193171510778244e-01, 
		2.5441775023615654e-01, 
		2.6714058730543810e-01, 
		2.8008873240697457e-01, 
		2.9325033205020234e-01, 
		3.0661319495549044e-01, 
		3.2016481384698270e-01, 
		3.3389238724544185e-01, 
		3.4778284126109205e-01, 
		3.6182285138646236e-01, 
		3.7599886428922880e-01, 
		3.9029711960505920e-01, 
		4.0470367173045396e-01, 
		4.1920441161559163e-01, 
		4.3378508855717035e-01, 
		4.4843133199125074e-01, 
		4.6312867328610041e-01, 
		4.7786256753503586e-01, 
		4.9261841534926576e-01, 
		5.0738158465073435e-01, 
		5.2213743246496436e-01, 
		5.3687132671389948e-01, 
		5.5156866800874915e-01, 
		5.6621491144282976e-01, 
		5.8079558838440848e-01, 
		5.9529632826954604e-01, 
		6.0970288039494136e-01, 
		6.2400113571077132e-01, 
		6.3817714861353769e-01, 
		6.5221715873890806e-01, 
		6.6610761275455821e-01, 
		6.7983518615301786e-01, 
		6.9338680504450978e-01, 
		7.0674966794979754e-01, 
		7.1991126759302526e-01, 
		7.3285941269456178e-01, 
		7.4558224976384357e-01, 
		7.5806828489221756e-01, 
		7.7030640554578467e-01, 
		7.8228590235824358e-01, 
		7.9399649092373314e-01, 
		8.0542833358967236e-01, 
		8.1657206124960879e-01, 
		8.2741879513605987e-01, 
		8.3796016861335465e-01, 
		8.4818834897047601e-01, 
		8.5809605921390641e-01, 
		8.6767659986047230e-01, 
		8.7692387073018008e-01, 
		8.8583239273906678e-01, 
		8.9439732969204044e-01, 
		9.0261451007572102e-01, 
		9.1048044885128654e-01, 
		9.1799236924731620e-01, 
		9.2514822455263168e-01, 
		9.3194671990913625e-01, 
		9.3838733410466979e-01, 
		9.4447034136584040e-01, 
		9.5019683315087100e-01, 
		9.5556873994244551e-01, 
		9.6058885304054709e-01, 
		9.6526084635530474e-01, 
		9.6958929819983375e-01, 
		9.7357971308308588e-01, 
		9.7723854350267647e-01, 
		9.8057321173774348e-01, 
		9.8359213164178971e-01, 
		9.8630473043551437e-01, 
		9.8872147049965875e-01, 
		9.9085387116786894e-01, 
		9.9271453051950509e-01, 
		9.9431714717251651e-01, 
		9.9567654207626521e-01, 
		9.9680868030437164e-01, 
		9.9773069284756843e-01, 
		9.9846089840652841e-01, 
		9.9901882518472185e-01, 
		9.9942523268124717e-01, 
		9.9970213348368553e-01, 
		9.9987281506093062e-01, 
		9.9996186155604327e-01, 
		9.9999517557909634e-01, 
		1.0000000000000000e+00
		};	
	
	// setup Function 
	this->setAttributeValue(TT("function"), TT("smoothPolynomial"));

	
	// create 1 channel audio signal objects
	TTObjectInstantiate(kTTSym_audiosignal, &input, 1);
	TTObjectInstantiate(kTTSym_audiosignal, &output, 1);
	input->allocWithVectorSize(N);
	output->allocWithVectorSize(N);
	
	// create a signal to be transformed and then process it)
	input->clear();	
	for (int i=0; i<N; i++)
		input->mSampleVectors[0][i] = inputSignal1[i]; 
	
	this->process(input, output);
	
	// now test the output
	for (int n=0; n<N; n++)
	{
		TTBoolean result = !TTTestFloatEquivalence(output->mSampleVectors[0][n], expectedSignal1[n]);
		badSampleCount += result;
		if (result) 
			TTTestLog("BAD SAMPLE @ n=%i ( value=%.10f	expected=%.10f )", n, output->mSampleVectors[0][n], expectedSignal1[n]);
	}
	
	TTTestAssertion("Produces correct function values", 
					badSampleCount == 0,
					testAssertionCount, 
					errorCount);
	if (badSampleCount)
		TTTestLog("badSampleCount is %i", badSampleCount);
	
	
	TTObjectRelease(&input);
	TTObjectRelease(&output);
	
	// wrap up test results and pass back to whoever called test
	return TTTestFinish(testAssertionCount, errorCount, returnedTestInfo);
	
}
Beispiel #17
0
void TTNodeLibTestAddressItem(int& errorCount, int& testAssertionCount)
{
	TTAddressItemPtr aNamespace, aParent, n, f;
	TTSymbol		aSymbol(kTTSymEmpty);
	TTBoolean aSelection, empty;
	TTUInt8 size;
	TTErr err;
	
	TTTestLog("\n");
	TTTestLog("Testing Address Item management");
	
	// The first test checks item creation and member access
	aNamespace = new TTAddressItem(kTTSymEmpty);
	aSymbol = aNamespace->getSymbol();
	aParent = aNamespace->getParent();
	aSelection = aNamespace->getSelection();
	empty = aNamespace->isEmpty();

	TTTestAssertion("TTAddressItem: Test fails if the namespace is not empty",
					empty &&
					aSymbol == NO_NAME &&
					aParent == NULL &&
					aSelection == NO,
					testAssertionCount,
					errorCount);
	
	// The second set of tests checks item management
	n = new TTAddressItem(TTSymbol("test"));
	aNamespace->merge(n);
	
	TTTestAssertion("TTAddressItem: Test fails if the namespace size is not equal 1",
					aNamespace->getSize() == 1,
					testAssertionCount,
					errorCount);
	
	f = aNamespace->getItem(n->getSymbol());
	
	if (f) {
		aSymbol = f->getSymbol();
		aParent = f->getParent();
		aSelection = f->getSelection();
		empty = f->isEmpty();
	}
	
	TTTestAssertion("TTAddressItem: Test fails if the namespace is not named \"test\" or have no parent",
					empty &&
					aSymbol == TTSymbol("test") &&
					aParent == aNamespace &&
					aSelection == NO,
					testAssertionCount,
					errorCount);
	
	aNamespace->destroy(n);
	
	TTTestAssertion("TTAddressItem: Test fails if the namespace is not empty",
					aNamespace->isEmpty(),
					testAssertionCount,
					errorCount);
	
	// The third set of tests checks item management using TTAddress
	aNamespace->clear();
    aNamespace->append(TTAddress("/parent/name"), &f);
	aNamespace->append(TTAddress("/parent/name.instance"), &f);
    
	aSymbol = aNamespace->getSymbol();
	size = aNamespace->getSize();
	
	TTTestAssertion("TTAddressItem: Test fails if the namespace is not named \"\" and size is not equal 1",
					size == 1 &&
					aSymbol == kTTSymEmpty,
					testAssertionCount,
					errorCount);
	
	f = NULL;
	err = aNamespace->find(TTAddress("/parent"), &f);
	
	if (!err) {
		aSymbol = f->getSymbol();
		aParent = f->getParent();
		aSelection = f->getSelection();
		empty = f->isEmpty();
	}
	
	TTTestAssertion("TTAddressItem: Test fails if the namespace is not named \"\" or have no parent or no child",
					!empty &&
					aSymbol == kTTSymEmpty &&
					aParent == aNamespace->getItem(TTSymbol("parent")) &&
					aSelection == NO,
					testAssertionCount,
					errorCount);
	
	n = f;
	f = NULL;
	err = aNamespace->find(TTAddress("/parent/name"), &f);
	
	if (!err) {
		aSymbol = f->getSymbol();
		aParent = f->getParent();
		aSelection = f->getSelection();
		empty = f->isEmpty();
	}
	
	TTTestAssertion("TTAddressItem: Test fails if the namespace is not named \"\" or have no parent or is not empty",
					empty &&
					aSymbol == kTTSymEmpty &&
					aParent == n->getItem(TTSymbol("name")) &&
					aSelection == NO,
					testAssertionCount,
					errorCount);
	
	n = f;
	f = NULL;
	err = aNamespace->find(TTAddress("/parent/name.instance"), &f);
	
	if (!err) {
		aSymbol = f->getSymbol();
		aParent = f->getParent();
		aSelection = f->getSelection();
		empty = f->isEmpty();
	}
    
	TTTestAssertion("TTAddressItem: Test fails if the namespace is not named \"instance\" or have no parent or is not empty",
					empty &&
					aSymbol == TTSymbol("instance") &&
					aParent == n->getParent() &&
					aSelection == NO,
					testAssertionCount,
					errorCount);
	
	f = NULL;
	aNamespace->append(TTAddress("/parent/name.other"), &f);
	
	size = f->getParent()->getSize();       // have to be 3 because there are the empty, "instance" and "other" instances
	
	TTTestAssertion("TTAddressItem: Test fails if size is not equal to 3",
					size == 3,
					testAssertionCount,
					errorCount);
}
Beispiel #18
0
TTErr TTSpatSnap::testSourceAndSinkCountSetterAndGetter(int& aTestAssertionCount, int& anErrorCount, TTValue& aReturnedTestInfo)
{
	
	TTTestLog(" ");
	TTTestLog("Changing number of sources and sinks");
	TTTestLog(" ");
	
	// Check that sourceCount defaults to 1
	
	TTFloat64 sourceCountTest;
	TTFloat64 sinkCountTest;
	
	this->getAttributeValue("sourceCount", sourceCountTest);
	TTTestAssertion("sourceCount attribute defaults to 1",
					TTTestFloatEquivalence(sourceCountTest, 1.),
					aTestAssertionCount,
					anErrorCount);
	
	// Check that sinkCount defaults to 1
	
	this->getAttributeValue("sinkCount", sinkCountTest);
	TTTestAssertion("sinkCount attribute attribute defaults to 1",
					TTTestFloatEquivalence(sinkCountTest, 1.),
					aTestAssertionCount,
					anErrorCount);
	
	// Test initial matrix size:
	
	TTTestAssertion("Initial matrix has 1 row",
					(this->mRenderer->mMixerMatrixCoefficients->getRowCount())==1,
					aTestAssertionCount,
					anErrorCount);
	
	TTTestAssertion("Initial matrix has 1 column",
					(this->mRenderer->mMixerMatrixCoefficients->getColumnCount())==1,
					aTestAssertionCount,
					anErrorCount);
	
	// Test setter and getter for sourceCount attribute
	
	this->setAttributeValue("sourceCount", 7);
	this->getAttributeValue("sourceCount", sourceCountTest);
	TTTestAssertion("setter and getter for sourceCount attribute",
					TTTestFloatEquivalence(sourceCountTest, 7.),
					aTestAssertionCount,
					anErrorCount);
	
	// Test setter and getter for sinkCount attribute
	
	this->setAttributeValue("sinkCount", 5);
	this->getAttributeValue("sinkCount", sinkCountTest);
	TTTestAssertion("setter and getter for sinkCount attribute",
					TTTestFloatEquivalence(sinkCountTest, 5.),
					aTestAssertionCount,
					anErrorCount);
	
	// Test initial matrix size:
	
	TTTestAssertion("Matrix now has 7 rows",
					(this->mRenderer->mMixerMatrixCoefficients->getRowCount())==7,
					aTestAssertionCount,
					anErrorCount);
	
	TTTestAssertion("Initial matrix has 5 columns",
					(this->mRenderer->mMixerMatrixCoefficients->getColumnCount())==5,
					aTestAssertionCount,
					anErrorCount);

	
	TTTestLog("testing");
	return kTTErrNone;
}
Beispiel #19
0
TTErr TTSpatSnap::testAudioProcessing(int& aTestAssertionCount, int& anErrorCount, TTValue& aReturnedTestInfo)
{
	TTAudioSignalPtr input = NULL;
	TTAudioSignalPtr output = NULL;
	
	// create audio signal objects
	TTObjectBaseInstantiate(kTTSym_audiosignal, &input, 7);
	TTObjectBaseInstantiate(kTTSym_audiosignal, &output, 5);
	
	input->allocWithVectorSize(64);
	output->allocWithVectorSize(64);
	
	for (TTInt16 sample=0; sample<64; sample++)
		input->mSampleVectors[0][sample] = 1.0;
	
	for (TTInt16 sample=0; sample<64; sample++)
		input->mSampleVectors[1][sample] = 2.0;
	
	for (TTInt16 sample=0; sample<64; sample++)
		input->mSampleVectors[2][sample] = 4.0;
	
	for (TTInt16 sample=0; sample<64; sample++)
		input->mSampleVectors[3][sample] = 8.0;
	
	for (TTInt16 sample=0; sample<64; sample++)
		input->mSampleVectors[4][sample] = 16.0;
	
	for (TTInt16 sample=0; sample<64; sample++)
		input->mSampleVectors[5][sample] = 32.0;
	
	for (TTInt16 sample=0; sample<64; sample++)
		input->mSampleVectors[6][sample] = 64.0;
	
	this->process(input, output);
	
	
	// Test processed audio
	TTTestLog("");
	
	// Sink 1 receieves signal fra source 2, 6 and 7: Expected value equals 2. + 32. +64. = 98.
	
	int validSampleCount = 0;
	TTSampleValuePtr samples = output->mSampleVectors[0];
	
	for (int i=0; i<64; i++) {
		validSampleCount += TTTestFloatEquivalence(98., samples[i]);
	}
	TTTestAssertion("Correct audio signal processed to sink 1",
					validSampleCount == 64,
					aTestAssertionCount,
					anErrorCount);
	TTTestLog("Number of bad samples: %i", 64-validSampleCount);
	
	// Sink 2 receieves signal fra source 3: Expected value equals 4.
	
	validSampleCount = 0;
	samples = output->mSampleVectors[1];
	
	for (int i=0; i<64; i++) {
		validSampleCount += TTTestFloatEquivalence(4., samples[i]);
	}
	TTTestAssertion("Correct audio signal processed to sink 2",
					validSampleCount == 64,
					aTestAssertionCount,
					anErrorCount);
	TTTestLog("Number of bad samples: %i", 64-validSampleCount);
	
	// Sink 3 receieves signal fra source 4: Expected value equals 8.
	
	validSampleCount = 0;
	samples = output->mSampleVectors[2];
	
	for (int i=0; i<64; i++) {
		validSampleCount += TTTestFloatEquivalence(8., samples[i]);
	}
	TTTestAssertion("Correct audio signal processed to sink 3",
					validSampleCount == 64,
					aTestAssertionCount,
					anErrorCount);
	TTTestLog("Number of bad samples: %i", 64-validSampleCount);
	
	// Sink 4 receieves signal fra source 5: Expected value equals 16.
	
	validSampleCount = 0;
	samples = output->mSampleVectors[3];
	
	for (int i=0; i<64; i++) {
		validSampleCount += TTTestFloatEquivalence(16., samples[i]);
	}
	TTTestAssertion("Correct audio signal processed to sink 4",
					validSampleCount == 64,
					aTestAssertionCount,
					anErrorCount);
	TTTestLog("Number of bad samples: %i", 64-validSampleCount);
	
	// Sink 5 receieves signal fra source 1: Expected value equals 1.
	
	validSampleCount = 0;
	samples = output->mSampleVectors[4];
	
	for (int i=0; i<64; i++) {
		validSampleCount += TTTestFloatEquivalence(1., samples[i]);
	}
	TTTestAssertion("Correct audio signal processed to sink 5",
					validSampleCount == 64,
					aTestAssertionCount,
					anErrorCount);
	TTTestLog("Number of bad samples: %i", 64-validSampleCount);
	
	TTObjectBaseRelease(&input);
	TTObjectBaseRelease(&output);
	
	return kTTErrNone;
}
Beispiel #20
0
void TTStringTestBasic(int& errorCount, int&testAssertionCount)
{	
	// TEST: empty string init
	
	TTTestLog("\n");
	TTTestLog("Testing empty string assigment");
		
	TTString empty;
	
	TTTestAssertion("created static const char* arg with correct size",
					empty.size() == 0,
					testAssertionCount,
					errorCount);
	TTTestAssertion("created from static const char* arg with correct length",
					empty.length() == 0,
					testAssertionCount,
					errorCount);
	TTTestAssertion("created from static const char* arg correctly null terminated",
					empty.at(0) == 0,
					testAssertionCount,
					errorCount);
	
	// TEST: c-string init
	
	TTTestLog("\n");
	TTTestLog("Testing basic string assigment");
	
	TTString foo("foo");
	
	TTTestAssertion("created from static const char* arg with correct size",
					foo.size() == 3,
					testAssertionCount,
					errorCount);
	TTTestAssertion("created from static const char* arg with correct length",
					foo.length() == 3,
					testAssertionCount,
					errorCount);
	TTTestAssertion("created from static const char* arg with correct chars",
					foo.at(0) == 'f' && foo.at(1) == 'o' && foo.at(2) == 'o',
					testAssertionCount,
					errorCount);
	TTTestAssertion("created from static const char* arg correctly null terminated",
					foo.at(3) == 0,
					testAssertionCount,
					errorCount);
	
	// TEST: = init
	
	TTTestLog("\n");
	TTTestLog("Testing = assigment");
	
	TTString jet;
	jet = "jet";
	
	TTTestAssertion("created from = with correct size",
					jet.size() == 3,
					testAssertionCount,
					errorCount);
	TTTestAssertion("created from = with correct length",
					jet.length() == 3,
					testAssertionCount,
					errorCount);
	TTTestAssertion("created from = with correct chars",
					jet.at(0) == 'j' && jet.at(1) == 'e' && jet.at(2) == 't',
					testAssertionCount,
					errorCount);
	TTTestAssertion("created from = correctly null terminated",
					jet.at(3) == 0,
					testAssertionCount,
					errorCount);
    
    // TEST: clear
    
    TTTestLog("\n");
	TTTestLog("Testing clear method");
    
    TTString nothing = "something";
    nothing.clear();
    
  	TTTestAssertion("cleared string with correct size",
					empty.size() == 0,
					testAssertionCount,
					errorCount);
	TTTestAssertion("cleared string with correct length",
					empty.length() == 0,
					testAssertionCount,
					errorCount);
	TTTestAssertion("cleared string correctly null terminated",
					empty.at(0) == 0,
					testAssertionCount,
					errorCount);

	// TEST: individual char access
	
	TTTestLog("\n");
	TTTestLog("Testing [] assigment");
	
	foo[0] = 'g';
	foo[2] = foo[2] + 1;
	TTTestAssertion("modified some chars using [] notation",
					foo.at(0) == 'g' && foo.at(1) == 'o' && foo.at(2) == 'p',
					testAssertionCount,
					errorCount);
	
	
	// TEST: comparison (depends on the result from above)
	
	TTTestLog("\n");
	TTTestLog("Testing == operator");
		
	TTString gop("gop");
	TTString bar("bar");
	TTString foobar("foobar");
	
	TTTestAssertion("== operator when strings have the same content",
					foo == gop,
					testAssertionCount,
					errorCount);
	TTTestAssertion("== operator when strings have different content",
					!(foo == bar),
					testAssertionCount,
					errorCount);
		
	TTTestAssertion("!= operator when strings have the same content",
					!(foo != gop),
					testAssertionCount,
					errorCount);
	TTTestAssertion("!= operator when strings have different content",
					(foo != bar),
					testAssertionCount,
					errorCount);
	
	TTTestAssertion("== operator with c-string when strings have the same content",
					foo == "gop",
					testAssertionCount,
					errorCount);
	TTTestAssertion("== operator with c-string when strings have different content",
					!(foo == "bar"),
					testAssertionCount,
					errorCount);
	
	TTTestAssertion("!= operator with c-string when strings have the same content",
					!(foo != "gop"),
					testAssertionCount,
					errorCount);
	TTTestAssertion("!= operator with c-string when strings have different content",
					(foo != "bar"),
					testAssertionCount,
					errorCount);
	
	// here the length given to the substring is too long 
	// so the foobar string is bar\00 after the substring
	// bu the last zero makes foobar different to bar
	foobar = foobar.substr(3, 4);		
	TTTestAssertion("== operator with string when strings have the same content but one created using substr with an oversize length",
					bar == foobar,
					testAssertionCount,
					errorCount);
	
}
Beispiel #21
0
void TTStringTestNumeric(int& errorCount, int&testAssertionCount)
{
	TTTestLog("\n");
	TTTestLog("Testing substring operation");
	
	TTString series("0123456789");
	
	TTString sub = series.substr(3,3);
	
	TTTestAssertion("created from substr with correct size",
					sub.size() == 3,
					testAssertionCount,
					errorCount);
	TTTestAssertion("created from substr with correct length",
					sub.length() == 3,
					testAssertionCount,
					errorCount);
	TTTestAssertion("created from substr with correct chars",
					sub.at(0) == '3' && sub.at(1) == '4' && sub.at(2) == '5',
					testAssertionCount,
					errorCount);
	TTTestAssertion("created from substr correctly null terminated",
					sub.at(3) == 0,
					testAssertionCount,
					errorCount);
	
	TTTestLog("\n");
	TTTestLog("Testing summing operation");
	
	TTString sumA;
	sumA += "/";
	
	TTTestAssertion("created from += operator with correct size",
					sumA.size() == 1,
					testAssertionCount,
					errorCount);
	TTTestAssertion("created from += operator with correct length",
					sumA.length() == 1,
					testAssertionCount,
					errorCount);
	TTTestAssertion("created from += operator correctly null terminated",
					sumA.at(1) == 0,
					testAssertionCount,
					errorCount);
	
	TTString sumB;
	sumB += '/';
	
	TTTestAssertion("created from += operator with correct size",
					sumB.size() == 1,
					testAssertionCount,
					errorCount);
	TTTestAssertion("created from += operator with correct length",
					sumB.length() == 1,
					testAssertionCount,
					errorCount);
	TTTestAssertion("created from += operator correctly null terminated",
					sumB.at(1) == 0,
					testAssertionCount,
					errorCount);
	
	
	// TEST: appending numbers
	
	TTTestLog("\n");
	TTTestLog("Testing appending numbers");
	
	TTString a;
	TTString b("Pi is roughly 7/22");

	a += "Pi is roughly ";
	a += 7u;
	a += "/";
	a += 22;
	TTTestAssertion("string built-up with a couple of ints in it",
					a == b,
					testAssertionCount,
					errorCount);
	
	b = "Pi is roughly 3.140000";
	a = "Pi is roughly ";
	a += 3.14f;
	
	TTTestAssertion("string built-up with a float in it",
					a == b,
					testAssertionCount,
					errorCount);
	
	a = "Pi is roughly ";
	a += 3.14;
	TTTestAssertion("string built-up with a double in it",
					a == b,
					testAssertionCount,
					errorCount);
	
	TTTestLog("\n");
	TTTestLog("Testing + operator");
	
	TTString z("At the far end of town");
	TTString y("where the grickle grass grows");
	TTString x("and the wind smells sour as it blows");
	TTString w = z + " " + y + " " + x + "...";
	
	TTTestAssertion("string built-up with + operator",
					w == TTString("At the far end of town where the grickle grass grows and the wind smells sour as it blows..."),
					testAssertionCount,
					errorCount);
	
}
TTErr TTSoundfile::test(TTValue& returnedTestInfo)
{
    int errorCount = 0;
    int testAssertionCount = 0;
    
    // assemble the full path of the target sound file
    
    TTString testSoundPath = TTFoundationBinaryPath;
    int pos = testSoundPath.find_last_of('/');
    testSoundPath = testSoundPath.substr(0,pos+1);
    testSoundPath += TESTFILE;

    std::cout << "We will be using the following path for testing: " << testSoundPath << "\n";

    {
        
        
		TTTestLog("\n");
		TTTestLog("Testing TTSoundfile Basics...");
		
		// TEST 0: instantiate the object to a pointer
        // ** REMOVED **
        
        // TEST 1: set the filepath
        TTBoolean result1 = { this->setFilePath(TT(testSoundPath)) == kTTErrNone };
        
        TTTestAssertion("setFilePath operates successfully",
                        result1,
                        testAssertionCount,
                        errorCount);
        
        // TEST 2: reports correct number of channels
        TTColumnID return2 = this->getNumChannels();
        TTBoolean result2 = { return2 == TESTNUMCHANNELS };
        
        TTTestAssertion("reports the correct number of channels",
                        result2,
                        testAssertionCount,
                        errorCount);
        
        if(!result2)
        {
            TTTestLog("Expected a value of %i, but returned value was %i", TESTNUMCHANNELS, return2);
        }
        
        // TEST 3: reports correct sample rate
        TTFloat64 return3 = this->getSampleRate();
        TTBoolean result3 = TTTestFloatEquivalence(return3, TESTSAMPLERATE, true, 0.0000001);
        
        TTTestAssertion("reports the correct sample rate",
                        result3,
                        testAssertionCount,
                        errorCount);
        
        if(!result3)
        {
            TTTestLog("Expected a value of %f, but returned value was %f", TESTSAMPLERATE, return3);
        }
        
        // TEST 4: reports correct duration in samples
        TTRowID return4 = this->getLengthInSamples();
        TTBoolean result4 = { return4 == TESTDURATIONINSAMPLES };
        
        TTTestAssertion("reports the correct duration in samples",
                        result4,
                        testAssertionCount,
                        errorCount);
        
        if(!result4)
        {
            TTTestLog("Expected a value of %i, but returned value was %i", TESTDURATIONINSAMPLES, return4);
        }
        
        // TEST 5: reports correct duration in seconds
        TTFloat64 return5 = this->getLengthInSeconds();
        TTBoolean result5 = TTTestFloatEquivalence(return5, TESTDURATIONINSECONDS, true, 0.0000001);
        
        TTTestAssertion("reports the correct duration in seconds",
                        result5,
                        testAssertionCount,
                        errorCount);
        
        if(!result5)
        {
            TTTestLog("Expected a value of %f, but returned value was %f", TESTDURATIONINSECONDS, return5);
        }
        
        TTTestLog("\n");
		TTTestLog("Testing TTSoundfile Metadata...");
        
        // TEST 6: reports correct title from metadata
        TTSymbol return6 = this->getTitle();
        
        TTTestLog("Expected metadata title:");
        TTTestLog(TESTTITLE);
        TTTestLog("Returned metadata title:");
        TTTestLog(return6.c_str());
        
        // TEST 7: reports correct artist from metadata
        TTSymbol return7 = this->getArtist();
        
        TTTestLog("Expected metadata artist:");
        TTTestLog(TESTARTIST);
        TTTestLog("Returned metadata artist:");
        TTTestLog(return7.c_str());
        
        // TEST 8: reports correct title from metadata
        TTSymbol return8 = this->getDate();
        
        TTTestLog("Expected metadata date:");
        TTTestLog(TESTDATE);
        TTTestLog("Returned metadata date:");
        TTTestLog(return8.c_str());
        
        // TEST 9: reports correct artist from metadata
        TTSymbol return9 = this->getAnnotation();
        
        TTTestLog("Expected metadata comment:");
        TTTestLog(TESTANNOTATION);
        TTTestLog("Returned metadata comment:");
        TTTestLog(return9.c_str());
        
        TTTestLog("\n");
		TTTestLog("Testing peek method on first 10 sample values...");
        
        TTSampleValue return10;
        TTErr error10;
        
        for (int channel=0;channel<return2;channel++)
        {
            TTTestLog("Channel %i", channel);
            for (int sample=0;sample<10;sample++)
            {
                error10 = this->peek(sample,channel,return10);
                if (error10 == kTTErrNone)
                {
                    TTTestLog("peek sample %i returned the value %f", sample, return10);
                } else {
                    TTTestLog("peek returned an error for sample %i", sample);
                }
            }
        }
        
        TTTestLog("\n");
		TTTestLog("Testing peeki between samples 2 & 3...");
        
        TTSampleValue return11;
        TTErr error11;
        TTFloat64 floatIndex;
        
        for (int channel=0;channel<return2;channel++)
        {
            TTTestLog("Channel %i", channel);
            for (int sample=0;sample<11;sample++)
            {
                floatIndex = 2 + sample*0.1;
                
                error11 = this->peeki(floatIndex,channel,return11);
                if (error11 == kTTErrNone)
                {
                    TTTestLog("peek sample %f returned the value %f", floatIndex, return11);
                } else {
                    TTTestLog("peek returned an error for sample %f", floatIndex);
                }
            }
        }
        
        
    }
    
    return TTTestFinish(testAssertionCount, errorCount, returnedTestInfo);
}
TTErr TTHalfbandLinear33::test(TTValue& returnedTestInfo)
{
	int					errorCount = 0;
	int					testAssertionCount = 0;
	int					badSampleCount = 0;
	TTAudioSignalPtr	input = NULL;
	TTAudioSignalPtr	output = NULL;
	
	// create 1 channel audio signal objects
	TTObjectBaseInstantiate(kTTSym_audiosignal, &input, 1);
	TTObjectBaseInstantiate(kTTSym_audiosignal, &output, 1);
	input->allocWithVectorSize(128);
	output->allocWithVectorSize(128);
	
	// create an impulse
	input->clear();						// set all samples to zero
	input->mSampleVectors[0][0] = 1.0;	// set the first sample to 1
	
	// setup the filter
	//this->setAttributeValue(TT("linearGain"), 0.5);
	//this->setAttributeValue(TT("delayInSamples"), 1);
	this->process(input, output);
	
	/// The following values are not necsessarily to be trusted. They were calculated from this filter unit itself at a time when the filter was assumed to work. As such, if this test fails in the future, it should be considered an indication that something has changed in the code or compiler that causes the calculated impulse response to differ from earlier results, but this test is not able to say anything meaningful about whether the old or new behaviour is to be trusted (or eventually none of them).
	TTFloat64 expectedImpulseResponse[128] = {
		0.0000000000000000e+00,
		-1.4033886144341021e-03,
		0.0000000000000000e+00,
		2.8696648020251339e-03,
		0.0000000000000000e+00,
		-5.7985191818626753e-03,
		0.0000000000000000e+00,
		1.0903029954258413e-02,
		0.0000000000000000e+00,
		-1.9971682303392909e-02,
		0.0000000000000000e+00,
		3.7485281415763530e-02,
		0.0000000000000000e+00,
		-7.9701634061165733e-02,
		0.0000000000000000e+00,
		2.9216925395010418e-01,
		5.0000000000000000e-01,
		3.4369037427197169e-01,
		0.0000000000000000e+00,
		-1.3023893952773802e-01,
		0.0000000000000000e+00,
		8.6104042704043690e-02,
		0.0000000000000000e+00,
		-6.5831676403848585e-02,
		0.0000000000000000e+00,
		5.3364446243041895e-02,
		0.0000000000000000e+00,
		-4.4382106227734967e-02,
		0.0000000000000000e+00,
		3.7295412888824341e-02,
		0.0000000000000000e+00,
		-3.1244797047627053e-02,
		0.0000000000000000e+00,
		2.6798062990289070e-02,
		0.0000000000000000e+00,
		-2.2131648330448058e-02,
		0.0000000000000000e+00,
		1.8346990400433229e-02,
		0.0000000000000000e+00,
		-1.5243355223767449e-02,
		0.0000000000000000e+00,
		1.2680069280636953e-02,
		0.0000000000000000e+00,
		-1.0553809725476822e-02,
		0.0000000000000000e+00,
		8.7857616982298780e-03,
		0.0000000000000000e+00,
		-7.3136670275350379e-03,
		0.0000000000000000e+00,
		6.0882749139391252e-03,
		0.0000000000000000e+00,
		-5.0669324833186669e-03,
		0.0000000000000000e+00,
		4.2169077154520593e-03,
		0.0000000000000000e+00,
		-3.5095610771282738e-03,
		0.0000000000000000e+00,
		2.9209172646183241e-03,
		0.0000000000000000e+00,
		-2.4310262000329379e-03,
		0.0000000000000000e+00,
		2.0233040542710959e-03,
		0.0000000000000000e+00,
		-1.6839620729024551e-03,
		0.0000000000000000e+00,
		1.4015316044449066e-03,
		0.0000000000000000e+00,
		-1.1664674133319290e-03,
		0.0000000000000000e+00,
		9.7082783948693727e-04,
		0.0000000000000000e+00,
		-8.0800107046215914e-04,
		0.0000000000000000e+00,
		6.7248368858447154e-04,
		0.0000000000000000e+00,
		-5.5969525911386462e-04,
		0.0000000000000000e+00,
		4.6582363007229645e-04,
		0.0000000000000000e+00,
		-3.8769606747829008e-04,
		0.0000000000000000e+00,
		3.2267198896539023e-04,
		0.0000000000000000e+00,
		-2.6855369234410987e-04,
		0.0000000000000000e+00,
		2.2351207385297981e-04,
		0.0000000000000000e+00,
		-1.8602480145583968e-04,
		0.0000000000000000e+00,
		1.5482486591515381e-04,
		0.0000000000000000e+00,
		-1.2885775959743082e-04,
		0.0000000000000000e+00,
		1.0724583623124941e-04,
		0.0000000000000000e+00,
		-8.9258647845389630e-05,
		0.0000000000000000e+00,
		7.4288256705464873e-05,
		0.0000000000000000e+00,
		-6.1828687935307859e-05,
		0.0000000000000000e+00,
		5.1458828369187624e-05,
		0.0000000000000000e+00,
		-4.2828193604805050e-05,
		0.0000000000000000e+00,
		3.5645082207555665e-05,
		0.0000000000000000e+00,
		-2.9666716680464188e-05,
		0.0000000000000000e+00,
		2.4691037980432186e-05,
		0.0000000000000000e+00,
		-2.0549876250725695e-05,
		0.0000000000000000e+00,
		1.7103266952687490e-05,
		0.0000000000000000e+00,
		-1.4234720291507337e-05,
		0.0000000000000000e+00,
		1.1847284050344966e-05,
		0.0000000000000000e+00,
		-9.8602667629068172e-06,
		0.0000000000000000e+00,
		8.2065104729977065e-06,
		0.0000000000000000e+00,
		-6.8301209047192577e-06,
		0.0000000000000000e+00,
		5.6845783267542965e-06,
		0.0000000000000000e+00,
		-4.7311652610242063e-06
	};
	
	//TTTestLog("\nRESULTING VALUES");
	for (int i=0; i<128; i++) {
		TTBoolean result = !TTTestFloatEquivalence(output->mSampleVectors[0][i], expectedImpulseResponse[i]);
		//TTTestLog("%.16e,", output->mSampleVectors[0][i]);
		badSampleCount += result;
		if (result)
			TTTestLog("BAD SAMPLE @ i=%i  ( value=%.10f   expected=%.10f )", i, output->mSampleVectors[0][i], expectedImpulseResponse[i]);
	}
	
	TTTestAssertion("Produces correct impulse response for a delay of 1 sample and alpha = 0.5",
					badSampleCount == 0,
					testAssertionCount,
					errorCount);
	if (badSampleCount)
		TTTestLog("badSampleCount is %i", badSampleCount);
	
	TTObjectBaseRelease(&input);
	TTObjectBaseRelease(&output);
	
	// Wrap up the test results to pass back to whoever called this test
	return TTTestFinish(testAssertionCount, errorCount, returnedTestInfo);
}
Beispiel #24
0
TTErr TTBuffer::test(TTValue& returnedTestInfo)
{
	int					errorCount = 0;
	int					testAssertionCount = 0;
	//int					badSampleCount = 0;
	
	// *** Tim's old list (we'll get there) ***
	// TODO: test filling with sine wave
	// TODO: test scaling (applying gain)
	// TODO: test normalizing (with optional arg, and also without an optional arg)
	
    this->init(1,"myFirstBuffer");
	this->setAttributeValue("lengthInSamples", 50);

	TTTestLog("\nTest checkout of first SampleMatrix...");
	
	// TEST 1: checking out a matrix returns something
	TTSampleMatrixPtr myFirstCheckOut = NULL;
	this->checkOutMatrix(myFirstCheckOut);
	
	TTBoolean result1 = { myFirstCheckOut != NULL };
	
	TTTestAssertion("checkOutMatrix returns a valid pointer", 
					result1,
					testAssertionCount, 
					errorCount);
	
	// TEST 2: how many channels does this matrix have?
	TTInt32 test2expect = 1;
	
	TTInt32 test2return = 0;
	myFirstCheckOut->getAttributeValue("numChannels", test2return);
	
	TTBoolean result2 = { test2expect == test2return };
	
	TTTestAssertion("numChannels is set properly", 
					result2,
					testAssertionCount, 
					errorCount);
	
	if(!result2)
	{
		TTTestLog("Expected a value of %i, but returned value was %i", test2expect, test2return);	
	}
	
	// TEST 3: what is the user count?
	TTInt32 test3expect = 1;
	
	TTInt32 test3return = 0;
	myFirstCheckOut->getAttributeValue("userCount", test3return);
	
	TTBoolean result3 = { test2expect == test3return };
	
	TTTestAssertion("userCount reports proper value", 
					result3,
					testAssertionCount, 
					errorCount);
	
	if(!result3)
	{
		TTTestLog("Expected a value of %i, but returned value was %i", test3expect, test3return);	
	}
	
	// TEST 4: what is the buffer stage?
	TTBoolean test4expect = true;
	
	TTBoolean test4return = false;
	test4return = myFirstCheckOut->isBufferPoolStage(kSM_Active);
	
	TTBoolean result4 = { test4expect == test4return };
	
	TTTestAssertion("bufferPoolStage reports proper value", 
					result4,
					testAssertionCount, 
					errorCount);
	
	if(!result4)
	{
		TTTestLog("Expected a value of %i, but returned value was %i", test4expect, test4return);	
	}
	
	TTTestLog("\nTest second checkout of first SampleMatrix...");
	
	// TEST 5: checking out a matrix returns something
	TTSampleMatrixPtr myFirstCheckOut2 = NULL;
	this->checkOutMatrix(myFirstCheckOut2);
	
	TTBoolean result5 = { myFirstCheckOut == myFirstCheckOut2 };
	
	TTTestAssertion("checkOutMatrix returns the same pointer", 
					result5,
					testAssertionCount, 
					errorCount);
    
    // TEST 6: what is the user count after 2 checkouts?
	TTInt32 test6expect = 2;
	
	TTInt32 test6return = 0;
	myFirstCheckOut->getAttributeValue("userCount", test6return);
	
	TTBoolean result6 = { test6expect == test6return };
	
	TTTestAssertion("userCount reports proper value after second checkout",
					result6,
					testAssertionCount,
					errorCount);
	
	if(!result6)
	{
		TTTestLog("Expected a value of %i, but returned value was %i", test6expect, test6return);
	}
	
	TTTestLog("\nTest if changing lengthInSamples attribute spawns new SampleMatrix...");
	
	// TEST 7: changing length at TTBuffer should spawn a new matrix
	TTSampleMatrixPtr mySecondCheckOut = NULL;
	this->setAttributeValue("lengthInSamples", 100);
	this->checkOutMatrix(mySecondCheckOut);
	
	TTBoolean result7 = { mySecondCheckOut != myFirstCheckOut };
	
	TTTestAssertion("checkOutMatrix returns pointer to different SampleMatrix", 
					result7,
					testAssertionCount, 
					errorCount);
					
	// TEST 8: what is the user count on new checkout?
	TTInt32 test8expect = 1;
	
	TTInt32 test8return = 0;
	mySecondCheckOut->getAttributeValue("userCount", test8return);
	
	TTBoolean result8 = { test8expect == test8return };
	
	TTTestAssertion("userCount reports proper value",
					result8,
					testAssertionCount,
					errorCount);
	
	if(!result8)
	{
		TTTestLog("Expected a value of %i, but returned value was %i", test8expect, test8return);
	}
	
	TTTestLog("\nRepeat with numChannels attribute...");
	
	// TEST 9: changing numChannels at TTBuffer should spawn a new matrix
	TTSampleMatrixPtr myThirdCheckOut = NULL;
	this->setAttributeValue("numChannels", 2);
	this->checkOutMatrix(myThirdCheckOut);
	
	TTBoolean result9 = { mySecondCheckOut != myThirdCheckOut && myFirstCheckOut != myThirdCheckOut};
	
	TTTestAssertion("checkOutMatrix returns pointer to different SampleMatrix", 
					result9,
					testAssertionCount, 
					errorCount);
					
	// TEST 10: what is the user count on new checkout?
	TTInt32 test10expect = 1;
	
	TTInt32 test10return = 0;
	myThirdCheckOut->getAttributeValue("userCount", test10return);
	
	TTBoolean result10 = { test10expect == test10return };
	
	TTTestAssertion("userCount reports proper value",
					result10,
					testAssertionCount,
					errorCount);
	
	if(!result10)
	{
		TTTestLog("Expected a value of %i, but returned value was %i", test10expect, test10return);
	}
	
	
	/******/
	TTTestLog("\nAt this point, 3 SampleMatrix objects are checked out via 4 pointers:");
	TTTestLog("myFirstCheckOut: userCount %i, Active %i, Becoming Idle %i", myFirstCheckOut->getUserCount(), myFirstCheckOut->isBufferPoolStage(kSM_Active), myFirstCheckOut->isBufferPoolStage(kSM_BecomingIdle));
	TTTestLog("myFirstCheckOut2: userCount %i, Active %i, Becoming Idle %i", myFirstCheckOut2->getUserCount(), myFirstCheckOut2->isBufferPoolStage(kSM_Active), myFirstCheckOut2->isBufferPoolStage(kSM_BecomingIdle));
	TTTestLog("mySecondCheckOut: userCount %i, Active %i, Becoming Idle %i", mySecondCheckOut->getUserCount(), mySecondCheckOut->isBufferPoolStage(kSM_Active), mySecondCheckOut->isBufferPoolStage(kSM_BecomingIdle));
	TTTestLog("myThirdCheckOut: userCount %i, Active %i, Becoming Idle %i", myThirdCheckOut->getUserCount(), myThirdCheckOut->isBufferPoolStage(kSM_Active), myThirdCheckOut->isBufferPoolStage(kSM_BecomingIdle));
	/******/
	
	
	TTTestLog("\nTesting check in process...");
	
	// TEST 11: checking out a matrix returns NULL pointer
	this->checkInMatrix(myFirstCheckOut);

	TTBoolean result11 = { myFirstCheckOut == NULL };
	
	TTTestAssertion("checkInMatrix(myFirstCheckOut) resets pointer to NULL", 
					result11,
					testAssertionCount, 
					errorCount);
					
	// TEST 12: second pointer to first matrix is still valid
	TTBoolean result12 = { myFirstCheckOut2 != NULL };
	
	TTTestAssertion("myFirstCheckOut2 is still a valid pointer", 
					result12,
					testAssertionCount, 
					errorCount);
	
	// TEST 13: poke/peek a sample into first matrix
	TTSampleValue test13expect = TTRandom64();
	myFirstCheckOut2->poke(10,0,test13expect);
					
	TTSampleValue test13return;
	myFirstCheckOut2->peek(10,0,test13return);
	
	TTBoolean result13 = TTTestFloatEquivalence(test13expect,test13return);
	
	TTTestAssertion("poke/peek sample value still works",
					result13,
					testAssertionCount,
					errorCount);

	if(!result13)
	{
		TTTestLog("Expected a value of %i, but returned value was %i", test13expect, test13return);
	}
	
	// TEST 14: checking out a matrix returns NULL pointer
	this->checkInMatrix(myFirstCheckOut2);

	TTBoolean result14 = { myFirstCheckOut2 == NULL };
	
	TTTestAssertion("checkInMatrix(myFirstCheckOut2) resets pointer to NULL", 
					result14,
					testAssertionCount, 
					errorCount);
	
	// TEST 15: checking out a matrix returns NULL pointer
	this->checkInMatrix(mySecondCheckOut);

	TTBoolean result15 = { mySecondCheckOut == NULL };
	
	TTTestAssertion("checkInMatrix(mySecondCheckOut) resets pointer to NULL", 
					result15,
					testAssertionCount, 
					errorCount);
					
	// TEST 16: checking out a matrix returns NULL pointer
	this->checkInMatrix(myThirdCheckOut);

	TTBoolean result16 = { myThirdCheckOut == NULL };
	
	TTTestAssertion("checkInMatrix(myThirdCheckOut) resets pointer to NULL", 
					result16,
					testAssertionCount, 
					errorCount);

	// The following is effectively taken care of through check in...
	//TTObjectRelease(&myFirstCheckOut);
	//TTObjectRelease(&mySecondCheckOut);
	//TTObjectRelease(&myThirdCheckOut);
	
	// Wrap up the test results to pass back to whoever called this test
	return TTTestFinish(testAssertionCount, errorCount, returnedTestInfo);
	

}
Beispiel #25
0
TTErr TTSpatSnap::testMatrixCoefficients(int& aTestAssertionCount, int& anErrorCount, TTValue& aReturnedTestInfo)
{
	TTFloat64 expectedValues[7][5];
	TTFloat64 retrievedCoefficientValues[7][5];
	TTFloat64 diff;
	TTFloat64 absDiffSum=0;
	
	// Extected matrix values based on matrix size and source/sink positions as set in previous methods
	expectedValues[0][0] = 0.;
	expectedValues[0][1] = 0.;
	expectedValues[0][2] = 0.;
	expectedValues[0][3] = 0.;
	expectedValues[0][4] = 1.;

	expectedValues[1][0] = 1.;
	expectedValues[1][1] = 0.;
	expectedValues[1][2] = 0.;
	expectedValues[1][3] = 0.;
	expectedValues[1][4] = 0.;

	expectedValues[2][0] = 0.;
	expectedValues[2][1] = 1.;
	expectedValues[2][2] = 0.;
	expectedValues[2][3] = 0.;
	expectedValues[2][4] = 0.;

	expectedValues[3][0] = 0.;
	expectedValues[3][1] = 0.;
	expectedValues[3][2] = 1.;
	expectedValues[3][3] = 0.;
	expectedValues[3][4] = 0.;

	expectedValues[4][0] = 0.;
	expectedValues[4][1] = 0.;
	expectedValues[4][2] = 0.;
	expectedValues[4][3] = 1.;
	expectedValues[4][4] = 0.;

	expectedValues[5][0] = 1.;
	expectedValues[5][1] = 0.;
	expectedValues[5][2] = 0.;
	expectedValues[5][3] = 0.;
	expectedValues[5][4] = 0.;

	expectedValues[6][0] = 1.;
	expectedValues[6][1] = 0.;
	expectedValues[6][2] = 0.;
	expectedValues[6][3] = 0.;
	expectedValues[6][4] = 0.;
	
	// Get all current matrix coefficients
	for (TTInt16 row=0; row<7; row++) {
		for (TTInt16 col=0; col<5; col++) {
			this->mRenderer->mMixerMatrixCoefficients->get2d(row, col, retrievedCoefficientValues[row][col]);
			diff = retrievedCoefficientValues[row][col] - expectedValues[row][col];
			absDiffSum += diff*diff;
		}
	}
	
	TTTestLog("");
	TTTestAssertion("Correct matrix coefficients",
					TTTestFloatEquivalence(absDiffSum, 0.),
					aTestAssertionCount,
					anErrorCount);
	
	return kTTErrNone;
}
TTErr TTLinearFunction::test(TTValue& returnedTestInfo)
{
	int					errorCount = 0;
	int					testAssertionCount = 0;
	int					badSampleCount = 0;
	TTAudioSignalPtr	input = NULL;
	TTAudioSignalPtr	output = NULL;
	int					N = 128;
	TTValue				v;
	

TTFloat64 expectedSignalTest1[128] = {
	0.0000000000000000e+00, 
	7.8740157480314960e-03, 
	1.5748031496062992e-02, 
	2.3622047244094488e-02, 
	3.1496062992125984e-02, 
	3.9370078740157480e-02, 
	4.7244094488188976e-02, 
	5.5118110236220472e-02, 
	6.2992125984251968e-02, 
	7.0866141732283464e-02, 
	7.8740157480314960e-02, 
	8.6614173228346455e-02, 
	9.4488188976377951e-02, 
	1.0236220472440945e-01, 
	1.1023622047244094e-01, 
	1.1811023622047244e-01, 
	1.2598425196850394e-01, 
	1.3385826771653545e-01, 
	1.4173228346456693e-01, 
	1.4960629921259844e-01, 
	1.5748031496062992e-01, 
	1.6535433070866143e-01, 
	1.7322834645669291e-01, 
	1.8110236220472442e-01, 
	1.8897637795275590e-01, 
	1.9685039370078741e-01, 
	2.0472440944881889e-01, 
	2.1259842519685040e-01, 
	2.2047244094488189e-01, 
	2.2834645669291340e-01, 
	2.3622047244094488e-01, 
	2.4409448818897639e-01, 
	2.5196850393700787e-01, 
	2.5984251968503935e-01, 
	2.6771653543307089e-01, 
	2.7559055118110237e-01, 
	2.8346456692913385e-01, 
	2.9133858267716534e-01, 
	2.9921259842519687e-01, 
	3.0708661417322836e-01, 
	3.1496062992125984e-01, 
	3.2283464566929132e-01, 
	3.3070866141732286e-01, 
	3.3858267716535434e-01, 
	3.4645669291338582e-01, 
	3.5433070866141730e-01, 
	3.6220472440944884e-01, 
	3.7007874015748032e-01, 
	3.7795275590551181e-01, 
	3.8582677165354329e-01, 
	3.9370078740157483e-01, 
	4.0157480314960631e-01, 
	4.0944881889763779e-01, 
	4.1732283464566927e-01, 
	4.2519685039370081e-01, 
	4.3307086614173229e-01, 
	4.4094488188976377e-01, 
	4.4881889763779526e-01, 
	4.5669291338582679e-01, 
	4.6456692913385828e-01, 
	4.7244094488188976e-01, 
	4.8031496062992124e-01, 
	4.8818897637795278e-01, 
	4.9606299212598426e-01, 
	5.0393700787401574e-01, 
	5.1181102362204722e-01, 
	5.1968503937007871e-01, 
	5.2755905511811019e-01, 
	5.3543307086614178e-01, 
	5.4330708661417326e-01, 
	5.5118110236220474e-01, 
	5.5905511811023623e-01, 
	5.6692913385826771e-01, 
	5.7480314960629919e-01, 
	5.8267716535433067e-01, 
	5.9055118110236215e-01, 
	5.9842519685039375e-01, 
	6.0629921259842523e-01, 
	6.1417322834645671e-01, 
	6.2204724409448819e-01, 
	6.2992125984251968e-01, 
	6.3779527559055116e-01, 
	6.4566929133858264e-01, 
	6.5354330708661412e-01, 
	6.6141732283464572e-01, 
	6.6929133858267720e-01, 
	6.7716535433070868e-01, 
	6.8503937007874016e-01, 
	6.9291338582677164e-01, 
	7.0078740157480313e-01, 
	7.0866141732283461e-01, 
	7.1653543307086609e-01, 
	7.2440944881889768e-01, 
	7.3228346456692917e-01, 
	7.4015748031496065e-01, 
	7.4803149606299213e-01, 
	7.5590551181102361e-01, 
	7.6377952755905509e-01, 
	7.7165354330708658e-01, 
	7.7952755905511806e-01, 
	7.8740157480314965e-01, 
	7.9527559055118113e-01, 
	8.0314960629921262e-01, 
	8.1102362204724410e-01, 
	8.1889763779527558e-01, 
	8.2677165354330706e-01, 
	8.3464566929133854e-01, 
	8.4251968503937003e-01, 
	8.5039370078740162e-01, 
	8.5826771653543310e-01, 
	8.6614173228346458e-01, 
	8.7401574803149606e-01, 
	8.8188976377952755e-01, 
	8.8976377952755903e-01, 
	8.9763779527559051e-01, 
	9.0551181102362199e-01, 
	9.1338582677165359e-01, 
	9.2125984251968507e-01, 
	9.2913385826771655e-01, 
	9.3700787401574803e-01, 
	9.4488188976377951e-01, 
	9.5275590551181100e-01, 
	9.6062992125984248e-01, 
	9.6850393700787396e-01, 
	9.7637795275590555e-01, 
	9.8425196850393704e-01, 
	9.9212598425196852e-01, 
	1.0000000000000000e+00	
};

	
	// setup Function
	this->setAttributeValue(TT("function"), TT("linear"));
	
	// 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->clear();	
	for (int i=0; i<N; i++)
		input->mSampleVectors[0][i] = expectedSignalTest1[i]; 
	
	this->process(input, output);
	
	// now test the output
	for (int n=0; n<N; n++)
	{
		TTBoolean result = !TTTestFloatEquivalence(output->mSampleVectors[0][n], expectedSignalTest1[n]);
		badSampleCount += result;
		if (result) 
			TTTestLog("BAD SAMPLE @ n=%i ( value=%.10f	expected=%.10f )", n, output->mSampleVectors[0][n], expectedSignalTest1[n]);
	}
	
	TTTestAssertion("Produces correct function values", 
					badSampleCount == 0,
					testAssertionCount, 
					errorCount);
	if (badSampleCount)
		TTTestLog("badSampleCount is %i", badSampleCount);
	
	
	TTObjectBaseRelease(&input);
	TTObjectBaseRelease(&output);
	
	// wrap up test results and pass back to whoever called test
	return TTTestFinish(testAssertionCount, errorCount, returnedTestInfo);
	
}
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);
}
TTErr TTSoundfileLoader::test(TTValue& returnedTestInfo)
{
    int errorCount = 0;
    int testAssertionCount = 0;
    
    // assemble the full path of the target sound file
    
    TTString testSoundPath = TTFoundationBinaryPath;
    int pos = testSoundPath.find_last_of('/');
    testSoundPath = testSoundPath.substr(0,pos+1);
    testSoundPath += TESTFILE;
    
    std::cout << "We will be using the following path for testing: " << testSoundPath << "\n";
    
    try {
        
		TTTestLog("\n");
		TTTestLog("Testing TTSoundfileLoader Basics...");
		
        // TEST 0: establish our objects & pointers
        TTObject* testTargetMatrix = new TTObject("samplematrix");
        TTObject* testNonSampleMatrix = new TTObject("delay");
        TTObjectBase* objectBasePtrToSampleMatrix;
        TTObjectBase* ptrToNonSampleMatrix;
        
        // TEST 1: set the filepath
        TTBoolean result1 = { this->setFilePath(TT(testSoundPath)) == kTTErrNone };
        
        TTTestAssertion("setFilePath operates successfully",
                        result1,
                        testAssertionCount,
                        errorCount);
        
        // TEST 2: set up the samplematrix first
        int channelsSend = 1;           // compiler complained about TTInt32 being ambiguous here
        int lengthSend = 22050;         // compiler complained about TTInt32 being ambiguous here
        testTargetMatrix->set("numChannels", channelsSend);
        testTargetMatrix->set("lengthInSamples", lengthSend);
        
        TTInt32 channelsReturn, lengthReturn;
        
        testTargetMatrix->get("numChannels", channelsReturn);
        testTargetMatrix->get("lengthInSamples", lengthReturn);
        
        // now for the actual test
        TTBoolean result2a = { channelsSend == channelsReturn };
        
        TTTestAssertion("numChannels attribute set successfully",
						result2a,
						testAssertionCount,
						errorCount);
        
        TTBoolean result2b = { lengthSend == lengthReturn };
        
        TTTestAssertion("lengthInSamples attribute set successfully",
						result2b,
						testAssertionCount,
						errorCount);
        //
        
        // TEST 3: set the target via an objectBasePtr
        objectBasePtrToSampleMatrix = testTargetMatrix->instance(); // is there a better syntax for this?
        
        TTBoolean result3 = { this->setTargetMatrix(objectBasePtrToSampleMatrix) == kTTErrNone };
        
        TTTestAssertion("setTargetMatrix via ObjectBasePtr operates successfully",
						result3,
						testAssertionCount,
						errorCount);
        
        // TEST 4: set the target to a non-SampleMatrix, should FAIL
        ptrToNonSampleMatrix = testNonSampleMatrix->instance();
        
        TTBoolean result4 = { this->setTargetMatrix(ptrToNonSampleMatrix) == kTTErrInvalidValue };
        
        TTTestAssertion("setTargetMatrix returns error when not a SampleMatrix",
						result4,
						testAssertionCount,
						errorCount);
        
        // TEST 5: copy samplevalues until samplematrix is filled
        
        TTBoolean result5 = { this->copyUntilFilled() == kTTErrNone };
        
        TTTestAssertion("copyUntilFilled operates successfully",
						result5,
						testAssertionCount,
						errorCount);
        
        // releasing objects
        objectBasePtrToSampleMatrix = NULL;
        ptrToNonSampleMatrix = NULL;
        delete testTargetMatrix;
        delete testNonSampleMatrix;
        
        
        // TEST 6: use TTSampleMatrix's load message, then compare 5 random sample values for equivalence
        
        // create a new TTSampleMatrix
        TTObject newTargetMatrix("samplematrix");
        
        // set the length and channel count
        newTargetMatrix.set("numChannels", TESTNUMCHANNELS);
        newTargetMatrix.set("lengthInSamples", TESTDURATIONINSAMPLES);
        
        // prepare necessary TTValues
        TTValue loadInput6 = TT(testSoundPath); // we cannot pass the naked TTString, it needs to be part of a TTValue
        TTValue aReturnWeDontCareAbout6;
        
        // send message
        TTBoolean result6a = { newTargetMatrix.send("load", loadInput6, aReturnWeDontCareAbout6) == kTTErrNone };
        
        TTTestAssertion("TTSampleMatrix load operates successfully",
                        result6a,
                        testAssertionCount,
                        errorCount);
        
        // now let's test some values!
        int randomIndex6, randomChannel6;
        TTSampleValue testValueSoundFile6;
        TTBoolean result6b = true;
        
        for (int i = 0; i<10; i++)
        {
            randomIndex6 = lengthReturn * TTRandom64();
            randomChannel6 = i % TESTNUMCHANNELS;
            //std::cout << "let's look at index " << randomIndex6 << " & channel " << randomChannel6 << "\n";
            
            TTValue peekInput6(randomIndex6);
            peekInput6.append(randomChannel6);
            TTValue peekOutput6;
            
            this->peek(randomIndex6,randomChannel6,testValueSoundFile6);
            newTargetMatrix.send("peek",peekInput6,peekOutput6);
            //std::cout << "Does " << testValueSoundFile6 << " = " << double(peekOutput6) << " ?\n";
            
            if (result6b) // allows test to keep variable false once it is false
                result6b = TTTestFloatEquivalence(testValueSoundFile6, double(peekOutput6), true, 0.0000001);
        }
        
        
        TTTestAssertion("comparing values @ 10 random indexes for equivalence",
                        result6b,
                        testAssertionCount,
                        errorCount);
        
        
        // TEST 7: now use TTBuffer's load message, and again compare 5 random sample values for equivalence
        
        // create a new TTBuffer with convenience syntax
        TTAudioBuffer aBufferByAnyOtherName(TESTNUMCHANNELS, TESTDURATIONINSAMPLES);
        
        // prepare necessary TTValues
        TTValue loadInput7 = TT(testSoundPath); // we cannot pass the naked TTString, it needs to be part of a TTValue
        
        // send message
        TTBoolean result7a = { aBufferByAnyOtherName.load(loadInput7) == kTTErrNone };
        
        TTTestAssertion("TTBuffer load operates successfully",
                        result7a,
                        testAssertionCount,
                        errorCount);
        
        // setup pointer to samplematrix
        TTSampleMatrixPtr myMatrix7;
        
        // check out samplematrix
        TTBoolean result7b = { aBufferByAnyOtherName.checkOutMatrix(myMatrix7) == kTTErrNone };
        
        TTTestAssertion("TTBuffer checks out SampleMatrix successfully",
                        result7b,
                        testAssertionCount,
                        errorCount);
        
        TTValue testChannel, testSample;
        myMatrix7->getNumChannels(testChannel);
        myMatrix7->getLengthInSamples(testSample);
        
        //std::cout << "Samplematrix has " << int(testChannel) << " channels & " << int(testSample) << " samples\n";
        
        // now let's test some values!
        int randomIndex7, randomChannel7;
        double testValueSoundFile7, testValueSampleMatrix7;
        TTBoolean result7c = true;
        
        for (int i = 0; i<10; i++)
        {
            randomIndex7 = lengthReturn * TTRandom64();
            randomChannel7 = i % TESTNUMCHANNELS;
            //std::cout << "let's look at index " << randomIndex7 << " & channel " << randomChannel7 << "\n";
            
            this->peek(randomIndex7,randomChannel7,testValueSoundFile7);
            myMatrix7->peek(randomIndex7,randomChannel7,testValueSampleMatrix7);
            //std::cout << "Does " << testValueSoundFile7 << " = " << testValueSampleMatrix7 << " ?\n";
            
            if (result7c) // allows test to keep variable false once it is false
                result7c = TTTestFloatEquivalence(testValueSoundFile7, testValueSampleMatrix7, true, 0.0000001);
        }
        
        TTTestAssertion("comparing values @ 10 random indexes for equivalence",
                        result7c,
                        testAssertionCount,
                        errorCount);
        
        // check in samplematrix
        TTBoolean result7d = { aBufferByAnyOtherName.checkInMatrix(myMatrix7) == kTTErrNone };
        
        TTTestAssertion("TTBuffer checks in SampleMatrix successfully",
                        result7d,
                        testAssertionCount,
                        errorCount);
        
        
        // TEST 8: use optional load parameters to copy samples 5 to 15 from channel 0
        
        // resize
        aBufferByAnyOtherName.set("numChannels", 1);
        aBufferByAnyOtherName.set("lengthInSamples", 10);
        
        // prepare necessary TTValues
        int copyChannel8 = 0;       // first channel
        int startIndex8 = 5;        // start @ sample 5
        int endIndex8 = 15;         // end @ sample 15
        
        TTValue loadInput8 = TT(testSoundPath); // we cannot pass the naked TTString, it needs to be part of a TTValue
        loadInput8.append(copyChannel8);
        loadInput8.append(startIndex8);
        loadInput8.append(endIndex8);
        
        // send message
        TTBoolean result8a = { aBufferByAnyOtherName.load(loadInput8) == kTTErrNone };
        
        TTTestAssertion("TTBuffer load operates successfully w optional parameters",
                        result8a,
                        testAssertionCount,
                        errorCount);
        
        // setup pointer to samplematrix
        TTSampleMatrixPtr myMatrix8;
        
        // check out samplematrix
        TTBoolean result8b = { aBufferByAnyOtherName.checkOutMatrix(myMatrix8) == kTTErrNone };
        
        TTTestAssertion("TTBuffer checks out SampleMatrix successfully",
                        result8b,
                        testAssertionCount,
                        errorCount);
        
        // now let's test some values!
        double testValueSoundFile8, testValueSampleMatrix8;
        TTBoolean result8c = true;

        for (int i = 0; i<10; i++)
        {
            //std::cout << "let's look at index " << i << "\n";
            
            this->peek(i+startIndex8,copyChannel8,testValueSoundFile8);
            myMatrix8->peek(i,copyChannel8,testValueSampleMatrix8);
            //std::cout << "Does " << testValueSoundFile8 << " = " << testValueSampleMatrix8 << " ?\n";
            
            if (result8c) // allows test to keep variable false once it is false
                result8c = TTTestFloatEquivalence(testValueSoundFile8, testValueSampleMatrix8, true, 0.0000001);
        }
        
        TTTestAssertion("comparing all 10 copied values for equivalence",
                        result8c,
                        testAssertionCount,
                        errorCount);
        
        // check in samplematrix
        TTBoolean result8d = { aBufferByAnyOtherName.checkInMatrix(myMatrix8) == kTTErrNone };
        
        TTTestAssertion("TTBuffer checks in SampleMatrix successfully",
                        result8d,
                        testAssertionCount,
                        errorCount);
        
        // TEST 9: load soundfile into buffer/samplematrix with different sample rate
        
        TTValue testChannel9in = 2;
        TTValue testSampleRate9in = 88200;
        TTValue testLengthSec9in = 0.25;
        
        
        aBufferByAnyOtherName.set("numChannels", testChannel9in);
        aBufferByAnyOtherName.set("sampleRate", testSampleRate9in);
        aBufferByAnyOtherName.set("lengthInSeconds", testLengthSec9in);
        
        TTValue loadInput9 = TT(testSoundPath); // we cannot pass the naked TTString, it needs to be part of a TTValue
        
        // send message
        TTBoolean result9a = { aBufferByAnyOtherName.load(loadInput9) == kTTErrNone };
        
        TTTestAssertion("TTBuffer load operates successfully when sample rates differ",
                        result9a,
                        testAssertionCount,
                        errorCount);
        
        // setup pointer to samplematrix
        TTSampleMatrixPtr myMatrix9;
        
        // check out samplematrix
        TTBoolean result9b = { aBufferByAnyOtherName.checkOutMatrix(myMatrix9) == kTTErrNone };
        
        TTTestAssertion("TTBuffer checks out SampleMatrix successfully",
                        result9b,
                        testAssertionCount,
                        errorCount);
        
        TTValue testChannel9, testSampleCount9, testSampleRate9;
        myMatrix9->getAttributeValue("numChannels", testChannel9);
        myMatrix9->getAttributeValue("lengthInSamples", testSampleCount9);
        myMatrix9->getAttributeValue("sampleRate", testSampleRate9);
        
        /*std::cout << "Samplematrix has " << TTInt32(testChannel9) << " channels & " << TTInt32(testSampleCount9) << " samples @ " << TTInt32(testSampleRate9) << " Hz\n";*/
        
        // check out samplematrix
        TTBoolean result9c = {  TTInt32(testChannel9) == TTInt32(testChannel9in) &&
                                TTInt32(testSampleRate9) == TTInt32(testSampleRate9in) &&
                                TTInt32(testSampleCount9) == (TTInt32(testSampleRate9in) * TTFloat64(testLengthSec9in)) };
        
        TTTestAssertion("SampleMatrix has same attributes set via TTBuffer",
                        result9c,
                        testAssertionCount,
                        errorCount);
        
        
        // let's test some values
        int randomIndex9, randomChannel9;
        TTSampleValue testSoundFileValue9, testSampleMatrixValue9;
        TTBoolean result9d = true;
        
        for (int i = 0; i<10; i++)
        {
            randomIndex9 = int(testSampleCount9) * TTRandom64();
            randomChannel9 = i % TESTNUMCHANNELS;
            //std::cout << "let's look at index " << randomIndex9 << " & channel " << randomChannel9 << "\n";
            
            this->peeki(float(randomIndex9)/2.0, randomChannel9, testSoundFileValue9);
            myMatrix9->peek(randomIndex9, randomChannel9, testSampleMatrixValue9);
            //std::cout << "Does " << testSoundFileValue9 << " = " << testSampleMatrixValue9 << " ?\n";
            
            if (result9d) // allows test to keep variable false once it is false
                result9d = TTTestFloatEquivalence(testSoundFileValue9, testSampleMatrixValue9, true, 0.0000001);
        }
        
        TTTestAssertion("comparing values @ 10 random indexes for equivalence",
                        result9d,
                        testAssertionCount,
                        errorCount);
        
        // check in samplematrix
        TTBoolean result9e = { aBufferByAnyOtherName.checkInMatrix(myMatrix9) == kTTErrNone };
        
        TTTestAssertion("TTBuffer checks in SampleMatrix successfully",
                        result9e,
                        testAssertionCount,
                        errorCount);
        
        // TEST 10: use resizeThenLoad message and test that TTSampleMatrix conforms to sound file loaded
        
        TTAudioBuffer bufferForTest10(1,1); // start by making the buffer really tiny
        
        TTValue loadInput10 = TT(testSoundPath);
        
        // send message
        TTBoolean result10a = { bufferForTest10.resizeThenLoad(loadInput10) == kTTErrNone };
        
        TTTestAssertion("TTBuffer resizeThenLoad operates successfully",
                        result10a,
                        testAssertionCount,
                        errorCount);
        
        // setup pointer to samplematrix
        TTSampleMatrixPtr myMatrix10;
        
        // check out samplematrix
        TTBoolean result10b = { bufferForTest10.checkOutMatrix(myMatrix10) == kTTErrNone };
        
        TTTestAssertion("TTBuffer checks out SampleMatrix successfully",
                        result10b,
                        testAssertionCount,
                        errorCount);
        
        // do some more tests here
        TTValue testChannel10, testLengthSec10, testLengthSample10;
        myMatrix10->getAttributeValue("numChannels", testChannel10);
        myMatrix10->getAttributeValue("lengthInSeconds", testLengthSec10);
        myMatrix10->getAttributeValue("lengthInSamples", testLengthSample10);
        
        /*std::cout << "Samplematrix has " << TTInt32(testChannel10) << " channels & " << TTInt32(testLengthSample10) << " samples and is " << TTFloat64(testLengthSec10) << " secs long\n";*/
        
        TTBoolean result10c = { TTInt32(testChannel10) == TESTNUMCHANNELS &&
                                TTInt32(testLengthSample10) == TESTDURATIONINSAMPLES };
        
        TTTestAssertion("TTBuffer.resizeThenLoad results in properly sized TTSampleMatrix",
                        result10c,
                        testAssertionCount,
                        errorCount);
        
        // check in samplematrix
        TTBoolean result10e = { bufferForTest10.checkInMatrix(myMatrix10) == kTTErrNone };
        
        TTTestAssertion("TTBuffer checks in SampleMartix successfully",
                        result10e,
                        testAssertionCount,
                        errorCount);
        
    } catch (...) {
        TTTestAssertion("FAILED to run tests -- likely that necessary objects did not instantiate",
            0,
            testAssertionCount,
            errorCount);
        
    }
    
    return TTTestFinish(testAssertionCount, errorCount, returnedTestInfo);
}
Beispiel #29
0
TTErr TTGain::test(TTValue& returnedTestInfo)
{
	// preliminary setup
	
	int	errorCount = 0;
	int testAssertionCount = 0;
	
	TTTestLog("Testing Parameter value conversions");
	
	
	// N test assertions
	
	// Test 1: trival value conversion
	this->setAttributeValue(TT("midiGain"), 100);
	TTTestAssertion("midi gain of 100 == linear gain of 1.", 
					TTTestFloatEquivalence(this->mGain, 1.0), 
					testAssertionCount, 
					errorCount);
	
	// Test 2: trival value conversion
	this->setAttributeValue(TT("midiGain"), 99);
	TTTestAssertion("midi gain of 99 != linear gain of 1.", 
					TTTestFloatEquivalence(this->mGain, 1.0, false), 
					testAssertionCount, 
					errorCount);
	
	// Test 3: audio test
	// set the input signals 1
	// apply -6 dB gain
	// check that the signals are properly scaled
	
	TTAudioSignalPtr input = NULL;
	TTAudioSignalPtr output = NULL;
	
	// create 1 channel audio signal objects
	TTObjectInstantiate(kTTSym_audiosignal, &input, 1);
	TTObjectInstantiate(kTTSym_audiosignal, &output, 1);
	
	input->allocWithVectorSize(64);
	output->allocWithVectorSize(64);
	
	for (int i=0; i<64; i++)
		input->mSampleVectors[0][i] = 1.0;
	
	this->setAttributeValue(TT("gain"), -6.0);
	this->process(input, output);
	
	TTSampleValuePtr samples = output->mSampleVectors[0];
	int validSampleCount = 0;
	
	for (int i=0; i<64; i++) {
		validSampleCount += TTTestFloatEquivalence(0.5011872336272722, samples[i]);
	}
	TTTestAssertion("accumulated audio error at gain = -6 dB", 
					validSampleCount == 64, 
					testAssertionCount, 
					errorCount);
	TTTestLog("Numbe of bad samples: %i", 64-validSampleCount);
	
	TTObjectRelease(&input);
	TTObjectRelease(&output);
	
	
	// Wrap up the test results to pass back to whoever called this test
	return TTTestFinish(testAssertionCount, errorCount, returnedTestInfo);
}
Beispiel #30
0
void TTNodeLibTestAddressParsing(int& errorCount, int& testAssertionCount)
{
	TTTestLog("\n");
	TTTestLog("Testing Address Parsing");
	
	TTAddress		testAddress1("directory1:/gran/parent1/name1.instance1:attribute1");
	
	TTSymbol		directory1	= testAddress1.getDirectory();
	TTAddress		parent1		= testAddress1.getParent();
	TTSymbol		name1		= testAddress1.getName();
	TTSymbol		instance1	= testAddress1.getInstance();
	TTSymbol		attribute1	= testAddress1.getAttribute();
	TTAddressType	type1		= testAddress1.getType();
	
	TTAddress		testAddress2("/gran/parent2/name2.instance2");
	
	TTSymbol		directory2	= testAddress2.getDirectory();
	TTAddress		parent2		= testAddress2.getParent();
	TTSymbol		name2		= testAddress2.getName();
	TTSymbol		instance2	= testAddress2.getInstance();
	TTSymbol		attribute2	= testAddress2.getAttribute();
	TTAddressType	type2		= testAddress2.getType();
	
	TTAddress		testAddress3("parent3/name3.instance3");
	
	TTSymbol		directory3	= testAddress3.getDirectory();
	TTAddress		parent3		= testAddress3.getParent();
	TTSymbol		name3		= testAddress3.getName();
	TTSymbol		instance3	= testAddress3.getInstance();
	TTSymbol		attribute3	= testAddress3.getAttribute();
	TTAddressType	type3		= testAddress3.getType();
	
	TTAddress		testAddress4("/");
	
	TTSymbol		directory4	= testAddress4.getDirectory();
	TTAddress		parent4		= testAddress4.getParent();
	TTSymbol		name4		= testAddress4.getName();
	TTSymbol		instance4	= testAddress4.getInstance();
	TTSymbol		attribute4	= testAddress4.getAttribute();
	TTAddressType	type4		= testAddress4.getType();
	
	TTAddress		testAddress5(":attribute5");
	
	TTSymbol		directory5	= testAddress5.getDirectory();
	TTAddress		parent5		= testAddress5.getParent();
	TTSymbol		name5		= testAddress5.getName();
	TTSymbol		instance5	= testAddress5.getInstance();
	TTSymbol		attribute5	= testAddress5.getAttribute();
	TTAddressType	type5		= testAddress5.getType();
	
	TTAddress		testAddress6("/gran/parent6.0/name6.0:attribute6");
	
	TTSymbol		directory6	= testAddress6.getDirectory();
	TTAddress		parent6		= testAddress6.getParent();
	TTSymbol		name6		= testAddress6.getName();
	TTSymbol		instance6	= testAddress6.getInstance();
	TTSymbol		attribute6	= testAddress6.getAttribute();
	TTAddressType	type6		= testAddress6.getType();
    
    TTAddress		testAddress7("/*.*");
	
	TTSymbol		directory7	= testAddress7.getDirectory();
	TTAddress		parent7		= testAddress7.getParent();
	TTSymbol		name7		= testAddress7.getName();
	TTSymbol		instance7	= testAddress7.getInstance();
	TTSymbol		attribute7	= testAddress7.getAttribute();
	TTAddressType	type7		= testAddress7.getType();
	
	// The first set of tests checks parsing of addresses
	TTTestAssertion("TTAddress: Test fails if parsing of testAddress1 is bad",
					directory1 == TTSymbol("directory1") &&
					parent1 == TTAddress("/gran/parent1") &&
					name1 == TTSymbol("name1") &&
					instance1 == TTSymbol("instance1") &&
					attribute1 == TTSymbol("attribute1") &&
					type1 == kAddressAbsolute,
					testAssertionCount,
					errorCount);
	
	TTTestAssertion("TTAddress: Test fails if parsing of testAddress2 is bad",
					directory2 == NO_DIRECTORY &&
					parent2 == TTAddress("/gran/parent2") &&
					name2 == TTSymbol("name2") &&
					instance2 == TTSymbol("instance2") &&
					attribute2 == NO_ATTRIBUTE &&
					type2 == kAddressAbsolute,
					testAssertionCount,
					errorCount);
	
	TTTestAssertion("TTAddress: Test fails if parsing of testAddress3 is bad",
					directory3 == NO_DIRECTORY &&
					parent3 == TTAddress("parent3") &&
					name3 == TTSymbol("name3") &&
					instance3 == TTSymbol("instance3") &&
					attribute3 == NO_ATTRIBUTE &&
					type3 == kAddressRelative,
					testAssertionCount,
					errorCount);

	TTTestAssertion("TTAddress: Test fails if parsing of testAddress4 is bad",
					directory4 == NO_DIRECTORY &&
					parent4 == NO_PARENT &&
					name4 == S_SEPARATOR &&
					instance4 == NO_INSTANCE &&
					attribute4 == NO_ATTRIBUTE &&
					type4 == kAddressAbsolute,
					testAssertionCount,
					errorCount);
	
	TTTestAssertion("TTAddress: Test fails if parsing of testAddress5 is bad",
					directory5 == NO_DIRECTORY &&
					parent5 == NO_PARENT &&
					name5 == NO_NAME &&
					instance5 == NO_INSTANCE &&
					attribute5 == TTSymbol("attribute5") &&
					type5 == kAddressRelative,
					testAssertionCount,
					errorCount);
	
	TTTestAssertion("TTAddress: Test fails if parsing of testAddress6 is bad",
					directory6 == NO_DIRECTORY &&
					parent6 == TTAddress("/gran/parent6") &&
					name6 == TTSymbol("name6") &&
					instance6 == NO_INSTANCE &&
					attribute6 == TTSymbol("attribute6") &&
					type6 == kAddressAbsolute,
					testAssertionCount,
					errorCount);
    
    TTTestAssertion("TTAddress: Test fails if parsing of testAddress7 is bad",
					directory7 == NO_DIRECTORY &&
					parent7 == kTTAdrsRoot &&
					name7 == S_WILDCARD &&
					instance7 == S_WILDCARD &&
					attribute7 == NO_ATTRIBUTE &&
					type7 == kAddressAbsolute,
					testAssertionCount,
					errorCount);
}