summaryrefslogtreecommitdiff
path: root/libs/ardour/midi_region.cc
diff options
context:
space:
mode:
authornick_m <mainsbridge@gmail.com>2016-06-29 05:23:52 +1000
committernick_m <mainsbridge@gmail.com>2016-07-10 02:18:37 +1000
commite40604f6bd1dde56227163a67d4c25c6ac529d41 (patch)
treef02ebe9b4f9e2696223a58dc1c038f8f34b324cf /libs/ardour/midi_region.cc
parente4a163e2faba353edf38c3170b5239c664c84b65 (diff)
Back to using exact beats for midi region start_beats calculation when trimming.
- seems to work quite well, but not tested on live recording.
Diffstat (limited to 'libs/ardour/midi_region.cc')
-rw-r--r--libs/ardour/midi_region.cc9
1 files changed, 5 insertions, 4 deletions
diff --git a/libs/ardour/midi_region.cc b/libs/ardour/midi_region.cc
index fbd5d34c67..9871fa219f 100644
--- a/libs/ardour/midi_region.cc
+++ b/libs/ardour/midi_region.cc
@@ -507,10 +507,11 @@ MidiRegion::trim_to_internal (framepos_t position, framecnt_t length, const int3
PropertyChange what_changed;
/* beat has been set exactly by set_position_internal, but the source starts on a frame.
- we have trimmed by frames, so we must ignore _beat and set start beats using frames.
+ working in beats seems the correct thing to do, but reports of a missing first note
+ on playback suggest otherwise. for now, we work in exact beats.
*/
- const double pos_beat = _session.tempo_map().beat_at_frame (position);
- const double beat_delta = pos_beat - _session.tempo_map().beat_at_frame (_position);
+ const double pos_beat = _session.tempo_map().exact_beat_at_frame (position, sub_num);
+ const double beat_delta = pos_beat - beat();
/* 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
@@ -526,7 +527,7 @@ MidiRegion::trim_to_internal (framepos_t position, framecnt_t length, const int3
}
const double new_start_beat = _start_beats.val().to_double() + beat_delta;
- new_start = _position - _session.tempo_map().frame_at_beat (pos_beat - new_start_beat);
+ new_start = _position - _session.tempo_map().frame_at_beat (beat() - new_start_beat);
if (!verify_start_and_length (new_start, length)) {
return;