From e40604f6bd1dde56227163a67d4c25c6ac529d41 Mon Sep 17 00:00:00 2001 From: nick_m Date: Wed, 29 Jun 2016 05:23:52 +1000 Subject: Back to using exact beats for midi region start_beats calculation when trimming. - seems to work quite well, but not tested on live recording. --- libs/ardour/midi_region.cc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'libs/ardour/midi_region.cc') 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; -- cgit v1.2.3