Tempo ramps - restore bbt settings in tempo dialog for audio-locked tempo markers
authornick_m <mainsbridge@gmail.com>
Sun, 28 Feb 2016 17:54:24 +0000 (04:54 +1100)
committernick_m <mainsbridge@gmail.com>
Fri, 27 May 2016 13:38:10 +0000 (23:38 +1000)
- see comments

gtk2_ardour/editor_tempodisplay.cc
gtk2_ardour/tempo_dialog.cc
libs/ardour/ardour/tempo.h
libs/ardour/tempo.cc

index 6e28b32e77ce5263c177f161259a45da507b98de..95fb178421a6f43109f3856c05e2b41da1b8c05f 100644 (file)
@@ -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));
index b8f5a0c531470d5dfeae32f01802112c8cc409d8..206302999eed4b06fa33ab088c3eeb07a7891e62 100644 (file)
@@ -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);
index 7b4b77a8933f1a6e5859bfb27c79411340e1b64d..6ce59ffbeab9ba74ce0412ac83ba8dc517531153 100644 (file)
@@ -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);
 
index ed35c2b565d0a6d9d3354480369a9a52a555a4fd..c27bc95b3a6bfb1cb2aafcdd018750a9998989e7 100644 (file)
@@ -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)
 {