diff options
author | nick_m <mainsbridge@gmail.com> | 2016-02-29 04:54:24 +1100 |
---|---|---|
committer | nick_m <mainsbridge@gmail.com> | 2016-05-27 23:38:10 +1000 |
commit | b8b6d562a46ca4410142f5a83bb2396a0ba0fde7 (patch) | |
tree | a98a08eae7eadc985cff482fbad9c2509f71fe17 | |
parent | c98e008745c506b1ce6610ac27fe1f50809834cb (diff) |
Tempo ramps - restore bbt settings in tempo dialog for audio-locked tempo markers
- see comments
-rw-r--r-- | gtk2_ardour/editor_tempodisplay.cc | 4 | ||||
-rw-r--r-- | gtk2_ardour/tempo_dialog.cc | 15 | ||||
-rw-r--r-- | libs/ardour/ardour/tempo.h | 1 | ||||
-rw-r--r-- | libs/ardour/tempo.cc | 24 |
4 files changed, 37 insertions, 7 deletions
diff --git a/gtk2_ardour/editor_tempodisplay.cc b/gtk2_ardour/editor_tempodisplay.cc index 6e28b32e77..95fb178421 100644 --- a/gtk2_ardour/editor_tempodisplay.cc +++ b/gtk2_ardour/editor_tempodisplay.cc @@ -378,7 +378,9 @@ Editor::edit_tempo_section (TempoSection* section) if (tempo_dialog.get_lock_style() == MusicTime) { _session->tempo_map().replace_tempo (*section, Tempo (bpm, nt), beat, tempo_dialog.get_tempo_type()); } else { - _session->tempo_map().replace_tempo (*section, Tempo (bpm, nt), section->frame(), tempo_dialog.get_tempo_type()); + _session->tempo_map().replace_c_func_from_tempo_and_beat (bpm, beat); + framepos_t const f = _session->tempo_map().frame_at_beat (beat); + _session->tempo_map().replace_tempo (*section, Tempo (bpm, nt), f, tempo_dialog.get_tempo_type()); } XMLNode &after = _session->tempo_map().get_state(); _session->add_command (new MementoCommand<TempoMap>(_session->tempo_map(), &before, &after)); diff --git a/gtk2_ardour/tempo_dialog.cc b/gtk2_ardour/tempo_dialog.cc index b8f5a0c531..206302999e 100644 --- a/gtk2_ardour/tempo_dialog.cc +++ b/gtk2_ardour/tempo_dialog.cc @@ -465,8 +465,8 @@ MeterDialog::init (const Timecode::BBT_Time& when, double bpb, double divisor, b lock_styles.insert (make_pair (_("music"), PositionLockStyle::MusicTime)); strings.push_back (_("music")); - lock_styles.insert (make_pair (_("audio ur brane wul xplod"), PositionLockStyle::AudioTime)); - strings.push_back (_("audio")); + lock_styles.insert (make_pair (_("audio"), PositionLockStyle::AudioTime)); + strings.push_back (_("audio ur brane wul xplod")); set_popdown_strings (lock_style, strings); LockStyles::iterator ls; for (ls = lock_styles.begin(); ls != lock_styles.end(); ++ls) { @@ -488,7 +488,7 @@ MeterDialog::init (const Timecode::BBT_Time& when, double bpb, double divisor, b table->attach (*bpb_label, 0, 1, 0, 1, FILL|EXPAND, FILL|EXPAND); table->attach (bpb_entry, 1, 2, 0, 1, FILL|EXPAND, FILL|EXPAND); table->attach (*note_label, 0, 1, 1, 2, FILL|EXPAND, FILL|EXPAND); - table->attach (note_type, 1, 2, 1, 2, FILL|EXPAND, SHRINK); + table->attach (note_type, 1, 2, 1, 2, FILL|EXPAND, FILL|EXPAND); snprintf (buf, sizeof (buf), "%" PRIu32, when.bars); when_bar_entry.set_text (buf); @@ -499,10 +499,13 @@ MeterDialog::init (const Timecode::BBT_Time& when, double bpb, double divisor, b table->attach (*when_label, 0, 1, 2, 3, FILL | EXPAND, FILL | EXPAND); table->attach (when_bar_entry, 1, 2, 2, 3, FILL | EXPAND, FILL | EXPAND); - } - table->attach (*lock_label, 0, 1, 3, 4, FILL|EXPAND, FILL|EXPAND); - table->attach (lock_style, 1, 2, 3, 4, FILL|EXPAND, SHRINK); + table->attach (*lock_label, 0, 1, 3, 4, FILL|EXPAND, FILL|EXPAND); + table->attach (lock_style, 1, 2, 3, 4, FILL|EXPAND, SHRINK); + } else { + table->attach (*lock_label, 0, 1, 2, 3, FILL|EXPAND, FILL|EXPAND); + table->attach (lock_style, 1, 2, 2, 3, FILL|EXPAND, SHRINK); + } get_vbox()->set_border_width (12); get_vbox()->pack_start (*table, false, false); diff --git a/libs/ardour/ardour/tempo.h b/libs/ardour/ardour/tempo.h index 7b4b77a893..6ce59ffbea 100644 --- a/libs/ardour/ardour/tempo.h +++ b/libs/ardour/ardour/tempo.h @@ -371,6 +371,7 @@ class LIBARDOUR_API TempoMap : public PBD::StatefulDestructible void remove_tempo (const TempoSection&, bool send_signal); void remove_meter (const MeterSection&, bool send_signal); + void replace_c_func_from_tempo_and_beat (const double& tempo, const double& beat); void replace_tempo (const TempoSection&, const Tempo&, const double& where, TempoSection::Type type); void replace_tempo (const TempoSection&, const Tempo&, const framepos_t& where, TempoSection::Type type); diff --git a/libs/ardour/tempo.cc b/libs/ardour/tempo.cc index ed35c2b565..c27bc95b3a 100644 --- a/libs/ardour/tempo.cc +++ b/libs/ardour/tempo.cc @@ -824,6 +824,30 @@ TempoMap::do_insert (MetricSection* section) } } +/* +This is for a gui who needs to know the frame of a beat if a proposed tempo section were to be placed there. +You probably shouldn't use this unless you know what you're doing, +as it doesn't recompute the tempo map and will make a ramp invalid intil that next happens. +It is assumed that the next frame calculation is the last time you need this c_func before the next do_insert() and/or recompute_map(). +*/ +void +TempoMap::replace_c_func_from_tempo_and_beat (const double& bpm, const double& beat) +{ + Glib::Threads::RWLock::WriterLock lm (lock); + TempoSection* prev_ts = 0; + TempoSection* t; + + for (Metrics::iterator i = metrics.begin(); i != metrics.end(); ++i) { + if ((t = dynamic_cast<TempoSection*> (*i)) != 0) { + if (prev_ts && t->beat() > prev_ts->beat()) { + prev_ts->set_c_func_from_tempo_and_beat (bpm, beat, _frame_rate); + break; + } + prev_ts = t; + } + } +} + void TempoMap::replace_tempo (const TempoSection& ts, const Tempo& tempo, const double& where, TempoSection::Type type) { |