summaryrefslogtreecommitdiff
path: root/libs/ardour/test/framewalk_to_beats_test.cc
diff options
context:
space:
mode:
authorCarl Hetherington <carl@carlh.net>2011-12-10 20:23:59 +0000
committerCarl Hetherington <carl@carlh.net>2011-12-10 20:23:59 +0000
commite3b4fa678d26055463ada04448987f025b6cac49 (patch)
tree6ef5601a30a0652a15f3dec8f21f92d776559f33 /libs/ardour/test/framewalk_to_beats_test.cc
parentd23a6de077181caa24af52229bb040c87ed34ebd (diff)
Fix framewalk_to_beats when it traverses more than one
metric change. git-svn-id: svn://localhost/ardour2/branches/3.0@10970 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/test/framewalk_to_beats_test.cc')
-rw-r--r--libs/ardour/test/framewalk_to_beats_test.cc39
1 files changed, 39 insertions, 0 deletions
diff --git a/libs/ardour/test/framewalk_to_beats_test.cc b/libs/ardour/test/framewalk_to_beats_test.cc
index 6aca63c6c1..7e50aedcb5 100644
--- a/libs/ardour/test/framewalk_to_beats_test.cc
+++ b/libs/ardour/test/framewalk_to_beats_test.cc
@@ -95,3 +95,42 @@ FramewalkToBeatsTest::doubleTempoTest ()
CPPUNIT_ASSERT_EQUAL (r, 3.5);
}
+void
+FramewalkToBeatsTest::tripleTempoTest ()
+{
+ int const sampling_rate = 48000;
+
+ TempoMap map (sampling_rate);
+ Meter meter (4, 4);
+ map.add_meter (meter, BBT_Time (1, 1, 0));
+
+ /*
+ 120bpm at bar 1, 240bpm at bar 2, 160bpm at bar 3
+
+ 120bpm = 24e3 samples per beat
+ 160bpm = 18e3 samples per beat
+ 240bpm = 12e3 samples per beat
+ */
+
+
+ /*
+
+ 120bpm 240bpm 160bpm
+ 0 beats 4 beats 8 beats
+ 0 frames 96e3 frames 144e3 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 4.4 |
+
+ */
+
+ Tempo tempoA (120);
+ map.add_tempo (tempoA, BBT_Time (1, 1, 0));
+ Tempo tempoB (240);
+ map.add_tempo (tempoB, BBT_Time (2, 1, 0));
+ Tempo tempoC (160);
+ map.add_tempo (tempoC, BBT_Time (3, 1, 0));
+
+ /* Walk from 1|3 to 4|1 */
+ double r = map.framewalk_to_beats (2 * 24e3, (2 * 24e3) + (4 * 12e3) + (4 * 18e3));
+ CPPUNIT_ASSERT_EQUAL (10.0, r);
+}