Jamoma API  0.6.0.a19
TTMirror5.test.cpp
Go to the documentation of this file.
1 /** @file
2  *
3  * @ingroup dspFilterLib
4  *
5  * @brief Unit test for the FilterLib #TTMirror5 class.
6  *
7  * @details Currently this test is just a stub
8  *
9  * @authors Trond Lossius, Tim Place
10  *
11  * @copyright Copyright © 2012 by Trond Lossius & Timothy Place @n
12  * This code is licensed under the terms of the "New BSD License" @n
13  * http://creativecommons.org/licenses/BSD/
14  */
15 
16 
17 #include "TTMirror5.h"
18 
19 
20 TTErr TTMirror5::test(TTValue& returnedTestInfo)
21 {
22  int errorCount = 0;
23  int testAssertionCount = 0;
24  int badSampleCount = 0;
25  TTAudioSignalPtr input = NULL;
26  TTAudioSignalPtr output = NULL;
27 
28  // create 1 channel audio signal objects
29  TTObjectBaseInstantiate(kTTSym_audiosignal, &input, 1);
30  TTObjectBaseInstantiate(kTTSym_audiosignal, &output, 1);
31  input->allocWithVectorSize(128);
32  output->allocWithVectorSize(128);
33 
34  // create an impulse
35  input->clear(); // set all samples to zero
36  input->mSampleVectors[0][0] = 1.0; // set the first sample to 1
37 
38  // setup the filter
39  //this->setAttributeValue(TT("linearGain"), 0.5);
40  //this->setAttributeValue(TT("delayInSamples"), 1);
41  this->process(input, output);
42 
43  /// 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).
44  TTFloat64 expectedImpulseResponse[128] = {
45  7.0674300000000009e-02,
46  2.9499740000000008e-01,
47  4.9001028663902008e-01,
48  3.2595306798647988e-01,
49  -6.9262268002024285e-02,
50  -1.9231061515606962e-01,
51  9.7901246149110100e-03,
52  1.1346226292688229e-01,
53  -1.3838204081432742e-03,
54  -6.6942145123093336e-02,
55  1.9560107734252700e-04,
56  3.9495517523470428e-02,
57  -2.7647938440890702e-05,
58  -2.3302149962156432e-02,
59  3.9079973915285613e-06,
60  1.3748147306492493e-02,
61  -5.5238996011132109e-07,
62  -8.1113354204645771e-03,
63  7.8079547525793074e-08,
64  4.7856457191299143e-03,
65  -1.1036434737947830e-08,
66  -2.8235060889289102e-03,
67  1.5599846034399431e-09,
68  1.6658539102363946e-03,
69  -2.2050164244277675e-10,
70  -9.8284514459913972e-04,
71  3.1167600196645400e-11,
72  5.7987352451874057e-04,
73  -4.4054977573835213e-12,
74  -3.4212236412372947e-04,
75  6.2271163772243082e-13,
76  2.0185041579670696e-04,
77  -8.8019856761032695e-14,
78  -1.1909069569789498e-04,
79  1.2441758262586756e-14,
80  7.0262891190140414e-05,
81  -1.7587966371346617e-15,
82  -4.1454740435148659e-05,
83  2.4871020593324766e-16,
84  2.4458081292087447e-05,
85  -3.5221112477168146e-17,
86  -1.4430140780308876e-05,
87  5.0194927135191785e-18,
88  8.5137080236501794e-06,
89  -7.3485316829127910e-19,
90  -5.0230434626718830e-06,
91  1.1950398800020321e-19,
92  2.9635695231504051e-06,
93  -2.6513228832670869e-20,
94  -1.7484906080972187e-06,
95  9.6589535937215692e-21,
96  1.0316003666261971e-06,
97  -4.9914184530848174e-21,
98  -6.0863885198754988e-07,
99  2.9266329760366538e-21,
100  3.5909375775062412e-07,
101  -1.7723171778773028e-21,
102  -2.1186344978532796e-07,
103  1.0805453189708951e-21,
104  1.2499833368340461e-07,
105  -6.5922640038317494e-22,
106  -7.3748366881873580e-08,
107  4.0190838638882530e-22,
108  4.3511152968797626e-08,
109  -2.4479756585757947e-22,
110  -2.5671353993595163e-08,
111  1.4895992104184382e-22,
112  1.5145965365180379e-08,
113  -9.0559076874096129e-23,
114  -8.9360408064365251e-09,
115  5.5006797979493654e-23,
116  5.2722176083853564e-09,
117  -3.3384399540656698e-23,
118  -3.1105809734157971e-09,
119  2.0245716674136402e-23,
120  1.8352265992942586e-09,
121  -1.2268830665260494e-23,
122  -1.0827741504052964e-09,
123  7.4296828674525858e-24,
124  6.3883111831354280e-10,
125  -4.4962438451158232e-24,
126  -3.7690703788317506e-10,
127  2.7192939589807101e-24,
128  2.2237319243447632e-10,
129  -1.6436236973575789e-24,
130  -1.3119902719574039e-10,
131  9.9288932759863952e-25,
132  7.7406743810545411e-11,
133  -5.9946375669920988e-25,
134  -4.5669576333153981e-11,
135  3.6174231588718040e-25,
136  2.6944812554763918e-11,
137  -2.1818251521322291e-25,
138  -1.5897299294285429e-11,
139  1.3153281833419012e-25,
140  9.3793239176720739e-12,
141  -7.9259362909325056e-26,
142  -5.5337523389421523e-12,
143  4.7739456955314446e-26,
144  3.2648851044637075e-12,
145  -2.8742364821490316e-26,
146  -1.9262652342310445e-12,
147  1.7297879530636474e-26,
148  1.1364864716170984e-12,
149  -1.0406277116216493e-26,
150  -6.7052110852443567e-13,
151  6.2580130465599618e-27,
152  3.9560396731965272e-13,
153  -3.7620291000851088e-27,
154  -2.3340428357796508e-13,
155  2.2607792704891021e-27,
156  1.3770731360872481e-13,
157  -1.3581567810419338e-27,
158  -8.1246598951116872e-14,
159  8.1564748482217489e-28,
160  4.7935070898844410e-14,
161  -4.8968950748891102e-28,
162  -2.8281442567949531e-14,
163  2.9390664139034975e-28,
164  1.6685904051588870e-14,
165  -1.7634886737622909e-28,
166  -9.8445966237363652e-15,
167  1.0578273101095320e-28,
168  5.8082608161020127e-15,
169  -6.3436563790738660e-29,
170  -3.4268436785439442e-15,
171  3.8032165947872505e-29,
172  2.0218199507537990e-15
173  };
174 
175  //TTTestLog("\nRESULTING VALUES");
176  for (int i=0; i<128; i++) {
177  TTBoolean result = !TTTestFloatEquivalence(output->mSampleVectors[0][i], expectedImpulseResponse[i]);
178  //TTTestLog("%.16e,", output->mSampleVectors[0][i]);
179  badSampleCount += result;
180  if (result)
181  TTTestLog("BAD SAMPLE @ i=%i ( value=%.10f expected=%.10f )", i, output->mSampleVectors[0][i], expectedImpulseResponse[i]);
182  }
183 
184  TTTestAssertion("Produces correct impulse response for a delay of 1 sample and alpha = 0.5",
185  badSampleCount == 0,
186  testAssertionCount,
187  errorCount);
188  if (badSampleCount)
189  TTTestLog("badSampleCount is %i", badSampleCount);
190 
191  TTObjectBaseRelease(&input);
192  TTObjectBaseRelease(&output);
193 
194  // Wrap up the test results to pass back to whoever called this test
195  return TTTestFinish(testAssertionCount, errorCount, returnedTestInfo);
196 }
197 
bool TTBoolean
Boolean flag, same as Boolean on the Mac.
Definition: TTBase.h:167
TTErr TTObjectBaseRelease(TTObjectBasePtr *anObject)
DEPRECATED.
virtual TTErr test(TTValue &returnedTestInfo)
Unit Tests.
double TTFloat64
64 bit floating point number
Definition: TTBase.h:188
TTErr clear()
Zero out all of the sample values in the audio signal.
TTErr TTObjectBaseInstantiate(const TTSymbol className, TTObjectBasePtr *returnedObjectPtr, const TTValue arguments)
DEPRECATED.
The TTAudioSignal class represents N vectors of audio samples for M channels.
Definition: TTAudioSignal.h:57
TTSampleValue ** mSampleVectors
An array of pointers to the first sample in each vector. Declared Public for fast access...
Definition: TTAudioSignal.h:74
TTErr process(TTAudioSignal &in, TTAudioSignal &out)
Process the input signal, resulting in an output signal.
TTErr
Jamoma Error Codes Enumeration of error codes that might be returned by any of the TTBlue functions a...
Definition: TTBase.h:342
TTMirror5 is a 5th-order lowpass/highpass filter built up from a 2-path allpass structure ...
TTErr allocWithVectorSize(const TTUInt16 newVectorSize)
Allocate memory for all channels at the specified vectorsize, if the vectorsize is different from the...
[doxygenAppendixC_copyExample]
Definition: TTValue.h:34