Hand out the length of a played sound from Play sound
game-maker / gate (push) Successful in 3m12s
game-maker / suite (push) Failing after 26m24s

Wired into the time of Set sound FX parameters, a change then spans
exactly one run of the clip, so a fade or a filter sweep ends with its
last sample.

- Play sound has a second output, length, in seconds. It is 0 where
  nothing was played or the sound has not loaded yet.
- The AudioSink gives the length of a file, the SoundLibrary takes it
  from the decoded buffer. A pitch the voice starts on keeps it (#312).
- A pitch changed while the voice plays still changes its length, so a
  pitch sweep over length does not end with the sound. A pitch that
  keeps the length in real time is #317.

Tests:
- soundfx, sounds, keep-on-scene-load, node-catalog, sound-library:
  462 tests green.
- Counter-check: with length always 0, the catalog case and the new
  soundfx case fail.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
adminandClaude Opus 5.5 committed 2026-10-05 22:27:44 +02:00
1 parent 297fca3e94
commit 804a97b0a9
10 files changed
+53 -11

No files matched your search

+3 -3
View File
@@ -1980,14 +1980,14 @@ const CASES: Record<string, Case[]> = {
name: 'no sound is a no-op that still continues the flow',
inputs: { sound: '', volume: 1, loop: '' },
next: 'exec',
outputs: { voice: 0 },
outputs: { voice: 0, length: 0 },
after: (ctx) => expect(ctx.played).toEqual([]),
},
{
name: 'hands the id on with the volume and loop it was given, and gives out the voice (#315)',
name: 'hands the id on with the volume and loop it was given, and gives out the voice (#315) and its length',
inputs: { sound: 'snd-1', volume: 0.5, loop: 'true' },
next: 'exec',
outputs: { voice: 1 },
outputs: { voice: 1, length: 0.25 },
// What the two mean – a factor on the asset's volume, an answer that overrules its loop
// flag – is the BehaviorSystem's to resolve, since only it holds the project (see
// `sounds.test.ts`).