summaryrefslogtreecommitdiff
path: root/libs/ardour
diff options
context:
space:
mode:
authornick_m <mainsbridge@gmail.com>2016-11-01 21:54:11 +1100
committernick_m <mainsbridge@gmail.com>2016-11-11 03:37:08 +1100
commit594137f5cc5d641873b9002c28453166e81bac9e (patch)
tree372b45608c4cb95e1d7a0fe4aa337e86e2deb793 /libs/ardour
parent3db68b4f9e88658e8130769ee469f2a7b4de97a2 (diff)
remove public pulse methods from TempoMap.
- the only object whose musical position is not expressed in quarter notes is MetricSection. there is now no need to expose this.
Diffstat (limited to 'libs/ardour')
-rw-r--r--libs/ardour/ardour/tempo.h13
-rw-r--r--libs/ardour/lv2_plugin.cc2
-rw-r--r--libs/ardour/session_vst.cc2
-rw-r--r--libs/ardour/tempo.cc82
-rw-r--r--libs/ardour/test/tempo_test.cc24
5 files changed, 42 insertions, 81 deletions
diff --git a/libs/ardour/ardour/tempo.h b/libs/ardour/ardour/tempo.h
index c32d829fba..0edf5d28a1 100644
--- a/libs/ardour/ardour/tempo.h
+++ b/libs/ardour/ardour/tempo.h
@@ -419,12 +419,6 @@ class LIBARDOUR_API TempoMap : public PBD::StatefulDestructible
const Meter& meter_at_frame (framepos_t) const;
- double pulse_at_beat (const double& beat) const;
- double beat_at_pulse (const double& pulse) const;
-
- double pulse_at_frame (const framecnt_t& frame) const;
- framepos_t frame_at_pulse (const double& pulse) const;
-
/* bbt - it's nearly always better to use beats.*/
Timecode::BBT_Time bbt_at_frame (framepos_t when);
Timecode::BBT_Time bbt_at_frame_rt (framepos_t when);
@@ -433,9 +427,7 @@ 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 pulse_at_bbt (const Timecode::BBT_Time& bbt);
- double pulse_at_bbt_rt (const Timecode::BBT_Time& bbt);
- Timecode::BBT_Time bbt_at_pulse (const double& pulse);
+ double quarter_note_at_bbt_rt (const Timecode::BBT_Time& bbt);
framecnt_t bbt_duration_at (framepos_t, const Timecode::BBT_Time&, int dir);
@@ -457,6 +449,7 @@ class LIBARDOUR_API TempoMap : public PBD::StatefulDestructible
double quarter_note_at_frame (const framepos_t frame);
double quarter_note_at_frame_rt (const framepos_t frame);
framepos_t frame_at_quarter_note (const double quarter_note);
+
double quarter_note_at_beat (const double beat);
double beat_at_quarter_note (const double beat);
@@ -465,7 +458,7 @@ class LIBARDOUR_API TempoMap : public PBD::StatefulDestructible
void gui_move_tempo (TempoSection*, const framepos_t& frame, const int& sub_num);
void gui_move_meter (MeterSection*, const framepos_t& frame);
bool gui_change_tempo (TempoSection*, const Tempo& bpm);
- void gui_dilate_tempo (TempoSection* tempo, const framepos_t& frame, const framepos_t& end_frame, const double& pulse);
+ void gui_dilate_tempo (TempoSection* tempo, const framepos_t& frame, const framepos_t& end_frame);
double exact_beat_at_frame (const framepos_t& frame, const int32_t sub_num);
double exact_qn_at_frame (const framepos_t& frame, const int32_t sub_num);
diff --git a/libs/ardour/lv2_plugin.cc b/libs/ardour/lv2_plugin.cc
index 017dc4e936..1b6775ab49 100644
--- a/libs/ardour/lv2_plugin.cc
+++ b/libs/ardour/lv2_plugin.cc
@@ -2607,7 +2607,7 @@ LV2Plugin::connect_and_run(BufferSet& bufs,
} else {
tmetric.set_metric(metric);
Timecode::BBT_Time bbt;
- bbt = tmap.bbt_at_pulse (metric->pulse());
+ bbt = tmap.bbt_at_frame (metric->frame());
double bpm = tmap.tempo_at_frame (start/*XXX*/).beats_per_minute();
write_position(&_impl->forge, _ev_buffers[port_index],
tmetric, bbt, speed, bpm,
diff --git a/libs/ardour/session_vst.cc b/libs/ardour/session_vst.cc
index a614fef956..5da17cf430 100644
--- a/libs/ardour/session_vst.cc
+++ b/libs/ardour/session_vst.cc
@@ -225,7 +225,7 @@ intptr_t Session::vst_callback (
bbt.beats = 1;
bbt.ticks = 0;
/* exact quarter note */
- double ppqBar = session->tempo_map().pulse_at_bbt_rt (bbt) * 4.0;
+ double ppqBar = session->tempo_map().quarter_note_at_bbt_rt (bbt);
/* quarter note at frame position (not rounded to note subdivision) */
double ppqPos = session->tempo_map().quarter_note_at_frame_rt (now);
if (value & (kVstPpqPosValid)) {
diff --git a/libs/ardour/tempo.cc b/libs/ardour/tempo.cc
index a060b93b34..3410646a8c 100644
--- a/libs/ardour/tempo.cc
+++ b/libs/ardour/tempo.cc
@@ -1584,7 +1584,7 @@ TempoMap::minute_at_beat_locked (const Metrics& metrics, const double& beat) con
return prev_t->minute_at_pulse (((beat - prev_m->beat()) / prev_m->note_divisor()) + prev_m->pulse());
}
-/** Returns a Tempo corresponding to the supplied frame.
+/** Returns a Tempo corresponding to the supplied frame position.
* @param frame The audio frame.
* @return a Tempo according to the tempo map at the supplied frame.
*
@@ -1744,6 +1744,7 @@ TempoMap::pulse_at_tempo_locked (const Metrics& metrics, const Tempo& tempo) con
/** Returns a Tempo corresponding to the supplied BBT (meter-based) beat.
* @param beat The BBT (meter-based) beat.
+ * @return the Tempo at the supplied BBT (meter-based) beat.
*/
Tempo
TempoMap::tempo_at_beat (const double& beat) const
@@ -1757,6 +1758,7 @@ TempoMap::tempo_at_beat (const double& beat) const
/** Returns a BBT (meter-based) beat corresponding to the supplied Tempo.
* @param tempo The tempo.
+ * @return the BBT (meter-based) beat at the supplied Tempo.
*/
double
TempoMap::beat_at_tempo (const Tempo& tempo) const
@@ -1766,21 +1768,17 @@ TempoMap::beat_at_tempo (const Tempo& tempo) const
return beat_at_pulse_locked (_metrics, pulse);
}
+
/** Returns the whole-note pulse corresponding to the supplied BBT (meter-based) beat.
+ * @param metrics the list of metric sections used to calculate the pulse.
* @param beat The BBT (meter-based) beat.
+ * @return the whole-note pulse at the supplied BBT (meter-based) beat.
*
* a pulse or whole note is the base musical position of a MetricSection.
* it is equivalent to four quarter notes.
*
*/
double
-TempoMap::pulse_at_beat (const double& beat) const
-{
- Glib::Threads::RWLock::ReaderLock lm (lock);
- return pulse_at_beat_locked (_metrics, beat);
-}
-
-double
TempoMap::pulse_at_beat_locked (const Metrics& metrics, const double& beat) const
{
const MeterSection* prev_m = &meter_section_at_beat_locked (metrics, beat);
@@ -1789,19 +1787,14 @@ TempoMap::pulse_at_beat_locked (const Metrics& metrics, const double& beat) cons
}
/** Returns the BBT (meter-based) beat corresponding to the supplied whole-note pulse .
+ * @param metrics the list of metric sections used to calculate the beat.
* @param pulse the whole-note pulse.
+ * @return the meter-based beat at the supplied whole-note pulse.
*
* a pulse or whole note is the base musical position of a MetricSection.
* it is equivalent to four quarter notes.
*/
double
-TempoMap::beat_at_pulse (const double& pulse) const
-{
- Glib::Threads::RWLock::ReaderLock lm (lock);
- return beat_at_pulse_locked (_metrics, pulse);
-}
-
-double
TempoMap::beat_at_pulse_locked (const Metrics& metrics, const double& pulse) const
{
MeterSection* prev_m = 0;
@@ -1821,13 +1814,6 @@ TempoMap::beat_at_pulse_locked (const Metrics& metrics, const double& pulse) con
return ret;
}
-double
-TempoMap::pulse_at_frame (const framepos_t& frame) const
-{
- Glib::Threads::RWLock::ReaderLock lm (lock);
- return pulse_at_minute_locked (_metrics, minute_at_frame (frame));
-}
-
/* tempo section based */
double
TempoMap::pulse_at_minute_locked (const Metrics& metrics, const double& minute) const
@@ -1861,14 +1847,6 @@ TempoMap::pulse_at_minute_locked (const Metrics& metrics, const double& minute)
return pulses_in_section + prev_t->pulse();
}
-framepos_t
-TempoMap::frame_at_pulse (const double& pulse) const
-{
- Glib::Threads::RWLock::ReaderLock lm (lock);
-
- return frame_at_minute (minute_at_pulse_locked (_metrics, pulse));
-}
-
/* tempo section based */
double
TempoMap::minute_at_pulse_locked (const Metrics& metrics, const double& pulse) const
@@ -1900,6 +1878,7 @@ TempoMap::minute_at_pulse_locked (const Metrics& metrics, const double& pulse) c
/** Returns the BBT (meter-based) beat corresponding to the supplied BBT time.
* @param bbt The BBT time (meter-based).
+ * @return bbt The BBT beat (meter-based) at the supplied BBT time.
*
*/
double
@@ -1944,6 +1923,7 @@ TempoMap::beat_at_bbt_locked (const Metrics& metrics, const Timecode::BBT_Time&
/** Returns the BBT time corresponding to the supplied BBT (meter-based) beat.
* @param beat The BBT (meter-based) beat.
+ * @return The BBT time (meter-based) at the supplied meter-based beat.
*
*/
Timecode::BBT_Time
@@ -2005,31 +1985,24 @@ TempoMap::bbt_at_beat_locked (const Metrics& metrics, const double& b) const
return ret;
}
-/** Returns the whole-note pulse corresponding to the supplied BBT time (meter-based).
+/** Returns the quarter-note beat corresponding to the supplied BBT time (meter-based).
* @param bbt The BBT time (meter-based).
+ * @return the quarter note beat at the supplied BBT time
+ *
+ * quarter-notes ignore meter and are based on pulse (the musical unit of MetricSection).
*
- * a pulse or whole note is the basic musical position of a MetricSection.
- * it is equivalent to four quarter notes.
* while the input uses meter, the output does not.
*/
double
-TempoMap::pulse_at_bbt (const Timecode::BBT_Time& bbt)
-{
- Glib::Threads::RWLock::ReaderLock lm (lock);
-
- return pulse_at_bbt_locked (_metrics, bbt);
-}
-
-double
-TempoMap::pulse_at_bbt_rt (const Timecode::BBT_Time& bbt)
+TempoMap::quarter_note_at_bbt_rt (const Timecode::BBT_Time& bbt)
{
Glib::Threads::RWLock::ReaderLock lm (lock);
if (!lm.locked()) {
- throw std::logic_error ("TempoMap::pulse_at_bbt_rt() could not lock tempo map");
+ throw std::logic_error ("TempoMap::quarter_note_at_bbt_rt() could not lock tempo map");
}
- return pulse_at_bbt_locked (_metrics, bbt);
+ return pulse_at_bbt_locked (_metrics, bbt) * 4.0;
}
double
@@ -2062,22 +2035,17 @@ TempoMap::pulse_at_bbt_locked (const Metrics& metrics, const Timecode::BBT_Time&
return ret;
}
-/** Returns the BBT time (meter-based) corresponding to the supplied whole-note pulse.
+
+/** Returns the BBT time (meter-based) corresponding to the supplied whole-note pulse position.
+ * @param metrics The list of metric sections used to determine the result.
* @param pulse The whole-note pulse.
+ * @return The BBT time at the supplied whole-note pulse.
*
* a pulse or whole note is the basic musical position of a MetricSection.
* it is equivalent to four quarter notes.
- * while the input uses meter, the output does not.
+ * while the output uses meter, the input does not.
*/
Timecode::BBT_Time
-TempoMap::bbt_at_pulse (const double& pulse)
-{
- Glib::Threads::RWLock::ReaderLock lm (lock);
-
- return bbt_at_pulse_locked (_metrics, pulse);
-}
-
-Timecode::BBT_Time
TempoMap::bbt_at_pulse_locked (const Metrics& metrics, const double& pulse) const
{
MeterSection* prev_m = 0;
@@ -3199,14 +3167,14 @@ TempoMap::gui_change_tempo (TempoSection* ts, const Tempo& bpm)
}
void
-TempoMap::gui_dilate_tempo (TempoSection* ts, const framepos_t& frame, const framepos_t& end_frame, const double& pulse)
+TempoMap::gui_dilate_tempo (TempoSection* ts, const framepos_t& frame, const framepos_t& end_frame)
{
/*
Ts (future prev_t) Tnext
| |
| [drag^] |
|----------|----------
- e_f pulse(frame)
+ e_f qn_beats(frame)
*/
Metrics future_map;
@@ -3300,7 +3268,7 @@ TempoMap::gui_dilate_tempo (TempoSection* ts, const framepos_t& frame, const fra
double frame_ratio = 1.0;
double pulse_ratio = 1.0;
- const double pulse_pos = prev_t->frame_at_pulse (pulse);
+ const double pulse_pos = frame;
if (prev_to_prev_t) {
if (pulse_pos > prev_to_prev_t->frame() + min_dframe && (pulse_pos - fr_off) > prev_to_prev_t->frame() + min_dframe) {
diff --git a/libs/ardour/test/tempo_test.cc b/libs/ardour/test/tempo_test.cc
index 30b20d3285..79fd0ee860 100644
--- a/libs/ardour/test/tempo_test.cc
+++ b/libs/ardour/test/tempo_test.cc
@@ -69,14 +69,14 @@ TempoTest::recomputeMapTest48 ()
/* pulse */
/* pulse - frame*/
- CPPUNIT_ASSERT_EQUAL (framepos_t (288e3), map.frame_at_pulse (3.0));
- CPPUNIT_ASSERT_EQUAL (framepos_t (144e3), map.frame_at_pulse (1.5));
- CPPUNIT_ASSERT_EQUAL (framepos_t (96e3), map.frame_at_pulse (1.0));
+ 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*/
- CPPUNIT_ASSERT_DOUBLES_EQUAL (3.0, map.pulse_at_frame (288e3), 1e-17);
- CPPUNIT_ASSERT_DOUBLES_EQUAL (1.5, map.pulse_at_frame (144e3), 1e-17);
- CPPUNIT_ASSERT_DOUBLES_EQUAL (1.0, map.pulse_at_frame (96e3), 1e-17);
+ 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);
/* pulse - internal minute based interface */
CPPUNIT_ASSERT_DOUBLES_EQUAL (0.1, map.minute_at_pulse_locked (map._metrics, 3.0), 1e-17);
@@ -170,14 +170,14 @@ TempoTest::recomputeMapTest44 ()
/* pulse */
/* pulse - frame*/
- CPPUNIT_ASSERT_EQUAL (framepos_t (264600), map.frame_at_pulse (3.0));
- CPPUNIT_ASSERT_EQUAL (framepos_t (132300), map.frame_at_pulse (1.5));
- CPPUNIT_ASSERT_EQUAL (framepos_t (88200), map.frame_at_pulse (1.0));
+ 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 (3.0, map.pulse_at_frame (264600), 1e-17);
- CPPUNIT_ASSERT_DOUBLES_EQUAL (1.5, map.pulse_at_frame (132300), 1e-17);
- CPPUNIT_ASSERT_DOUBLES_EQUAL (1.0, map.pulse_at_frame (88200), 1e-17);
+ 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);
/* pulse - internal minute based interface */
CPPUNIT_ASSERT_DOUBLES_EQUAL (0.1, map.minute_at_pulse_locked (map._metrics, 3.0), 1e-17);