From e3b4fa678d26055463ada04448987f025b6cac49 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sat, 10 Dec 2011 20:23:59 +0000 Subject: 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 --- libs/ardour/test/framewalk_to_beats_test.cc | 39 +++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'libs/ardour/test/framewalk_to_beats_test.cc') 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); +} -- cgit v1.2.3