Skip to content

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

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
Owner

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.

This computes the duration in 64 bits and carries 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. No hardware; this path is timing-only and I could not measure it on a device.

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

Stacked on #36.

🤖 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>
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