A composition's sound ran on the audio clock while its picture ran on the frames. A frame counts at most 0.1 s, so after a hitch the sound stayed ahead of the picture until the next stop. Songs in a trailer drifted off the cut. The items of a composition also had no bus of their own, and a video sprite could not pick where its sound goes. - CompositionSound.follow compares the audio clock with the picture each frame. More than 40 ms apart, it starts the sound again where the picture is. This holds in the tab and in a run. - A time scale other than 1 now restarts the sound again and again. It stays in time but comes in pieces. - The sprite of a video item shows "Driven (by composition)" as a fixed Video clock row. Video time is hidden there, because the composition sets it every frame. - Every composition has a bus in the mix and a node in the master routing. A new one goes to the master unless other compositions are linked elsewhere, apart from where the sounds go. - Audio items pick From asset, To composition, Master or a bus. New items start with To composition. Items saved before keep From asset, so music already sent through a bus does not bypass it. - Video sprites have a new row Video bus: From asset by default, the master or a bus. In a composition the default is the composition's bus, also for video sprites inside a container item. - The chosen bus is part of the key of the video player, so a sprite with another bus gets a player of its own. Found along the way: - Six tests with full lists of sprite defaults expected the old rows and now list Video bus too. Tests: - tsc, eslint, Prettier clean - Unit: 971 green in the 28 files touched - npm run check on melektaus-atx: green, 309 files, 4804 tests - e2e 68 (melektaus-atx): 13 checks green, 68i new. The sound item and the video item go into mix:cp68-cut, which goes to the master. - e2e 69 (melektaus-atx): ALL PASSED, 23 checks, 69q and 69r new. After a hitch of 500 ms the sound restarted twice and then lay 0.5 to 5 ms off the playhead. - Counter-checks in unit tests: without the comparison the hitch test fails, without the bus in the preload the run test fails. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
64 lines
2.4 KiB
TypeScript
64 lines
2.4 KiB
TypeScript
import { masterRoutingProblems } from '../../core/music/projectRouting';
|
|
import { ROUTING_ID } from '../../core/model/Project';
|
|
import { Button, Label, Spacer, VStack } from '../../ui';
|
|
import { GraphCanvas } from '../graph/GraphCanvas';
|
|
import { GRAPH_SNAPS_AT_FIRST, SnapToggle } from '../graph/SnapToggle';
|
|
import type { EditorState } from '../state';
|
|
import { TabHeader } from '../TabHeader';
|
|
|
|
const INFO_WIDTH = 220;
|
|
|
|
/**
|
|
* The Master routing tab (#351), one per project: a node per sound, instrument, pattern, song, video
|
|
* with sound, composition and bus and the master, the links between them where each one goes. Edited as the routing of a song is
|
|
* (#350); a click on a node shows its asset in the inspector, a double click opens it.
|
|
*/
|
|
export class RoutingEditor extends VStack {
|
|
readonly canvas: GraphCanvas;
|
|
readonly fitButton: Button;
|
|
readonly snap: SnapToggle;
|
|
private readonly info = new Label('', { style: 'small', align: 'right' });
|
|
|
|
constructor(private readonly state: EditorState) {
|
|
super();
|
|
this.canvas = new GraphCanvas(state, 'routing');
|
|
this.snap = new SnapToggle(() => this.canvas, GRAPH_SNAPS_AT_FIRST);
|
|
this.fitButton = new Button('Fit', { onClick: () => this.canvas.fit() });
|
|
this.info.minWidth = INFO_WIDTH;
|
|
const header = new TabHeader();
|
|
for (const widget of this.snap.widgets) header.add(widget);
|
|
header.add(this.fitButton);
|
|
header.add(new Spacer(), 1);
|
|
header.add(this.info);
|
|
this.add(header);
|
|
this.add(this.canvas, 1);
|
|
state.on('project', () => this.refresh());
|
|
state.on('load', () => this.close());
|
|
}
|
|
|
|
/** Shows the routing of the project; framed the first time, as it was left after that. */
|
|
open(): void {
|
|
this.canvas.show(ROUTING_ID);
|
|
this.refresh();
|
|
}
|
|
|
|
/** The tab is closed: opened again, the routing starts from a fitted view. */
|
|
close(): void {
|
|
this.canvas.show('');
|
|
this.refresh();
|
|
}
|
|
|
|
/** The readout: how many links, and how many nodes go nowhere and are never heard. */
|
|
get shownInfo(): string {
|
|
return this.info.text;
|
|
}
|
|
|
|
private refresh(): void {
|
|
if (this.canvas.currentAssetId !== ROUTING_ID) return this.info.setText('');
|
|
const graph = this.state.project.routing;
|
|
const silent = Object.keys(masterRoutingProblems(graph)).length;
|
|
const links = `${graph.edges.length} link${graph.edges.length === 1 ? '' : 's'}`;
|
|
this.info.setText(silent > 0 ? `${links} · ${silent} going nowhere` : links);
|
|
}
|
|
}
|