diff options
Diffstat (limited to 'gtk2_ardour')
-rw-r--r-- | gtk2_ardour/editor.cc | 26 | ||||
-rw-r--r-- | gtk2_ardour/editor.h | 1 | ||||
-rw-r--r-- | gtk2_ardour/editor_drag.cc | 15 | ||||
-rw-r--r-- | gtk2_ardour/tempo_lines.cc | 4 |
4 files changed, 43 insertions, 3 deletions
diff --git a/gtk2_ardour/editor.cc b/gtk2_ardour/editor.cc index 0d7717614c..856e527a9a 100644 --- a/gtk2_ardour/editor.cc +++ b/gtk2_ardour/editor.cc @@ -2136,6 +2136,32 @@ Editor::snap_type() const return _snap_type; } +bool +Editor::snap_musical() const +{ + switch (_snap_type) { + case SnapToBeatDiv128: + case SnapToBeatDiv64: + case SnapToBeatDiv32: + case SnapToBeatDiv28: + case SnapToBeatDiv24: + case SnapToBeatDiv20: + case SnapToBeatDiv16: + case SnapToBeatDiv14: + case SnapToBeatDiv12: + case SnapToBeatDiv10: + case SnapToBeatDiv8: + case SnapToBeatDiv7: + case SnapToBeatDiv6: + case SnapToBeatDiv5: + case SnapToBeatDiv4: + case SnapToBeatDiv3: + case SnapToBeatDiv2: + return true; + } + return false; +} + SnapMode Editor::snap_mode() const { diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h index 7a2988005d..96b3d490fb 100644 --- a/gtk2_ardour/editor.h +++ b/gtk2_ardour/editor.h @@ -171,6 +171,7 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD Editing::SnapMode snap_mode () const; Editing::SnapType snap_type () const; + bool snap_musical () const; void undo (uint32_t n = 1); void redo (uint32_t n = 1); diff --git a/gtk2_ardour/editor_drag.cc b/gtk2_ardour/editor_drag.cc index 15246fb8fe..3305bfd040 100644 --- a/gtk2_ardour/editor_drag.cc +++ b/gtk2_ardour/editor_drag.cc @@ -3316,7 +3316,20 @@ TempoMarkerDrag::motion (GdkEvent* event, bool first_move) _marker->hide(); } - framepos_t const pf = adjusted_current_frame (event); + framepos_t pf; + if (!_editor->snap_musical()) { + pf = adjusted_current_frame (event); + } else { + pf = adjusted_current_frame (event); + Timecode::BBT_Time when; + _editor->session()->tempo_map().bbt_time (pf, when); + if (_editor->snap_type() == SnapToBar) { + _editor->session()->tempo_map().round_bbt (when, -1); + } else { + _editor->session()->tempo_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); + } Tempo const tp = _marker->tempo(); if (Keyboard::modifier_state_equals (event->button.state, ArdourKeyboard::constraint_modifier ())) { diff --git a/gtk2_ardour/tempo_lines.cc b/gtk2_ardour/tempo_lines.cc index 370ee4aac1..7a5be311ed 100644 --- a/gtk2_ardour/tempo_lines.cc +++ b/gtk2_ardour/tempo_lines.cc @@ -59,7 +59,6 @@ TempoLines::draw_ticks (std::vector<ARDOUR::TempoMap::BBTPoint>& grid, framecnt_t leftmost_frame, framecnt_t frame_rate) { - const double fpb = grid.begin()->tempo.frames_per_beat(frame_rate); const uint32_t base = UIConfiguration::instance().color_mod("measure line beat", "measure line beat"); for (unsigned l = 1; l < divisions; ++l) { @@ -82,7 +81,8 @@ TempoLines::draw_ticks (std::vector<ARDOUR::TempoMap::BBTPoint>& grid, grid.begin()->tempo.pulses_per_minute()) + 1) / grid.begin()->c; f = grid.begin()->frame + (framecnt_t) floor ((time_at_pulse * 60.0 * frame_rate) + 0.5); } else { - f = grid.begin()->frame + (l * (fpb / (double)divisions)); + const double fpb = grid.begin()->tempo.frames_per_beat (frame_rate); + f = grid.begin()->frame + (l * (fpb / (double) divisions)); } if (f > leftmost_frame) { |