Route a video's sound through its own Master routing node
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>
This commit is contained in:
1 parent
846a8b70b3
commit
93190e185c
25 files changed
+376
-99
No files matched your search
+17
-3
@@ -59,10 +59,12 @@ export function routeOf(project: Project, assetId: string): MixRoute {
|
||||
return only && only.gain === 1 && only.tap === 'post' ? only.to : sends;
|
||||
}
|
||||
|
||||
const OWN_BUS_TYPES: readonly string[] = ['sound', 'instrument', 'video'];
|
||||
|
||||
/**
|
||||
* The master and every bus of the project (#325), each where the routing sends it (#351); and a bus
|
||||
* of its own for each sound and instrument the routing sends anywhere but straight into one bus, for
|
||||
* all its voices to go through. A sound FX that does not compile is none.
|
||||
* of its own for each sound, instrument and video the routing sends anywhere but straight into one
|
||||
* bus, for all its voices to go through. A sound FX that does not compile is none.
|
||||
*/
|
||||
export function mixOf(project: Project): MixBus[] {
|
||||
const fxOf = (id: string) => fxVoiceOf(project, id, DEFAULT_TEMPO);
|
||||
@@ -78,7 +80,7 @@ export function mixOf(project: Project): MixBus[] {
|
||||
fx: fxOf(coerceAs(asset.props[BUS_FX_KEY], 'asset', '')),
|
||||
},
|
||||
];
|
||||
if ((asset.type !== 'sound' && asset.type !== 'instrument') || !isRouted(asset)) return [];
|
||||
if (!OWN_BUS_TYPES.includes(asset.type) || !isRouted(asset)) return [];
|
||||
const route = routeOf(project, asset.id);
|
||||
return typeof route === 'string'
|
||||
? []
|
||||
@@ -125,6 +127,18 @@ export function playedBus(project: Project, picked: string, assetId: string): st
|
||||
return typeof route === 'string' ? route : mixBusName(assetId);
|
||||
}
|
||||
|
||||
/**
|
||||
* The bus the sound of each video file is heard on, by the routing of its asset: a player knows
|
||||
* the file it plays, not the asset. Where two videos share a file, the first one says.
|
||||
*/
|
||||
export function videoBusesOf(project: Project): Map<string, string> {
|
||||
const buses = new Map<string, string>();
|
||||
for (const asset of project.assets)
|
||||
if (asset.type === 'video' && asset.file !== '' && !buses.has(asset.file))
|
||||
buses.set(asset.file, playedBus(project, '', asset.id));
|
||||
return buses;
|
||||
}
|
||||
|
||||
/** Where a playing of a pattern or a song goes: the bus a node picked, else along its routing (#351). */
|
||||
export function playedRoute(project: Project, picked: string, assetId: string): MixRoute {
|
||||
if (picked === MASTER_BUS) return MASTER_MIX;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* The master routing of a project (#351): a graph with a node per sound, instrument, pattern, song and
|
||||
* bus, and the master, its links the sends from one to the next. Its nodes follow the assets: one
|
||||
* The master routing of a project (#351): a graph with a node per sound, instrument, pattern, song,
|
||||
* video with sound and bus, and the master, its links the sends from one to the next. Its nodes follow the assets: one
|
||||
* that comes gets a node of its own and the links most others of its type have, one that goes takes
|
||||
* its node along.
|
||||
*/
|
||||
@@ -16,7 +16,7 @@ import { isEmbedded } from './embedded';
|
||||
import { addLink, heldSend } from './routing';
|
||||
import { ROUTED_ASSET, ROUTED_KIND, ROUTED_MASTER, ROUTED_NAME } from './routingNodes';
|
||||
|
||||
const ROUTED_TYPES: readonly AssetType[] = ['sound', 'instrument', 'pattern', 'song', 'bus'];
|
||||
const ROUTED_TYPES: readonly AssetType[] = ['sound', 'instrument', 'pattern', 'song', 'video', 'bus'];
|
||||
/** What has its own sound FX and level on a bus of its own, and so may send from before them. */
|
||||
const TAPPED_TYPES: readonly AssetType[] = ['bus', 'song'];
|
||||
|
||||
@@ -29,8 +29,9 @@ const ROW_STEP = 80;
|
||||
const COLUMN_OF = (type: string) => (type === 'bus' ? 1 : 0);
|
||||
const MASTER_COLUMN = 2;
|
||||
|
||||
/** A video only where it has sound: one without has nothing to send. */
|
||||
export function isRouted(asset: Asset): boolean {
|
||||
return ROUTED_TYPES.includes(asset.type) && !isEmbedded(asset);
|
||||
return ROUTED_TYPES.includes(asset.type) && !isEmbedded(asset) && (asset.type !== 'video' || asset.audio);
|
||||
}
|
||||
|
||||
/** Whether links out of an asset of this type may take the sound before its sound FX or its level. */
|
||||
@@ -132,9 +133,11 @@ export function heldRouting(graph: Graph | undefined, assets: readonly Asset[],
|
||||
}
|
||||
|
||||
/**
|
||||
* The links a new sound, instrument, pattern or song takes, so it is heard where the others are: those
|
||||
* The links a new sound, instrument, pattern, song or video takes, so it is heard where the others are: those
|
||||
* of the one whose targets most others of its type share too – the latest of them on a tie –, or of
|
||||
* all that plays where nothing of its type is linked yet. Empty where nothing is, and for a bus.
|
||||
* all that plays where nothing of its type is linked yet. Videos and the music go by each other
|
||||
* apart: a video where no other is linked goes to the master, not where the sounds go. Empty where
|
||||
* nothing is, and for a bus.
|
||||
*/
|
||||
function linksLikeTheirs(
|
||||
kind: string,
|
||||
@@ -159,7 +162,7 @@ function linksLikeTheirs(
|
||||
};
|
||||
const playing = nodes.filter((node) => {
|
||||
const of = routedKind(node);
|
||||
return of !== '' && of !== 'bus' && out.has(node.id);
|
||||
return of !== '' && of !== 'bus' && (of === 'video') === (kind === 'video') && out.has(node.id);
|
||||
});
|
||||
const own = playing.filter((node) => routedKind(node) === kind);
|
||||
return pick(own.length > 0 ? own : playing);
|
||||
|
||||
@@ -41,8 +41,9 @@ export function isSongRoutingDef(def: NodeDef): boolean {
|
||||
}
|
||||
|
||||
/**
|
||||
* The nodes of the master routing (#351): one per sound, instrument, pattern, song and bus of the
|
||||
* project, named and typed after its asset, and the master. Only a bus and the master take links in.
|
||||
* 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';
|
||||
@@ -54,6 +55,7 @@ const KIND_WORDS: Record<string, string> = {
|
||||
instrument: 'Instrument',
|
||||
pattern: 'Pattern',
|
||||
song: 'Song',
|
||||
video: 'Video',
|
||||
bus: 'Bus',
|
||||
};
|
||||
|
||||
@@ -62,7 +64,7 @@ registerNode({
|
||||
label: 'Asset',
|
||||
category: 'sound',
|
||||
description:
|
||||
'A sound, an instrument, a pattern, a song or a bus of the project: all it plays, sent on to every link.',
|
||||
'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: [],
|
||||
|
||||
Reference in new issue
Block a user