Tempo ramps - tempo related tests pass, add ramp test.
This commit is contained in:
@@ -57,6 +57,7 @@ FrameposMinusBeatsTest::doubleTempoTest ()
|
||||
120bpm 240bpm
|
||||
0 beats 12 beats
|
||||
0 frames 288e3 frames
|
||||
0 pulses 4 pulses
|
||||
| | | | |
|
||||
| 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 |
|
||||
|
||||
@@ -65,7 +66,7 @@ FrameposMinusBeatsTest::doubleTempoTest ()
|
||||
Tempo tempoA (120);
|
||||
map.add_tempo (tempoA, 0.0, TempoSection::Constant);
|
||||
Tempo tempoB (240);
|
||||
map.add_tempo (tempoB, 12.0, TempoSection::Constant);
|
||||
map.add_tempo (tempoB, 12.0 / tempoA.note_type(), TempoSection::Constant);
|
||||
|
||||
/* Now some tests */
|
||||
|
||||
@@ -109,6 +110,7 @@ FrameposMinusBeatsTest::doubleTempoWithMeterTest ()
|
||||
120bpm 240bpm
|
||||
0 beats 12 beats
|
||||
0 frames 288e3 frames
|
||||
0 pulses 4 pulses
|
||||
| | | | |
|
||||
| 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 |
|
||||
|
||||
@@ -117,9 +119,9 @@ FrameposMinusBeatsTest::doubleTempoWithMeterTest ()
|
||||
Tempo tempoA (120);
|
||||
map.add_tempo (tempoA, 0.0, TempoSection::Constant);
|
||||
Tempo tempoB (240);
|
||||
map.add_tempo (tempoB, 12.0, TempoSection::Constant);
|
||||
map.add_tempo (tempoB, 12.0 / tempoA.note_type(), TempoSection::Constant);
|
||||
Meter meterB (3, 4);
|
||||
map.add_meter (meterB, 12.0, BBT_Time (4, 1, 0));
|
||||
map.add_meter (meterB, 12.0 / tempoA.note_type(), BBT_Time (4, 1, 0));
|
||||
|
||||
/* Now some tests */
|
||||
|
||||
|
||||
@@ -56,6 +56,7 @@ FrameposPlusBeatsTest::doubleTempoTest ()
|
||||
120bpm 240bpm
|
||||
0 beats 12 beats
|
||||
0 frames 288e3 frames
|
||||
0 pulses 4 pulses
|
||||
| | | | |
|
||||
| 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 |
|
||||
|
||||
@@ -64,7 +65,7 @@ FrameposPlusBeatsTest::doubleTempoTest ()
|
||||
Tempo tempoA (120);
|
||||
map.add_tempo (tempoA, 0.0, TempoSection::Constant);
|
||||
Tempo tempoB (240);
|
||||
map.add_tempo (tempoB, 12.0, TempoSection::Constant);
|
||||
map.add_tempo (tempoB, 12.0 / tempoA.note_type(), TempoSection::Constant);
|
||||
|
||||
/* Now some tests */
|
||||
|
||||
@@ -108,6 +109,7 @@ FrameposPlusBeatsTest::doubleTempoWithMeterTest ()
|
||||
120bpm 240bpm
|
||||
0 beats 12 beats
|
||||
0 frames 288e3 frames
|
||||
0 pulses 4 pulses
|
||||
| | | | |
|
||||
| 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 |
|
||||
|
||||
@@ -116,9 +118,9 @@ FrameposPlusBeatsTest::doubleTempoWithMeterTest ()
|
||||
Tempo tempoA (120);
|
||||
map.add_tempo (tempoA, 0.0, TempoSection::Constant);
|
||||
Tempo tempoB (240);
|
||||
map.add_tempo (tempoB, 12.0, TempoSection::Constant);
|
||||
map.add_tempo (tempoB, 12.0 / tempoA.note_type(), TempoSection::Constant);
|
||||
Meter meterB (3, 4);
|
||||
map.add_meter (meterB, 12.0, BBT_Time (4, 1, 0));
|
||||
map.add_meter (meterB, 12.0 / tempoA.note_type(), BBT_Time (4, 1, 0));
|
||||
|
||||
/* Now some tests */
|
||||
|
||||
|
||||
@@ -63,6 +63,7 @@ FramewalkToBeatsTest::doubleTempoTest ()
|
||||
0 beats 12 beats
|
||||
0 frames 288e3 frames
|
||||
24e3 frames per beat 12e3 frames per beat
|
||||
0 pulses 4 pulses
|
||||
| | | | |
|
||||
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 5.1
|
||||
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
|
||||
@@ -72,7 +73,7 @@ FramewalkToBeatsTest::doubleTempoTest ()
|
||||
Tempo tempoA (120);
|
||||
map.add_tempo (tempoA, 0.0, TempoSection::Constant);
|
||||
Tempo tempoB (240);
|
||||
map.add_tempo (tempoB, 12.0, TempoSection::Constant);
|
||||
map.add_tempo (tempoB, 12.0 / tempoB.note_type(), TempoSection::Constant);
|
||||
|
||||
/* Now some tests */
|
||||
|
||||
@@ -119,6 +120,7 @@ FramewalkToBeatsTest::tripleTempoTest ()
|
||||
120bpm 240bpm 160bpm
|
||||
0 beats 4 beats 8 beats
|
||||
0 frames 96e3 frames 144e3 frames
|
||||
0 pulses 1 pulse 2 pulses
|
||||
| | | | |
|
||||
| 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 |
|
||||
|
||||
@@ -127,9 +129,9 @@ FramewalkToBeatsTest::tripleTempoTest ()
|
||||
Tempo tempoA (120);
|
||||
map.add_tempo (tempoA, 0.0, TempoSection::Constant);
|
||||
Tempo tempoB (240);
|
||||
map.add_tempo (tempoB, 4.0, TempoSection::Constant);
|
||||
map.add_tempo (tempoB, 4.0 / tempoB.note_type(), TempoSection::Constant);
|
||||
Tempo tempoC (160);
|
||||
map.add_tempo (tempoC, 8.0, TempoSection::Constant);
|
||||
map.add_tempo (tempoC, 8.0 / tempoB.note_type(), TempoSection::Constant);
|
||||
|
||||
/* Walk from 1|3 to 4|1 */
|
||||
double r = map.framewalk_to_beats (2 * 24e3, (2 * 24e3) + (4 * 12e3) + (4 * 18e3)).to_double();
|
||||
|
||||
@@ -29,6 +29,7 @@ TempoTest::recomputeMapTest ()
|
||||
120bpm 240bpm
|
||||
0 beats 12 beats
|
||||
0 frames 288e3 frames
|
||||
0 pulses 4 pulses
|
||||
| | | | |
|
||||
| 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 |
|
||||
|
||||
@@ -48,3 +49,45 @@ TempoTest::recomputeMapTest ()
|
||||
--i;
|
||||
CPPUNIT_ASSERT_EQUAL (framepos_t (288e3), (*i)->frame ());
|
||||
}
|
||||
|
||||
void
|
||||
TempoTest::rampTest ()
|
||||
{
|
||||
int const sampling_rate = 48000;
|
||||
|
||||
TempoMap map (sampling_rate);
|
||||
Meter meterA (4, 4);
|
||||
Tempo tempoA (77.0, 4.0);
|
||||
Tempo tempoB (217.0, 4.0);
|
||||
map.add_tempo (tempoA, 0.0, TempoSection::Ramp);
|
||||
map.add_tempo (tempoB, 100.0, TempoSection::Ramp);
|
||||
map.add_meter (meterA, 0.0, BBT_Time (1, 1, 0));
|
||||
|
||||
/*
|
||||
|
||||
120bpm 240bpm
|
||||
0 beats 12 beats
|
||||
0 frames 288e3 frames
|
||||
0 pulses 4 pulses
|
||||
| | | | |
|
||||
| 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 |
|
||||
|
||||
*/
|
||||
|
||||
TempoSection* tA = 0;
|
||||
TempoSection* tB;
|
||||
list<MetricSection*>::iterator i;
|
||||
|
||||
for (i = map._metrics.begin(); i != map._metrics.end(); ++i) {
|
||||
if ((tB = dynamic_cast<TempoSection*> (*i)) != 0) {
|
||||
if (tA) {
|
||||
break;
|
||||
}
|
||||
tA = tB;
|
||||
}
|
||||
}
|
||||
map.recompute_map (map._metrics);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL (tB->frame(), tA->frame_at_tempo (tB->beats_per_minute() / tB->note_type(), 100.0, sampling_rate));
|
||||
CPPUNIT_ASSERT_EQUAL (tB->frame(), tA->frame_at_pulse (tB->pulse(), sampling_rate));
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ class TempoTest : public CppUnit::TestFixture
|
||||
{
|
||||
CPPUNIT_TEST_SUITE (TempoTest);
|
||||
CPPUNIT_TEST (recomputeMapTest);
|
||||
CPPUNIT_TEST (rampTest);
|
||||
CPPUNIT_TEST_SUITE_END ();
|
||||
|
||||
public:
|
||||
@@ -13,5 +14,6 @@ public:
|
||||
void tearDown () {}
|
||||
|
||||
void recomputeMapTest ();
|
||||
void rampTest ();
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user