Skip to content

Commit c187af0

Browse files
committed
fix(studio): keep timeline preset apply off auditions
1 parent fe15c0f commit c187af0

2 files changed

Lines changed: 18 additions & 3 deletions

File tree

‎packages/studio/src/components/editor/TimelineFxPopover.tsx‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,11 @@ export function TimelineFxPopover({
9191
onOpenRack,
9292
}: TimelineFxPopoverProps) {
9393
const rootRef = useRef<HTMLDivElement | null>(null);
94-
const { audition, clearAudition } = useFxAudition(chain, onChainPreview, onAuditionTransport);
94+
const { audition, clearAudition, storedChain } = useFxAudition(
95+
chain,
96+
onChainPreview,
97+
onAuditionTransport,
98+
);
9599

96100
// Outside click dismisses like any other popover; the button itself is
97101
// excluded by pointerdown timing (the button's own click hasn't happened yet).
@@ -104,7 +108,7 @@ export function TimelineFxPopover({
104108
}, [onClose]);
105109

106110
const applyPreset = (id: string) => {
107-
const next = applyPresetToChain(chain, id, trackKind);
111+
const next = applyPresetToChain(storedChain(), id, trackKind);
108112
if (!next) return;
109113
clearAudition();
110114
onChainChange(next);

‎packages/studio/src/components/editor/useFxAudition.ts‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,17 @@ export function useFxAudition(
5252
[chain, onChainPreview, onAuditionTransport],
5353
);
5454

55+
/**
56+
* The chain as the DOCUMENT has it, ignoring whatever is being auditioned.
57+
*
58+
* An audition writes through the preview channel, and the `chain` prop is
59+
* read back from that same live attribute — so mid-hover it is the hovered
60+
* preset, not the stored chain. Applying on top of it stacked the auditioned
61+
* preset into the saved chain: hover a reverb, click a different preset, and
62+
* both were persisted, which is heard as the effect running twice.
63+
*/
64+
const storedChain = useCallback(() => auditionBase.current ?? chain, [chain]);
65+
5566
/**
5667
* Drop whatever is being auditioned WITHOUT reverting the preview, for a
5768
* caller that is about to mutate the real chain anyway — reverting first
@@ -91,5 +102,5 @@ export function useFxAudition(
91102
[],
92103
);
93104

94-
return { audition, clearAudition };
105+
return { audition, clearAudition, storedChain };
95106
}

0 commit comments

Comments
 (0)