Mercurial > hg > match-vamp
comparison test/TestFeatureExtractor.cpp @ 185:a17b22abd551 re-minimise
Code now builds, DistanceMetric tests fail
author | Chris Cannam |
---|---|
date | Thu, 26 Feb 2015 10:28:23 +0000 |
parents | d1bc89794cd4 |
children | 487261a22b18 |
comparison
equal
deleted
inserted
replaced
184:6c12db195986 | 185:a17b22abd551 |
---|---|
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, | 38 void checkAlternateProcessType(FeatureExtractor &fe, feature_t expected, |
39 vector<double> real, vector<double> imag) | 39 vector<double> real, vector<double> imag) |
40 { | 40 { |
41 vector<float> in; | 41 vector<float> in; |
42 for (int i = 0; i < (int)real.size(); ++i) { | 42 for (int i = 0; i < (int)real.size(); ++i) { |
43 in.push_back(float(real[i])); | 43 in.push_back(float(real[i])); |
44 in.push_back(float(imag[i])); | 44 in.push_back(float(imag[i])); |
45 } | 45 } |
46 vector<double> alt = fe.process(&in[0]); | 46 feature_t alt = fe.process(&in[0]); |
47 BOOST_CHECK_EQUAL_COLLECTIONS(alt.begin(), alt.end(), | 47 BOOST_CHECK_EQUAL_COLLECTIONS(alt.begin(), alt.end(), |
48 expected.begin(), expected.end()); | 48 expected.begin(), expected.end()); |
49 } | 49 } |
50 | 50 |
51 BOOST_AUTO_TEST_CASE(chroma) | 51 BOOST_AUTO_TEST_CASE(chroma) |
81 // use two input sweeps, so we can test that they are | 81 // use two input sweeps, so we can test that they are |
82 // properly summed into the output bin | 82 // properly summed into the output bin |
83 real[hs-bin-1] += 5.0; | 83 real[hs-bin-1] += 5.0; |
84 imag[hs-bin-1] += 5.0; | 84 imag[hs-bin-1] += 5.0; |
85 | 85 |
86 vector<double> out = fe.process(real, imag); | 86 feature_t out = fe.process(real, imag); |
87 | 87 |
88 checkAlternateProcessType(fe, out, real, imag); | 88 checkAlternateProcessType(fe, out, real, imag); |
89 | 89 |
90 // We expect to find all bins are 0 except for: | 90 // We expect to find all bins are 0 except for: |
91 // | 91 // |
105 // input bins less than the 17th are shepherded into | 105 // input bins less than the 17th are shepherded into |
106 // the separate bin 0 (see docs in FeatureExtractor.h) | 106 // the separate bin 0 (see docs in FeatureExtractor.h) |
107 | 107 |
108 double cutoff = (17.0 * rate) / sz; | 108 double cutoff = (17.0 * rate) / sz; |
109 | 109 |
110 vector<double> expected(fsz); | 110 feature_t expected(fsz); |
111 | 111 |
112 double infreq1 = (double(bin) * rate) / sz; | 112 double infreq1 = (double(bin) * rate) / sz; |
113 | 113 |
114 if (bin == hs-bin-1) { | 114 if (bin == hs-bin-1) { |
115 expected[freq2chroma(infreq1) + 1] += 450; | 115 expected[freq2chroma(infreq1) + 1] += 450; |
157 // use two input sweeps, so we can test that they are properly | 157 // use two input sweeps, so we can test that they are properly |
158 // summed into the output bin | 158 // summed into the output bin |
159 real[hs-bin-1] += 5.0; | 159 real[hs-bin-1] += 5.0; |
160 imag[hs-bin-1] += 5.0; | 160 imag[hs-bin-1] += 5.0; |
161 | 161 |
162 vector<double> out = fe.process(real, imag); | 162 feature_t out = fe.process(real, imag); |
163 | 163 |
164 checkAlternateProcessType(fe, out, real, imag); | 164 checkAlternateProcessType(fe, out, real, imag); |
165 | 165 |
166 // We expect to find all bins are 0 except for: | 166 // We expect to find all bins are 0 except for: |
167 // | 167 // |
185 // So MIDI pitches up to and including 77 are mapped linearly | 185 // So MIDI pitches up to and including 77 are mapped linearly |
186 // by frequency into 34 bins; those from 78-126 inclusive are | 186 // by frequency into 34 bins; those from 78-126 inclusive are |
187 // mapped linearly by MIDI pitch into the next 49 bins; | 187 // mapped linearly by MIDI pitch into the next 49 bins; |
188 // everything above goes into the last bin, for 84 bins total. | 188 // everything above goes into the last bin, for 84 bins total. |
189 | 189 |
190 vector<double> expected(fsz); | 190 feature_t expected(fsz); |
191 | 191 |
192 if (bin == hs-bin-1) { | 192 if (bin == hs-bin-1) { |
193 expected[bin2warped(bin, rate, sz)] += 450; | 193 expected[bin2warped(bin, rate, sz)] += 450; |
194 } else { | 194 } else { |
195 expected[bin2warped(bin, rate, sz)] += 200; | 195 expected[bin2warped(bin, rate, sz)] += 200; |