merge: pull in the main-merge conflict fix

This commit is contained in:
Vance Ingalls
2026-08-12 16:01:10 -07:00
2 changed files with 35 additions and 2 deletions
+12
View File
@@ -69,6 +69,18 @@ function readChain(el: { getAttribute?(name: string): string | null }): {
}
}
/**
* An element's automation lanes, bound to whatever chain it carries.
*
* FX lanes need the chain to resolve their target's range, so they are dropped
* for an element with no chain; a volume lane is always readable.
*/
export function readElementAutomation(el: {
getAttribute?(name: string): string | null;
}): HfAutomation {
return readAutomation(el, readChain(el).chain);
}
/**
* Splice an element's FX chain between a decoded source and its gain stage.
*
+23 -2
View File
@@ -1,5 +1,10 @@
import { attachElementFxChain, type ElementFxHandle } from "./audioFx.js";
import type { AutomationTiming } from "../audio/audioFxAutomation.js";
import { attachElementFxChain, readElementAutomation, type ElementFxHandle } from "./audioFx.js";
import {
scheduleParamLane,
volumeLane,
type AutomationTiming,
} from "../audio/audioFxAutomation.js";
import { VOLUME_RANGE } from "../audioAutomation.js";
import { swallow } from "./diagnostics";
import { getDebugSurface } from "./globals.js";
@@ -58,6 +63,20 @@ function startBoundedSource(
return true;
}
/**
* The volume lane rides the fader, after the effects — where a DAW puts it,
* and the order the render bakes it in.
*/
function scheduleVolumeLane(
el: HTMLMediaElement,
gainNode: GainNode,
timing: AutomationTiming,
): void {
const lane = volumeLane(readElementAutomation(el));
if (!lane) return;
scheduleParamLane([{ param: gainNode.gain }], lane, VOLUME_RANGE.scale, timing);
}
export type ScheduledSource = {
el: HTMLMediaElement;
sourceNode: AudioBufferSourceNode;
@@ -200,6 +219,8 @@ export class WebAudioTransport {
const fx = attachElementFxChain(this._ctx, el, sourceNode, gainNode, timing);
gainNode.connect(this._masterGain);
scheduleVolumeLane(el, gainNode, timing);
this._rate = safeRate;
this._rateAnchorCtx = scheduledAt;
this._rateAnchorComp = compositionTime;