summaryrefslogtreecommitdiff
path: root/libs/ardour/tempo.cc
diff options
context:
space:
mode:
authornick_m <mainsbridge@gmail.com>2016-11-04 02:17:59 +1100
committernick_m <mainsbridge@gmail.com>2016-11-11 03:37:08 +1100
commit5788f4243854569096d8c0ba89edc84ca677de22 (patch)
treefab315c15e08f0121e2cd930062f25f3ebcb0ea2 /libs/ardour/tempo.cc
parent93ca7b42fb36e56f6e12d228398073c3a68f2e27 (diff)
fix lock error in empoMap::quarter_note_at_bbt_rt(), expand constant tempo test.
Diffstat (limited to 'libs/ardour/tempo.cc')
-rw-r--r--libs/ardour/tempo.cc25
1 files changed, 24 insertions, 1 deletions
diff --git a/libs/ardour/tempo.cc b/libs/ardour/tempo.cc
index 3671def7ff..073e0dc0a8 100644
--- a/libs/ardour/tempo.cc
+++ b/libs/ardour/tempo.cc
@@ -1975,10 +1975,18 @@ TempoMap::bbt_at_beat_locked (const Metrics& metrics, const double& b) const
* while the input uses meter, the output does not.
*/
double
-TempoMap::quarter_note_at_bbt_rt (const Timecode::BBT_Time& bbt)
+TempoMap::quarter_note_at_bbt (const Timecode::BBT_Time& bbt)
{
Glib::Threads::RWLock::ReaderLock lm (lock);
+ return pulse_at_bbt_locked (_metrics, bbt) * 4.0;
+}
+
+double
+TempoMap::quarter_note_at_bbt_rt (const Timecode::BBT_Time& bbt)
+{
+ Glib::Threads::RWLock::ReaderLock lm (lock, Glib::Threads::TRY_LOCK);
+
if (!lm.locked()) {
throw std::logic_error ("TempoMap::quarter_note_at_bbt_rt() could not lock tempo map");
}
@@ -2017,6 +2025,21 @@ TempoMap::pulse_at_bbt_locked (const Metrics& metrics, const Timecode::BBT_Time&
return ret;
}
+/** Returns the BBT time corresponding to the supplied quarter-note beat.
+ * @param qn the quarter-note beat.
+ * @return The BBT time (meter-based) at the supplied meter-based beat.
+ *
+ * quarter-notes ignore meter and are based on pulse (the musical unit of MetricSection).
+ *
+ */
+Timecode::BBT_Time
+TempoMap::bbt_at_quarter_note (const double& qn)
+{
+ Glib::Threads::RWLock::ReaderLock lm (lock);
+
+ return bbt_at_pulse_locked (_metrics, qn / 4.0);
+}
+
/** 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.