Tempo ramps - more code cleanup, fix cross-marker jumping using tempo dialog bbt
authornick_m <mainsbridge@gmail.com>
Fri, 20 May 2016 18:48:42 +0000 (04:48 +1000)
committernick_m <mainsbridge@gmail.com>
Fri, 27 May 2016 13:38:17 +0000 (23:38 +1000)
gtk2_ardour/editor_drag.cc
gtk2_ardour/editor_tempodisplay.cc
libs/ardour/ardour/tempo.h
libs/ardour/tempo.cc

index f60a8758b0ad14cca8031a0741d8db6be48d57c4..e8b8d9e3a256c1c140014e74b28ff9482ce12cd1 100644 (file)
@@ -3142,10 +3142,6 @@ MeterMarkerDrag::setup_pointer_frame_offset ()
 void
 MeterMarkerDrag::motion (GdkEvent* event, bool first_move)
 {
-       if (!_marker->meter().movable()) {
-               //return;
-       }
-
        if (first_move) {
 
                // create a dummy marker to catch events, then hide it.
@@ -3281,6 +3277,7 @@ TempoMarkerDrag::motion (GdkEvent* event, bool first_move)
        if (!_real_section->active()) {
                return;
        }
+
        if (first_move) {
 
                // mvc drag - create a dummy marker to catch events, hide it.
@@ -3342,7 +3339,7 @@ TempoMarkerDrag::motion (GdkEvent* event, bool first_move)
                                } else if (use_snap) {
                                        map.round_bbt (bbt, _editor->get_grid_beat_divisions (0), RoundNearest);
                                }
-                               double const pulse = map.predict_tempo_pulse (_real_section, map.frame_time (bbt));
+                               double const pulse = map.predict_tempo_pulse (_real_section, bbt);
                                _real_section = map.add_tempo (_marker->tempo(), pulse, 0, _real_section->type(), MusicTime);
                        } else {
                                if (use_snap && _editor->snap_type() == SnapToBar) {
@@ -3400,7 +3397,7 @@ TempoMarkerDrag::motion (GdkEvent* event, bool first_move)
 
                        if (_real_section->position_lock_style() == MusicTime) {
 
-                               const double pulse = map.predict_tempo_pulse (_real_section, pf);
+                               const double pulse = map.predict_tempo_pulse (_real_section, when);
                                when = map.pulse_to_bbt (pulse);
                                if (use_snap && _editor->snap_type() == SnapToBar) {
                                        map.round_bbt (when, -1, (pf > _real_section->frame()) ? RoundUpMaybe : RoundDownMaybe);
index ad9551b87f60a6b2e5562db939dbe637d878c62b..e2540ddfd0324015449058433b7d7ff48fd41e4d 100644 (file)
@@ -425,9 +425,13 @@ Editor::edit_tempo_section (TempoSection* section)
        begin_reversible_command (_("replace tempo mark"));
        XMLNode &before = _session->tempo_map().get_state();
 
-       framepos_t const f = _session->tempo_map().predict_tempo_frame (section, when);
-       double const p = _session->tempo_map().predict_tempo_pulse (section, f);
-       _session->tempo_map().replace_tempo (*section, Tempo (bpm, nt), p, f, tempo_dialog.get_tempo_type(), tempo_dialog.get_lock_style());
+       if (tempo_dialog.get_lock_style() == AudioTime) {
+               framepos_t const f = _session->tempo_map().predict_tempo_frame (section, when);
+               _session->tempo_map().replace_tempo (*section, Tempo (bpm, nt), 0.0, f, tempo_dialog.get_tempo_type(), AudioTime);
+       } else {
+               double const p = _session->tempo_map().predict_tempo_pulse (section, when);
+               _session->tempo_map().replace_tempo (*section, Tempo (bpm, nt), p, 0, tempo_dialog.get_tempo_type(), MusicTime);
+       }
 
        XMLNode &after = _session->tempo_map().get_state();
        _session->add_command (new MementoCommand<TempoMap>(_session->tempo_map(), &before, &after));
index e436f9dbde973221f66d38211ff299f9c82bdccb..f3b94e05ee8e9f9f25127365d6245119a302b3fc 100644 (file)
@@ -392,7 +392,7 @@ class LIBARDOUR_API TempoMap : public PBD::StatefulDestructible
        void remove_meter (const MeterSection&, bool send_signal);
 
        framepos_t predict_tempo_frame (TempoSection* section, const Timecode::BBT_Time& bbt);
-       double predict_tempo_pulse (TempoSection* section, const framepos_t& frame);
+       double predict_tempo_pulse (TempoSection* section, const Timecode::BBT_Time& bbt);
 
        void replace_tempo (const TempoSection&, const Tempo&, const double& pulse, const framepos_t& frame
                            , TempoSection::Type type, PositionLockStyle pls);
index dafb7f71c351be17032c0a2b7a37bacc0ec662b7..874c42e8f0afd5ae90a9916e5eb623c63a438c87 100644 (file)
@@ -2339,14 +2339,15 @@ TempoMap::predict_tempo_frame (TempoSection* section, const BBT_Time& bbt)
 }
 
 double
-TempoMap::predict_tempo_pulse (TempoSection* section, const framepos_t& frame)
+TempoMap::predict_tempo_pulse (TempoSection* section, const BBT_Time& bbt)
 {
        Glib::Threads::RWLock::ReaderLock lm (lock);
        Metrics future_map;
        double ret = 0.0;
        TempoSection* tempo_copy = copy_metrics_and_point (_metrics, future_map, section);
+       const double beat = bbt_to_beats_locked (future_map, bbt);
 
-       if (solve_map_frame (future_map, tempo_copy, frame)) {
+       if (solve_map_pulse (future_map, tempo_copy, pulse_at_beat_locked (future_map, beat))) {
                ret = tempo_copy->pulse();
        } else {
                ret = section->pulse();