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' }; export const SongTrackNode = 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' }), }); export const SongOutputNode = 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; }