Route the tracks of a song through a graph (#350)
Every track of a song went straight into its output. Now the Song tab has a second view, Routing: a graph with a node per track and one Output, the links between them sends. A track can go into other tracks, into several at once, and a link has its own volume and the point of the track it taps. - The song asset has a graph like an instrument (SongTrack, SongOutput). heldSongGraph keeps it in step with the tracks on load and in SetSongCommand: a node per track named after it, one output, a new track and every track of an old song linked to the output. Links of gone tracks, doubled links and links closing a loop are dropped. - A link carries an optional send (volume in dB, tap). The inspector shows Volume and Mode for a picked link of a song: Post volume (Post pan), Pre volume (Post FX), Pre volume (Pre FX). SetSendCommand. - NodeDef has two new flags. `fixed` nodes are never added or deleted by hand. Links between `acyclic` nodes may not close a loop, checked in canConnect, dropTargetPort and ConnectCommand. - songBuses gives each track its sends instead of one `into`, and a bus `song:<song>:<track>:#items` for its own items. That bus is what solo closes on a track that only passes a soloed one on. - Mute and solo now act on the sends (trackGates). A muted track passes nothing on, on any tap. A soloed track is heard with what goes into it, through the tracks it goes through, their own items silent. Only sends on a way through a soloed track stay open, so a track going into it and into the output is heard through it only. - SoundLibrary: a bus has either `into` or sends. Each send is tap, delay, level, target. busLatency takes the latest way (arrivalOf), and each send is held back so all ways of a track arrive together (sendDelays). Taps are wired again whenever a chain comes or goes. - The Song tab has Timeline and Routing in its header. The routing uses GraphCanvas with an empty palette. A track linked nowhere shows "Goes nowhere". Delete takes links, never a track node. - Game playings route the same way, the output being the master of the playing. Decided without asking: a send ranges -60 to +12 dB like a track, default 0 dB Post. Mute closes the sends, the track's own level stays. Found on the way: the inspector built the Mode row with the send as it was when the rows were made. Setting Volume and then Mode wrote the old volume back. Both rows now read the current send when they change. Tests: - Unit song-routing (new): 13 green. Sound library: 4 new, 94 green. 11 counter-probes (loop on load, canConnect, solo, solo past the soloed track, mute, preFx latency, graph sync, delete guard, delays, taps, glide), each red. - Existing tests adjusted to the new bus names and send shape: song, bus-fx, song-play, graph registry, edge description. - e2e 65 on melektaus-atx: ALL PASSED, 43 checks (5 new). The first run caught the inspector bug. Counter-probe with the old closure: 2 FAILED. - Gate on melektaus-atx: typecheck, lint, format clean, 2 tests red (registry rule, edge shape), fixed and rerun locally: 56 green. - Not rerun after the per-send solo fix: e2e 65 and the gate. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
3a52f2290f
commit
daeffe0f9d
30 files changed
+1323
-104
No files matched your search
@@ -1,5 +1,16 @@
|
||||
import { NameTransitionCommand } from '../../core/commands/graphCommands';
|
||||
import { findNode, type GraphEdge, isStateNode, resolveDef, stateName } from '../../core/graph';
|
||||
import { SetSendCommand } from '../../core/commands/songCommands';
|
||||
import {
|
||||
type EdgeSend,
|
||||
findNode,
|
||||
type GraphEdge,
|
||||
isStateNode,
|
||||
resolveDef,
|
||||
stateName,
|
||||
} from '../../core/graph';
|
||||
import { SEND_TAPS, sendOf } from '../../core/music/routing';
|
||||
import { TRACK_MAX_DB, TRACK_MIN_DB } from '../../core/music/song';
|
||||
import type { PropertyDef } from '../../core/properties/PropertySchema';
|
||||
import { graphLookup } from '../../core/model/graphLookup';
|
||||
import { findGraphAsset, type Project } from '../../core/model/Project';
|
||||
import { textOf } from '../../core/model/Properties';
|
||||
@@ -9,6 +20,22 @@ import { createFieldRow, labelledRow } from './fieldFactory';
|
||||
import { addNote, addTitle, type InspectorHost } from './host';
|
||||
|
||||
const NAME_KEY = 'transition-name';
|
||||
const SEND_VOLUME: PropertyDef = {
|
||||
key: 'send-volume',
|
||||
label: 'Volume',
|
||||
kind: 'number',
|
||||
default: 0,
|
||||
min: TRACK_MIN_DB,
|
||||
max: TRACK_MAX_DB,
|
||||
step: 0.5,
|
||||
};
|
||||
const SEND_TAP: PropertyDef = {
|
||||
key: 'send-tap',
|
||||
label: 'Mode',
|
||||
kind: 'enum',
|
||||
default: 'post',
|
||||
options: SEND_TAPS.map((tap) => ({ value: tap.value, label: tap.label })),
|
||||
};
|
||||
|
||||
/** What the panel says about one link: the two ends by the names drawn on them. */
|
||||
export interface EdgeDescription {
|
||||
@@ -20,6 +47,8 @@ export interface EdgeDescription {
|
||||
/** What flows through it, as the output names it. */
|
||||
type: string;
|
||||
name: string;
|
||||
/** On a link of a song's routing (#350): what it sends; null on any other link. */
|
||||
send: EdgeSend | null;
|
||||
}
|
||||
|
||||
/** Null when the link is gone. An end whose node or port is gone reads `?`. */
|
||||
@@ -49,6 +78,7 @@ export function describeEdge(project: Project, assetId: string, edgeId: string):
|
||||
input: to.port,
|
||||
type: from.type,
|
||||
name: edge.label ?? '',
|
||||
send: findGraphAsset(project, assetId)?.type === 'song' ? sendOf(edge) : null,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -99,6 +129,26 @@ export function buildEdgeSection(
|
||||
host.fields.set(NAME_KEY, name);
|
||||
host.body.add(name.row);
|
||||
addNote(host, 'A State transition node takes it by this name.', 'small');
|
||||
} else if (d.send) {
|
||||
const send = d.send;
|
||||
// The rows outlive an edit of the other one, so what stands is read when one of them changes.
|
||||
const set = (next: Partial<EdgeSend>) => {
|
||||
const now = describeEdge(host.state.project, assetId, edgeId)?.send ?? send;
|
||||
void host.state.execute(new SetSendCommand(assetId, edgeId, { ...now, ...next }));
|
||||
};
|
||||
const volume = createFieldRow(host, SEND_VOLUME, send.volume, {
|
||||
onInput: () => {},
|
||||
onChange: (next) => set({ volume: Number(next) }),
|
||||
});
|
||||
const tap = createFieldRow(host, SEND_TAP, send.tap, {
|
||||
onInput: () => {},
|
||||
onChange: (next) => set({ tap: SEND_TAPS.find((t) => t.value === textOf(next))?.value ?? 'post' }),
|
||||
});
|
||||
host.fields.set(SEND_VOLUME.key, volume);
|
||||
host.fields.set(SEND_TAP.key, tap);
|
||||
host.body.add(volume.row);
|
||||
host.body.add(tap.row);
|
||||
addNote(host, 'In decibels. Mode says where on its track the link takes the sound.', 'small');
|
||||
} else {
|
||||
fact('Input', d.input);
|
||||
fact('Type', d.type);
|
||||
@@ -110,5 +160,9 @@ export function refreshEdgeSection(host: InspectorHost, assetId: string, edgeId:
|
||||
const d = describeEdge(host.state.project, assetId, edgeId);
|
||||
if (!d) return false;
|
||||
host.fields.get(NAME_KEY)?.setValue(d.name);
|
||||
if (d.send) {
|
||||
host.fields.get(SEND_VOLUME.key)?.setValue(d.send.volume);
|
||||
host.fields.get(SEND_TAP.key)?.setValue(d.send.tap);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
Reference in new issue
Block a user