feat: one knob for the five effects that cannot honestly have one (#3188)

* fix(studio): close the typecheck and fallow gaps wa-18b-reschedule opened

useAutomationLanes.ts's write() assumed gesture-scoped coalescing and a
preview-only commit that useDomEditAttributeCommits.ts never grew — backported
that option support from its own later commit so the two sides of the API
agree. The paste path and its tests were missing the box selection's v0/v1
bounds a sibling commit added to AutomationSelection. The FX panel's carve
controls still edited the six mechanism numbers (maxCutDb, bands,
intelligibilityBias) after carveProfile() collapsed authoring to one Strength
knob, so those fields no longer existed on HfCarveSettings; UI now edits
strength, and analyseCarveBands is called with carveProfile(strength).

Also closes fallow's complexity, dead-code and duplication findings on this
PR's diff: extracted automationLaneDragMath.ts (pure group/point-move math)
and useAutomationRangeDrag.ts (the marquee-select gesture) out of
useAutomationLaneGestures.ts, pulled a couple of render-loop ternaries and a
resolver into named functions, dropped an export nothing outside its file
used, and shared a step-simplifier between audioCarve's two envelope
builders.

The edge-stretch vs. box-select priority test in TimelineAutomationLane.test
was still pinning the pre-box-select rule (edge wins over a point sitting on
it) that a sibling commit deliberately reversed — a point inside the box is
now selected content, so grabbing it drags the group instead. Updated the
test to the shipped rule instead of the old one.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix(core): cap the via conic's weight so an edge-clamped via point can't NaN

A via point pulled out past the segment (viaX: 5, viaY: -3) clamps to
(0.999, 0.001) — exactly on the steady region's edge, where edge - viaX is 0.
viaConic divided by that zero to get an infinite weight, and shapeVia turned
Infinity into NaN a few steps later (Infinity - Infinity in the quadratic
coefficient). NaN reaching setValueCurveAtTime silences the automated
parameter for the rest of the render.

Capped the weight at 1e6 instead of leaving it unbounded — past that point
the arc already reads as touching the via point, so nothing visible is lost.
Also hardened shapeVia's existing denominator guard (`<= 0`) to `!(> 0)`,
since NaN fails the original comparison and fell through it.

Review by Miga (PR #3208).

* fix(studio-server): fingerprint the proactive waveform cache key too

The route already keys the waveform cache on the asset's size and mtime as
well as its path, so a rebuilt-in-place file gets fresh peaks instead of
stale ones. generateWaveformCache — the proactive path that runs on upload —
still called buildWaveformCacheKey with the path alone, so it wrote to a
different key than the route reads from (making the pre-generated cache
never found) and kept the exact collision bug this fingerprint exists to fix
on its own path.

Review by Miga (PR #3211).

* style(docs): run oxfmt on the /hyperframes-audio skill docs

Table column widths had drifted out of alignment with oxfmt's own rules,
failing format:check and blocking the Preflight gate every downstream
branch inherits. Whitespace only, no content change.

* fix(core): stop \b from missing underscore-separated names, guard clipsOverlap's negative duration

\b treats `_` as a word character, so \bbed\b never matched bed_01,
music_bed_loop, or theme_song, and \bvo\b/\bvox\b/\btts\b had the same gap —
an underscore-separated bed classified as "unknown" and could end up offered
as its own carve source. Replaced the short hints with a boundary that
actually excludes letters and digits on both sides.

clipsOverlap computed end = start + duration without guarding sign, so a
negative duration put end before start — an interval that does not describe
anything, and one specific case showed it silently dropping a real overlap
(a shorter, earlier broken end rejected a clip that genuinely contained the
point). Duration clamps to zero instead: a clip cannot un-play time, and a
zero-length clip at its start is the sane reading of "duration nobody wrote
down as positive."

Review by Miga (PR #3212).

* fix(studio): widen PropertyPanel's resetModules render timeout again

The 20s margin (already once widened for the same reason) is timing out in
CI's full-monorepo Test run — the resetModules()+fresh-import render this
test needs is uncached and competes with every other package's test suite
for the same worker pool, and the same test passes in well under 2s
standalone. Went to 45s rather than re-tuning to whatever number happens to
clear the current CI load, since that number moves every time CI gains a
package.

* fix(studio): stop the single-candidate auto-apply carve firing twice

Two auto-apply effects both fire when sourceOptions.length === 1: the
multi-candidate effect only guards length === 0, so a single candidate
passes it too, and the single-candidate effect passes its own guard right
after — both compute the same sources list and both call setCarve, so the
common case (one narrator, one bed) triggered two decodes, two FFT runs, and
two concurrent attribute writes for one decision.

The multi-candidate effect now defers to its sibling for exactly one
candidate, which already has its own detailed handling for that case.

Review by Miga (PR #3213).

* feat(core): carve against every voice over a bed, always (#3212)

* feat(core): carve against every voice over a bed, always dynamically

A bed usually runs under a whole sequence — a narrator, an interview answer, a
second presenter — and carving against one of them left the others fighting it.
`source` becomes `sources`, and `mixCarveSources` sums every voice onto the BED's
clock before anything is measured. That is what keeps one analysis sufficient: the
chain is fixed, so there is no per-voice filter to switch between, and bands drawn
from all the speech there is with envelopes that rise wherever any of it happens
answer the actual question — where and when is speech masking this bed.

Summed rather than averaged: two people talking at once mask more than either
alone. Audio before the bed starts is dropped rather than folded in at zero, since
it plays over nothing and shifting it would put a cut where there is no voice.

`dynamic` is gone. A fixed depth thins the bed through every pause, and once both
have been heard there is no reason to want it, so every carve follows the speech.

Two helpers the panel and the headless script now share instead of each carrying a
copy — two definitions of "what does this name suggest" drift, and then the two
disagree about which track is the voice:

- `classifyAudioName` reads a track's kind from its id and filename together.
  `unknown` is deliberately common: treating an unrecognised name as "not a voice"
  would hide the one track somebody needs to pick.
- `clipsOverlap` keeps out a voice that never plays while the bed does. An unwritten
  duration counts as unbounded, not zero — refusing a clip whose length the
  composition leaves to the media would drop the commonest case there is.

Files written before this still load: a single `source` reads as a one-voice list,
a stored `dynamic` is ignored, and an absent attribute means the defaults whole.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix(core): stop \b from missing underscore-separated names, guard clipsOverlap's negative duration

\b treats `_` as a word character, so \bbed\b never matched bed_01,
music_bed_loop, or theme_song, and \bvo\b/\bvox\b/\btts\b had the same gap —
an underscore-separated bed classified as "unknown" and could end up offered
as its own carve source. Replaced the short hints with a boundary that
actually excludes letters and digits on both sides.

clipsOverlap computed end = start + duration without guarding sign, so a
negative duration put end before start — an interval that does not describe
anything, and one specific case showed it silently dropping a real overlap
(a shorter, earlier broken end rejected a clip that genuinely contained the
point). Duration clamps to zero instead: a clip cannot un-play time, and a
zero-length clip at its start is the sane reading of "duration nobody wrote
down as positive."

Review by Miga (PR #3212).

---------

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix(studio): port the carve UI off the removed source/dynamic fields

#3212 (accidentally squash-merged into this branch instead of main) changed
HfCarveSettings from a single `source` + `dynamic` toggle to a `sources`
list with dynamic mode removed outright — the multi-voice UI consumer that
goes with that shape lands in the very next PR, so this branch was left with
a type that no longer matched its own code.

Minimal port, not the multi-voice redesign that PR does properly: the
"Listen to" picker and analyse() treat sources[0] as the one voice this UI
still understands, and every dynamic-mode branch (the automated envelope
lanes, the toggle, the checkbox) is gone along with the field — a carve is
now always the static value the analysis computes, matching what the type
change made permanent. Test suite trimmed the same way: the automation-lane
and toggle tests covered behavior that no longer exists.

---------

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Vance Ingalls
2026-08-13 12:07:37 -07:00
committed by GitHub
co-authored by Claude Opus 5
parent 2020b82c9b
commit 29f516d490
7 changed files with 504 additions and 22 deletions
@@ -16,11 +16,17 @@ import {
getAudioFxDef,
type HfAudioFxDef,
type HfAudioFxNode,
type HfAudioFxParam,
type HfAudioFxParamValues,
} from "@hyperframes/core/audio-fx";
import { EFFECT_COPY, SUMMARY } from "@hyperframes/core/audio-fx-copy";
import {
applyAudioFxProfile,
audioFxProfileStrength,
getAudioFxProfile,
} from "@hyperframes/core/audio-fx-profiles";
import { fxAutomationTarget } from "@hyperframes/core/audio-automation";
import { FxParams } from "./propertyPanelFxControls.js";
import { FxParams, FxParamRow } from "./propertyPanelFxControls.js";
import { FxBandRuler } from "./propertyPanelFxBandRuler.js";
import { FX_FAMILY_TYPE, fxFamilyOf, fxFamilyTint } from "./propertyPanelFxFamily.js";
@@ -40,13 +46,37 @@ import { FX_FAMILY_TYPE, fxFamilyOf, fxFamilyTint } from "./propertyPanelFxFamil
*/
function primaryParamOf(def: HfAudioFxDef): string | null {
const primary = EFFECT_COPY[def.id]?.primary;
// "strength" names no parameter, which is exactly what makes this work: the
// day `PROFILES` ships and a derived `strength` knob really is in the
// registry, this starts using it without being told.
if (!primary) return null;
// "strength" names no real parameter, and for the five effects that declare it
// that is the point: their one knob is derived, and `profileRow` below builds
// it. Anything else has to be a parameter the effect actually has.
if (!primary || primary === "strength") return null;
return def.params.some((p) => p.key === primary) ? primary : null;
}
/**
* The derived knob, as a parameter the existing controls can render.
*
* A profile is not in the registry — it sets five real parameters and is none of
* them — so this fabricates the one row it needs rather than teaching `FxParams`
* about a second kind of control. 0..1 in hundredths, the same shape and the
* same feel as the carve's Strength.
*/
function profileParam(type: string): HfAudioFxParam | null {
const profile = getAudioFxProfile(type);
if (!profile) return null;
return {
kind: "number",
key: "strength",
label: profile.label,
unit: "",
min: 0,
max: 1,
step: 0.01,
default: 0.5,
hint: `Sets ${profile.derives.length} settings at once. Open Details to see where they land.`,
};
}
/**
* The registry's definition with the plain names written over it.
*
@@ -292,6 +322,15 @@ export function FxNodeRow({
const registryDef = getAudioFxDef(node.type);
const def = useMemo(() => (registryDef ? plainDef(registryDef) : null), [registryDef]);
const primary = registryDef ? primaryParamOf(registryDef) : null;
/**
* The derived knob, for a module with no real parameter that can be its face.
*
* It behaves like the primary one everywhere below — one control on the open
* face, everything it sets behind Details — so the two are the same shape and
* only their source differs.
*/
const profile = getAudioFxProfile(node.type);
const derived = useMemo(() => profileParam(node.type), [node.type]);
/** The same def cut down to the one knob, so the open face reuses every wire. */
const onlyPrimary = useMemo(
() => (def && primary ? { ...def, params: def.params.filter((p) => p.key === primary) } : def),
@@ -301,6 +340,7 @@ export function FxNodeRow({
// the row itself, so it stays with its effect across a reorder.
const [details, setDetails] = useState(false);
if (!registryDef || !def || !onlyPrimary) return null;
const oneKnob = primary !== null || derived !== null;
const copy = EFFECT_COPY[node.type];
const bypassed = node.enabled === false;
const params = node.params ?? defaultAudioFxParams(node.type);
@@ -349,6 +389,33 @@ export function FxNodeRow({
{copy.does}
</p>
) : null}
{derived && !details ? (
<>
{/* Not routed through FxNodeParams: this knob is not in the
registry, so it has no AudioParam behind it and nothing to
automate. What automation there is belongs to the parameters it
sets, under Details, where they can be aimed at individually. */}
<div className="hf-fx-params space-y-0.5 border-t border-panel-border-input px-1.5 py-1.5">
<FxParamRow
param={derived}
value={audioFxProfileStrength(node.type, params)}
disabled={Boolean(disabled) || bypassed}
onChange={(_k, v) =>
onPreview(index, applyAudioFxProfile(node.type, Number(v), params))
}
onCommit={(_k, v) =>
onUpdate(index, { params: applyAudioFxProfile(node.type, Number(v), params) })
}
/>
</div>
{profile ? (
<p className="hf-fx-node-ends flex justify-between gap-2 px-1.5 pb-1 text-[9px] text-panel-text-4">
<span className="truncate">{profile.ends.low}</span>
<span className="truncate text-right">{profile.ends.high}</span>
</p>
) : null}
</>
) : null}
{primary && !details ? (
<>
<FxNodeParams
@@ -382,7 +449,7 @@ export function FxNodeRow({
) : null}
{/* The DSP name lives on the disclosure, so it is read at the moment
the author asks what this really is — and never before. */}
{primary ? (
{oneKnob ? (
<button
type="button"
className="hf-fx-node-details flex w-full items-center gap-1 border-t border-panel-border-input px-1.5 py-1 text-left font-mono text-[9px] uppercase tracking-wide text-panel-text-4 hover:text-panel-text-0"
@@ -397,7 +464,7 @@ export function FxNodeRow({
Details {registryDef.label}
</p>
)}
{details || !primary ? (
{details || !oneKnob ? (
<FxNodeParams
node={node}
def={def}
@@ -10,6 +10,7 @@ import {
import { DEFAULT_CARVE } from "@hyperframes/core/audio-carve";
import { BANDS, EFFECT_COPY, PRESET_PROBLEM } from "@hyperframes/core/audio-fx-copy";
import { HF_AUDIO_FX_JOBS, HF_AUDIO_FX_JOB_TYPES } from "@hyperframes/core/audio-fx-jobs";
import { audioFxProfileStrength } from "@hyperframes/core/audio-fx-profiles";
import { getAudioFxPreset } from "@hyperframes/core/audio-fx-presets";
/**
@@ -220,14 +221,17 @@ describe("FxSection chain", () => {
});
it("adds an effect seeded with its declared defaults", () => {
// An effect with no derived knob arrives exactly as the registry declares
// it. The five that DO have one are seeded on their curve instead — see
// "adds a profiled effect on its curve" below.
const { host, onChainChange } = mount();
click(host.querySelector(".hf-fx-add"));
click(byText(host, ".hf-fx-add-item", EFFECT_COPY.compressor?.title ?? ""));
click(byText(host, ".hf-fx-add-item", EFFECT_COPY.delay?.title ?? ""));
expect(onChainChange).toHaveBeenCalledTimes(1);
const next = onChainChange.mock.calls[0]![0] as HfAudioFxChain;
expect(next.nodes).toHaveLength(1);
expect(next.nodes[0]!.type).toBe("compressor");
expect(next.nodes[0]!.params).toEqual(defaultAudioFxParams("compressor"));
expect(next.nodes[0]!.type).toBe("delay");
expect(next.nodes[0]!.params).toEqual(defaultAudioFxParams("delay"));
});
it("renders a control for every parameter the effect declares", () => {
@@ -236,11 +240,21 @@ describe("FxSection chain", () => {
const labels = Array.from(host.querySelectorAll(".hf-fx-label")).map((e) =>
e.textContent?.trim(),
);
for (const p of def.params) expect(labels).toContain(plainLabel("compressor", p.key));
// Under Details: a compressor's face is one derived knob, and its seven real
// controls are one click in.
openDetails(host);
const opened = Array.from(host.querySelectorAll(".hf-fx-label")).map((e) =>
e.textContent?.trim(),
);
for (const p of def.params) expect(opened).toContain(plainLabel("compressor", p.key));
void labels;
});
it("uses a select for an enum parameter and a slider for a number", () => {
const { host } = mount({ chain: chainOf("saturate") });
// Its curve type is an enum and lives under Details, since saturation's one
// knob is derived rather than being any single parameter.
openDetails(host);
expect(host.querySelector(".hf-fx-select")).toBeTruthy();
expect(host.querySelector(".hf-fx-slider")).toBeTruthy();
});
@@ -476,18 +490,50 @@ describe("FxSection chain", () => {
expect(fxCard(host).querySelector(".hf-fx-ruler")).toBeNull();
});
it("opens a module on all of its controls when its one knob does not exist yet", () => {
// Five effects want a single DERIVED control over several parameters — the
// `PROFILES` idea, whose figures are proposed rather than measured. Until it
// ships they open on everything, which is honest: inventing one knob for
// them now would be a knob that lies about what it sets.
const { host } = mount({ chain: chainOf("compressor") });
it("adds a profiled effect on its curve, not at registry defaults", () => {
// The registry's defaults are not a point on the profile's curve, so an
// effect seeded with them opened reading a strength it was not set to: a
// compressor arrived showing Evenness 0.67 with its make-up gain at 0 dB —
// the "quieter as you turn it up" bug the profiles exist to prevent, on the
// very first frame. Caught in a running studio, not by these tests.
const { host, onChainChange } = mount({ chain: { version: 1, nodes: [] } });
click(host.querySelector(".hf-fx-add"));
click(byText(host, ".hf-fx-add-item", EFFECT_COPY.compressor?.title ?? ""));
const written = onChainChange.mock.calls[0]?.[0] as HfAudioFxChain | undefined;
const added = written?.nodes[0]?.params ?? {};
expect(audioFxProfileStrength("compressor", added)).toBeCloseTo(0.5, 2);
// And the mechanism agrees with the knob rather than sitting at its default.
expect(added.makeup).not.toBe(defaultAudioFxParams("compressor").makeup);
});
it("gives a module with no single real control a derived one", () => {
// A compressor has seven controls and an author wants one, but no single one
// of them can be its face: threshold means nothing without ratio. So the
// knob is derived, and it sets all five at once.
const { host, onChainChange } = mount({ chain: chainOf("compressor") });
const node = fxCard(host);
expect(EFFECT_COPY.compressor?.primary).toBe("strength");
expect(node.querySelector(".hf-fx-node-details")).toBeNull();
expect(node.querySelectorAll(".hf-fx-row").length).toBe(
getAudioFxDef("compressor")?.params.length,
// One control on the open face, named for the outcome.
const rows = Array.from(node.querySelectorAll(".hf-fx-row"));
expect(rows).toHaveLength(1);
expect(rows[0]?.querySelector(".hf-fx-label")?.textContent).toBe("Evenness");
expect(node.querySelector(".hf-fx-node-details")).toBeTruthy();
// Moving it moves the mechanism underneath.
const before = defaultAudioFxParams("compressor");
typeInto(node.querySelector<HTMLInputElement>(".hf-fx-number")!, "0.9");
act(() =>
node
.querySelector(".hf-fx-number")
?.dispatchEvent(new FocusEvent("focusout", { bubbles: true })),
);
const next = onChainChange.mock.calls.at(-1)?.[0] as HfAudioFxChain;
const params = next.nodes[0]?.params ?? {};
expect(params.ratio).not.toBe(before.ratio);
expect(params.threshold).not.toBe(before.threshold);
// And leaves alone what the author set under Details.
expect(params.knee).toBe(before.knee);
});
it("offers presets as the complaint they answer", () => {
@@ -893,6 +939,7 @@ describe("FxSection chain", () => {
it("commits an enum immediately, since a select has no drag", () => {
const { host, onChainChange } = mount({ chain: chainOf("saturate") });
openDetails(host);
const select = fxCard(host).querySelector<HTMLSelectElement>(".hf-fx-select")!;
const setter = Object.getOwnPropertyDescriptor(HTMLSelectElement.prototype, "value")?.set;
act(() => {
@@ -1147,6 +1194,9 @@ describe("automation in the panel", () => {
// Saturate: `output` is a make-up gain, but the curve's type and threshold
// are rebuilt wholesale and cannot be scheduled.
const { host } = automatable(idChain("saturate"));
// Under Details, where the real parameters are: the derived knob on the open
// face has no AudioParam behind it and nothing to automate.
openDetails(host);
expect(
rowFor(host, plainLabel("saturate", "output"))?.querySelector(".hf-fx-automate"),
).toBeTruthy();
@@ -26,6 +26,7 @@ import {
setAudioEqBandGain,
} from "@hyperframes/core/audio-fx-eq";
import { EFFECT_COPY } from "@hyperframes/core/audio-fx-copy";
import { applyAudioFxProfile, getAudioFxProfile } from "@hyperframes/core/audio-fx-profiles";
import {
audioFxJobNode,
HF_AUDIO_FX_JOBS,
@@ -249,13 +250,30 @@ export function FxSection({
[chain, mutate],
);
/** One effect at its defaults, appended — what both adding and auditioning do. */
/**
* One effect appended, at the values its module opens on.
*
* For most effects that is the registry's defaults. For the five with a
* derived knob it is NOT: the registry defaults are not a point on the
* profile's curve, so the module opened reading a strength it was not set to —
* a compressor arrived showing Evenness 0.67 with its make-up gain at 0 dB,
* which is the "quieter as you turn it up" bug the profiles exist to prevent,
* on the very first frame. Seeding through the profile puts the knob and the
* mechanism in agreement from the start.
*/
const withEffect = useCallback(
(base: HfAudioFxChain, type: string): HfAudioFxChain => ({
...base,
nodes: [
...base.nodes,
{ type, id: mintAudioFxNodeId(base), enabled: true, params: defaultAudioFxParams(type) },
{
type,
id: mintAudioFxNodeId(base),
enabled: true,
params: getAudioFxProfile(type)
? applyAudioFxProfile(type, 0.5, defaultAudioFxParams(type))
: defaultAudioFxParams(type),
},
],
}),
[],