Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/147.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Preserve composition audio beds in loop and scrub head-only composition modes.
3 changes: 3 additions & 0 deletions src/runtime/scene-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1584,6 +1584,9 @@ export function createSceneLoader(options: SceneLoaderOptions): SceneLoader {
id: resolved.composition.id,
manifestSlice: Object.freeze([headEntry]),
sceneSlice: Object.freeze([headScene]),
...(resolved.composition.audioBed === undefined
? {}
: { audioBed: resolved.composition.audioBed }),
// PUL-F029 / ADR-028: preserve the absolute composition start
// index even when the slice is truncated to its head, so a
// failure diagnostic names the right manifest entry.
Expand Down
3 changes: 3 additions & 0 deletions src/runtime/scene-navigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,9 @@ function truncateToHead(target: SceneNavigationTarget, headOnly: boolean): Scene
id: target.composition.id,
manifestSlice: Object.freeze([headEntry]),
sceneSlice: Object.freeze([headScene]),
...(target.composition.audioBed === undefined
? {}
: { audioBed: target.composition.audioBed }),
// PUL-F029 / ADR-028: preserve the absolute composition start
// index so a failure diagnostic still points operators at the
// right manifest entry even after the slice was truncated to
Expand Down
30 changes: 30 additions & 0 deletions tests/runtime/scene-loader-audio.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,7 @@ describe('scene loader — audio service wiring (PUL-F024 / ADR-004)', () => {
const head = buildScene({
id: 'head',
assets: ['/audio/head.mp3'],
audio: ['/audio/head.mp3'],
create: (ctx) => {
// Would register a sound — but prompter never mounts the scene.
(ctx as { audio: AudioService }).audio.load('head-bed', { src: '/audio/head.mp3' });
Expand Down Expand Up @@ -1233,6 +1234,35 @@ describe('scene loader — composition audio bed (PUL-F014 / ADR-004)', () => {
expect(audio.calls.some((c) => c.method === 'loop')).toBe(true);
});

it.each(['loop', 'scrub'] as const)(
'preserves and starts the composition audio bed under mode=%s head slices',
async (mode) => {
const audio = recordingAudioEngine();
const { adapter } = buildRecordingUnlockAdapter('resolve');
const loader = createSceneLoader({
scenes: createSceneRegistry([buildScene({ id: 'head' })]),
compositions: bedComposition(),
stage: null,
buildCtx: stubCtx,
createPreloader: () => () => Promise.resolve(),
timeline: noopTimeline,
audioEngine: audio.engine,
audioUnlockAdapter: adapter,
});

await loader.handle({
locator: { kind: 'composition', composition: 'deck' },
mode,
});
await loader.idle();

expect(audio.created).toHaveLength(1);
expect(audio.created[0]?.src).toEqual([BED_SRC]);
expect(audio.calls).toContainEqual({ sound: 0, method: 'play' });
expect(audio.calls).toContainEqual({ sound: 0, method: 'loop' });
},
);

it('suppresses the composition audio bed under mode=standalone', async () => {
const audio = recordingAudioEngine();
const loader = createSceneLoader({
Expand Down
Loading