Tempo spamr - smallify some code.
authornick_m <mainsbridge@gmail.com>
Wed, 30 Mar 2016 18:26:09 +0000 (05:26 +1100)
committernick_m <mainsbridge@gmail.com>
Fri, 27 May 2016 13:38:13 +0000 (23:38 +1000)
gtk2_ardour/editor_drag.cc

index 72389a9a02f08a05d4a7dd165b4a8099d0ce4dff..dc7eb3586c6dd1dec7aa55fc58a154a93665f7ba 100644 (file)
@@ -3329,9 +3329,10 @@ TempoMarkerDrag::motion (GdkEvent* event, bool first_move)
                if (!_editor->snap_musical()) {
                        pf = adjusted_current_frame (event);
                } else {
-                       pf = adjusted_current_frame (event, false);
                        bool use_snap;
+                       TempoMap& map (_editor->session()->tempo_map());
 
+                       pf = adjusted_current_frame (event, false);
                        if (Keyboard::modifier_state_equals (event->button.state, ArdourKeyboard::snap_modifier ())) {
                                if (_editor->snap_mode() == Editing::SnapOff) {
                                        use_snap = true;
@@ -3347,27 +3348,27 @@ TempoMarkerDrag::motion (GdkEvent* event, bool first_move)
                        }
 
                        Timecode::BBT_Time when;
-                       _editor->session()->tempo_map().bbt_time (pf, when);
+                       map.bbt_time (pf, when);
 
                        if (_real_section->position_lock_style() == MusicTime) {
 
-                               const double pulse = _editor->session()->tempo_map().predict_tempo_pulse (_real_section, Tempo (_real_section->beats_per_minute(), _real_section->note_type()), pf);
-                               when = _editor->session()->tempo_map().pulse_to_bbt (pulse);
+                               const double pulse = map.predict_tempo_pulse (_real_section, Tempo (_real_section->beats_per_minute(), _real_section->note_type()), pf);
+                               when = map.pulse_to_bbt (pulse);
                                if (use_snap && _editor->snap_type() == SnapToBar) {
-                                       _editor->session()->tempo_map().round_bbt (when, -1);
+                                       map.round_bbt (when, -1);
                                } else if (use_snap) {
-                                       _editor->session()->tempo_map().round_bbt (when, _editor->get_grid_beat_divisions (0));
+                                       map.round_bbt (when, _editor->get_grid_beat_divisions (0));
                                }
-                               const double beat = _editor->session()->tempo_map().bbt_to_beats (when);
-                               _editor->session()->tempo_map().gui_move_tempo_beat (_real_section, tp, beat);
+                               const double beat = map.bbt_to_beats (when);
+                               map.gui_move_tempo_beat (_real_section, tp, beat);
                        } else {
                                if (use_snap && _editor->snap_type() == SnapToBar) {
-                                       _editor->session()->tempo_map().round_bbt (when, -1);
+                                       map.round_bbt (when, -1);
                                } else if (use_snap) {
-                                       _editor->session()->tempo_map().round_bbt (when, _editor->get_grid_beat_divisions (0));
+                                       map.round_bbt (when, _editor->get_grid_beat_divisions (0));
                                }
-                               pf = _editor->session()->tempo_map().predict_tempo_frame (_real_section, Tempo (_real_section->beats_per_minute(), _real_section->note_type()), when);
-                               _editor->session()->tempo_map().gui_move_tempo_frame (_real_section, tp, pf);
+                               pf = map.predict_tempo_frame (_real_section, Tempo (_real_section->beats_per_minute(), _real_section->note_type()), when);
+                               map.gui_move_tempo_frame (_real_section, tp, pf);
                        }
                }