Fix MIDI panic timestamp at cycle-end

Previousy stopping, locating or looping in the middle of
an active MIDI note would generate unordered MIDI events
on the port. "it's too late for this event".
Usually caused by the MIDI state tracker adding a Note-Off
at cycle end and then MidiPort::resolve_notes adding a panic
message at cycle-start...
This commit is contained in:
Robin Gareus 2025-08-06 04:56:01 +02:00
parent cf85399f38
commit f4da0ff76d
No known key found for this signature in database
GPG key ID: A090BCE02CF57F04

View file

@ -273,10 +273,13 @@ MidiPort::flush_buffers (pframes_t nframes)
void* port_buffer = 0;
if (_resolve_required) {
if (_resolve_required && (_global_port_buffer_offset + nframes) > 0) {
port_buffer = port_engine.get_buffer (_port_handle, nframes);
/* resolve all notes at the start of the buffer */
resolve_notes (port_buffer, _global_port_buffer_offset);
/* This is called from ARDOUR::PortManager::cycle_end() at which
* point other MIDI data has already been written to the port.
* So we "resolve notes" (panic) at the end of he buffer.
*/
resolve_notes (port_buffer, _global_port_buffer_offset + nframes -1);
_resolve_required = false;
}