From 41d65d6346284ff5789483c31da521cbbb22baa1 Mon Sep 17 00:00:00 2001 From: Anachronaut Date: Sat, 5 Sep 2026 16:13:10 -0400 Subject: [PATCH] Play waits for its own sound to finish before handing back The gates all go down on the tick the tracks end, but a gate down is a note RELEASED and not a note stopped: the oboe and the strings have a release left to run. Rendered and measured, the tail dies eight tenths of a second after the last event, and the ring was eight ticks - one second, which sounds like enough and was two tenths short. A program that exits with sound still in the air leaves nothing able to end it: the program is gone and cannot drop a gate. What that becomes depends on the front end. Behind a window the tail finishes on its own. On a terminal it does not, because emulated time stops while the machine blocks on a key - measured, and the reason the leftover sound came out a snippet per keystroke rather than fading. Twelve ticks, which is a second and a half and covers the measured tail with room over. It is a number about THESE FOUR INSTRUMENTS: a patch with a longer release would want more, and the general answer is for the system to quieten the device when a program stops, the way it puts the screen back. That is not built and is worth deciding on rather than guessing at. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01E2JrLzFvuFX9fgi1LDRjrW --- Programs/CosmOS/Apps/Play.asm | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/Programs/CosmOS/Apps/Play.asm b/Programs/CosmOS/Apps/Play.asm index ba27cd0..ad2e7b4 100644 --- a/Programs/CosmOS/Apps/Play.asm +++ b/Programs/CosmOS/Apps/Play.asm @@ -113,9 +113,23 @@ tickLoop: BRI tickLoop finished: - ; Let the last note ring rather than cutting it off, then give the timer back - stopped - ; before the handler goes away, because an interrupt with nothing to catch it is a fault. - INIB 0d8 + ; ---- Let the last note finish, and MEASURE how long that takes ---- + ; + ; The gates all went down on the tick the tracks ended, but a gate down is a note released + ; rather than a note stopped: the oboe and the strings have a release to run. Rendered and + ; measured, the tail dies out eight tenths of a second after the last event, and eight ticks + ; of ring is one second - which sounds like enough and is two tenths short of it. + ; + ; A program that exits with sound still in the air leaves nothing able to end it: the + ; program is gone and cannot drop a gate. What that turns into depends on the front end - + ; behind a window the tail simply finishes, and on a terminal EMULATED TIME STOPS while the + ; machine blocks on a key, so the tail freezes and comes out a snippet per keystroke. + ; + ; Twelve ticks is a second and a half, which covers the measured tail with room over. It is + ; a number about THESE FOUR INSTRUMENTS, and a patch with a longer release would want more - + ; the general answer is for the system to quieten the device when a program stops, the way + ; it puts the screen back, and that is not built. + INIB 0d12 lastRing: WAIT DECB