summaryrefslogtreecommitdiff
path: root/libs/ardour
diff options
context:
space:
mode:
authornick_m <mainsbridge@gmail.com>2016-05-28 00:10:53 +1000
committernick_m <mainsbridge@gmail.com>2016-05-28 00:10:53 +1000
commit78bec77c3e4deeffcb02da3e8de5b034705a6ebb (patch)
treee5a84d45fc79feb5de73708251cd4974d9d6f229 /libs/ardour
parentbf96a74e96224f620105e8ec6a87361e15055c8c (diff)
Tempo ramps - fix merge conflicts, add bbt_at_frame_rt().
Diffstat (limited to 'libs/ardour')
-rw-r--r--libs/ardour/ardour/tempo.h1
-rw-r--r--libs/ardour/session_vst.cc32
-rw-r--r--libs/ardour/tempo.cc12
3 files changed, 19 insertions, 26 deletions
diff --git a/libs/ardour/ardour/tempo.h b/libs/ardour/ardour/tempo.h
index 4a2e5877b8..f190ba1185 100644
--- a/libs/ardour/ardour/tempo.h
+++ b/libs/ardour/ardour/tempo.h
@@ -422,6 +422,7 @@ class LIBARDOUR_API TempoMap : public PBD::StatefulDestructible
/* 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);
framepos_t frame_at_bbt (const Timecode::BBT_Time&);
double beat_at_bbt (const Timecode::BBT_Time& bbt);
diff --git a/libs/ardour/session_vst.cc b/libs/ardour/session_vst.cc
index 3741ceb9a1..5bc82a1795 100644
--- a/libs/ardour/session_vst.cc
+++ b/libs/ardour/session_vst.cc
@@ -223,29 +223,10 @@ intptr_t Session::vst_callback (
Timecode::BBT_Time bbt;
try {
- bbt = session->tempo_map().bbt_at_frame (now);
-
- /* PPQ = pulse per quarter
- * VST's "pulse" is our "division".
- *
- * 8 divisions per bar, 1 division = quarter, so 8 quarters per bar, ppq = 1
- * 8 divisions per bar, 1 division = eighth, so 4 quarters per bar, ppq = 2
- * 4 divisions per bar, 1 division = quarter, so 4 quarters per bar, ppq = 1
- * 4 divisions per bar, 1 division = half, so 8 quarters per bar, ppq = 0.5
- * 4 divisions per bar, 1 division = fifth, so (4 * 5/4) quarters per bar, ppq = 5/4
- *
- * general: divs_per_bar / (note_type / 4.0)
- */
- double ppq_scaling = tm.meter().note_divisor() / 4.0;
-
- /* Note that this assumes constant meter/tempo throughout the session. Stupid VST */
- double ppqBar = double(bbt.bars - 1) * tm.meter().divisions_per_bar();
- double ppqBeat = double(bbt.beats - 1);
- double ppqTick = double(bbt.ticks) / Timecode::BBT_Time::ticks_per_beat;
-
- ppqBar *= ppq_scaling;
- ppqBeat *= ppq_scaling;
- ppqTick *= ppq_scaling;
+ bbt = session->tempo_map().bbt_at_frame_rt (now);
+
+ double ppqBar;
+ double ppqPos = vst_ppq (tm, bbt, ppqBar);
if (value & (kVstPpqPosValid)) {
timeinfo->ppqPos = ppqPos;
@@ -310,10 +291,10 @@ intptr_t Session::vst_callback (
double ppqBar;
Timecode::BBT_Time bbt;
- session->tempo_map().bbt_time_rt (looploc->start (), bbt);
+ bbt = session->tempo_map ().bbt_at_frame_rt (looploc->start ());
timeinfo->cycleStartPos = vst_ppq (tm, bbt, ppqBar);
- session->tempo_map().bbt_time_rt (looploc->end (), bbt);
+ bbt = session->tempo_map ().bbt_at_frame (looploc->end ());
timeinfo->cycleEndPos = vst_ppq (tm, bbt, ppqBar);
newflags |= kVstCyclePosValid;
@@ -568,4 +549,3 @@ intptr_t Session::vst_callback (
return 0;
}
-
diff --git a/libs/ardour/tempo.cc b/libs/ardour/tempo.cc
index 693f5234ee..b258734c89 100644
--- a/libs/ardour/tempo.cc
+++ b/libs/ardour/tempo.cc
@@ -1860,6 +1860,18 @@ TempoMap::bbt_at_frame (framepos_t frame)
return bbt_at_frame_locked (_metrics, frame);
}
+BBT_Time
+TempoMap::bbt_at_frame_rt (framepos_t frame)
+{
+ Glib::Threads::RWLock::ReaderLock lm (lock, Glib::Threads::TRY_LOCK);
+
+ if (!lm.locked()) {
+ throw std::logic_error ("TempoMap::bbt_time_rt() could not lock tempo map");
+ }
+
+ return bbt_at_frame_locked (_metrics, frame);
+}
+
Timecode::BBT_Time
TempoMap::bbt_at_frame_locked (const Metrics& metrics, const framepos_t& frame) const
{