An editor recording had no sound while the video tab played a video. The tab played its <video> straight to the speakers, past the Web Audio graph, so the recording tap behind the limiter never heard it. Fixing only that would have left videos as the one sound source the Master routing cannot reach, so they get their own node, like sounds. - A video asset with sound has a routing node labelled "Video". One without sound has none, it would have nothing to send. - Its links take the sound after volume and FX. Several links or another level give the video its own bus, as with a sound. - A new video follows the bus most other videos use. With none linked yet it goes to the Master, not to where the sounds go. Songs and sounds no longer follow videos either. - Players only know their file, so videoBusesOf maps each file to the bus of its first asset. setMix takes that map and moves the gains of running videos at once when the routing changes. - In the game, played in the editor or released, a video's sound follows its links. The tabs (video, composition, animation preview) play straight into the Master, as the sound tabs have since #368. - The video tab's sound now goes through the Master, so its volume, FX and limiter apply there and the editor recording hears it. - The recording badge beside the menu is an HTML element over the canvas now. The second render that drew it on the desynchronized canvas let the screen show a frame without it, so it flickered. The element is never in the copy, and clicks go through it. Tests: - Unit master-routing and sound-library: 3 new, green. Red without video in the routing kinds, without moving the gains, and with the old rule for the links of a new video. - e2e 66e-iii: the tab plays a video linked to a bus, the level is 0.09 on the Master and 0 on the bus. 66g: in the game the bus has 0.09. Both red with the old ways. - e2e 67e reads the badge from a real screenshot, still green. - The README names 2043 e2e checks. - Gate on melektaus-atx: 304 files, 4694 tests green. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
98 lines
2.8 KiB
TypeScript
98 lines
2.8 KiB
TypeScript
import { registerNode, type NodeDef, type PortDef } from '../graph/NodeRegistry';
|
|
import { textOf } from '../model/Properties';
|
|
|
|
/** The two nodes of a song's routing (#350): one per track, and the one output of the song. */
|
|
export const SONG_TRACK = 'SongTrack';
|
|
export const SONG_OUTPUT = 'SongOutput';
|
|
/** The node param a track's node shows its track's name by, kept in step with the track. */
|
|
export const SONG_TRACK_NAME = 'name';
|
|
|
|
const audioIn: PortDef = { key: 'in', label: 'in', type: 'audio', many: true };
|
|
const audioOut: PortDef = { key: 'out', label: 'out', type: 'audio' };
|
|
|
|
registerNode({
|
|
type: SONG_TRACK,
|
|
label: 'Track',
|
|
category: 'sound',
|
|
description:
|
|
'A track of the song: its items and whatever comes in, through its sound FX, volume and pan, sent on to every link.',
|
|
inputs: [audioIn],
|
|
outputs: [audioOut],
|
|
params: [],
|
|
fixed: true,
|
|
acyclic: true,
|
|
derivePorts: ({ node }) => ({ label: textOf(node.params[SONG_TRACK_NAME] ?? '') || 'Track' }),
|
|
});
|
|
|
|
registerNode({
|
|
type: SONG_OUTPUT,
|
|
label: 'Output',
|
|
category: 'sound',
|
|
description: 'What the song sounds like: on to the bus of the song.',
|
|
inputs: [audioIn],
|
|
outputs: [],
|
|
params: [],
|
|
fixed: true,
|
|
acyclic: true,
|
|
});
|
|
|
|
export function isSongRoutingDef(def: NodeDef): boolean {
|
|
return def.type === SONG_TRACK || def.type === SONG_OUTPUT;
|
|
}
|
|
|
|
/**
|
|
* The nodes of the master routing (#351): one per sound, instrument, pattern, song, video with sound
|
|
* and bus of the project, named and typed after its asset, and the master. Only a bus and the master
|
|
* take links in.
|
|
*/
|
|
export const ROUTED_ASSET = 'RoutedAsset';
|
|
export const ROUTED_MASTER = 'RoutedMaster';
|
|
export const ROUTED_NAME = 'name';
|
|
export const ROUTED_KIND = 'kind';
|
|
|
|
const KIND_WORDS: Record<string, string> = {
|
|
sound: 'Sound',
|
|
instrument: 'Instrument',
|
|
pattern: 'Pattern',
|
|
song: 'Song',
|
|
video: 'Video',
|
|
bus: 'Bus',
|
|
};
|
|
|
|
registerNode({
|
|
type: ROUTED_ASSET,
|
|
label: 'Asset',
|
|
category: 'sound',
|
|
description:
|
|
'A sound, an instrument, a pattern, a song, a video or a bus of the project: all it plays, sent on to every link.',
|
|
inputs: [],
|
|
outputs: [],
|
|
params: [],
|
|
fixed: true,
|
|
acyclic: true,
|
|
derivePorts: ({ node }) => {
|
|
const kind = textOf(node.params[ROUTED_KIND] ?? '');
|
|
return {
|
|
label: textOf(node.params[ROUTED_NAME] ?? '') || 'Asset',
|
|
inputs: kind === 'bus' ? [audioIn] : [],
|
|
outputs: [{ ...audioOut, label: KIND_WORDS[kind] ?? 'out' }],
|
|
};
|
|
},
|
|
});
|
|
|
|
registerNode({
|
|
type: ROUTED_MASTER,
|
|
label: 'Master',
|
|
category: 'sound',
|
|
description: 'Where the game is heard: through the volume and the sound FX of the master to the speakers.',
|
|
inputs: [audioIn],
|
|
outputs: [],
|
|
params: [],
|
|
fixed: true,
|
|
acyclic: true,
|
|
});
|
|
|
|
export function isMasterRoutingDef(def: NodeDef): boolean {
|
|
return def.type === ROUTED_ASSET || def.type === ROUTED_MASTER;
|
|
}
|