13
0

triggerbox: fix up what happens at the end of a MIDI trigger

This commit is contained in:
Paul Davis 2021-12-04 11:49:09 -07:00
parent 050b046e4d
commit 4a13a1fa62

View File

@ -1281,7 +1281,7 @@ MIDITrigger::run (BufferSet& bufs, samplepos_t start_sample, samplepos_t end_sam
const timepos_t region_start_time = _region->start();
const Temporal::Beats region_start = region_start_time.beats();
Temporal::TempoMap::SharedPtr tmap (Temporal::TempoMap::use());
samplepos_t last_event_samples = 0;
samplepos_t last_event_samples = max_samplepos;
/* see if we're going to start or stop or retrigger in this run() call */
dest_offset = maybe_compute_next_transition (start_sample, start_beats, end_beats, dest_offset, passthru);
@ -1361,7 +1361,6 @@ MIDITrigger::run (BufferSet& bufs, samplepos_t start_sample, samplepos_t end_sam
DEBUG_TRACE (DEBUG::Triggers, string_compose ("%1 reached end\n", index()));
if (!(_state == Stopping)) {
_loop_cnt++;
if (_loop_cnt == _follow_count) {
@ -1385,11 +1384,14 @@ MIDITrigger::run (BufferSet& bufs, samplepos_t start_sample, samplepos_t end_sam
retrigger ();
_state = WaitingToStart;
}
}
/* the time we processed spans from start to the last event */
nframes -= (last_event_samples - start_sample);
if (last_event_samples != max_samplepos) {
nframes = (last_event_samples - start_sample);
} else {
/* all frames covered */
}
} else {
/* we didn't reach the end of the MIDI data, ergo we covered