summaryrefslogtreecommitdiff
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
parentb564f07635ea917ec574361346ab12d7fa733289 (diff)
Tempo ramps - rename bbt_time() -> bbt_at_frame(), frame_time() -> frame_at_bbt()
-rw-r--r--gtk2_ardour/audio_clock.cc4
-rw-r--r--gtk2_ardour/editor_drag.cc2
-rw-r--r--gtk2_ardour/editor_regions.cc2
-rw-r--r--gtk2_ardour/editor_rulers.cc6
-rw-r--r--gtk2_ardour/editor_tempodisplay.cc4
-rw-r--r--gtk2_ardour/midi_list_editor.cc4
-rw-r--r--gtk2_ardour/tempo_dialog.cc13
-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
-rw-r--r--libs/backends/jack/jack_session.cc2
-rw-r--r--libs/surfaces/control_protocol/basic_ui.cc3
14 files changed, 62 insertions, 52 deletions
diff --git a/gtk2_ardour/audio_clock.cc b/gtk2_ardour/audio_clock.cc
index 7cdf66123d..ee28f138e2 100644
--- a/gtk2_ardour/audio_clock.cc
+++ b/gtk2_ardour/audio_clock.cc
@@ -1258,12 +1258,12 @@ AudioClock::set_bbt (framepos_t when, bool /*force*/)
BBT.beats = 0;
BBT.ticks = 0;
} else {
- _session->tempo_map().bbt_time (when, BBT);
+ BBT = _session->tempo_map().bbt_at_frame (when);
BBT.bars--;
BBT.beats--;
}
} else {
- _session->tempo_map().bbt_time (when, BBT);
+ BBT = _session->tempo_map().bbt_at_frame (when);
}
if (negative) {
diff --git a/gtk2_ardour/editor_drag.cc b/gtk2_ardour/editor_drag.cc
index 07b2eabbad..12216bc3c0 100644
--- a/gtk2_ardour/editor_drag.cc
+++ b/gtk2_ardour/editor_drag.cc
@@ -3180,7 +3180,7 @@ MeterMarkerDrag::motion (GdkEvent* event, bool first_move)
}
const double beat = map.beat_at_bbt (bbt);
_real_section = map.add_meter (Meter (_marker->meter().divisions_per_bar(), _marker->meter().note_divisor())
- , beat, bbt, map.frame_time (bbt), _real_section->position_lock_style());
+ , beat, bbt, map.frame_at_bbt (bbt), _real_section->position_lock_style());
}
}
diff --git a/gtk2_ardour/editor_regions.cc b/gtk2_ardour/editor_regions.cc
index f95e5b797e..8321931871 100644
--- a/gtk2_ardour/editor_regions.cc
+++ b/gtk2_ardour/editor_regions.cc
@@ -728,7 +728,7 @@ EditorRegions::format_position (framepos_t pos, char* buf, size_t bufsize, bool
switch (ARDOUR_UI::instance()->secondary_clock->mode ()) {
case AudioClock::BBT:
- _session->tempo_map().bbt_time (pos, bbt);
+ bbt = _session->tempo_map().bbt_at_frame (pos);
if (onoff) {
snprintf (buf, bufsize, "%03d|%02d|%04d" , bbt.bars, bbt.beats, bbt.ticks);
} else {
diff --git a/gtk2_ardour/editor_rulers.cc b/gtk2_ardour/editor_rulers.cc
index f2b42fccc3..596f4f26b9 100644
--- a/gtk2_ardour/editor_rulers.cc
+++ b/gtk2_ardour/editor_rulers.cc
@@ -1275,7 +1275,7 @@ Editor::metric_get_bbt (std::vector<ArdourCanvas::Ruler::Mark>& marks, gdouble l
next_beat.beats = (*i).beat;
next_beat.bars = (*i).bar;
next_beat.ticks = tick;
- pos = _session->tempo_map().frame_time (next_beat);
+ pos = _session->tempo_map().frame_at_bbt (next_beat);
if (t % bbt_accent_modulo == (bbt_accent_modulo - 1)) {
i_am_accented = true;
@@ -1345,7 +1345,7 @@ Editor::metric_get_bbt (std::vector<ArdourCanvas::Ruler::Mark>& marks, gdouble l
next_beat.beats = (*i).beat;
next_beat.bars = (*i).bar;
next_beat.ticks = tick;
- pos = _session->tempo_map().frame_time (next_beat);
+ pos = _session->tempo_map().frame_at_bbt (next_beat);
if (t % bbt_accent_modulo == (bbt_accent_modulo - 1)) {
i_am_accented = true;
@@ -1421,7 +1421,7 @@ Editor::metric_get_bbt (std::vector<ArdourCanvas::Ruler::Mark>& marks, gdouble l
while (tick < Timecode::BBT_Time::ticks_per_beat && (n < bbt_nmarks)) {
next_beat.ticks = tick;
- pos = _session->tempo_map().frame_time (next_beat);
+ pos = _session->tempo_map().frame_at_bbt (next_beat);
if (t % bbt_accent_modulo == (bbt_accent_modulo - 1)) {
i_am_accented = true;
}
diff --git a/gtk2_ardour/editor_tempodisplay.cc b/gtk2_ardour/editor_tempodisplay.cc
index adf0f72fe3..7af6fef059 100644
--- a/gtk2_ardour/editor_tempodisplay.cc
+++ b/gtk2_ardour/editor_tempodisplay.cc
@@ -358,7 +358,7 @@ Editor::mouse_add_new_meter_event (framepos_t frame)
if (meter_dialog.get_lock_style() == MusicTime) {
map.add_meter (Meter (bpb, note_type), map.beat_at_bbt (requested), requested, 0, MusicTime);
} else {
- map.add_meter (Meter (bpb, note_type), map.beat_at_bbt (requested), requested, map.frame_time (requested), AudioTime);
+ map.add_meter (Meter (bpb, note_type), map.beat_at_bbt (requested), requested, map.frame_at_bbt (requested), AudioTime);
}
_session->add_command(new MementoCommand<TempoMap>(map, &before, &map.get_state()));
@@ -406,7 +406,7 @@ Editor::edit_meter_section (MeterSection* section)
double const note_type = meter_dialog.get_note_type ();
Timecode::BBT_Time when;
meter_dialog.get_bbt_time (when);
- framepos_t const frame = _session->tempo_map().frame_time (when);
+ framepos_t const frame = _session->tempo_map().frame_at_bbt (when);
begin_reversible_command (_("replace meter mark"));
XMLNode &before = _session->tempo_map().get_state();
diff --git a/gtk2_ardour/midi_list_editor.cc b/gtk2_ardour/midi_list_editor.cc
index 6334c38dcc..e0eda7a536 100644
--- a/gtk2_ardour/midi_list_editor.cc
+++ b/gtk2_ardour/midi_list_editor.cc
@@ -764,9 +764,7 @@ MidiListEditor::redisplay_model ()
row[columns.note] = (*i)->note();
row[columns.velocity] = (*i)->velocity();
- Timecode::BBT_Time bbt;
-
- _session->tempo_map().bbt_time (conv.to ((*i)->time()), bbt);
+ Timecode::BBT_Time bbt (_session->tempo_map().bbt_at_frame (conv.to ((*i)->time())));
ss.str ("");
ss << bbt;
diff --git a/gtk2_ardour/tempo_dialog.cc b/gtk2_ardour/tempo_dialog.cc
index b4951f35ca..68a781a54f 100644
--- a/gtk2_ardour/tempo_dialog.cc
+++ b/gtk2_ardour/tempo_dialog.cc
@@ -45,9 +45,8 @@ TempoDialog::TempoDialog (TempoMap& map, framepos_t frame, const string&)
, pulse_selector_label (_("Pulse note"), ALIGN_LEFT, ALIGN_CENTER)
, tap_tempo_button (_("Tap tempo"))
{
- Timecode::BBT_Time when;
Tempo tempo (map.tempo_at_frame (frame));
- map.bbt_time (frame, when);
+ Timecode::BBT_Time when (map.bbt_at_frame (frame));
init (when, tempo.beats_per_minute(), tempo.note_type(), TempoSection::Constant, true, MusicTime);
}
@@ -63,8 +62,7 @@ TempoDialog::TempoDialog (TempoMap& map, TempoSection& section, const string&)
, pulse_selector_label (_("Pulse note"), ALIGN_LEFT, ALIGN_CENTER)
, tap_tempo_button (_("Tap tempo"))
{
- Timecode::BBT_Time when;
- map.bbt_time (section.frame(), when);
+ Timecode::BBT_Time when (map.bbt_at_frame (section.frame()));
init (when, section.beats_per_minute(), section.note_type(), section.type(), section.movable(), section.position_lock_style());
}
@@ -420,19 +418,18 @@ TempoDialog::tap_tempo_focus_out (GdkEventFocus* )
MeterDialog::MeterDialog (TempoMap& map, framepos_t frame, const string&)
: ArdourDialog (_("New Meter"))
{
- Timecode::BBT_Time when;
frame = map.round_to_bar(frame, RoundNearest);
+ Timecode::BBT_Time when (map.bbt_at_frame (frame));
Meter meter (map.meter_at_frame (frame));
- map.bbt_time (frame, when);
init (when, meter.divisions_per_bar(), meter.note_divisor(), true, MusicTime);
}
MeterDialog::MeterDialog (TempoMap& map, MeterSection& section, const string&)
: ArdourDialog (_("Edit Meter"))
{
- Timecode::BBT_Time when;
- map.bbt_time (section.frame(), when);
+ Timecode::BBT_Time when (map.bbt_at_frame (section.frame()));
+
init (when, section.divisions_per_bar(), section.note_divisor(), section.movable(), section.position_lock_style());
}
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,
diff --git a/libs/backends/jack/jack_session.cc b/libs/backends/jack/jack_session.cc
index 430ee5b0e7..0c78d9a908 100644
--- a/libs/backends/jack/jack_session.cc
+++ b/libs/backends/jack/jack_session.cc
@@ -121,7 +121,7 @@ JACKSession::timebase_callback (jack_transport_state_t /*state*/,
TempoMetric metric (tempo_map.metric_at (tf));
try {
- tempo_map.bbt_time (tf, bbt);
+ bbt = tempo_map.bbt_at_frame (tf);
pos->bar = bbt.bars;
pos->beat = bbt.beats;
diff --git a/libs/surfaces/control_protocol/basic_ui.cc b/libs/surfaces/control_protocol/basic_ui.cc
index 8227c55ca5..dd5e84cfd7 100644
--- a/libs/surfaces/control_protocol/basic_ui.cc
+++ b/libs/surfaces/control_protocol/basic_ui.cc
@@ -402,9 +402,8 @@ BasicUI::jump_by_seconds (double secs)
void
BasicUI::jump_by_bars (double bars)
{
- Timecode::BBT_Time bbt;
TempoMap& tmap (session->tempo_map());
- tmap.bbt_time (session->transport_frame(), bbt);
+ Timecode::BBT_Time bbt (tmap.bbt_at_frame (session->transport_frame()));
bars += bbt.bars;
if (bars < 0) bars = 0;