Repository navigation
Conversation
The decoder read any byte with a high nibble of 15 as an "End of Track" event and stopped there. A MIDI track conventionally opens with a Set Tempo meta event, which begins 0xFF, so for most real files the track ended before a single note was played and the sample was silent. Meta and System Exclusive events both carry an explicit length, so skip exactly that many bytes instead of guessing, and end the track only on an actual End of Track meta event. Decoding the first 30 seconds of a stock Bach Toccata now yields 479 and 423 note events on its two note tracks, where it previously yielded 2 and none. Also report error_location as the offset where the error was found rather than the end of the track it was abandoned at. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
tyeth
added this pull request to stack #11668
October 23, 2026 22:57
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.
First of five stacked PRs fixing
synthio.MidiTrack's MIDI parsing. Each later one targets the previous branch; review in order.MidiTrackread any byte with a high nibble of 15 as an "End of Track" event and stopped there. A MIDI track conventionally opens with a Set Tempo meta event, which begins0xFF, so for most real files the track ended before a single note played and the sample was silent.Meta and System Exclusive events both carry an explicit length, so skip exactly that many bytes instead of guessing, and end the track only on an actual End of Track meta event. Also report
error_locationas the offset where the error was found rather than the end of the track it was abandoned at.Effect
Decoding the first 30 seconds of a stock Bach Toccata (public-domain MIDI from mfiles.co.uk, format 1, 256 ticks/beat):
Verification
The before and after decoders were mirrored in Python and cross-checked against the
adafruit_midi_parserlibrary as an independent oracle on hand-built files covering each case; the new decoder reproduces its note timeline exactly where the old one returned nothing.Builds clean for
circuitplayground_bluefruit(arm) andadafruit_funhouse(xtensa).pre-commitformatting passes and no newMP_ERROR_TEXTstrings are added, so the translations check is unaffected.Playback through this decoder is confirmed on hardware (Adafruit FunHouse), though via
audiopwmiofrom #11663 rather than a stock board.Size
About +272 bytes of flash on nrf52840.
🤖 Generated with Claude Code