A game should be able to start the next piece of music when one is over, or wait for a sound before it goes on. Until now a behavior could start and stop music and sounds, but never learn that they had ended. - Two new events: On music finished with the fields Song and Pattern and the input playback, and On sound finished with the field Sound and the input voice. Both give out what ended and stopped. - Two new data nodes, Music playing and Sound playing, ask whether something is still heard. - Over means nothing is heard any more: no tail of the effects, and a fade-out has run down. - stopped is on for Stop song, pattern or sound, when the behavior that owns it ends and on a scene change. For a sound also when a newer voice needs its place or the file does not load. - Only what the Play nodes of this run started is heard, across scene changes too. Previews in the tabs, compositions and notes of instruments do not count. - Switch song ends nothing. The number goes on, and the end is told under the song heard last. - Playbacks and the SoundLibrary tell each end once to a new PlayedEnds per run. The AudioSwitch passes them on from both sinks. Found and fixed: a pattern whose last bar ends in silence counted as done up to one planning window before its end. In e2e 65 the next pattern started after 1.962 s instead of 2 s. Scheduler.done now also wants the playhead to have reached the end. Cleaning up done playbacks therefore comes a few tenths of a second later. One test that expected the early end is adjusted. Tests: - Unit: 23 new (played-ends 12, sound-library 5, node catalog 5, audio-switch 1), all green. - Counter-probes: 19 bends, all red. One was green at first for want of a case, which is added now. - e2e 65 on atx: ALL PASSED, 78 checks. New 65k6: the event came once with stopped off, and the second pattern started 2.051 s after the stinger. Stop song gave exactly one end with stopped on, and the switch from 65k3 gave none. - Gate on atx: CHECK EXIT 0, 337 files, 5222 tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
26 lines
1.4 KiB
TypeScript
26 lines
1.4 KiB
TypeScript
import { textOf } from '../../../model/Properties';
|
||
import type { NodeDef } from '../../NodeRegistry';
|
||
import { hiddenOrder, orderParam } from '../../eventOrder';
|
||
import { bool, exec, num } from '../shared';
|
||
|
||
/** The input that picks one play (#373): not typed in, so unconnected it is null and the Sound decides. */
|
||
export const VOICE_INPUT = 'voice';
|
||
|
||
export const OnSoundFinished: NodeDef = {
|
||
type: 'OnSoundFinished',
|
||
label: 'On sound finished',
|
||
category: 'event',
|
||
description:
|
||
'Runs once when a sound a Play sound of this game started is over: once nothing of it is heard ' +
|
||
'any more, the echoes of its FX included. "stopped" is on where it did not play to its end but ' +
|
||
'was stopped – by Stop sound, by the end of the behavior that owns it, or to make room for ' +
|
||
'newer voices – and where it never started because its file would not load. A looping sound ' +
|
||
'ends only so. Pick a Sound to hear only that one, or connect "voice" to hear only that play, ' +
|
||
'the number Play sound handed out. A note of an instrument is none of them. It comes in the ' +
|
||
'first frame after the end, so up to a frame late.',
|
||
inputs: [{ ...num(VOICE_INPUT), inline: false }],
|
||
outputs: [exec(), num('voice'), bool('stopped')],
|
||
params: [{ key: 'sound', label: 'Sound', kind: 'sound', default: '' }, orderParam],
|
||
hiddenParams: (params) => [...(textOf(params.sound ?? '') ? [] : ['sound']), ...hiddenOrder(params)],
|
||
};
|