Skip to content

No stuck notes: note ledger, arp hand-over, stop and audition - #42

Merged
nooga merged 1 commit into
masterfrom
fix/stuck-notes
Nov 4, 2026
Merged

nooga merged 1 commit into
masterfrom
fix/stuck-notes

Conversation

@nooga

@nooga nooga commented Nov 4, 2026

Copy link
Copy Markdown
Owner

Notes could hang in any instrument (seen on Mog Passenger), sometimes after a clip ended and sometimes after stop, and a stopped audition cut off about 3 s after release. Five causes were reproduced, and each now has a test:

  • Edits under the playhead. A clip note's id was its index in the snapshot, so deleting, adding or moving an earlier note renumbered the sounding ones. Their note-offs then went to the wrong id, and a removed note never got one. Each track now keeps a ledger of the notes it sounds (src/note_ledger.zig), with ids that don't change. Every block it finds them in the snapshot again: a note that only moved in the list plays on, and one that was deleted, retuned, moved or shortened behind the playhead ends at once (docs/07).
  • Arp on or off mid-note. When the arp came in, the notes' offs stopped at the arp and the notes hung on the instrument. takeOver/handBack move sounding notes between the instrument and the arp, which reads its switch once per block. A seek or loop ends the arp's notes, which before could hang until their old position came round again (docs/45).
  • Key held through a stop. It was started a second time, so its release freed only one voice.
  • Switching tracks while stopped. The other track's note-off was dropped. Stopped auditions now ring until quiet instead of a 3 s hard cut. They go through the whole graph when the track feeds a bus (so send reverbs are heard) or when another track needs a note-off. A ring that never falls quiet fades at 30 s and starts clean, so it doesn't come back on play (docs/31).
  • Rack lanes matched id-less notes (held keys) to the first held key, not the one let go. They now match by source pitch.
  • Held-note queue. Requests the queue refused were dropped (a lost release is a stuck note). They are now sent again the next frame.

Performance

  • The 16 tracked songs render bit-identical to 0.0.22 (--bits 32f --no-dither --threads 1, sha256).
  • Old and new note paths timed in one ReleaseFast binary: dense track −30%, 64 notes held at once −5.5%, sparse track −25%, with identical event counts. Most of the gain is from the wake check: a sounding ledger skips the notesNear scan.
  • Full song renders run alternately with 0.22 are equal within noise.

Test plan

  • zig build test: 586/586
  • New engine tests ("stuck notes: …", "audition: a tail rings …", "stop: a ring that never falls quiet …") use an instrument that counts sounding voices
  • Ledger, arp (jump, adopt, reserve), rack lane and holdNotes retry tests
  • 16-song bit-exact renders against a 0.0.22 build
  • By hand in the app: toggle the arp under a held chord, audition a track with a send reverb

🤖 Generated with Claude Code

Notes hung when a clip was edited while it played (a clip note's id was
its snapshot index, so an edit orphaned its note-off), when the arp came
in or went out mid-note (the notes' offs stopped at the arp), when a key
was held through a stop (it started twice), when the editor moved to
another track while a key sounded (that track never heard the note-off),
and in a rack lane holding two keys (released by id -1, not pitch).

- note_ledger.zig: each track's sounding clip notes with ids that don't
  change. Every block finds them in the snapshot again: an edited note
  ends at once, the rest where they end; a jump ends what chase doesn't
  keep. Expression runs to a note's end on its id (docs/07).
- engine: takeOver/handBack around the arp, its switch read once a
  block; Arp.runAs ends the arp's notes on a jump (docs/45).
- Stop no longer starts held keys again. A stopped audition rings until
  quiet (it was cut after 3 s), through the whole graph when the track
  feeds a bus or another track must hear a note-off. A ring that never
  falls quiet fades at 30 s and starts clean (docs/31).
- Rack lanes match id-less notes by source pitch; held-note requests the
  engine's queue refused are sent again the next frame.

The 16 tracked songs render bit-identical at 32-bit float; the note path
per block is 5-30% faster (dense, 64 held, sparse tracks).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@nooga
nooga merged commit ebbac25 into master Nov 4, 2026
1 check passed
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