Update automated Plugin Controlls when seeking and not rolling
[ardour.git] / gtk2_ardour / midi_region_view.cc
index bb8092807da3099afefac5a889bca41785bf5586..bf7ff669cb7e621aa95f4040568837fa554e2e15 100644 (file)
@@ -1716,8 +1716,9 @@ MidiRegionView::update_sustained (Note* ev, bool update_ghost_regions)
        const double x0 = trackview.editor().sample_to_pixel (note_start_frames);
        double x1;
        const double y0 = 1 + floor(midi_stream_view()->note_to_y(note->note()));
-       double y1;/* trim note display to not overlap the end of its region */
+       double y1;
 
+       /* trim note display to not overlap the end of its region */
        if (note->length() > 0) {
                Evoral::Beats note_end_time = note->end_time();
 
@@ -3747,9 +3748,12 @@ MidiRegionView::update_ghost_note (double x, double y)
 
        /* calculate time in beats relative to start of source */
        const Evoral::Beats length = get_grid_beats(unsnapped_frame);
-       const Evoral::Beats time   = std::max(
+       const uint32_t divisions   = editor.get_grid_music_divisions (0);
+
+       Evoral::Beats time         = std::max(
                Evoral::Beats(),
-               absolute_frames_to_source_beats (f + _region->position ()));
+               Evoral::Beats (trackview.session()->tempo_map().exact_beat_at_frame (f + _region->position(), divisions))
+               - (_region->beat() - midi_region()->start_beats().to_double()));
 
        _ghost_note->note()->set_time (time);
        _ghost_note->note()->set_length (length);