Tempo ramps - rename bbt_time() -> bbt_at_frame(), frame_time() -> frame_at_bbt()
This commit is contained in:
parent
b564f07635
commit
34c9ac9dd7
|
@ -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) {
|
||||
|
|
|
@ -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());
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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".
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue