From: nick_m Date: Tue, 28 Jun 2016 17:46:26 +0000 (+1000) Subject: Use frame-based (non-exact) beat calculation to set new start in midi region trim. X-Git-Tag: 5.0-pre1~230 X-Git-Url: https://main.carlh.net/gitweb/?a=commitdiff_plain;h=6612b730338f77e6272fc2677195a3f81f7e7118;p=ardour.git Use frame-based (non-exact) beat calculation to set new start in midi region trim. --- diff --git a/libs/ardour/midi_region.cc b/libs/ardour/midi_region.cc index 6dd7fc61ae..3fd95388cf 100644 --- a/libs/ardour/midi_region.cc +++ b/libs/ardour/midi_region.cc @@ -506,8 +506,11 @@ MidiRegion::trim_to_internal (framepos_t position, framecnt_t length, const int3 PropertyChange what_changed; - /* beat has not been set by set_position_internal */ - const double beat_delta = _session.tempo_map().exact_beat_at_frame (position, sub_num) - beat(); + /* beat has not been set exactly by set_position_internal. + we have trimmed by frames, so we must ignore _beat and set start beats using frames. + */ + const double pos_beat = _session.tempo_map().beat_at_frame (position); + const double beat_delta = pos_beat - _session.tempo_map().beat_at_frame (_position); /* Set position before length, otherwise for MIDI regions this bad thing happens: * 1. we call set_length_internal; length in beats is computed using the region's current @@ -522,10 +525,8 @@ MidiRegion::trim_to_internal (framepos_t position, framecnt_t length, const int3 what_changed.add (Properties::position); } - const double new_beat = _session.tempo_map().exact_beat_at_frame (position, sub_num); const double new_start_beat = _start_beats.val().to_double() + beat_delta; - - new_start = _position - _session.tempo_map().frame_at_beat (new_beat - new_start_beat); + new_start = _position - _session.tempo_map().frame_at_beat (pos_beat - new_start_beat); if (!verify_start_and_length (new_start, length)) { return;