Skip to content

Commit ccaa33d

Browse files
committed
merge: pull in the main-merge conflict fix
2 parents bc22dab + 9094910 commit ccaa33d

2 files changed

Lines changed: 35 additions & 2 deletions

File tree

packages/core/src/runtime/audioFx.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,18 @@ function readChain(el: { getAttribute?(name: string): string | null }): {
6969
}
7070
}
7171

72+
/**
73+
* An element's automation lanes, bound to whatever chain it carries.
74+
*
75+
* FX lanes need the chain to resolve their target's range, so they are dropped
76+
* for an element with no chain; a volume lane is always readable.
77+
*/
78+
export function readElementAutomation(el: {
79+
getAttribute?(name: string): string | null;
80+
}): HfAutomation {
81+
return readAutomation(el, readChain(el).chain);
82+
}
83+
7284
/**
7385
* Splice an element's FX chain between a decoded source and its gain stage.
7486
*

packages/core/src/runtime/webAudioTransport.ts

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1-
import { attachElementFxChain } from "./audioFx.js";
2-
import type { AutomationTiming } from "../audio/audioFxAutomation.js";
1+
import { attachElementFxChain, readElementAutomation } from "./audioFx.js";
2+
import {
3+
scheduleParamLane,
4+
volumeLane,
5+
type AutomationTiming,
6+
} from "../audio/audioFxAutomation.js";
7+
import { VOLUME_RANGE } from "../audioAutomation.js";
38
import { swallow } from "./diagnostics";
49
import { getDebugSurface } from "./globals.js";
510

@@ -58,6 +63,20 @@ function startBoundedSource(
5863
return true;
5964
}
6065

66+
/**
67+
* The volume lane rides the fader, after the effects — where a DAW puts it,
68+
* and the order the render bakes it in.
69+
*/
70+
function scheduleVolumeLane(
71+
el: HTMLMediaElement,
72+
gainNode: GainNode,
73+
timing: AutomationTiming,
74+
): void {
75+
const lane = volumeLane(readElementAutomation(el));
76+
if (!lane) return;
77+
scheduleParamLane([{ param: gainNode.gain }], lane, VOLUME_RANGE.scale, timing);
78+
}
79+
6180
export type ScheduledSource = {
6281
el: HTMLMediaElement;
6382
sourceNode: AudioBufferSourceNode;
@@ -200,6 +219,8 @@ export class WebAudioTransport {
200219
const fx = attachElementFxChain(this._ctx, el, sourceNode, gainNode, timing);
201220
gainNode.connect(this._masterGain);
202221

222+
scheduleVolumeLane(el, gainNode, timing);
223+
203224
this._rate = safeRate;
204225
this._rateAnchorCtx = scheduledAt;
205226
this._rateAnchorComp = compositionTime;

0 commit comments

Comments
 (0)