summaryrefslogtreecommitdiff
path: root/libs/ardour
diff options
context:
space:
mode:
authornick_m <mainsbridge@gmail.com>2016-05-27 03:22:24 +1000
committernick_m <mainsbridge@gmail.com>2016-05-27 23:38:17 +1000
commit34c9ac9dd7b1187d9efa2c6894fccba34fe298cd (patch)
treea44a03530b47c2a8c63f78180a44e5e2f4ac8e8a /libs/ardour
parentb564f07635ea917ec574361346ab12d7fa733289 (diff)
Tempo ramps - rename bbt_time() -> bbt_at_frame(), frame_time() -> frame_at_bbt()
Diffstat (limited to 'libs/ardour')
-rw-r--r--libs/ardour/ardour/tempo.h15
-rw-r--r--libs/ardour/lv2_plugin.cc2
-rw-r--r--libs/ardour/session_time.cc4
-rw-r--r--libs/ardour/session_vst.cc2
-rw-r--r--libs/ardour/tempo.cc51
5 files changed, 45 insertions, 29 deletions
diff --git a/libs/ardour/ardour/tempo.h b/libs/ardour/ardour/tempo.h
index f08ffa64b9..8227a968a0 100644
--- a/libs/ardour/ardour/tempo.h
+++ b/libs/ardour/ardour/tempo.h
@@ -330,13 +330,13 @@ class LIBARDOUR_API TempoMap : public PBD::StatefulDestructible
static const Tempo& default_tempo() { return _default_tempo; }
static const Meter& default_meter() { return _default_meter; }
+ /* because tempos may be ramped, this is only valid for the instant requested.*/
double frames_per_beat_at (const framepos_t&, const framecnt_t& sr) const;
const TempoSection& tempo_section_at (framepos_t frame) const;
const MeterSection& meter_section_at (framepos_t frame) const;
const MeterSection& meter_section_at_beat (double beat) const;
-
/** add a tempo section locked to pls. ignored values will be set in recompute_tempos()
* @param pulse pulse position of new section. ignored if pls == AudioTime
* @param frame frame position of new section. ignored if pls == MusicTime
@@ -366,8 +366,6 @@ class LIBARDOUR_API TempoMap : public PBD::StatefulDestructible
void set_length (framepos_t frames);
- void fix_legacy_session();
-
XMLNode& get_state (void);
int set_state (const XMLNode&, int version);
@@ -417,6 +415,9 @@ class LIBARDOUR_API TempoMap : public PBD::StatefulDestructible
const Tempo tempo_at_frame (const framepos_t& frame) const;
const Meter& meter_at_frame (framepos_t) const;
+ const Timecode::BBT_Time bbt_at_frame (framepos_t when);
+ const framepos_t frame_at_bbt (const Timecode::BBT_Time&);
+
double beat_at_bbt (const Timecode::BBT_Time& bbt);
Timecode::BBT_Time bbt_at_beat (const double& beats);
@@ -425,8 +426,6 @@ class LIBARDOUR_API TempoMap : public PBD::StatefulDestructible
std::pair<double, framepos_t> predict_tempo_position (TempoSection* section, const Timecode::BBT_Time& bbt);
- void bbt_time (framepos_t when, Timecode::BBT_Time&);
- framepos_t frame_time (const Timecode::BBT_Time&);
framecnt_t bbt_duration_at (framepos_t, const Timecode::BBT_Time&, int dir);
/* TEMPO-SENSITIVE FUNCTIONS
@@ -452,6 +451,7 @@ class LIBARDOUR_API TempoMap : public PBD::StatefulDestructible
bool can_solve_bbt (TempoSection* section, const Timecode::BBT_Time& bbt);
PBD::Signal0<void> MetricPositionChanged;
+ void fix_legacy_session();
private:
double pulse_at_beat_locked (const Metrics& metrics, const double& beat) const;
@@ -469,9 +469,10 @@ private:
double pulse_at_bbt_locked (const Metrics& metrics, const Timecode::BBT_Time& bbt) const;
Timecode::BBT_Time bbt_at_pulse_locked (const Metrics& metrics, const double& pulse) const;
- const Tempo tempo_at_frame_locked (const Metrics& metrics, const framepos_t& frame) const;
+ Timecode::BBT_Time bbt_at_frame_locked (const Metrics& metrics, const framepos_t& frame) const;
+ framepos_t frame_at_bbt_locked (const Metrics& metrics, const Timecode::BBT_Time&) const;
- framepos_t frame_time_locked (const Metrics& metrics, const Timecode::BBT_Time&) const;
+ const Tempo tempo_at_frame_locked (const Metrics& metrics, const framepos_t& frame) const;
const TempoSection& tempo_section_at_locked (const Metrics& metrics, framepos_t frame) const;
const TempoSection& tempo_section_at_beat_locked (const Metrics& metrics, const double& beat) const;
diff --git a/libs/ardour/lv2_plugin.cc b/libs/ardour/lv2_plugin.cc
index fa11f7b051..4c3ca31d2d 100644
--- a/libs/ardour/lv2_plugin.cc
+++ b/libs/ardour/lv2_plugin.cc
@@ -2310,7 +2310,7 @@ LV2Plugin::connect_and_run(BufferSet& bufs,
if (_session.transport_frame() != _next_cycle_start ||
_session.transport_speed() != _next_cycle_speed) {
// Transport has changed, write position at cycle start
- tmap.bbt_time(_session.transport_frame(), bbt);
+ bbt = tmap.bbt_at_frame (_session.transport_frame());
write_position(&_impl->forge, _ev_buffers[port_index],
tmetric, bbt, _session.transport_speed(),
_session.transport_frame(), 0);
diff --git a/libs/ardour/session_time.cc b/libs/ardour/session_time.cc
index 6bb018649f..54770d5cc8 100644
--- a/libs/ardour/session_time.cc
+++ b/libs/ardour/session_time.cc
@@ -46,7 +46,7 @@ using namespace PBD;
void
Session::bbt_time (framepos_t when, Timecode::BBT_Time& bbt)
{
- _tempo_map->bbt_time (when, bbt);
+ bbt = _tempo_map->bbt_at_frame (when);
}
/* Timecode TIME */
@@ -226,7 +226,7 @@ Session::convert_to_frames (AnyTime const & position)
switch (position.type) {
case AnyTime::BBT:
- return _tempo_map->frame_time (position.bbt);
+ return _tempo_map->frame_at_bbt (position.bbt);
break;
case AnyTime::Timecode:
diff --git a/libs/ardour/session_vst.cc b/libs/ardour/session_vst.cc
index ad732e052a..3741ceb9a1 100644
--- a/libs/ardour/session_vst.cc
+++ b/libs/ardour/session_vst.cc
@@ -223,7 +223,7 @@ intptr_t Session::vst_callback (
Timecode::BBT_Time bbt;
try {
- session->tempo_map().bbt_time (now, bbt);
+ bbt = session->tempo_map().bbt_at_frame (now);
/* PPQ = pulse per quarter
* VST's "pulse" is our "division".
diff --git a/libs/ardour/tempo.cc b/libs/ardour/tempo.cc
index 44c59bd6d2..97c468e1b6 100644
--- a/libs/ardour/tempo.cc
+++ b/libs/ardour/tempo.cc
@@ -1805,25 +1805,40 @@ TempoMap::bbt_at_pulse_locked (const Metrics& metrics, const double& pulse) cons
return ret;
}
-void
-TempoMap::bbt_time (framepos_t frame, BBT_Time& bbt)
+const BBT_Time
+TempoMap::bbt_at_frame (framepos_t frame)
{
-
if (frame < 0) {
+ BBT_Time bbt;
bbt.bars = 1;
bbt.beats = 1;
bbt.ticks = 0;
warning << string_compose (_("tempo map asked for BBT time at frame %1\n"), frame) << endmsg;
- return;
+ return bbt;
}
Glib::Threads::RWLock::ReaderLock lm (lock);
- const double beat = beat_at_frame_locked (_metrics, frame);
- bbt = bbt_at_beat_locked (_metrics, beat);
+ return bbt_at_frame_locked (_metrics, frame);
}
-framepos_t
-TempoMap::frame_time (const BBT_Time& bbt)
+Timecode::BBT_Time
+TempoMap::bbt_at_frame_locked (const Metrics& metrics, const framepos_t& frame) const
+{
+ if (frame < 0) {
+ BBT_Time bbt;
+ bbt.bars = 1;
+ bbt.beats = 1;
+ bbt.ticks = 0;
+ warning << string_compose (_("tempo map asked for BBT time at frame %1\n"), frame) << endmsg;
+ return bbt;
+ }
+ const double beat = beat_at_frame_locked (metrics, frame);
+
+ return bbt_at_beat_locked (metrics, beat);
+}
+
+const framepos_t
+TempoMap::frame_at_bbt (const BBT_Time& bbt)
{
if (bbt.bars < 1) {
warning << string_compose (_("tempo map asked for frame time at bar < 1 (%1)\n"), bbt) << endmsg;
@@ -1835,12 +1850,12 @@ TempoMap::frame_time (const BBT_Time& bbt)
}
Glib::Threads::RWLock::ReaderLock lm (lock);
- return frame_time_locked (_metrics, bbt);
+ return frame_at_bbt_locked (_metrics, bbt);
}
-/* meter section based */
+/* meter & tempo section based */
framepos_t
-TempoMap::frame_time_locked (const Metrics& metrics, const BBT_Time& bbt) const
+TempoMap::frame_at_bbt_locked (const Metrics& metrics, const BBT_Time& bbt) const
{
/* HOLD THE READER LOCK */
@@ -2802,22 +2817,22 @@ TempoMap::round_to_type (framepos_t frame, RoundMode dir, BBTPointType type)
/* find bar previous to 'frame' */
bbt.beats = 1;
bbt.ticks = 0;
- return frame_time_locked (_metrics, bbt);
+ return frame_at_bbt_locked (_metrics, bbt);
} else if (dir > 0) {
/* find bar following 'frame' */
++bbt.bars;
bbt.beats = 1;
bbt.ticks = 0;
- return frame_time_locked (_metrics, bbt);
+ return frame_at_bbt_locked (_metrics, bbt);
} else {
/* true rounding: find nearest bar */
- framepos_t raw_ft = frame_time_locked (_metrics, bbt);
+ framepos_t raw_ft = frame_at_bbt_locked (_metrics, bbt);
bbt.beats = 1;
bbt.ticks = 0;
- framepos_t prev_ft = frame_time_locked (_metrics, bbt);
+ framepos_t prev_ft = frame_at_bbt_locked (_metrics, bbt);
++bbt.bars;
- framepos_t next_ft = frame_time_locked (_metrics, bbt);
+ framepos_t next_ft = frame_at_bbt_locked (_metrics, bbt);
if ((raw_ft - prev_ft) > (next_ft - prev_ft) / 2) {
return next_ft;
@@ -3354,7 +3369,7 @@ TempoMap::insert_time (framepos_t where, framecnt_t amount)
tempo = t;
// cerr << "NEW TEMPO, frame = " << (*i)->frame() << " beat = " << (*i)->pulse() <<endl;
} else if ((m = dynamic_cast<MeterSection*>(*i)) != 0) {
- bbt_time (m->frame(), bbt);
+ bbt = bbt_at_frame_locked (_metrics, m->frame());
// cerr << "timestamp @ " << (*i)->frame() << " with " << bbt.bars << "|" << bbt.beats << "|" << bbt.ticks << " => ";
@@ -3493,7 +3508,7 @@ TempoMap::framepos_plus_bbt (framepos_t pos, BBT_Time op) const
}
pos_bbt.bars += op.bars;
- return frame_time_locked (_metrics, pos_bbt);
+ return frame_at_bbt_locked (_metrics, pos_bbt);
}
/** Count the number of beats that are equivalent to distance when going forward,