diff options
author | nick_m <mainsbridge@gmail.com> | 2016-10-02 03:55:18 +1100 |
---|---|---|
committer | nick_m <mainsbridge@gmail.com> | 2016-10-02 03:55:18 +1100 |
commit | af289cab6231ec8785a2e69ab78f6257626aef9f (patch) | |
tree | 42a5af66405bdcbb974ee3a74fd9b67d42ae4521 /libs/ardour/test/framepos_plus_beats_test.cc | |
parent | bb3312c3bb9c6ed9b75ac6739a6ee720ddf86c86 (diff) |
Remove unused methods, add tests to ensure meter divisors don't mess with Beats.
- TempoMap::framepos_minus_beats() was only used by its test,
so don't build the test.
Diffstat (limited to 'libs/ardour/test/framepos_plus_beats_test.cc')
-rw-r--r-- | libs/ardour/test/framepos_plus_beats_test.cc | 74 |
1 files changed, 65 insertions, 9 deletions
diff --git a/libs/ardour/test/framepos_plus_beats_test.cc b/libs/ardour/test/framepos_plus_beats_test.cc index 8193eafb61..25a0545402 100644 --- a/libs/ardour/test/framepos_plus_beats_test.cc +++ b/libs/ardour/test/framepos_plus_beats_test.cc @@ -25,11 +25,11 @@ FrameposPlusBeatsTest::singleTempoTest () map.replace_tempo (map.first_tempo(), tempo, 0.0, 0, TempoSection::Constant, AudioTime); /* Add 1 beat to beat 3 of the first bar */ - framepos_t r = map.framepos_plus_beats (frames_per_beat * 2, Evoral::Beats(1)); + framepos_t r = map.framepos_plus_qn (frames_per_beat * 2, Evoral::Beats(1)); CPPUNIT_ASSERT_EQUAL (framepos_t (frames_per_beat * 3), r); /* Add 4 beats to a -ve frame of 1 beat before zero */ - r = map.framepos_plus_beats (-frames_per_beat * 1, Evoral::Beats(4)); + r = map.framepos_plus_qn (-frames_per_beat * 1, Evoral::Beats(4)); CPPUNIT_ASSERT_EQUAL (framepos_t (frames_per_beat * 3), r); } @@ -70,15 +70,15 @@ FrameposPlusBeatsTest::doubleTempoTest () /* Now some tests */ /* Add 1 beat to 1|2 */ - framepos_t r = map.framepos_plus_beats (24e3, Evoral::Beats(1)); + framepos_t r = map.framepos_plus_qn (24e3, Evoral::Beats(1)); CPPUNIT_ASSERT_EQUAL (framepos_t (48e3), r); /* Add 2 beats to 3|4 (over the tempo change) */ - r = map.framepos_plus_beats (264e3, Evoral::Beats(2)); + r = map.framepos_plus_qn (264e3, Evoral::Beats(2)); CPPUNIT_ASSERT_EQUAL (framepos_t (264e3 + 24e3 + 12e3), r); /* Add 2.5 beats to 3|3|960 (over the tempo change) */ - r = map.framepos_plus_beats (264e3 - 12e3, Evoral::Beats(2.5)); + r = map.framepos_plus_qn (264e3 - 12e3, Evoral::Beats(2.5)); CPPUNIT_ASSERT_EQUAL (framepos_t (264e3 + 24e3 + 12e3), r); } @@ -119,21 +119,77 @@ FrameposPlusBeatsTest::doubleTempoWithMeterTest () map.replace_tempo (map.first_tempo(), tempoA, 0.0, 0, TempoSection::Constant, AudioTime); Tempo tempoB (240); map.add_tempo (tempoB, 12.0 / tempoA.note_type(), 0, TempoSection::Constant, MusicTime); - Meter meterB (3, 4); + Meter meterB (3, 8); map.add_meter (meterB, 12.0, BBT_Time (4, 1, 0), 0, MusicTime); /* Now some tests */ /* Add 1 beat to 1|2 */ - framepos_t r = map.framepos_plus_beats (24e3, Evoral::Beats(1)); + framepos_t r = map.framepos_plus_qn (24e3, Evoral::Beats(1)); CPPUNIT_ASSERT_EQUAL (framepos_t (48e3), r); /* Add 2 beats to 3|4 (over the tempo change) */ - r = map.framepos_plus_beats (264e3, Evoral::Beats(2)); + r = map.framepos_plus_qn (264e3, Evoral::Beats(2)); CPPUNIT_ASSERT_EQUAL (framepos_t (264e3 + 24e3 + 12e3), r); /* Add 2.5 beats to 3|3|960 (over the tempo change) */ - r = map.framepos_plus_beats (264e3 - 12e3, Evoral::Beats(2.5)); + r = map.framepos_plus_qn (264e3 - 12e3, Evoral::Beats(2.5)); + CPPUNIT_ASSERT_EQUAL (framepos_t (264e3 + 24e3 + 12e3), r); +} + +/* Same as doubleTempoWithMeterTest () except use odd meter divisors + (which shouldn't affect anything, since we are just dealing with + beats) +*/ + +void +FrameposPlusBeatsTest::doubleTempoWithComplexMeterTest () +{ + int const sampling_rate = 48000; + + TempoMap map (sampling_rate); + Meter meterA (3, 4); + map.replace_meter (map.first_meter(), meterA, BBT_Time (1, 1, 0), (framepos_t) 0, AudioTime); + + /* + 120bpm at bar 1, 240bpm at bar 4 + + 120bpm = 24e3 samples per beat + 240bpm = 12e3 samples per beat + */ + + + /* + + 120bpm 5/8 240bpm + 0 beats 9 quarter note beats 12 quarter note beats + 9 meter-based beat 15 meter-based beat + 0 frames 288e3 frames + 0 pulses | 3 pulses + | | | | | + | 1.1 1.2 1.3 | 2.1 2.2 2.3 | 3.1 3.2 3.3 |4.14.24.34.44.5|5.15.2^5.35.45.5| + | + 4|1|0 + */ + + Tempo tempoA (120); + map.replace_tempo (map.first_tempo(), tempoA, 0.0, 0, TempoSection::Constant, AudioTime); + Tempo tempoB (240, 4.0); + map.add_tempo (tempoB, 12.0 / 4.0, 0, TempoSection::Constant, MusicTime); + Meter meterB (5, 8); + map.add_meter (meterB, 9.0, BBT_Time (4, 1, 0), 0, MusicTime); + /* Now some tests */ + + /* Add 1 beat to 1|2 */ + framepos_t r = map.framepos_plus_qn (24e3, Evoral::Beats(1)); + CPPUNIT_ASSERT_EQUAL (framepos_t (48e3), r); + + /* Add 2 beats to 5|1 (over the tempo change) */ + r = map.framepos_plus_qn (264e3, Evoral::Beats(2)); + CPPUNIT_ASSERT_EQUAL (framepos_t (264e3 + 24e3 + 12e3), r); + + /* Add 2.5 beats to 4|5 (over the tempo change) */ + r = map.framepos_plus_qn (264e3 - 12e3, Evoral::Beats(2.5)); CPPUNIT_ASSERT_EQUAL (framepos_t (264e3 + 24e3 + 12e3), r); } |