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
@@ -4,8 +4,8 @@
|
||||
* same clip share a player and show the same picture.
|
||||
*
|
||||
* In the editor a video plays without sound, as a preview. A run starts every player over at its
|
||||
* clip's start and lets it be heard through the master bus; a pause holds them, and the end of the
|
||||
* run makes them quiet previews again.
|
||||
* clip's start and lets it be heard along the master routing of its video; a pause holds them, and
|
||||
* the end of the run makes them quiet previews again.
|
||||
*
|
||||
* A sprite whose Video clock is driven (#404) has a player of its own instead, which shows the
|
||||
* picture at its Video time and leaves runs and pauses to it (see `wear` and `videoFollow.ts`).
|
||||
@@ -50,12 +50,18 @@ function frameTime(): number {
|
||||
return typeof now === 'number' ? now : performance.now();
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether a wearer lets its video be heard: in a game along the master routing of the video, in a
|
||||
* preview of a tab straight into the master, as every tab's preview is (#368).
|
||||
*/
|
||||
export type VideoHearing = 'none' | 'preview' | 'game';
|
||||
|
||||
/** What the wearer of a driven player (#404) asks of it, see `wear`; its seeks, see `videoSeek.ts`. */
|
||||
interface Drive extends SeekChase {
|
||||
/** Seconds into the clip. */
|
||||
time: number;
|
||||
/** Whether the wearer lets it be heard, when it plays at about 1x. */
|
||||
heard: boolean;
|
||||
/** Whether and how the wearer lets it be heard, when it plays at about 1x. */
|
||||
heard: VideoHearing;
|
||||
reading: SpeedReading | null;
|
||||
}
|
||||
|
||||
@@ -64,7 +70,7 @@ interface Player {
|
||||
element: HTMLVideoElement;
|
||||
/** Made once the video has shown its first frame, see `openVideo`. */
|
||||
texture: Texture | null;
|
||||
/** The sound on its way into the master, made the first time a run lets it be heard. */
|
||||
/** The sound on its way into its bus, made the first time a run lets it be heard. */
|
||||
gain: GainNode | null;
|
||||
gone: boolean;
|
||||
/** When a sprite last asked for its picture, by `performance.now()`. */
|
||||
@@ -110,7 +116,7 @@ export class VideoLibrary {
|
||||
* as an ask: a sprite switched off wears its player without drawing it, and one let go for that
|
||||
* loaded again when it was switched back on, white until then.
|
||||
*/
|
||||
wear(ref: TextureRef, props: PropertyBag, wearer: string, heard: boolean): TextureRef {
|
||||
wear(ref: TextureRef, props: PropertyBag, wearer: string, heard: VideoHearing): TextureRef {
|
||||
if (!videoDrivenOf(props) || !isVideoKey(ref.file)) return ref;
|
||||
const key = drivenVideoKey(ref.file, wearer);
|
||||
const time = videoTimeOf(props);
|
||||
@@ -196,7 +202,7 @@ export class VideoLibrary {
|
||||
return;
|
||||
}
|
||||
if (Math.abs(element.playbackRate - step.rate) > 0.001) element.playbackRate = step.rate;
|
||||
if (step.heard && drive.heard) this.hear(player);
|
||||
if (step.heard && drive.heard !== 'none') this.hear(player, drive.heard === 'game');
|
||||
else element.muted = true;
|
||||
if (element.paused) void element.play().catch(() => {});
|
||||
}
|
||||
@@ -261,7 +267,7 @@ export class VideoLibrary {
|
||||
const play = parseVideoKey(key);
|
||||
if (!play) return null;
|
||||
const drive: Drive | null = isDrivenVideoKey(key)
|
||||
? { time, heard: false, reading: null, wanted: null, landing: false }
|
||||
? { time, heard: 'none', reading: null, wanted: null, landing: false }
|
||||
: null;
|
||||
const at = drive ? drivenTimeOf(play, time, NaN) : play.start;
|
||||
const player: Player = {
|
||||
@@ -321,8 +327,9 @@ export class VideoLibrary {
|
||||
element.requestVideoFrameCallback(check);
|
||||
}
|
||||
|
||||
private hear(player: Player): void {
|
||||
player.gain ??= soundLibrary.mediaInput(player.element);
|
||||
/** Along the master routing of its video where `routed`, else straight into the master. */
|
||||
private hear(player: Player, routed = true): void {
|
||||
player.gain ??= soundLibrary.mediaInput(player.element, player.play.file, routed);
|
||||
if (player.gain) player.gain.gain.value = player.play.volume;
|
||||
player.element.muted = false;
|
||||
}
|
||||
@@ -335,7 +342,7 @@ export class VideoLibrary {
|
||||
private drop(player: Player): void {
|
||||
player.gone = true;
|
||||
player.element.pause();
|
||||
player.gain?.disconnect();
|
||||
if (player.gain) soundLibrary.releaseMedia(player.gain);
|
||||
player.element.removeAttribute('src');
|
||||
player.element.load();
|
||||
// The texture itself stays whole: a wearer that has not synced since still draws it, and a
|
||||
|
||||
Reference in new issue
Block a user