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

+49
View File
@@ -2084,6 +2084,55 @@ const CASES: Record<string, Case[]> = {
},
{ name: 'with none picked the bundle is empty', outputs: { params: {} } },
],
PlayPattern: [
{
name: 'no pattern is a no-op that still continues the flow',
inputs: { pattern: '' },
next: 'exec',
outputs: { playback: 0 },
after: (ctx) => expect(ctx.patterns).toEqual([]),
},
{
name: 'hands the pattern on with its volume, looping and owned unless asked otherwise',
inputs: { pattern: 'pat-1', volume: 0.5, loop: true },
next: 'exec',
outputs: { playback: 1 },
after: (ctx) =>
expect(ctx.patterns).toEqual([{ patternId: 'pat-1', volume: 0.5, loop: true, detached: false }]),
},
{
name: 'plays once and detached when asked to',
inputs: { pattern: 'pat-1', loop: false, detached: true },
next: 'exec',
after: (ctx) => expect(ctx.patterns[0]).toMatchObject({ loop: false, detached: true }),
},
],
StopPattern: [
{
name: 'stops the pattern it names, letting its notes ring when asked to',
inputs: { pattern: 'pat-1', letRing: true },
next: 'exec',
after: (ctx) => expect(ctx.silenced).toEqual(['pattern pat-1 (let ring)']),
},
{
name: 'naming none stops every pattern',
inputs: { pattern: '' },
next: 'exec',
after: (ctx) => expect(ctx.silenced).toEqual(['pattern ']),
},
{
name: 'with a playback connected stops only that one, whatever pattern is named',
inputs: { pattern: 'pat-1', playback: 4 },
next: 'exec',
after: (ctx) => expect(ctx.silenced).toEqual(['voice 4']),
},
{
name: 'a connected playback of 0 – a Play pattern that played nothing – stops nothing',
inputs: { pattern: 'pat-1', playback: 0 },
next: 'exec',
after: (ctx) => expect(ctx.silenced).toEqual([]),
},
],
SoundFxParameters: [
{
name: 'bundles its picked parameters as numbers',