Skip to content

synthio: keep MidiTrack's timing accurate for long delays - #11661

Open
tyeth wants to merge 1 commit into
synthio-miditrack-note-off-velocityfrom
synthio-miditrack-long-delays
Open

tyeth wants to merge 1 commit into
synthio-miditrack-note-off-velocityfrom
synthio-miditrack-long-delays

Conversation

@tyeth

@tyeth tyeth commented Oct 23, 2026

Copy link
Copy Markdown
Member

Fourth of five stacked PRs; targets the branch of the previous one.

span.dur is a uint16_t, so a delay longer than 65535 samples wrapped. At 44.1kHz that is any gap beyond 1.5 seconds, so a held note or a rest of ordinary length came out far too short. The conversion overflowed too: delta * sample_rate does not fit in 32 bits for a long delay.

Compute the duration in 64 bits and carry whatever does not fit in span.dur in a separate field, handing it over a chunk at a time.

Verification

Builds clean on arm and xtensa. This path is timing-only and was not measured on a device.

Size

About +160 bytes of flash on nrf52840, plus four bytes per MidiTrack object.

🤖 Generated with Claude Code

span.dur is a uint16_t, so a delay longer than 65535 samples wrapped: at
44.1kHz that is any gap beyond 1.5 seconds, and a held note or a rest of
ordinary length came out far too short. The conversion overflowed too,
because delta * sample_rate does not fit in 32 bits for a long delay.

Compute the duration in 64 bits and carry whatever does not fit in
span.dur in a separate field, handing it over a chunk at a time.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@tyeth
tyeth added this pull request to stack #11668 October 23, 2026 22:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant