summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libs/ardour/ardour/tempo.h5
-rw-r--r--libs/ardour/tempo.cc11
-rw-r--r--libs/ardour/test/tempo_test.cc34
3 files changed, 22 insertions, 28 deletions
diff --git a/libs/ardour/ardour/tempo.h b/libs/ardour/ardour/tempo.h
index f139c071c7..57c6ced275 100644
--- a/libs/ardour/ardour/tempo.h
+++ b/libs/ardour/ardour/tempo.h
@@ -410,9 +410,6 @@ class LIBARDOUR_API TempoMap : public PBD::StatefulDestructible
const Meter& meter_at_frame (framepos_t) const;
- Tempo tempo_at_beat (const double& beat) const;
- double beat_at_tempo (const Tempo& tempo) const;
-
/* bbt - it's nearly always better to use meter-based beat (above)
unless tick resolution is desirable.
*/
@@ -423,7 +420,9 @@ class LIBARDOUR_API TempoMap : public PBD::StatefulDestructible
double beat_at_bbt (const Timecode::BBT_Time& bbt);
Timecode::BBT_Time bbt_at_beat (const double& beats);
+ double quarter_note_at_bbt (const Timecode::BBT_Time& bbt);
double quarter_note_at_bbt_rt (const Timecode::BBT_Time& bbt);
+ Timecode::BBT_Time bbt_at_quarter_note (const double& quarter_note);
framecnt_t bbt_duration_at (framepos_t, const Timecode::BBT_Time&, int dir);
framepos_t framepos_plus_bbt (framepos_t pos, Timecode::BBT_Time b) const;
diff --git a/libs/ardour/tempo.cc b/libs/ardour/tempo.cc
index 07c008ab7c..3671def7ff 100644
--- a/libs/ardour/tempo.cc
+++ b/libs/ardour/tempo.cc
@@ -1730,13 +1730,11 @@ TempoMap::pulse_at_tempo_locked (const Metrics& metrics, const Tempo& tempo) con
* @return the Tempo at the supplied quarter-note.
*/
Tempo
-TempoMap::tempo_at_beat (const double& beat) const
+TempoMap::tempo_at_quarter_note (const double& qn) const
{
Glib::Threads::RWLock::ReaderLock lm (lock);
- const MeterSection* prev_m = &meter_section_at_beat_locked (_metrics, beat);
- const TempoSection* prev_t = &tempo_section_at_beat_locked (_metrics, beat);
- return Tempo (prev_t->tempo_at_pulse (((beat - prev_m->beat()) / prev_m->note_divisor()) + prev_m->pulse()), prev_t->note_type());
+ return tempo_at_pulse_locked (_metrics, qn / 4.0);
}
/** Returns the position in quarter-note beats corresponding to the supplied Tempo.
@@ -1745,12 +1743,11 @@ TempoMap::tempo_at_beat (const double& beat) const
* is equal to that of the Tempo. currently ignores note_type.
*/
double
-TempoMap::beat_at_tempo (const Tempo& tempo) const
+TempoMap::quarter_note_at_tempo (const Tempo& tempo) const
{
Glib::Threads::RWLock::ReaderLock lm (lock);
- const double pulse = pulse_at_tempo_locked (_metrics, tempo);
- return beat_at_pulse_locked (_metrics, pulse);
+ return pulse_at_tempo_locked (_metrics, tempo) * 4.0;;
}
/** Returns the whole-note pulse corresponding to the supplied BBT (meter-based) beat.
diff --git a/libs/ardour/test/tempo_test.cc b/libs/ardour/test/tempo_test.cc
index 4c25a8c719..2042c52fdd 100644
--- a/libs/ardour/test/tempo_test.cc
+++ b/libs/ardour/test/tempo_test.cc
@@ -88,15 +88,14 @@ TempoTest::recomputeMapTest48 ()
CPPUNIT_ASSERT_DOUBLES_EQUAL (240.0, map.tempo_at_frame (288e3).beats_per_minute(), 1e-17);
CPPUNIT_ASSERT_DOUBLES_EQUAL (120.0, map.tempo_at_frame (288e3 - 1).beats_per_minute(), 1e-17);
- /* tempo - bbt (meter based) beat */
- CPPUNIT_ASSERT_DOUBLES_EQUAL (240.0, map.tempo_at_beat (24.0).beats_per_minute(), 1e-17);
- CPPUNIT_ASSERT_DOUBLES_EQUAL (240.0, map.tempo_at_beat (12.0).beats_per_minute(), 1e-17);
- CPPUNIT_ASSERT_DOUBLES_EQUAL (120.0, map.tempo_at_beat (6.0).beats_per_minute(), 1e-17);
- CPPUNIT_ASSERT_DOUBLES_EQUAL (120.0, map.tempo_at_beat (0.0).beats_per_minute(), 1e-17);
- /*bbt (meter based) beat - tempo */
- /* this is expected for constant tempi */
- CPPUNIT_ASSERT_DOUBLES_EQUAL (12.0, map.beat_at_tempo (240.0), 1e-17);
- CPPUNIT_ASSERT_DOUBLES_EQUAL (0.0, map.beat_at_tempo (120.0), 1e-17);
+ /* tempo - quarter note */
+ CPPUNIT_ASSERT_DOUBLES_EQUAL (240.0, map.tempo_at_quarter_note (24.0).beats_per_minute(), 1e-17);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL (240.0, map.tempo_at_quarter_note (12.0).beats_per_minute(), 1e-17);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL (120.0, map.tempo_at_quarter_note (6.0).beats_per_minute(), 1e-17);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL (120.0, map.tempo_at_quarter_note (0.0).beats_per_minute(), 1e-17);
+
+ CPPUNIT_ASSERT_DOUBLES_EQUAL (12.0, map.quarter_note_at_tempo (240.0), 1e-17);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL (0.0, map.quarter_note_at_tempo (120.0), 1e-17);
/* tempo - internal minute interface */
CPPUNIT_ASSERT_DOUBLES_EQUAL (240.0, map.tempo_at_minute_locked (map._metrics, 0.1).beats_per_minute(), 1e-17);
@@ -189,15 +188,14 @@ TempoTest::recomputeMapTest44 ()
CPPUNIT_ASSERT_DOUBLES_EQUAL (240.0, map.tempo_at_frame (264600).beats_per_minute(), 1e-17);
CPPUNIT_ASSERT_DOUBLES_EQUAL (120.0, map.tempo_at_frame (264600 - 1).beats_per_minute(), 1e-17);
- /* tempo - meter-based beat (bbt beat) */
- CPPUNIT_ASSERT_DOUBLES_EQUAL (240.0, map.tempo_at_beat (24.0).beats_per_minute(), 1e-17);
- CPPUNIT_ASSERT_DOUBLES_EQUAL (240.0, map.tempo_at_beat (12.0).beats_per_minute(), 1e-17);
- CPPUNIT_ASSERT_DOUBLES_EQUAL (120.0, map.tempo_at_beat (6.0).beats_per_minute(), 1e-17);
- CPPUNIT_ASSERT_DOUBLES_EQUAL (120.0, map.tempo_at_beat (0.0).beats_per_minute(), 1e-17);
- /* meter-based beat (bbt beat) - tempo */
- /* this is expected for constant tempi */
- CPPUNIT_ASSERT_DOUBLES_EQUAL (12.0, map.beat_at_tempo (240.0), 1e-17);
- CPPUNIT_ASSERT_DOUBLES_EQUAL (0.0, map.beat_at_tempo (120.0), 1e-17);
+ /* tempo - quarter note */
+ CPPUNIT_ASSERT_DOUBLES_EQUAL (240.0, map.tempo_at_quarter_note (24.0).beats_per_minute(), 1e-17);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL (240.0, map.tempo_at_quarter_note (12.0).beats_per_minute(), 1e-17);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL (120.0, map.tempo_at_quarter_note (6.0).beats_per_minute(), 1e-17);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL (120.0, map.tempo_at_quarter_note (0.0).beats_per_minute(), 1e-17);
+
+ CPPUNIT_ASSERT_DOUBLES_EQUAL (12.0, map.quarter_note_at_tempo (240.0), 1e-17);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL (0.0, map.quarter_note_at_tempo (120.0), 1e-17);
/* tempo - internal minute interface */
CPPUNIT_ASSERT_DOUBLES_EQUAL (240.0, map.tempo_at_minute_locked (map._metrics, 0.1).beats_per_minute(), 1e-17);