Play and stop a pattern from a behavior in the game #336
game-maker / gate (push) Successful in 3m21s
game-maker / suite (push) Failing after 13m22s

A pattern could only be heard in its tab. Songs come with #334, and
only then can #336 play them in a game. Until then a game plays a
single pattern, looped or once, through two new nodes.

- Play pattern plays the whole pattern through its instrument at its
  own tempo. The loop on the ruler is only for editing. Inputs are
  pattern, volume, loop (on by default) and detached. It gives out
  playback, 0 where there is no instrument or no note.
- Stop pattern stops one pattern, every pattern for none, or one
  playback by its number. Let ring lets notes with an Envelope fall
  away in their release.
- A playing is numbered and owned like a voice. Destroying the object,
  Stop sound with nothing named and the end of the run stop it. Stop
  sound with a voice takes a playback too.
- Each playing runs on a scheduler of its own (core/music/playbacks).
  It waits for its files first, and a stop that came earlier wins.
- The scheduler has an end for a sequence that does not loop. It stops
  waking there and is done once its last notes are.
- The worker clock moved to viewport/wake.ts, so SoundLibrary can use
  it without importing music.ts.

Tests:
- pattern-play.test.ts (new): 8 tests, node catalog +7 cases
- e2e 64 (melektaus-atx): ALL PASSED, 23 checks (+3)
- Gate (melektaus-atx): CHECK EXIT 0, 248 files, 3854 tests
- Counter-checks: no end in the scheduler, and no owner for the
  playing, each fail 1 test

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
adminandClaude Opus 5.5 committed 2026-10-06 15:29:45 +02:00
1 parent 4ea752feef
commit 2a3b90b017
19 files changed
+745 -28

No files matched your search

+2
View File
@@ -65,6 +65,8 @@ export function installDebugHook(app: Application, state: EditorState, editor: E
stopAll: () => soundLibrary.stopAll(),
/** What Stop sound asks for: every voice of that file, its echoes cut or left to ring (#324). */
stop: (file: string, letRing: boolean) => soundLibrary.stop(file, letRing),
/** The patterns a game plays, with the notes last planned of each. */
patterns: () => soundLibrary.patterns(),
/** The nodes a stage of a voice becomes, in any context – an offline one renders what it does. */
stageNodes: (context: BaseAudioContext, stage: FxStage) => stageNodes(context, stage),
/** What drives the two shares of a Mix "Both at center", in any context (unstarted). */