summaryrefslogtreecommitdiff
path: root/gtk2_ardour/midi_region_view.cc
diff options
context:
space:
mode:
authornick_m <mainsbridge@gmail.com>2016-08-16 00:48:54 +1000
committernick_m <mainsbridge@gmail.com>2016-08-16 00:48:54 +1000
commit62372b48eaefde1beffe93f2a4039b5e1e5622b2 (patch)
tree7ed04cb73d9aea233f84d3a3b61f711aab721116 /gtk2_ardour/midi_region_view.cc
parent4848cb6d428b348e0fbb9dfee44e4e10024d2672 (diff)
Fix frame-based beat calculation in MidiRegionView::snap_frame_to_grid_underneath()
- this caused the ghost note under the pointer to behave badly when hovering near an audio-locked meter.
Diffstat (limited to 'gtk2_ardour/midi_region_view.cc')
-rw-r--r--gtk2_ardour/midi_region_view.cc13
1 files changed, 7 insertions, 6 deletions
diff --git a/gtk2_ardour/midi_region_view.cc b/gtk2_ardour/midi_region_view.cc
index 6a4f08a332..bb8092807d 100644
--- a/gtk2_ardour/midi_region_view.cc
+++ b/gtk2_ardour/midi_region_view.cc
@@ -4122,18 +4122,19 @@ MidiRegionView::snap_frame_to_grid_underneath (framepos_t p, framecnt_t& grid_fr
{
PublicEditor& editor = trackview.editor ();
const Evoral::Beats grid_beats = get_grid_beats(p);
- const Evoral::Beats p_beat = max (Evoral::Beats(), region_frames_to_region_beats (p));
-
- grid_frames = region_beats_to_region_frames (p_beat + grid_beats) - region_beats_to_region_frames (p_beat);
+ Evoral::Beats p_beat = max (Evoral::Beats(), region_frames_to_region_beats (p));
+ const double rem = fmod (p_beat.to_double(), grid_beats.to_double());
/* Hack so that we always snap to the note that we are over, instead of snapping
to the next one if we're more than halfway through the one we're over.
*/
- if (editor.snap_mode() == SnapNormal && p >= grid_frames / 2) {
- p -= grid_frames / 2;
+ if (editor.snap_mode() == SnapNormal && rem >= grid_beats.to_double() / 2.0) {
+ p_beat -= Evoral::Beats(grid_beats.to_double() / 2.0);
}
- return snap_frame_to_frame (p);
+ const framepos_t snap_me = trackview.session()->tempo_map().frame_at_beat (p_beat.to_double() + _region->beat()) - _region->position();
+
+ return snap_frame_to_frame (snap_me);
}
ChannelMode