Play and stop a song from a behavior in the game #336
A song could only be heard in its tab. Now a game plays it through Play song and ends it through Stop song, with its tracks as they are set. A playing pattern or song also no longer undoes the pause of the toolbar. - Play song plays from the start of the song and then round the loop of its ruler, so an intro is heard once. Without loop it plays once to its end. Inputs are song, volume, fade in, loop (on by default) and detached (off by default). It gives out playback. - Stop song stops one song, every song for none, or one playback by its number, over its fade out. Stop sound with no sound named stops songs too. Stop pattern with no pattern named stops only patterns. - Songs play side by side, as patterns do. They are owned like a sound, so leaving the scene ends one unless it is detached. Pause game and the time scale leave the music alone. - Each playing is heard through a master of its own, silent until its first note. The fades move it, and a song's tracks sit inside it on buses of their own. They go once the playing and its voices have. - Notes and clips are struck the same way in the editor and the game (strikeNote, playClip). What a sequence needs comes from one place (core/music/needs). Findings: - Reading the audio clock resumed a suspended context. A playing pattern read it every 25 ms and so undid the toolbar's pause. The library now leaves a context alone while the toolbar holds it. - A pattern played once to its end asked the list of playings about its voices, and that list asked the pattern again. Once its last voice was gone this ran until the stack overflowed. The scheduler of a playing now asks only after voices. - e2e 64 reads the playings through __gm.sound.playbacks() now. Tests: - song-play.test.ts (new): 8 tests, node catalog +8 cases - sound-library.test.ts: 66 tests, 4 new - e2e 64 (melektaus-atx): 23 of 23 checks passed - e2e 65 (melektaus-atx): ALL PASSED, 22 checks (+4) - Gate (melektaus-atx): CHECK EXIT 0, 251 files, 3903 tests - Counter-checks: the old way of asking after voices, a clock read that wakes a held context, and a start after a fade out began each fail 1 test Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
8f9c250eb6
commit
f97961c8ff
23 files changed
+1134
-194
No files matched your search
@@ -228,6 +228,8 @@ export type FakeContext = NodeContext & {
|
||||
}[];
|
||||
/** The patterns the context was asked to play; a playing's number is how many have been played. */
|
||||
patterns: { patternId: string; volume: number; loop: boolean; detached: boolean }[];
|
||||
/** The songs the context was asked to play, numbered the same way. */
|
||||
songs: { songId: string; volume: number; fadeIn: number; loop: boolean; detached: boolean }[];
|
||||
silenced: string[];
|
||||
tuned: { voice: number; fxParams: Readonly<Record<string, number>>; time: number; ease: EaseShare }[];
|
||||
/** The scenes the context was asked to load, in order. */
|
||||
@@ -292,6 +294,11 @@ export function fakeContext(overrides: Partial<NodeContext> = {}): FakeContext {
|
||||
ctx.patterns.push({ patternId, volume, loop, detached }),
|
||||
stopPattern: (patternId, letRing) =>
|
||||
ctx.silenced.push(`pattern ${patternId}${letRing ? ' (let ring)' : ''}`),
|
||||
songs: [],
|
||||
playSong: (songId, volume, fadeIn, loop, detached) =>
|
||||
ctx.songs.push({ songId, volume, fadeIn, loop, detached }),
|
||||
stopSong: (songId, fadeOut) => ctx.silenced.push(`song ${songId} (fade ${fadeOut})`),
|
||||
stopPlayback: (playback, fadeOut) => ctx.silenced.push(`playback ${playback} (fade ${fadeOut})`),
|
||||
// Every sound lasts a quarter of a second, as if it had been loaded.
|
||||
soundLength: () => 0.25,
|
||||
// The tail of a voice is its number in tenths of a second, so a test can tell one from another.
|
||||
|
||||
Reference in new issue
Block a user