New test.
authorCarl Hetherington <carl@carlh.net>
Tue, 3 Jan 2012 14:32:51 +0000 (14:32 +0000)
committerCarl Hetherington <carl@carlh.net>
Tue, 3 Jan 2012 14:32:51 +0000 (14:32 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@11139 d708f5d6-7413-0410-9779-e7cbd77b26cf

libs/ardour/test/tempo_test.cc [new file with mode: 0644]
libs/ardour/wscript

diff --git a/libs/ardour/test/tempo_test.cc b/libs/ardour/test/tempo_test.cc
new file mode 100644 (file)
index 0000000..1f074d5
--- /dev/null
@@ -0,0 +1,58 @@
+#include "ardour/tempo.h"
+#include "tempo_test.h"
+
+CPPUNIT_TEST_SUITE_REGISTRATION (TempoTest);
+
+using namespace std;
+using namespace ARDOUR;
+using namespace Timecode;
+
+void
+TempoTest::recomputeMapTest ()
+{
+       int const sampling_rate = 48000;
+
+       TempoMap map (sampling_rate);
+       Meter meterA (4, 4);
+       map.add_meter (meterA, BBT_Time (1, 1, 0));
+
+       /*
+         120bpm at bar 1, 240bpm at bar 4
+         
+         120bpm = 24e3 samples per beat
+         240bpm = 12e3 samples per beat
+       */
+       
+
+       /*
+         
+         120bpm                                                240bpm
+         0 beats                                               12 beats
+         0 frames                                              288e3 frames
+         |                 |                 |                 |             |
+         | 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 |
+
+       */
+
+       Tempo tempoA (120);
+       map.add_tempo (tempoA, BBT_Time (1, 1, 0));
+       Tempo tempoB (240);
+       map.add_tempo (tempoB, BBT_Time (4, 1, 0));
+       Meter meterB (3, 4);
+       map.add_meter (meterB, BBT_Time (4, 1, 0));
+
+       cout << "\n\n\n";
+       for (list<MetricSection*>::iterator i = map.metrics->begin(); i != map.metrics->end(); ++i) {
+               if (dynamic_cast<TempoSection*> (*i)) {
+                       cout << "\tTempo MS @ " << (*i)->start() << " " << (*i)->frame() << "\n";
+               } else {
+                       cout << "\tMeter MS @ " << (*i)->start() << " " << (*i)->frame() << "\n";
+               }
+       }
+       
+       list<MetricSection*>::iterator i = map.metrics->begin();
+       CPPUNIT_ASSERT_EQUAL (framepos_t (0), (*i)->frame ());
+       CPPUNIT_ASSERT_EQUAL (framepos_t (0), (*i)->frame ());
+       CPPUNIT_ASSERT_EQUAL (framepos_t (288e3), (*i)->frame ());
+       CPPUNIT_ASSERT_EQUAL (framepos_t (288e3), (*i)->frame ());
+}
index 42c72784f9b10b4411eb419e1c18116026766b54..a3b39d4dc70cd21b2967e8b67026b8735d160d2d 100644 (file)
@@ -424,6 +424,7 @@ def build(bld):
         testobj.source       = '''
                 test/dummy_lxvst.cc
                 test/bbt_test.cc
+                test/tempo_test.cc
                 test/interpolation_test.cc
                 test/midi_clock_slave_test.cc
                 test/resampled_source_test.cc