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
@@ -1979,6 +1979,144 @@ describe('a sound FX on a bus (#346)', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('the sends of the tracks of a song (#350)', () => {
|
||||
const LATE = 2048 / 48000;
|
||||
const voice = (plan: FxPlan): FxVoice => ({ plan, params: {}, tempo: 120 });
|
||||
const up: FxPlan = { pitch: [{ value: 12 }], stages: [] };
|
||||
const crush: FxPlan = planOf({ pitch: 0, stages: [{ kind: 'crush', bits: 4, rate: 8000, mix: 1 }] });
|
||||
const out = { name: 'song:s:o', gain: 1, pan: 0 };
|
||||
const sendsOf = (library: SoundLibrary, name: string) =>
|
||||
library.busLevels().find((bus) => bus.name === name)?.sends;
|
||||
|
||||
it('taps each send where its mode says: after the pan, after the sound FX, or where it comes in', async () => {
|
||||
const library = new SoundLibrary();
|
||||
await library.setBuses([
|
||||
out,
|
||||
{
|
||||
name: 'song:s:t',
|
||||
gain: 0.5,
|
||||
pan: 0,
|
||||
fx: voice(crush),
|
||||
sends: [
|
||||
{ to: 'song:s:o', gain: 1, tap: 'post' },
|
||||
{ to: 'song:s:o', gain: 0.25, tap: 'postFx' },
|
||||
{ to: 'song:s:o', gain: 0.5, tap: 'preFx' },
|
||||
],
|
||||
},
|
||||
]);
|
||||
expect(wires).toEqual(
|
||||
expect.arrayContaining(['panner > delay', 'crush > delay', 'gain > delay', 'delay > gain']),
|
||||
);
|
||||
expect(sendsOf(library, 'song:s:t')).toEqual([
|
||||
{ to: 'song:s:o', tap: 'post', gain: 1, delay: 0 },
|
||||
{ to: 'song:s:o', tap: 'postFx', gain: 0.25, delay: 0 },
|
||||
{ to: 'song:s:o', tap: 'preFx', gain: 0.5, delay: 0 },
|
||||
]);
|
||||
// A track with sends is not also sent on as a whole.
|
||||
expect(library.busLevels().find((bus) => bus.name === 'song:s:t')?.into).toBeNull();
|
||||
});
|
||||
|
||||
it('holds back the ways that pass a Pitch by, so all of a track is heard as late as its latest way', async () => {
|
||||
const library = new SoundLibrary();
|
||||
await library.setBuses([
|
||||
out,
|
||||
{
|
||||
name: 'song:s:t',
|
||||
gain: 1,
|
||||
pan: 0,
|
||||
fx: voice(up),
|
||||
sends: [
|
||||
{ to: 'song:s:o', gain: 1, tap: 'post' },
|
||||
{ to: 'song:s:o', gain: 1, tap: 'preFx' },
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'song:s:u',
|
||||
gain: 1,
|
||||
pan: 0,
|
||||
sends: [
|
||||
{ to: 'song:s:t', gain: 1, tap: 'post' },
|
||||
{ to: 'song:s:o', gain: 1, tap: 'post' },
|
||||
],
|
||||
},
|
||||
]);
|
||||
expect(library.busLatency('song:s:t')).toBeCloseTo(LATE, 12);
|
||||
expect(library.busLatency('song:s:u')).toBeCloseTo(LATE, 12);
|
||||
expect(sendsOf(library, 'song:s:t')?.map((send) => send.delay)).toEqual([0, expect.closeTo(LATE, 9)]);
|
||||
expect(sendsOf(library, 'song:s:u')?.map((send) => send.delay)).toEqual([0, expect.closeTo(LATE, 9)]);
|
||||
// Without its Pitch nothing of the track is late any more, and nothing is held back.
|
||||
await library.setBuses([
|
||||
out,
|
||||
{
|
||||
name: 'song:s:t',
|
||||
gain: 1,
|
||||
pan: 0,
|
||||
sends: [
|
||||
{ to: 'song:s:o', gain: 1, tap: 'post' },
|
||||
{ to: 'song:s:o', gain: 1, tap: 'preFx' },
|
||||
],
|
||||
},
|
||||
]);
|
||||
expect(sendsOf(library, 'song:s:u')?.map((send) => send.delay)).toEqual([0, 0]);
|
||||
});
|
||||
|
||||
it('glides the level of a send that only changed its level, and makes the sends anew that go elsewhere', async () => {
|
||||
const library = new SoundLibrary();
|
||||
const track = { name: 'song:s:t', gain: 1, pan: 0 };
|
||||
await library.setBuses([out, { ...track, sends: [{ to: 'song:s:o', gain: 1, tap: 'post' as const }] }]);
|
||||
const made = delays.length;
|
||||
await library.setBuses([out, { ...track, sends: [{ to: 'song:s:o', gain: 0, tap: 'post' as const }] }]);
|
||||
expect(delays).toHaveLength(made);
|
||||
expect(sendsOf(library, 'song:s:t')).toEqual([{ to: 'song:s:o', tap: 'post', gain: 0, delay: 0 }]);
|
||||
await library.setBuses([out, { ...track, sends: [{ to: 'mix', gain: 1, tap: 'postFx' as const }] }]);
|
||||
expect(delays).toHaveLength(made + 1);
|
||||
expect(disconnects).toEqual(expect.arrayContaining(['delay']));
|
||||
// Back to one way out as a whole: no sends left.
|
||||
await library.setBuses([out, track]);
|
||||
expect(library.busLevels().find((bus) => bus.name === 'song:s:t')).toEqual({
|
||||
name: 'song:s:t',
|
||||
gain: 1,
|
||||
pan: 0,
|
||||
into: 'mix',
|
||||
fx: false,
|
||||
latency: 0,
|
||||
});
|
||||
});
|
||||
|
||||
it('sends the tracks of a game’s playing into one another and into its master', () => {
|
||||
const library = new SoundLibrary();
|
||||
const id = library.playSequence(
|
||||
'song:s',
|
||||
{
|
||||
sequence: { notes: [{ tick: 0, length: 480, velocity: 1, instrument: 'i', note: 60, bus: 't' }] },
|
||||
tempo: 120,
|
||||
length: 1920,
|
||||
loop: null,
|
||||
needs: { layers: [], files: [] },
|
||||
buses: [
|
||||
{
|
||||
name: 't',
|
||||
gain: 1,
|
||||
pan: 0,
|
||||
sends: [
|
||||
{ to: 'u', gain: 0.5, tap: 'post' },
|
||||
{ gain: 1, tap: 'preFx' },
|
||||
],
|
||||
},
|
||||
{ name: 'u', gain: 1, pan: 0, sends: [{ gain: 1, tap: 'post' }] },
|
||||
],
|
||||
strike: () => 0,
|
||||
},
|
||||
'',
|
||||
);
|
||||
expect(sendsOf(library, `play:${id}:t`)?.map((send) => [send.to, send.gain, send.tap])).toEqual([
|
||||
[`play:${id}:u`, 0.5, 'post'],
|
||||
[`play:${id}`, 1, 'preFx'],
|
||||
]);
|
||||
expect(sendsOf(library, `play:${id}:u`)?.map((send) => send.to)).toEqual([`play:${id}`]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('the master and the buses of the project (#325)', () => {
|
||||
const bus = (name: string, volume: number, into: string | null, fx: FxVoice | null = null): MixBus => ({
|
||||
name,
|
||||
|
||||
Reference in new issue
Block a user