Merge branch 'windows+cc' into cairocanvas
[ardour.git] / libs / ardour / test / tempo_test.cc
1 #include "ardour/tempo.h"
2 #include "tempo_test.h"
3
4 CPPUNIT_TEST_SUITE_REGISTRATION (TempoTest);
5
6 using namespace std;
7 using namespace ARDOUR;
8 using namespace Timecode;
9
10 void
11 TempoTest::recomputeMapTest ()
12 {
13         int const sampling_rate = 48000;
14
15         TempoMap map (sampling_rate);
16         Meter meterA (4, 4);
17         map.add_meter (meterA, BBT_Time (1, 1, 0));
18
19         /*
20           120bpm at bar 1, 240bpm at bar 4
21           
22           120bpm = 24e3 samples per beat
23           240bpm = 12e3 samples per beat
24         */
25         
26
27         /*
28           
29           120bpm                                                240bpm
30           0 beats                                               12 beats
31           0 frames                                              288e3 frames
32           |                 |                 |                 |             |
33           | 1.1 1.2 1.3 1.4 | 2.1 2.2 2.3.2.4 | 3.1 3.2 3.3 3.4 | 4.1 4.2 4.3 |
34
35         */
36
37         Tempo tempoA (120);
38         map.add_tempo (tempoA, BBT_Time (1, 1, 0));
39         Tempo tempoB (240);
40         map.add_tempo (tempoB, BBT_Time (4, 1, 0));
41         Meter meterB (3, 4);
42         map.add_meter (meterB, BBT_Time (4, 1, 0));
43
44         list<MetricSection*>::iterator i = map.metrics.begin();
45         CPPUNIT_ASSERT_EQUAL (framepos_t (0), (*i)->frame ());
46
47         i = map.metrics.end();
48         --i;
49         CPPUNIT_ASSERT_EQUAL (framepos_t (288e3), (*i)->frame ());
50 }