Mercurial > hg > btrack
comparison unit-tests/BTrack Tests/tests/Test_BTrack.cpp @ 57:296af6af6c3d
Replaced switch statements in OnsetDetectionFunction with enums. Renamed lots of functions so that they have better names, in camel case. Added some unit tests for initialisation of BTrack.
author | Adam Stark <adamstark@users.noreply.github.com> |
---|---|
date | Thu, 23 Jan 2014 15:31:11 +0000 |
parents | b6d440942ff6 |
children |
comparison
equal
deleted
inserted
replaced
56:b6d440942ff6 | 57:296af6af6c3d |
---|---|
6 | 6 |
7 #include <iostream> | 7 #include <iostream> |
8 #include "../../../src/BTrack.h" | 8 #include "../../../src/BTrack.h" |
9 | 9 |
10 //====================================================================== | 10 //====================================================================== |
11 //==================== CHECKING INITIALISATION ========================= | |
12 //====================================================================== | |
13 BOOST_AUTO_TEST_SUITE(checkingInitialisation) | |
14 | |
15 //====================================================================== | |
16 BOOST_AUTO_TEST_CASE(constructorWithNoArguments) | |
17 { | |
18 BTrack b; | |
19 | |
20 BOOST_CHECK_EQUAL(b.getHopSize(), 512); | |
21 } | |
22 | |
23 //====================================================================== | |
24 BOOST_AUTO_TEST_CASE(constructorWithHopSize) | |
25 { | |
26 BTrack b(1024); | |
27 | |
28 BOOST_CHECK_EQUAL(b.getHopSize(), 1024); | |
29 } | |
30 | |
31 //====================================================================== | |
32 BOOST_AUTO_TEST_CASE(constructorWithHopSizeAndFrameSize) | |
33 { | |
34 BTrack b(256,512); | |
35 | |
36 BOOST_CHECK_EQUAL(b.getHopSize(), 256); | |
37 } | |
38 | |
39 BOOST_AUTO_TEST_SUITE_END() | |
40 //====================================================================== | |
41 //====================================================================== | |
42 | |
43 | |
44 //====================================================================== | |
11 //=================== PROCESSING SIMPLE VALUES ========================= | 45 //=================== PROCESSING SIMPLE VALUES ========================= |
12 //====================================================================== | 46 //====================================================================== |
13 BOOST_AUTO_TEST_SUITE(processingSimpleValues) | 47 BOOST_AUTO_TEST_SUITE(processingSimpleValues) |
14 | 48 |
15 //====================================================================== | 49 //====================================================================== |
29 { | 63 { |
30 b.processOnsetDetectionFunctionSample(0.0); | 64 b.processOnsetDetectionFunctionSample(0.0); |
31 | 65 |
32 currentInterval++; | 66 currentInterval++; |
33 | 67 |
34 if (b.playbeat == 1) | 68 if (b.beatDueInCurrentFrame()) |
35 { | 69 { |
36 numBeats++; | 70 numBeats++; |
37 | 71 |
38 if (currentInterval > maxInterval) | 72 if (currentInterval > maxInterval) |
39 { | 73 { |
75 { | 109 { |
76 b.processOnsetDetectionFunctionSample(odfSamples[i]); | 110 b.processOnsetDetectionFunctionSample(odfSamples[i]); |
77 | 111 |
78 currentInterval++; | 112 currentInterval++; |
79 | 113 |
80 if (b.playbeat == 1) | 114 if (b.beatDueInCurrentFrame()) |
81 { | 115 { |
82 numBeats++; | 116 numBeats++; |
83 | 117 |
84 if (currentInterval > maxInterval) | 118 if (currentInterval > maxInterval) |
85 { | 119 { |
121 { | 155 { |
122 b.processOnsetDetectionFunctionSample(odfSamples[i]); | 156 b.processOnsetDetectionFunctionSample(odfSamples[i]); |
123 | 157 |
124 currentInterval++; | 158 currentInterval++; |
125 | 159 |
126 if (b.playbeat == 1) | 160 if (b.beatDueInCurrentFrame()) |
127 { | 161 { |
128 numBeats++; | 162 numBeats++; |
129 | 163 |
130 if (currentInterval > maxInterval) | 164 if (currentInterval > maxInterval) |
131 { | 165 { |
176 { | 210 { |
177 b.processOnsetDetectionFunctionSample(odfSamples[i]); | 211 b.processOnsetDetectionFunctionSample(odfSamples[i]); |
178 | 212 |
179 currentInterval++; | 213 currentInterval++; |
180 | 214 |
181 if (b.playbeat == 1) | 215 if (b.beatDueInCurrentFrame()) |
182 { | 216 { |
183 numBeats++; | 217 numBeats++; |
184 | 218 |
185 if (currentInterval > maxInterval) | 219 if (currentInterval > maxInterval) |
186 { | 220 { |
208 BOOST_CHECK(((double)correct) > (((double)numBeats)*0.99)); | 242 BOOST_CHECK(((double)correct) > (((double)numBeats)*0.99)); |
209 } | 243 } |
210 | 244 |
211 | 245 |
212 BOOST_AUTO_TEST_SUITE_END() | 246 BOOST_AUTO_TEST_SUITE_END() |
213 | 247 //====================================================================== |
248 //====================================================================== | |
214 | 249 |
215 | 250 |
216 | 251 |
217 | 252 |
218 | 253 |