mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-16 19:56:31 +01:00
Tempo ramps - fix merge conflicts, add bbt_at_frame_rt().
This commit is contained in:
parent
bf96a74e96
commit
78bec77c3e
3 changed files with 18 additions and 25 deletions
|
|
@ -422,6 +422,7 @@ class LIBARDOUR_API TempoMap : public PBD::StatefulDestructible
|
||||||
|
|
||||||
/* bbt - it's nearly always better to use beats.*/
|
/* bbt - it's nearly always better to use beats.*/
|
||||||
Timecode::BBT_Time bbt_at_frame (framepos_t when);
|
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&);
|
framepos_t frame_at_bbt (const Timecode::BBT_Time&);
|
||||||
|
|
||||||
double beat_at_bbt (const Timecode::BBT_Time& bbt);
|
double beat_at_bbt (const Timecode::BBT_Time& bbt);
|
||||||
|
|
|
||||||
|
|
@ -223,29 +223,10 @@ intptr_t Session::vst_callback (
|
||||||
Timecode::BBT_Time bbt;
|
Timecode::BBT_Time bbt;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
bbt = session->tempo_map().bbt_at_frame (now);
|
bbt = session->tempo_map().bbt_at_frame_rt (now);
|
||||||
|
|
||||||
/* PPQ = pulse per quarter
|
double ppqBar;
|
||||||
* VST's "pulse" is our "division".
|
double ppqPos = vst_ppq (tm, bbt, ppqBar);
|
||||||
*
|
|
||||||
* 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;
|
|
||||||
|
|
||||||
if (value & (kVstPpqPosValid)) {
|
if (value & (kVstPpqPosValid)) {
|
||||||
timeinfo->ppqPos = ppqPos;
|
timeinfo->ppqPos = ppqPos;
|
||||||
|
|
@ -310,10 +291,10 @@ intptr_t Session::vst_callback (
|
||||||
double ppqBar;
|
double ppqBar;
|
||||||
Timecode::BBT_Time bbt;
|
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);
|
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);
|
timeinfo->cycleEndPos = vst_ppq (tm, bbt, ppqBar);
|
||||||
|
|
||||||
newflags |= kVstCyclePosValid;
|
newflags |= kVstCyclePosValid;
|
||||||
|
|
@ -568,4 +549,3 @@ intptr_t Session::vst_callback (
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1860,6 +1860,18 @@ TempoMap::bbt_at_frame (framepos_t frame)
|
||||||
return bbt_at_frame_locked (_metrics, 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
|
Timecode::BBT_Time
|
||||||
TempoMap::bbt_at_frame_locked (const Metrics& metrics, const framepos_t& frame) const
|
TempoMap::bbt_at_frame_locked (const Metrics& metrics, const framepos_t& frame) const
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue