fix issues with the length of captured MIDI regions when there are tempo changes present

This commit is contained in:
Paul Davis 2024-06-03 17:23:46 -06:00
parent c7b8840f8f
commit 144fe5b08a

View File

@ -1086,7 +1086,21 @@ Track::use_captured_midi_sources (SourceList& srcs, CaptureInfos const & capture
if (time_domain() == Temporal::BeatTime) {
const timepos_t ss (start_off);
const timecnt_t ll ((*ci)->samples, ss);
const timepos_t ss (start_off);
/* 2nd argument is the timeline position of the
* start of the region in samples. We have to
* get this right so that the conversion of
* the capture duration (samples) to beats is
* using the actual position where the region
* will end up, rather than using its
* source-relative start offset as a timeline position.
*
* This matters if the region ought to cover
* part of the timeline where the tempo is
* different from the value at the natural
* position of the source.
*/
const timecnt_t ll ((*ci)->samples, timepos_t (initial_capture + start_off));
s = timepos_t (ss.beats());
l = timecnt_t (ll.beats(), s);