mirror of
https://github.com/Ardour/ardour.git
synced 2026-01-30 08:53:08 +01:00
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
This commit is contained in:
parent
d23a6de077
commit
e3b4fa678d
3 changed files with 42 additions and 0 deletions
|
|
@ -2182,6 +2182,7 @@ TempoMap::framewalk_to_beats (framepos_t pos, framecnt_t distance) const
|
|||
double const sub = min (distance, distance_to_end);
|
||||
|
||||
/* Update */
|
||||
pos += sub;
|
||||
distance -= sub;
|
||||
beats += sub / tempo->frames_per_beat (_frame_rate, *meter);
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ class FramewalkToBeatsTest : public CppUnit::TestFixture
|
|||
CPPUNIT_TEST_SUITE (FramewalkToBeatsTest);
|
||||
CPPUNIT_TEST (singleTempoTest);
|
||||
CPPUNIT_TEST (doubleTempoTest);
|
||||
CPPUNIT_TEST (tripleTempoTest);
|
||||
CPPUNIT_TEST_SUITE_END ();
|
||||
|
||||
public:
|
||||
|
|
@ -15,5 +16,6 @@ public:
|
|||
|
||||
void singleTempoTest ();
|
||||
void doubleTempoTest ();
|
||||
void tripleTempoTest ();
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue