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); }
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 TTSvf::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] = { 5.0000000000000000e+05, 5.0087319869171590e+17, 5.0174842408388438e+29, 5.0262517884414260e+41, 5.0350346564490692e+53, 5.0438328716326373e+65, 5.0526464608097724e+77, 5.0614754508449776e+89, 5.0703198686496978e+101, 5.0791797411824051e+113, 5.0880550954486772e+125, 5.0969459585012814e+137, 5.1058523574402592e+149, 5.1147743194130052e+161, 5.1237118716143473e+173, 5.1326650412866394e+185, 5.1416338557198395e+197, 5.1506183422515868e+209, 5.1596185282672929e+221, 5.1686344412002213e+233, 5.1776661085315740e+245, 5.1867135577905743e+257, 5.1957768165545460e+269, 5.2048559124490098e+281, 5.2139508731477499e+293, 5.2230617263729118e+305, 5.2230617263729118e+305, 5.2230617263729118e+305, 5.2230617263729118e+305, 5.2230617263729118e+305, 5.2230617263729118e+305, 5.2230617263729118e+305, 5.2230617263729118e+305, 5.2230617263729118e+305, 5.2230617263729118e+305, 5.2230617263729118e+305, 5.2230617263729118e+305, 5.2230617263729118e+305, 5.2230617263729118e+305, 5.2230617263729118e+305, 5.2230617263729118e+305, 5.2230617263729118e+305, 5.2230617263729118e+305, 5.2230617263729118e+305, 5.2230617263729118e+305, 5.2230617263729118e+305, 5.2230617263729118e+305, 5.2230617263729118e+305, 5.2230617263729118e+305, 5.2230617263729118e+305, 5.2230617263729118e+305, 5.2230617263729118e+305, 5.2230617263729118e+305, 5.2230617263729118e+305, 5.2230617263729118e+305, 5.2230617263729118e+305, 5.2230617263729118e+305, 5.2230617263729118e+305, 5.2230617263729118e+305, 5.2230617263729118e+305, 5.2230617263729118e+305, 5.2230617263729118e+305, 5.2230617263729118e+305, 5.2230617263729118e+305, 5.2230617263729118e+305, 5.2230617263729118e+305, 5.2230617263729118e+305, 5.2230617263729118e+305, 5.2230617263729118e+305, 5.2230617263729118e+305, 5.2230617263729118e+305, 5.2230617263729118e+305, 5.2230617263729118e+305, 5.2230617263729118e+305, 5.2230617263729118e+305, 5.2230617263729118e+305, 5.2230617263729118e+305, 5.2230617263729118e+305, 5.2230617263729118e+305, 5.2230617263729118e+305, 5.2230617263729118e+305, 5.2230617263729118e+305, 5.2230617263729118e+305, 5.2230617263729118e+305, 5.2230617263729118e+305, 5.2230617263729118e+305, 5.2230617263729118e+305, 5.2230617263729118e+305, 5.2230617263729118e+305, 5.2230617263729118e+305, 5.2230617263729118e+305, 5.2230617263729118e+305, 5.2230617263729118e+305, 5.2230617263729118e+305, 5.2230617263729118e+305, 5.2230617263729118e+305, 5.2230617263729118e+305, 5.2230617263729118e+305, 5.2230617263729118e+305, 5.2230617263729118e+305, 5.2230617263729118e+305, 5.2230617263729118e+305, 5.2230617263729118e+305, 5.2230617263729118e+305, 5.2230617263729118e+305, 5.2230617263729118e+305, 5.2230617263729118e+305, 5.2230617263729118e+305, 5.2230617263729118e+305, 5.2230617263729118e+305, 5.2230617263729118e+305, 5.2230617263729118e+305, 5.2230617263729118e+305, 5.2230617263729118e+305, 5.2230617263729118e+305, 5.2230617263729118e+305, 5.2230617263729118e+305, 5.2230617263729118e+305, 5.2230617263729118e+305, 5.2230617263729118e+305, 5.2230617263729118e+305, 5.2230617263729118e+305, 5.2230617263729118e+305, 5.2230617263729118e+305, 5.2230617263729118e+305, 5.2230617263729118e+305, 5.2230617263729118e+305, 5.2230617263729118e+305 }; //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); }
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); }
TTErr TTHalfband9::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] = { 8.7103045030879483e-03, 6.5442805786156327e-02, 2.1752960418473016e-01, 4.0159114675452823e-01, 4.0353211792457022e-01, 1.2030853381927020e-01, -1.8246245365496197e-01, -1.6374428214620290e-01, 7.3759595434999117e-02, 1.3557578188789043e-01, -2.9480119034157672e-02, -1.0385906449486471e-01, 1.1768051181853019e-02, 7.8235267984828785e-02, -4.6970087126678179e-03, -5.8706586396073894e-02, 1.8747000302069827e-03, 4.4013161078726402e-02, -7.4824100988214021e-04, -3.2990420653853873e-02, 2.9864218340860499e-04, 2.4727036940893864e-02, -1.1919575486409350e-04, -1.8533241881956156e-02, 4.7574082755266522e-05, 1.3890873825360833e-02, -1.8988036545967643e-05, -1.0411360218772368e-02, 7.5786123658265979e-06, 7.8034260100494678e-03, -3.0248185615325640e-06, -5.8487511897430174e-03, 1.2072826644949055e-06, 4.3837014883001159e-03, -4.8185747420545896e-07, -3.2856310826633872e-03, 1.9232167600518332e-07, 2.4626155853971947e-03, -7.6760513308280766e-08, -1.8457566806100649e-03, 3.0637089514506656e-08, 1.3834143437329480e-03, -1.2228048165209913e-08, -1.0368838246887998e-03, 4.8805276317090555e-09, 7.7715549991975530e-04, -1.9479437471995521e-09, -5.8248634675791178e-04, 7.7747430781886294e-10, 4.3657973750991743e-04, -3.1030993589390189e-10, -3.2722117568094997e-04, 1.2385265383832053e-10, 2.4525576570440455e-04, -4.9432770557625903e-11, -1.8382181558415425e-04, 1.9729886516544118e-11, 1.3777641389022791e-04, -7.8747037150572516e-12, -1.0326489358256396e-04, 3.1429962127728598e-12, 7.7398140549037774e-05, -1.2544503959705767e-12, -5.8010732908556275e-05, 5.0068332553363524e-13, 4.3479663835796007e-05, -1.9983555609105167e-13, -3.2588472382409617e-05, 7.9759495556712181e-14, 2.4425408076516508e-05, -3.1834060243826912e-14, -1.8307104202478260e-05, 1.2705789881620152e-14, 1.3721370108965461e-05, -5.0712066032225982e-15, -1.0284313432908937e-05, 2.0240486150152843e-15, 7.7082027484415434e-06, -8.0784971240215606e-16, -5.7773802790718454e-06, 3.2243353889171191e-16, 4.3302082182200926e-06, -1.2869149472504737e-16, -3.2455373036571498e-06, 5.1364076055775978e-17, 2.4325648695387360e-06, -2.0500720072451300e-17, -1.8232333480949888e-06, 8.1823631565498873e-18, 1.3665328654672198e-06, -3.2657909863192238e-18, -1.0242309764426052e-06, 1.3034609393725535e-18, 7.6767205503389109e-07, -5.2024469036363035e-19, -5.7537840353823865e-07, 2.0764299847898359e-19, 4.3125225815807068e-07, -8.2875646048798849e-20, -3.2322817301236335e-07, 3.3077795824167722e-20, 2.4226296756135623e-07, -1.3202196649436381e-20, -1.8157868141459877e-07, 5.2693352754490783e-21, 1.3609516087477989e-07, -2.1031268494457227e-21, -1.0200477649268290e-07, 8.3941186385839346e-22, 7.6453669332855475e-08, -3.3503080300264441e-22, -5.7302841645625260e-08, 1.3371938590986161e-22, 4.2949091774362909e-08, -5.3370836376407339e-23, -3.2190802956164986e-08, 2.1301669583177287e-23, 2.4127350594668349e-08, -8.5020426479852997e-24, -1.8083706936752792e-08, 3.3933832700722577e-24, 1.3553931472551566e-08, -1.3543862921382747e-24, -1.0158816386769628e-08, 5.4057030471922016e-25, 7.6141413721247876e-09, -2.1575547245305183e-25, -5.7068802730017340e-09 }; //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); }