comparison test/TestFeatureExtractor.cpp @ 130:8e240bbea845 refactors

FeatureConditioner tests
author Chris Cannam
date Thu, 11 Dec 2014 13:53:16 +0000
parents dad9fdc32a6a
children d6f22887283e
comparison
equal deleted inserted replaced
129:dad9fdc32a6a 130:8e240bbea845
33 return outbin; 33 return outbin;
34 } 34 }
35 35
36 BOOST_AUTO_TEST_SUITE(TestFeatureExtractor) 36 BOOST_AUTO_TEST_SUITE(TestFeatureExtractor)
37 37
38 void checkAlternateProcessType(FeatureExtractor &fe, vector<double> expected,
39 vector<double> real, vector<double> imag)
40 {
41 vector<float> in;
42 for (int i = 0; i < (int)real.size(); ++i) {
43 in.push_back(float(real[i]));
44 in.push_back(float(imag[i]));
45 }
46 vector<double> alt = fe.process(&in[0]);
47 BOOST_CHECK_EQUAL_COLLECTIONS(alt.begin(), alt.end(),
48 expected.begin(), expected.end());
49 }
50
38 BOOST_AUTO_TEST_CASE(chroma) 51 BOOST_AUTO_TEST_CASE(chroma)
39 { 52 {
40 int szs[] = { 1024, 2048, 4000 }; 53 int szs[] = { 1024, 2048, 4000 };
41 int rates[] = { 44100, 48000 }; 54 int rates[] = { 44100, 48000 };
42 55
69 // properly summed into the output bin 82 // properly summed into the output bin
70 real[hs-bin-1] += 5.0; 83 real[hs-bin-1] += 5.0;
71 imag[hs-bin-1] += 5.0; 84 imag[hs-bin-1] += 5.0;
72 85
73 vector<double> out = fe.process(real, imag); 86 vector<double> out = fe.process(real, imag);
87
88 checkAlternateProcessType(fe, out, real, imag);
74 89
75 // We expect to find all bins are 0 except for: 90 // We expect to find all bins are 0 except for:
76 // 91 //
77 // * two bins of 200 and 50 respectively, if the two input 92 // * two bins of 200 and 50 respectively, if the two input
78 // bins are distinct and their output chroma are also distinct 93 // bins are distinct and their output chroma are also distinct
144 real[hs-bin-1] += 5.0; 159 real[hs-bin-1] += 5.0;
145 imag[hs-bin-1] += 5.0; 160 imag[hs-bin-1] += 5.0;
146 161
147 vector<double> out = fe.process(real, imag); 162 vector<double> out = fe.process(real, imag);
148 163
164 checkAlternateProcessType(fe, out, real, imag);
165
149 // We expect to find all bins are 0 except for: 166 // We expect to find all bins are 0 except for:
150 // 167 //
151 // * two bins of 200 and 50 respectively, if the two input 168 // * two bins of 200 and 50 respectively, if the two input
152 // bins are distinct and their output bins are also distinct 169 // bins are distinct and their output bins are also distinct
153 // 170 //