Play and stop a pattern from a behavior #336

Patterns gets a section on playing one in a game, Behaviors a line on
the two nodes, Development the new check count.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
adminandClaude Opus 5.5 committed 2026-10-06 15:30:07 +02:00
1 parent 0610d7a352
commit 340046d1c1
3 files changed
+36 -3

No files matched your search

+2
@@ -260,6 +260,8 @@ the inspector).
direction; every play is a voice of its own, so two in a row overlap, and the voice ends with the
behavior that started it unless `detached` says otherwise), `Play note` (one note of an
instrument, its parameters from an `Instrument parameters` node, see [Instruments](Instruments)),
`Play pattern` / `Stop pattern` (a whole pattern through its instrument, looped or once, owned
like a sound, see [Patterns](Patterns#playing-one-in-a-game)),
`Load scene` (swaps the running scene once the frame is over — see [Scenes](Scenes)), `Log`, `Stop game`, `Restart game`,
`Pause game`, `Resume game`, `Set time scale` with the data nodes `Is game paused` and `Time scale` (see [Concepts](Concepts), *The game pauses itself*),
`Apply force`, `Apply impulse`, `Set velocity`, `Set angular velocity`, `Set gravity` (see [Physics](Physics)),
+1 -1
@@ -18,7 +18,7 @@ php tests/php/accounts.test.php # the API's accoun
# has and the web server's container has not (SKIP there)
php tests/php/snapshots.test.php # the snapshot store (#231), the same way
php tests/php/releases.test.php # the release store (#266), the same way
node tools/seed-e2e.mjs && node tools/e2e.mjs # 1796 editor checks, screenshots in /tmp/gm-e2e-*.png
node tools/seed-e2e.mjs && node tools/e2e.mjs # 1799 editor checks, screenshots in /tmp/gm-e2e-*.png
GM_STEPS=20 node tools/e2e.mjs # or 1-12, or 6,20 — a subset while working on one step
./e2e.sh start [GM_STEPS] # the same run detached, see below
./e2e.sh status # live progress, or the last run's result
+33 -2
@@ -97,9 +97,40 @@ Measured (2026-10-06, e2e 64 on the CI's Windows machine): bar 1 of a pattern at
at ticks 720, 960, 1440 and 1680 were planned exactly 0, 0.25, 0.75 and 1 s apart on the audio
clock; a note drawn at tick 1800 while it played came in the next round with the playing going on.
## Playing one in a game
**Play pattern** plays a pattern through its instrument, at the pattern's own tempo, on the same
scheduler as the tab. It plays the **whole pattern** from its first bar to its end: the loop set on
the ruler is only for editing.
| Input | |
|---|---|
| `pattern` | The pattern asset. |
| `volume` | 0 to 1, how loud every note of it is next to its velocity. |
| `loop` | On (the default): round and round until it is stopped. Off: once, and it is over by itself when its last note has ended. |
| `detached` | As for a sound: off, the pattern belongs to the object of the behavior and stops when that object is destroyed; on, it outlives it. |
It gives out `playback`, the number of this playing, and 0 where the pattern has no instrument or
no notes. Firing it twice plays the pattern twice, overlapping. Its files are loaded first, so the
first note may come a moment later, but always in time with the ones after it.
**Stop pattern** stops every playing of the pattern it names, and every pattern where it names
none (sounds play on). With `playback` connected it stops only that one, and nothing where it is 0.
Its notes fade out in 10 ms; with **Let ring** a note of an instrument with an
[Envelope](Instruments#envelopes) falls away in its release. `Stop sound` reaches patterns as well:
naming no sound it stops everything, patterns included, and its `voice` takes a `playback`. The end
of the run stops every pattern.
This is a step ahead of songs: a song (#334) will play several patterns on tracks, and a game will
play a song (#336). A pattern has no tempo input in the game yet, and nothing tells a graph that a
pattern played once has ended.
Measured (2026-10-06, e2e 64): a bar of quarters at 150 BPM played by `Play pattern` in a game was
planned 0.4 s apart, round and round, owned by the behavior; stopping the game ended it, and played
once it was gone by itself after its bar.
## Not yet
No notes of other patterns in the background (ghost notes, with the song, #334), no lanes for
pitch bend or an instrument's parameters (automation, #337), no swing. The computer keyboard does
not play notes in this tab as it does in the Instrument tab, and there is no step input. A game
can not play a pattern yet (#336).
not play notes in this tab as it does in the Instrument tab, and there is no step input.