Skip to content

Write HTML. Render video. Built for agents.

fix(studio): audition from the playhead while paused, and let an author out of a menu (#3190)

Vance Ingalls6bcf73939084
diff --git a/packages/core/src/audio/audioFxGraph.ts b/packages/core/src/audio/audioFxGraph.ts
index ba34c8b582..3c50ad95ec 100644
--- a/packages/core/src/audio/audioFxGraph.ts
+++ b/packages/core/src/audio/audioFxGraph.ts
@@ -705,7 +705,8 @@ export function buildFxChain(
if (!wrap) continue;
wrap.wet.gain.value = run.amount;
wrap.dry.gain.value = 1 - run.amount;
- } // `shape` is not reassigned: the early return above already established
+ }
+ // `shape` is not reassigned: the early return above already established
// that `shapeOf(next)` equals it, so recomputing was a whole normalise +
// join per observer tick to write back the string that was already there.
return true;
diff --git a/packages/core/src/audioFx.ts b/packages/core/src/audioFx.ts
index 84f48f613f..0e13828648 100644
--- a/packages/core/src/audioFx.ts
+++ b/packages/core/src/audioFx.ts
@@ -843,10 +843,11 @@ export interface HfAudioFxNode {
* the first node of each run. Absent means fully applied, which is what every
* chain written before this means.
*/
- presetAmount?: number /**
+ presetAmount?: number;
+ /**
* Set on the gain stage the leveller writes, so re-running replaces it rather
* than stacking a second one — the same contract `fromCarve` has.
- */;
+ */
fromLeveller?: boolean;
/** Absent means enabled — chain files written before the field existed still load. */
enabled?: boolean;
diff --git a/packages/studio/src/components/editor/propertyPanelAudioFxGroup.test.tsx b/packages/studio/src/components/editor/propertyPanelAudioFxGroup.test.tsx
index 5175f2ffbb..f14ec48eb2 100644
--- a/packages/studio/src/components/editor/propertyPanelAudioFxGroup.test.tsx
+++ b/packages/studio/src/components/editor/propertyPanelAudioFxGroup.test.tsx
@@ -435,6 +435,45 @@ describe("AudioFxGroup dynamic carve", () => {
* nobody asked to level, through a channel that does not persist: audible,
* absent from the document, and gone on the next reload.
*/
+ describe("auditioning starts the transport when it has to", () => {
+ const store = () => usePlayerStore.getState();
+
+ const hoverPreset = (host: HTMLElement) => {
+ act(() => byTextButton(host, "Presets")?.click());
+ act(() => host.querySelector<HTMLElement>(".hf-fx-preset-item")?.focus());
+ };
+ const leaveShelf = (host: HTMLElement) =>
+ act(() => {
+ host
+ .querySelector(".hf-fx-preset-menu")
+ ?.dispatchEvent(new FocusEvent("focusout", { bubbles: true }));
+ });
+
+ it("plays from the playhead, then puts it back exactly where it was", () => {
+ // Browsing the shelf must not cost the author their place: hovering is not
+ // an edit, so the playhead it borrows has to be returned.
+ act(() => usePlayerStore.setState({ isPlaying: false, currentTime: 42 }));
+ const { host } = mount({ "fx-chain": CHAIN });
+ hoverPreset(host);
+ expect(store().playbackRequest?.playing).toBe(true);
+
+ leaveShelf(host);
+ expect(store().playbackRequest?.playing).toBe(false);
+ expect(store().playbackRequest?.returnTo).toBe(42);
+ });
+
+ it("leaves a transport the author started alone", () => {
+ // Stopping their playback because they passed over a preset would be the
+ // panel taking a decision nobody offered it.
+ act(() => usePlayerStore.setState({ isPlaying: true, currentTime: 12 }));
+ const { host } = mount({ "fx-chain": CHAIN });
+ const before = store().playbackRequest?.nonce ?? 0;
+ hoverPreset(host);
+ leaveShelf(host);
+ expect(store().playbackRequest?.nonce ?? 0).toBe(before);
+ });
+ });
+
it("drops a levelling measurement that lands after the pointer has gone", async () => {
const { release, decoded } = stubGatedDecode();
const { host, onSetAttributeLive } = mount({ "fx-chain": CHAIN });
diff --git a/packages/studio/src/components/editor/propertyPanelAudioFxGroup.tsx b/packages/studio/src/components/editor/propertyPanelAudioFxGroup.tsx
index f6c720bf63..d99d045afe 100644
--- a/packages/studio/src/components/editor/propertyPanelAudioFxGroup.tsx
+++ b/packages/studio/src/components/editor/propertyPanelAudioFxGroup.tsx
@@ -578,6 +578,40 @@ export function AudioFxGroup({
}
};
+ /**
+ * Where the playhead was when an audition started the transport, so leaving
+ * can put it back. Null means this audition did not start playback — the
+ * transport was already running and must be left alone.
+ */
+ const auditionReturn = useRef<number | null>(null);
+
+ /**
+ * Start playback for an audition, and stop it again on the way out.
+ *
+ * An audition writes the preset to the running graph, which is silent while
+ * the transport is paused — so a paused author hovering a preset heard
+ * nothing at all, and the whole affordance only worked mid-playback. Hovering
+ * now plays from the playhead, and leaving stops and rewinds to exactly where
+ * it started: browsing the shelf must not cost the author their place.
+ *
+ * Already playing, this does nothing in either direction. The author started
+ * that, and stopping their transport because they passed over a preset would
+ * be the panel taking a decision that was not offered to it.
+ */
+ const auditionTransport = (on: boolean): void => {
+ const store = usePlayerStore.getState();
+ if (on) {
+ if (store.isPlaying || auditionReturn.current !== null) return;
+ auditionReturn.current = store.currentTime;
+ store.requestPlayback(true);
+ return;
+ }
+ const returnTo = auditionReturn.current;
+ if (returnTo === null) return;
+ auditionReturn.current = null;
+ store.requestPlayback(false, returnTo);
+ };
+
const [auditioningLevel, setAuditioningLevel] = useState(false);
/**
* Bumped on every enter and leave, so a measurement can tell whether the
@@ -812,6 +846,7 @@ export function AudioFxGroup({
next.nodes.length ? serializeAudioFxChain(next) : null,
)
}
+ onAuditionTransport={auditionTransport}
onChainPreview={(next) =>
// Live writes skip the preview refresh entirely, so dragging a knob no
// longer reloads the composition and restarts playback on every pixel.
diff --git a/packages/studio/src/components/editor/propertyPanelFxPresetMenu.tsx b/packages/studio/src/components/editor/propertyPanelFxPresetMenu.tsx
index e661024c79..257a3c28de 100644
--- a/packages/studio/src/components/editor/propertyPanelFxPresetMenu.tsx
+++ b/packages/studio/src/components/editor/propertyPanelFxPresetMenu.tsx
@@ -68,7 +68,8 @@ export function FxPresetMenu({ onPick, onAudition }: FxPresetMenuProps) {
<button
key={preset.id}
type="button"
- className="hf-fx-preset-item block w-full rounded-[3px] bg-panel-surface px-1.5 py-1 text-left text-panel-text-1 hover:text-panel-text-0"
+ // `pr-8` so a long complaint does not run under the wave.
+ className="hf-fx-preset-item block w-full rounded-[3px] bg-panel-surface py-1 pl-1.5 pr-8 text-left text-panel-text-1 hover:text-panel-text-0"
// The description says what it does; the count is doing real work
// — it tells the author a preset IS a chain they can open and
// edit, rather than an opaque setting they cannot follow.
@@ -87,6 +88,20 @@ export function FxPresetMenu({ onPick, onAudition }: FxPresetMenuProps) {
<span className="hf-fx-preset-name block truncate font-mono text-[9px] text-panel-text-4">
{preset.label}
</span>
+ {/* Hovering a preset plays it, and playing is otherwise invisible:
+ the panel looks identical whether the audition is sounding or
+ the pointer is just resting there. Only rendered when there IS
+ an audition channel, so it never claims audio that is not
+ happening. Four bars because that reads as a level meter at
+ this size; three reads as an ellipsis. */}
+ {onAudition ? (
+ <span className="hf-fx-preset-wave" aria-hidden="true">
+ <span />
+ <span />
+ <span />
+ <span />
+ </span>
+ ) : null}
</button>
))}
</div>
diff --git a/packages/studio/src/components/editor/propertyPanelFxSection.test.tsx b/packages/studio/src/components/editor/propertyPanelFxSection.test.tsx
index 36090f92a6..d5a0b82609 100644
--- a/packages/studio/src/components/editor/propertyPanelFxSection.test.tsx
+++ b/packages/studio/src/components/editor/propertyPanelFxSection.test.tsx
@@ -90,6 +90,7 @@ function mount(overrides: Partial<Parameters<typeof FxSection>[0]> = {}) {
onRemoveNodeAutomation={overrides.onRemoveNodeAutomation}
onAutomatePreset={overrides.onAutomatePreset}
onRemovePresetAutomation={overrides.onRemovePresetAutomation}
+ onAuditionTransport={overrides.onAuditionTransport}
automatedPresets={overrides.automatedPresets}
onLevel={overrides.onLevel}
onRemoveLevel={overrides.onRemoveLevel}
@@ -563,6 +564,7 @@ describe("FxSection chain", () => {
expect(onRemoveNodeAutomation).toHaveBeenCalled();
});
});
+
it("brackets only nodes a preset still sits next to", () => {
// Pulled apart by a reorder, they are no longer a unit — and a bracket
// around the gap would claim an adjacency the signal path does not have.
@@ -696,6 +698,158 @@ describe("FxSection chain", () => {
expect(item?.querySelector(".hf-fx-preset-name")?.textContent).toBe("Telephone");
});
+ describe("auditioning while the transport is paused", () => {
+ it("starts playback so a paused author can hear the preset at all", () => {
+ // The audition is written to the running graph, which is silent while the
+ // transport is paused — so without this, hovering a preset did nothing
+ // whatsoever unless the author happened to be mid-playback.
+ const onAuditionTransport = vi.fn();
+ const { host } = mount({ chain: chainOf("peaking"), onAuditionTransport });
+ click(byText(host, "button", "Presets"));
+ act(() => (presetButton(host, "telephone") as HTMLElement | null)?.focus());
+ expect(onAuditionTransport).toHaveBeenLastCalledWith(true);
+ });
+
+ it("stops it again on the way out", () => {
+ const onAuditionTransport = vi.fn();
+ const { host } = mount({ chain: chainOf("peaking"), onAuditionTransport });
+ click(byText(host, "button", "Presets"));
+ act(() => (presetButton(host, "telephone") as HTMLElement | null)?.focus());
+ act(() => {
+ host
+ .querySelector(".hf-fx-preset-menu")
+ ?.dispatchEvent(new FocusEvent("focusout", { bubbles: true }));
+ });
+ expect(onAuditionTransport).toHaveBeenLastCalledWith(false);
+ });
+
+ it("stops it when the preset is applied, rather than playing on", () => {
+ // The click means "keep this", not "and carry on playing from wherever
+ // the audition reached".
+ const onAuditionTransport = vi.fn();
+ const { host } = mount({ chain: { version: 1, nodes: [] }, onAuditionTransport });
+ click(byText(host, "button", "Presets"));
+ act(() => (presetButton(host, "telephone") as HTMLElement | null)?.focus());
+ click(presetButton(host, "telephone"));
+ expect(onAuditionTransport).toHaveBeenLastCalledWith(false);
+ });
+
+ it("stops it if the panel goes away mid-audition", () => {
+ const onAuditionTransport = vi.fn();
+ const { host, root } = mount({ chain: chainOf("peaking"), onAuditionTransport });
+ click(byText(host, "button", "Presets"));
+ act(() => (presetButton(host, "telephone") as HTMLElement | null)?.focus());
+ act(() => root.unmount());
+ expect(onAuditionTransport).toHaveBeenLastCalledWith(false);
+ });
+ });
+
+ describe("getting back out of a menu", () => {
+ /** Escape, from inside the section, the way a keystroke really arrives. */
+ const escape = (host: HTMLElement) =>
+ act(() => {
+ host
+ .querySelector(".hf-fx-section")
+ ?.dispatchEvent(new KeyboardEvent("keydown", { key: "Escape", bubbles: true }));
+ });
+
+ it("closes the preset shelf with the button that opened it", () => {
+ // Opening a menu used to hide both buttons, and picking something was the
+ // only thing that set them back — so an author who changed their mind had
+ // to add an effect they did not want, or deselect the clip.
+ const { host } = mount();
+ click(byText(host, "button", "Presets"));
+ expect(host.querySelector(".hf-fx-preset-menu")).toBeTruthy();
+
+ click(byText(host, "button", "Close"));
+ expect(host.querySelector(".hf-fx-preset-menu")).toBeNull();
+ expect(byText(host, "button", "Presets")).toBeTruthy();
+ });
+
+ it("closes the add menu the same way", () => {
+ const { host } = mount();
+ click(host.querySelector(".hf-fx-add"));
+ expect(host.querySelector(".hf-fx-add-menu")).toBeTruthy();
+
+ click(host.querySelector(".hf-fx-add"));
+ expect(host.querySelector(".hf-fx-add-menu")).toBeNull();
+ expect(byText(host, "button", "Add effect")).toBeTruthy();
+ });
+
+ it("opens one menu in place of the other", () => {
+ // Two open at once is two surfaces covering the rack, and neither says
+ // which one the next click belongs to.
+ const { host } = mount();
+ click(byText(host, "button", "Presets"));
+ click(host.querySelector(".hf-fx-add"));
+ expect(host.querySelector(".hf-fx-add-menu")).toBeTruthy();
+ expect(host.querySelector(".hf-fx-preset-menu")).toBeNull();
+
+ // And back the other way, which is a separate handler.
+ click(byText(host, "button", "Presets"));
+ expect(host.querySelector(".hf-fx-preset-menu")).toBeTruthy();
+ expect(host.querySelector(".hf-fx-add-menu")).toBeNull();
+ });
+
+ it("closes on Escape, which is what anyone reaches for first", () => {
+ const { host } = mount();
+ click(byText(host, "button", "Presets"));
+ escape(host);
+ expect(host.querySelector(".hf-fx-preset-menu")).toBeNull();
+
+ click(host.querySelector(".hf-fx-add"));
+ escape(host);
+ expect(host.querySelector(".hf-fx-add-menu")).toBeNull();
+ });
+
+ it("puts the chain back when a closing menu was auditioning", () => {
+ // Leaving the shelf by closing it is still leaving it, and an audition
+ // left playing is audible over a chain the document does not have.
+ const { host, onChainPreview } = mount({ chain: chainOf("peaking") });
+ click(byText(host, "button", "Presets"));
+ act(() => (presetButton(host, "telephone") as HTMLElement | null)?.focus());
+ click(byText(host, "button", "Close"));
+
+ const back = onChainPreview.mock.calls.at(-1)?.[0] as HfAudioFxChain;
+ expect(back.nodes.map((n) => n.type)).toEqual(["peaking"]);
+ });
+
+ it("leaves Escape alone when no menu is open", () => {
+ // The panel has its own Escape handling; swallowing the key when this has
+ // nothing to close would break it.
+ const { host } = mount();
+ let reached = false;
+ host.addEventListener("keydown", () => {
+ reached = true;
+ });
+ escape(host);
+ expect(reached).toBe(true);
+ });
+ });
+
+ it("shows a wave on a preset only when hovering it can be heard", () => {
+ // Hovering plays the preset, and playing is otherwise invisible — the panel
+ // looks identical whether the audition is sounding or the pointer is just
+ // resting there. Without an audition channel there is no audio to claim.
+ const { host } = mount({ chain: { version: 1, nodes: [] } });
+ click(byText(host, "button", "Presets"));
+ expect(presetButton(host, "telephone")?.querySelector(".hf-fx-preset-wave")).toBeTruthy();
+
+ // Rendered directly rather than through `mount`, which supplies a preview
+ // handler by default — the case being covered is a section that has none.
+ const { host: dry } = renderInto(
+ <FxSection
+ chain={{ version: 1, nodes: [] }}
+ onChainChange={vi.fn()}
+ carve={null}
+ onCarveChange={vi.fn()}
+ sourceOptions={[]}
+ />,
+ );
+ click(byText(dry, "button", "Presets"));
+ expect(presetButton(dry, "telephone")?.querySelector(".hf-fx-preset-wave")).toBeNull();
+ });
+
describe("hover-audition", () => {
/** Focus is the keyboard's hover, and both go through the same handler. */
const enter = (el: Element | null | undefined) => {
diff --git a/packages/studio/src/components/editor/propertyPanelFxSection.tsx b/packages/studio/src/components/editor/propertyPanelFxSection.tsx
index fc0c22c1de..6853759fca 100644
--- a/packages/studio/src/components/editor/propertyPanelFxSection.tsx
+++ b/packages/studio/src/components/editor/propertyPanelFxSection.tsx
@@ -5,7 +5,7 @@
* is not an entry in the chain.
*/
-import { useCallback, useEffect, useMemo, useRef, useState } from "react";
+import { useCallback, useEffect, useMemo, useRef, useState, type KeyboardEvent } from "react";
import {
defaultAudioFxParams,
getAudioFxDef,
@@ -68,6 +68,7 @@ const PRESET_AMOUNT_PARAM: HfAudioFxParam = {
default: 1,
hint: "How much of this preset is applied. Automate it to bring the whole preset in or out over time.",
};
+
export interface FxSectionProps {
chain: HfAudioFxChain;
/** Targets this track already automates, as `fx.<nodeId>.<param>` strings. */
@@ -110,6 +111,14 @@ export interface FxSectionProps {
onAuditionLevel?(on: boolean): void;
/** Whether that measurement is running, so the button can say so. */
auditioningLevel?: boolean;
+ /**
+ * Start the transport for an audition, and stop it on the way out.
+ *
+ * An audition is written to the running graph, which is silent while the
+ * transport is paused — so without this, hovering a preset does nothing at all
+ * for a paused author.
+ */
+ onAuditionTransport?(on: boolean): void;
/** Structural edits and gesture-end writes; this is the one that persists. */
onChainChange(chain: HfAudioFxChain): void;
/** Continuous updates while a control is being dragged. */
@@ -155,6 +164,7 @@ export function FxSection({
onAutomatePreset,
onRemovePresetAutomation,
automatedPresets,
+ onAuditionTransport,
}: FxSectionProps) {
const presetAutomated = automatedPresets ?? new Set<string>();
// Falls back to the persisting write when no preview handler is supplied, which
@@ -227,12 +237,18 @@ export function FxSection({
if (make) {
auditionBase.current ??= chain;
onChainPreview(make(auditionBase.current));
+ // After the chain is in the graph, not before: starting the transport
+ // first plays a moment of the un-auditioned mix.
+ onAuditionTransport?.(true);
} else if (auditionBase.current) {
+ // Stop before reverting, for the mirror of that reason — the last thing
+ // heard should be the preset, not a frame of the chain coming back.
+ onAuditionTransport?.(false);
onChainPreview(auditionBase.current);
auditionBase.current = null;
}
},
- [chain, onChainPreview],
+ [chain, onChainPreview, onAuditionTransport],
);
/**
@@ -252,9 +268,14 @@ export function FxSection({
// Leaving by any route other than the pointer — the element deselected, the
// panel closed — would otherwise leave the audition playing over a chain the
// document does not have.
+ const transportRef = useRef(onAuditionTransport);
+ transportRef.current = onAuditionTransport;
useEffect(
() => () => {
- if (auditionBase.current) previewRef.current?.(auditionBase.current);
+ if (auditionBase.current) {
+ transportRef.current?.(false);
+ previewRef.current?.(auditionBase.current);
+ }
},
[],
);
@@ -271,13 +292,14 @@ export function FxSection({
// old chain back over the write that just landed is a race the author
// hears as the preset arriving and then leaving again.
auditionBase.current = null;
+ onAuditionTransport?.(false);
mutate(next.nodes);
// Land on the first node the preset wrote, so the author can hear what
// arrived and immediately see what it is made of.
setOpenNode(next.nodes.findIndex((n) => n.fromPreset === preset.id));
setPicking(false);
},
- [chain, mutate],
+ [chain, mutate, onAuditionTransport],
);
/**
@@ -321,21 +343,23 @@ export function FxSection({
const addJob = useCallback(
(job: HfAudioFxJob) => {
auditionBase.current = null;
+ onAuditionTransport?.(false);
mutate(withJob(chain, job).nodes);
setOpenNode(chain.nodes.length);
setAdding(false);
},
- [chain, mutate, withJob],
+ [chain, mutate, withJob, onAuditionTransport],
);
const addEffect = useCallback(
(type: string) => {
auditionBase.current = null;
+ onAuditionTransport?.(false);
mutate(withEffect(chain, type).nodes);
setOpenNode(chain.nodes.length);
setAdding(false);
},
- [chain, mutate, withEffect],
+ [chain, mutate, withEffect, onAuditionTransport],
);
const updateNode = useCallback(
@@ -457,11 +481,12 @@ export function FxSection({
const addEq = useCallback(() => {
auditionBase.current = null;
+ onAuditionTransport?.(false);
const { chain: next, eqId } = addAudioEq(chain);
mutate(next.nodes);
setOpenEq(eqId);
setAdding(false);
- }, [chain, mutate]);
+ }, [chain, mutate, onAuditionTransport]);
// Dragging a fader is heard immediately and written once on release, the same
// split every other control in the rack uses.
@@ -498,8 +523,34 @@ export function FxSection({
[chain.nodes, mutate],
);
+ /**
+ * Escape closes whichever menu is open.
+ *
+ * The first thing anyone reaches for, and on a surface that covers the rack it
+ * is the one that needs no discovering. Bound on the section rather than the
+ * window: a keystroke aimed at the timeline is not aimed at this.
+ */
+ const closeMenus = useCallback(
+ (event: KeyboardEvent) => {
+ if (event.key !== "Escape" || (!adding && !picking)) return;
+ // Stops the panel's own Escape handling from also firing — closing a menu
+ // and deselecting the clip on one keystroke loses the author their place.
+ event.stopPropagation();
+ audition(null);
+ onAuditionLevel?.(false);
+ setAdding(false);
+ setPicking(false);
+ },
+ [adding, picking, audition, onAuditionLevel],
+ );
+
return (
- <div className="hf-fx-section space-y-2">
+ <div
+ className="hf-fx-section space-y-2"
+ // Focus lives on the buttons and menu items inside, so the keystroke
+ // bubbles to here without the section needing focus of its own.
+ onKeyDown={closeMenus}
+ >
<div className="hf-fx-chain space-y-1">
{/* The rack IS the signal path, and saying so costs two lines. Without
them the order reads as a list, which is the one reading that makes
@@ -790,26 +841,44 @@ export function FxSection({
/>
) : null}
- {adding || picking ? null : (
- <div className="flex gap-1">
- <button
- type="button"
- className="hf-fx-preset w-full rounded-[4px] border border-dashed border-panel-border-input py-1 text-[11px] text-panel-text-4 hover:text-panel-text-0 disabled:opacity-40"
- disabled={disabled}
- onClick={() => setPicking(true)}
- >
- Presets
- </button>
- <button
- type="button"
- className="hf-fx-add w-full rounded-[4px] border border-dashed border-panel-border-input py-1 text-[11px] text-panel-text-4 hover:text-panel-text-0 disabled:opacity-40"
- disabled={disabled}
- onClick={() => setAdding(true)}
- >
- Add effect
- </button>
- </div>
- )}
+ {/* The buttons stay while their menu is open, and close it — an author who
+ opened one and changed their mind had no way back: picking something
+ was the only thing that set these false, so the only exits were adding
+ an effect they did not want or deselecting the clip. */}
+ <div className="flex gap-1">
+ <button
+ type="button"
+ className="hf-fx-preset w-full rounded-[4px] border border-dashed border-panel-border-input py-1 text-[11px] text-panel-text-4 hover:text-panel-text-0 disabled:opacity-40"
+ aria-expanded={picking}
+ disabled={disabled}
+ onClick={() => {
+ // Leaving the shelf by closing it is still leaving it, and an
+ // audition left playing is audible over a chain the document does
+ // not have.
+ if (picking) audition(null);
+ setPicking(!picking);
+ setAdding(false);
+ }}
+ >
+ {picking ? "Close" : "Presets"}
+ </button>
+ <button
+ type="button"
+ className="hf-fx-add w-full rounded-[4px] border border-dashed border-panel-border-input py-1 text-[11px] text-panel-text-4 hover:text-panel-text-0 disabled:opacity-40"
+ aria-expanded={adding}
+ disabled={disabled}
+ onClick={() => {
+ if (adding) {
+ audition(null);
+ onAuditionLevel?.(false);
+ }
+ setAdding(!adding);
+ setPicking(false);
+ }}
+ >
+ {adding ? "Close" : "Add effect"}
+ </button>
+ </div>
</div>
);
}
diff --git a/packages/studio/src/player/hooks/useTimelinePlayer.ts b/packages/studio/src/player/hooks/useTimelinePlayer.ts
index b53efd3f36..2faff57a2b 100644
--- a/packages/studio/src/player/hooks/useTimelinePlayer.ts
+++ b/packages/studio/src/player/hooks/useTimelinePlayer.ts
@@ -389,8 +389,20 @@ export function useTimelinePlayer() {
seek(state.requestedSeekTime);
usePlayerStore.getState().clearSeekRequest();
}
+ // Play or stop from outside the loop — the FX rack auditioning a preset
+ // while paused, which is silent otherwise. `returnTo` puts the playhead
+ // back where the request found it: hovering is not an edit.
+ const request = state.playbackRequest;
+ if (request && request.nonce !== prev.playbackRequest?.nonce) {
+ if (request.playing) play();
+ else {
+ pause();
+ if (request.returnTo !== null) seek(request.returnTo);
+ }
+ usePlayerStore.getState().clearPlaybackRequest();
+ }
});
- }, [seek]);
+ }, [seek, play, pause]);
const { playbackKeyDownRef, playbackKeyUpRef, attachIframeShortcutListeners, togglePlay } =
usePlaybackKeyboard({
iframeRef,
diff --git a/packages/studio/src/player/store/playerStore.ts b/packages/studio/src/player/store/playerStore.ts
index 4523d85771..966a031fbc 100644
--- a/packages/studio/src/player/store/playerStore.ts
+++ b/packages/studio/src/player/store/playerStore.ts
@@ -166,6 +166,32 @@ interface PlayerState extends KeyframeSlice, AutomationSelectionSlice, Thumbnail
requestSeek: (time: number) => void;
clearSeekRequest: () => void;
+ /**
+ * Request the transport start or stop from outside the player loop.
+ *
+ * The FX rack auditions a preset by writing it to the running graph, which is
+ * silent while the transport is paused — so hovering one has to start
+ * playback, and leaving has to put the playhead back where it was. Hovering is
+ * not an edit and must not cost the author their place.
+ *
+ * A nonce rather than a bare boolean: two hovers in a row both want play, and
+ * without it the second request is indistinguishable from the first having
+ * already been served.
+ */
+ playbackRequest: { playing: boolean; returnTo: number | null; nonce: number } | null;
+ requestPlayback: (playing: boolean, returnTo?: number | null) => void;
+ clearPlaybackRequest: () => void;
+
+ /**
+ * Request the timeline to scroll a clip into view (e.g. clicking an
+ * already-added asset card in the sidebar). Consumed and cleared by
+ * useTimelineRevealClip. The nonce makes repeat requests for the same
+ * clip observable so a second click re-reveals after the user scrolls away.
+ */
+ clipRevealRequest: { elementId: string; nonce: number } | null;
+ requestClipReveal: (elementId: string) => void;
+ clearClipRevealRequest: () => void;
+
timelineFocus: TimelineFocusRequest | null;
timelineFocusNonce: number;
requestTimelineFocus: (id: string) => void;
@@ -322,6 +348,20 @@ export const usePlayerStore = create<PlayerState>((set, get) => ({
requestSeek: (time) => set({ requestedSeekTime: time }),
clearSeekRequest: () => set({ requestedSeekTime: null }),
+ playbackRequest: null,
+ requestPlayback: (playing, returnTo = null) =>
+ set((s) => ({
+ playbackRequest: { playing, returnTo, nonce: (s.playbackRequest?.nonce ?? 0) + 1 },
+ })),
+ clearPlaybackRequest: () => set({ playbackRequest: null }),
+
+ clipRevealRequest: null,
+ requestClipReveal: (elementId) =>
+ set((s) => ({
+ clipRevealRequest: { elementId, nonce: (s.clipRevealRequest?.nonce ?? 0) + 1 },
+ })),
+ clearClipRevealRequest: () => set({ clipRevealRequest: null }),
+
timelineFocus: null,
timelineFocusNonce: 0,
requestTimelineFocus: (id) =>
diff --git a/packages/studio/src/styles/studio.css b/packages/studio/src/styles/studio.css
index 50e3a02fe9..ed97c1eb6e 100644
--- a/packages/studio/src/styles/studio.css
+++ b/packages/studio/src/styles/studio.css
@@ -469,3 +469,92 @@ body {
animation: none;
}
}
+
+/* Preset shelf: the hovered row, and the wave that says it is being heard.
+ *
+ * Hovering a preset auditions it on the running audio, which is invisible — the
+ * panel looks identical whether the audition is playing or the pointer just
+ * happens to be resting there. The bars are that feedback: they run only while a
+ * preset is actually sounding, so they are a readout of the audio rather than a
+ * hover decoration. */
+.hf-fx-preset-item {
+ position: relative;
+}
+
+@media (prefers-reduced-motion: no-preference) {
+ .hf-fx-preset-item {
+ transition:
+ background-color 120ms ease,
+ color 120ms ease;
+ }
+}
+
+.hf-fx-preset-item:hover,
+.hf-fx-preset-item:focus-visible {
+ /* The accent at low alpha rather than a grey: the row is lit by the thing that
+ is playing, and it should read as the same event as the bars. */
+ background-color: rgba(60, 230, 172, 0.12);
+}
+
+.hf-fx-preset-wave {
+ position: absolute;
+ top: 50%;
+ right: 0.5rem;
+ display: flex;
+ align-items: center;
+ gap: 2px;
+ height: 0.75rem;
+ transform: translateY(-50%);
+ opacity: 0;
+ transition: opacity 120ms ease;
+ pointer-events: none;
+}
+
+.hf-fx-preset-item:hover .hf-fx-preset-wave,
+.hf-fx-preset-item:focus-visible .hf-fx-preset-wave {
+ opacity: 1;
+}
+
+.hf-fx-preset-wave span {
+ width: 2px;
+ height: 100%;
+ border-radius: 1px;
+ background: #3ce6ac;
+ transform: scaleY(0.25);
+ transform-origin: center;
+}
+
+@media (prefers-reduced-motion: no-preference) {
+ .hf-fx-preset-wave span {
+ animation: hf-fx-preset-wave 900ms ease-in-out infinite;
+ }
+ /* Staggered so it reads as a waveform travelling rather than four bars
+ pumping in unison, which reads as a loading spinner. */
+ .hf-fx-preset-wave span:nth-child(2) {
+ animation-delay: 150ms;
+ }
+ .hf-fx-preset-wave span:nth-child(3) {
+ animation-delay: 300ms;
+ }
+ .hf-fx-preset-wave span:nth-child(4) {
+ animation-delay: 450ms;
+ }
+}
+
+/* Still visible without motion — it is telling the author something is
+ playing, and that fact does not go away because the bars hold still. */
+@media (prefers-reduced-motion: reduce) {
+ .hf-fx-preset-wave span {
+ transform: scaleY(0.7);
+ }
+}
+
+@keyframes hf-fx-preset-wave {
+ 0%,
+ 100% {
+ transform: scaleY(0.25);
+ }
+ 50% {
+ transform: scaleY(1);
+ }
+}