summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornick_m <mainsbridge@gmail.com>2016-11-04 01:21:57 +1100
committernick_m <mainsbridge@gmail.com>2016-11-11 03:37:08 +1100
commit1fa7c0d829d673e6a1ffbb94bade9b0d60a02b44 (patch)
tree00bd6d1136b0ff6dcc7226d520866e2bcee2e69f
parent594137f5cc5d641873b9002c28453166e81bac9e (diff)
remove remaining frame api from TempoSection.
-rw-r--r--libs/ardour/ardour/tempo.h3
-rw-r--r--libs/ardour/tempo.cc25
-rw-r--r--libs/ardour/test/tempo_test.cc70
3 files changed, 37 insertions, 61 deletions
diff --git a/libs/ardour/ardour/tempo.h b/libs/ardour/ardour/tempo.h
index 0edf5d28a1..8b31f83b28 100644
--- a/libs/ardour/ardour/tempo.h
+++ b/libs/ardour/ardour/tempo.h
@@ -206,9 +206,6 @@ class LIBARDOUR_API TempoSection : public MetricSection, public Tempo {
double tempo_at_pulse (const double& pulse) const;
double pulse_at_tempo (const double& bpm, const double& minute) const;
- double pulse_at_frame (const framepos_t& frame) const;
- framepos_t frame_at_pulse (const double& pulse) const;
-
double pulse_at_minute (const double& minute) const;
double minute_at_pulse (const double& pulse) const;
diff --git a/libs/ardour/tempo.cc b/libs/ardour/tempo.cc
index 3410646a8c..344fd73e7c 100644
--- a/libs/ardour/tempo.cc
+++ b/libs/ardour/tempo.cc
@@ -282,17 +282,9 @@ TempoSection::pulse_at_tempo (const double& bpm, const double& m) const
return _pulse_at_tempo (bpm) + pulse();
}
-/** returns the zero-based pulse (relative to session origin)
- where the zero-based frame (relative to session)
- lies.
+/** returns the pulse at the supplied session-relative minute.
*/
double
-TempoSection::pulse_at_frame (const framepos_t& f) const
-{
- return pulse_at_minute (minute_at_frame (f));
-}
-
-double
TempoSection::pulse_at_minute (const double& m) const
{
if (_type == Constant || _c_func == 0.0) {
@@ -302,17 +294,8 @@ TempoSection::pulse_at_minute (const double& m) const
return _pulse_at_time (m - minute()) + pulse();
}
-/** returns the zero-based frame (relative to session start frame)
- where the zero-based pulse (relative to session start)
- falls.
+/** returns the minute (relative to session start) at the supplied pulse.
*/
-
-framepos_t
-TempoSection::frame_at_pulse (const double& p) const
-{
- return frame_at_minute (minute_at_pulse (p));
-}
-
double
TempoSection::minute_at_pulse (const double& p) const
{
@@ -3219,8 +3202,8 @@ TempoMap::gui_dilate_tempo (TempoSection* ts, const framepos_t& frame, const fra
const frameoffset_t prev_t_frame_contribution = fr_off - (contribution * (double) fr_off);
- const double start_pulse = prev_t->pulse_at_frame (frame);
- const double end_pulse = prev_t->pulse_at_frame (end_frame);
+ const double start_pulse = prev_t->pulse_at_minute (minute_at_frame (frame));
+ const double end_pulse = prev_t->pulse_at_minute (minute_at_frame (end_frame));
double new_bpm;
diff --git a/libs/ardour/test/tempo_test.cc b/libs/ardour/test/tempo_test.cc
index 79fd0ee860..4c25a8c719 100644
--- a/libs/ardour/test/tempo_test.cc
+++ b/libs/ardour/test/tempo_test.cc
@@ -50,30 +50,29 @@ TempoTest::recomputeMapTest48 ()
/* check the tempo section for expected result (no map) */
const TempoSection& tsa (map.tempo_section_at_frame (0));
- CPPUNIT_ASSERT_EQUAL (framepos_t (288e3), tsa.frame_at_pulse (3.0));
- CPPUNIT_ASSERT_EQUAL (framepos_t (144e3), tsa.frame_at_pulse (1.5));
- CPPUNIT_ASSERT_EQUAL (framepos_t (96e3), tsa.frame_at_pulse (1.0));
+ CPPUNIT_ASSERT_DOUBLES_EQUAL (0.1, tsa.minute_at_pulse (3.0), 1e-17);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL (0.1 / 2.0, tsa.minute_at_pulse (1.5), 1e-17);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL (0.1 / 3.0, tsa.minute_at_pulse (1.0), 1e-17);
+
+ CPPUNIT_ASSERT_DOUBLES_EQUAL (3.0, tsa.pulse_at_minute (0.1), 1e-17);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL (1.5, tsa.pulse_at_minute (0.1 / 2.0), 1e-17);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL (1.0, tsa.pulse_at_minute (0.1 / 3.0), 1e-17);
- CPPUNIT_ASSERT_DOUBLES_EQUAL (3.0, tsa.pulse_at_frame (288e3), 1e-17);
- CPPUNIT_ASSERT_DOUBLES_EQUAL (1.5, tsa.pulse_at_frame (144e3), 1e-17);
- CPPUNIT_ASSERT_DOUBLES_EQUAL (1.0, tsa.pulse_at_frame (96e3), 1e-17);
CPPUNIT_ASSERT_DOUBLES_EQUAL (1.0, tsa.minute_at_frame (60.0 * sampling_rate), 1e-17);
CPPUNIT_ASSERT_DOUBLES_EQUAL (0.1, tsa.minute_at_tempo (240.0, 3.0), 1e-17);
CPPUNIT_ASSERT_DOUBLES_EQUAL (0.1, tsa.minute_at_tempo (240.0, 3.0), 1e-17);
- CPPUNIT_ASSERT_DOUBLES_EQUAL (0.1, tsa.minute_at_pulse (3.0), 1e-17);
- CPPUNIT_ASSERT_DOUBLES_EQUAL (3.0, tsa.pulse_at_minute (0.1), 1e-17);
/* do the same via the map */
- /* pulse */
+ /* quarter note */
- /* pulse - frame*/
+ /* quarter note - frame*/
CPPUNIT_ASSERT_EQUAL (framepos_t (288e3), map.frame_at_quarter_note (12.0));
CPPUNIT_ASSERT_EQUAL (framepos_t (144e3), map.frame_at_quarter_note (6.0));
CPPUNIT_ASSERT_EQUAL (framepos_t (96e3), map.frame_at_quarter_note (4.0));
- /* frame - pulse*/
+ /* frame - quarter note*/
CPPUNIT_ASSERT_DOUBLES_EQUAL (12.0, map.quarter_note_at_frame (288e3), 1e-17);
CPPUNIT_ASSERT_DOUBLES_EQUAL (6.0, map.quarter_note_at_frame (144e3), 1e-17);
CPPUNIT_ASSERT_DOUBLES_EQUAL (4.0, map.quarter_note_at_frame (96e3), 1e-17);
@@ -150,34 +149,34 @@ TempoTest::recomputeMapTest44 ()
/* check the tempo section for expected result (no map) */
const TempoSection& tsa (map.tempo_section_at_frame (0));
- CPPUNIT_ASSERT_EQUAL (framepos_t (264600), tsa.frame_at_pulse (3.0));
- CPPUNIT_ASSERT_EQUAL (framepos_t (132300), tsa.frame_at_pulse (1.5));
- CPPUNIT_ASSERT_EQUAL (framepos_t (88200), tsa.frame_at_pulse (1.0));
+ CPPUNIT_ASSERT_DOUBLES_EQUAL (0.1, tsa.minute_at_pulse (3.0), 1e-17);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL (0.1 / 2.0, tsa.minute_at_pulse (1.5), 1e-17);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL (0.1 / 3.0, tsa.minute_at_pulse (1.0), 1e-17);
+
+ CPPUNIT_ASSERT_DOUBLES_EQUAL (3.0, tsa.pulse_at_minute (0.1), 1e-17);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL (1.5, tsa.pulse_at_minute (0.1 / 2.0), 1e-17);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL (1.0, tsa.pulse_at_minute (0.1 / 3.0), 1e-17);
- CPPUNIT_ASSERT_DOUBLES_EQUAL (3.0, tsa.pulse_at_frame (264600), 1e-17);
- CPPUNIT_ASSERT_DOUBLES_EQUAL (1.5, tsa.pulse_at_frame (132300), 1e-17);
- CPPUNIT_ASSERT_DOUBLES_EQUAL (1.0, tsa.pulse_at_frame (88200), 1e-17);
CPPUNIT_ASSERT_DOUBLES_EQUAL (1.0, tsa.minute_at_frame (60.0 * sampling_rate), 1e-17);
CPPUNIT_ASSERT_DOUBLES_EQUAL (0.1, tsa.minute_at_tempo (240.0, 3.0), 1e-17);
- CPPUNIT_ASSERT_DOUBLES_EQUAL (0.1, tsa.minute_at_tempo (240.0, 3.0), 1e-17);
CPPUNIT_ASSERT_DOUBLES_EQUAL (0.1, tsa.minute_at_pulse (3.0), 1e-17);
CPPUNIT_ASSERT_DOUBLES_EQUAL (3.0, tsa.pulse_at_minute (0.1), 1e-17);
/* do the same via the map */
- /* pulse */
+ /* quarter note */
- /* pulse - frame*/
+ /* quarter note - frame */
CPPUNIT_ASSERT_EQUAL (framepos_t (264600), map.frame_at_quarter_note (12.0));
CPPUNIT_ASSERT_EQUAL (framepos_t (132300), map.frame_at_quarter_note (6.0));
CPPUNIT_ASSERT_EQUAL (framepos_t (88200), map.frame_at_quarter_note (4.0));
- /* frame - pulse*/
- CPPUNIT_ASSERT_DOUBLES_EQUAL (12.0, map.quarter_note_at_frame (264600), 1e-17);
- CPPUNIT_ASSERT_DOUBLES_EQUAL (6.0, map.quarter_note_at_frame (132300), 1e-17);
- CPPUNIT_ASSERT_DOUBLES_EQUAL (4.0, map.quarter_note_at_frame (88200), 1e-17);
+ /* frame - quarter note */
+ CPPUNIT_ASSERT_DOUBLES_EQUAL (3.0 * 4.0, map.quarter_note_at_frame (264600), 1e-17);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL (1.5 * 4.0, map.quarter_note_at_frame (132300), 1e-17);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL (1.0 * 4.0, map.quarter_note_at_frame (88200), 1e-17);
/* pulse - internal minute based interface */
CPPUNIT_ASSERT_DOUBLES_EQUAL (0.1, map.minute_at_pulse_locked (map._metrics, 3.0), 1e-17);
@@ -376,11 +375,10 @@ TempoTest::rampTest48 ()
CPPUNIT_ASSERT_DOUBLES_EQUAL (1.0, tA.minute_at_tempo (tB.beats_per_minute(), 300.0), 1e-17);
CPPUNIT_ASSERT_DOUBLES_EQUAL (217.0, tA.tempo_at_minute (1.0), 1e-17);
- CPPUNIT_ASSERT_EQUAL ((framepos_t) 60 * sampling_rate, tA.frame_at_pulse (tB.pulse()));
/* note 1e-14 here. pulse is two derivatives away from time */
- CPPUNIT_ASSERT_DOUBLES_EQUAL (tB.pulse(), tA.pulse_at_frame ((framepos_t) 60 * sampling_rate), 1e-14);
CPPUNIT_ASSERT_DOUBLES_EQUAL (tB.pulse(), tA.pulse_at_minute (1.0), 1e-14);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL (1.0, tA.minute_at_pulse (tB.pulse()), 1e-15);
/* note 1e-17 here. tempo is one derivative away from pulse, so we can get the same stuff with more precision */
CPPUNIT_ASSERT_DOUBLES_EQUAL (tB.pulse(), tA.pulse_at_tempo (217.0, 1.0), 1e-17);
@@ -397,9 +395,9 @@ TempoTest::rampTest48 ()
CPPUNIT_ASSERT_DOUBLES_EQUAL ((tB.pulse() - tA.pulse()) / 2.0, tA.pulse_at_tempo (147.0, 0), 1e-17);
/* self-check frame at pulse 20 seconds in. */
- const framepos_t target = 20 * sampling_rate;
- const framepos_t result = tA.frame_at_pulse (tA.pulse_at_frame (target));
- CPPUNIT_ASSERT_EQUAL (target, result);
+ const double target = 20.0 / 60.0;
+ const double result = tA.minute_at_pulse (tA.pulse_at_minute (target));
+ CPPUNIT_ASSERT_DOUBLES_EQUAL (target, result, 1e-14);
}
void
@@ -439,17 +437,15 @@ TempoTest::rampTest44 ()
CPPUNIT_ASSERT_DOUBLES_EQUAL (1.0, tA.minute_at_tempo (tB.beats_per_minute(), 300.0), 1e-17);
CPPUNIT_ASSERT_DOUBLES_EQUAL (217.0, tA.tempo_at_minute (1.0), 1e-17);
- CPPUNIT_ASSERT_EQUAL ((framepos_t) 60 * sampling_rate, tA.frame_at_pulse (tB.pulse()));
/* note 1e-14 here. pulse is two derivatives away from time */
- CPPUNIT_ASSERT_DOUBLES_EQUAL (tB.pulse(), tA.pulse_at_frame ((framepos_t) 60 * sampling_rate), 1e-14);
CPPUNIT_ASSERT_DOUBLES_EQUAL (tB.pulse(), tA.pulse_at_minute (1.0), 1e-14);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL (1.0, tA.minute_at_pulse (tB.pulse()), 1e-15);
/* note 1e-17 here. tempo is one derivative away from pulse, so we can get the same stuff with more precision */
CPPUNIT_ASSERT_DOUBLES_EQUAL (tB.pulse(), tA.pulse_at_tempo (217.0, 1.0), 1e-17);
CPPUNIT_ASSERT_DOUBLES_EQUAL (1.0, tA.minute_at_tempo (217.0, tB.pulse()), 1e-17);
-
/* self-check tempo at pulse @ 125 bpm. */
CPPUNIT_ASSERT_DOUBLES_EQUAL (125.0, tA.tempo_at_pulse (tA.pulse_at_tempo (125.0, 0)), 1e-17);
@@ -461,9 +457,9 @@ TempoTest::rampTest44 ()
CPPUNIT_ASSERT_DOUBLES_EQUAL ((tB.pulse() - tA.pulse()) / 2.0, tA.pulse_at_tempo (147.0, 0), 1e-17);
/* self-check frame at pulse 20 seconds in. */
- const framepos_t target = 20 * sampling_rate;
- const framepos_t result = tA.frame_at_pulse (tA.pulse_at_frame (target));
- CPPUNIT_ASSERT_EQUAL (target, result);
+ const double target = 20.0 / 60.0;
+ const double result = tA.minute_at_pulse (tA.pulse_at_minute (target));
+ CPPUNIT_ASSERT_DOUBLES_EQUAL (target, result, 1e-14);
}
void
@@ -516,8 +512,8 @@ TempoTest::tempoAtPulseTest ()
CPPUNIT_ASSERT_DOUBLES_EQUAL (((160.0 - 123.0) / 2.0) + 123.0, tB->tempo_at_pulse (25.0), 1e-17);
CPPUNIT_ASSERT_DOUBLES_EQUAL (((20.0 - 30.0) / 2.0) + 30.0, tB->pulse_at_tempo (141.5, 0), 1e-17);
- CPPUNIT_ASSERT_EQUAL (tB->frame(), tA->frame_at_pulse (20.0));
- CPPUNIT_ASSERT_EQUAL (tC->frame(), tB->frame_at_pulse (30.0));
+ CPPUNIT_ASSERT_DOUBLES_EQUAL (tB->minute(), tA->minute_at_pulse (20.0), 1e-17);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL (tC->minute(), tB->minute_at_pulse (30.0), 1e-17);
CPPUNIT_ASSERT_DOUBLES_EQUAL (tB->minute(), tA->minute_at_tempo (160.0, 20.0), 1e-17);
CPPUNIT_ASSERT_DOUBLES_EQUAL (tC->minute(), tB->minute_at_tempo (123.0, 30.0), 1e-17);