Repository navigation
Conversation
Slab released held MIDI notes only when the last source disappeared. A device unplugged, or a program quitting its virtual source, while others stayed connected left its notes stuck: it can't send their note-offs. The live state doesn't record which source held which note, so any source leaving now releases them all. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
mparrett
marked this pull request as ready for review
November 18, 2026 10:18
…nput) Two holes in releasing a departed source's notes: - poll rescanned before draining the ring, so a note-on the source queued just before it went was applied after the release and stuck. The ring now drains first (pollFrom, which tests drive with a queue of their own). - The check compared source counts, so a source replaced between two rescans (a program restarting its virtual source) changed nothing. Rescans now compare CoreMIDI unique IDs (slab_midi_source_id); any ID gone releases held notes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Slab releases held MIDI notes when a source disappears only if it was the last one (
if (count == 0) allOff()inmidi_in.rescan). With a second device connected, unplugging a keyboard mid-note, or quitting a program that sends through a virtual source, leaves its notes held: the source is gone, so their note-offs never come.The live state doesn't record which source held which note, so a departed source now releases them all. Sources are compared by CoreMIDI's unique ID (
slab_midi_source_id,sourcesNow), not by count, so a source replaced between two rescans counts as gone too: a program restarting its virtual source gets a new ID. A key still held on a device that stays connected is cut short as well; that is the cheaper failure than a note stuck until panic.pollnow drains the input ring before it rescans, so a note-on a source queued just before it went is released with the rest instead of arriving after the release.Found by reading the code while testing per-channel MIDI input, which this is independent of.
Testing. Unit tests cover a source arriving (nothing released), one leaving while another remains, one replaced with the count unchanged, and a note-on queued ahead of the rescan (
pollFromwith a fake queue).zig build testpasses. Live, a program's virtual source gets a new unique ID each time it is recreated, which is what the ID comparison relies on.🤖 Generated with Claude Code