Skip to content

Write HTML. Render video. Built for agents.

feat(core): name every preset node, and add a multi-band EQ over existing filters (#3178)

Vance Ingalls9f676205239a
diff --git a/packages/core/package-subpaths.json b/packages/core/package-subpaths.json
index 936fb0520c..83ae2ba1d4 100644
--- a/packages/core/package-subpaths.json
+++ b/packages/core/package-subpaths.json
@@ -98,6 +98,12 @@
"types": "./dist/audioFx.d.ts",
"environments": ["browser", "bun", "node"]
},
+ "./audio-fx-eq": {
+ "source": "./src/audioFxEq.ts",
+ "runtime": "./dist/audioFxEq.js",
+ "types": "./dist/audioFxEq.d.ts",
+ "environments": ["browser", "bun", "node"]
+ },
"./audio-fx-presets": {
"source": "./src/audioFxPresets.ts",
"runtime": "./dist/audioFxPresets.js",
diff --git a/packages/core/package.json b/packages/core/package.json
index daecd009e1..b9f8f5ecde 100644
--- a/packages/core/package.json
+++ b/packages/core/package.json
@@ -112,6 +112,12 @@
"import": "./src/audioFx.ts",
"types": "./src/audioFx.ts"
},
+ "./audio-fx-eq": {
+ "bun": "./src/audioFxEq.ts",
+ "node": "./dist/audioFxEq.js",
+ "import": "./src/audioFxEq.ts",
+ "types": "./src/audioFxEq.ts"
+ },
"./audio-fx-presets": {
"bun": "./src/audioFxPresets.ts",
"node": "./dist/audioFxPresets.js",
@@ -408,6 +414,10 @@
"import": "./dist/audioFx.js",
"types": "./dist/audioFx.d.ts"
},
+ "./audio-fx-eq": {
+ "import": "./dist/audioFxEq.js",
+ "types": "./dist/audioFxEq.d.ts"
+ },
"./audio-fx-presets": {
"import": "./dist/audioFxPresets.js",
"types": "./dist/audioFxPresets.d.ts"
diff --git a/packages/core/src/audioFx.ts b/packages/core/src/audioFx.ts
index 26487ab8e9..87531da235 100644
--- a/packages/core/src/audioFx.ts
+++ b/packages/core/src/audioFx.ts
@@ -813,6 +813,25 @@ export interface HfAudioFxNode {
* and each has to be able to find its own.
*/
fromPreset?: string;
+ /**
+ * What the rack calls this node, when the effect's own name is not specific
+ * enough to be useful.
+ *
+ * A peaking filter is "Shape One Range" wherever it appears, so a chain that
+ * cuts mud at 250 Hz and lifts clarity at 3 kHz shows the same words twice
+ * and an author cannot tell the two apart. A preset names each node for the
+ * JOB it is doing instead — "Reduce Mud", "Add Clarity" — and the rack reads
+ * as a list of things that were done rather than a list of filter types.
+ */
+ label?: string;
+ /**
+ * Id of the multi-band EQ that owns this node, when it is one of its bands.
+ *
+ * Same device as `fromCarve`: the module gathers its own nodes out of the
+ * chain and presents them as one control surface, so an EQ needs no new
+ * effect type and its bands stay ordinary filters underneath.
+ */
+ fromEq?: string;
/** Absent means enabled — chain files written before the field existed still load. */
enabled?: boolean;
params?: HfAudioFxParamValues;
@@ -862,6 +881,9 @@ export function parseAudioFxChain(json: string): HfAudioFxChain {
enabled?: unknown;
params?: unknown;
fromCarve?: unknown;
+ fromPreset?: unknown;
+ label?: unknown;
+ fromEq?: unknown;
};
if (typeof node.type !== "string" || !BY_ID.has(node.type)) {
throw new AudioFxChainError(`Node ${i} has unknown effect type: ${String(node.type)}`);
@@ -870,6 +892,14 @@ export function parseAudioFxChain(json: string): HfAudioFxChain {
type: node.type,
...(typeof node.id === "string" && node.id ? { id: node.id } : {}),
...(node.fromCarve === true ? { fromCarve: true as const } : {}),
+ // Both survive the round trip or a preset stops being able to find its
+ // own nodes after a reload: re-applying would stack a second copy and
+ // the rack would lose the grouping it braces them with.
+ ...(typeof node.fromPreset === "string" && node.fromPreset
+ ? { fromPreset: node.fromPreset }
+ : {}),
+ ...(typeof node.label === "string" && node.label ? { label: node.label } : {}),
+ ...(typeof node.fromEq === "string" && node.fromEq ? { fromEq: node.fromEq } : {}),
enabled: node.enabled !== false,
params: normalizeAudioFxParams(
node.type,
@@ -893,6 +923,9 @@ export function serializeAudioFxChain(chain: HfAudioFxChain): string {
type: node.type,
...(node.id ? { id: node.id } : {}),
...(node.fromCarve === true ? { fromCarve: true } : {}),
+ ...(node.fromPreset ? { fromPreset: node.fromPreset } : {}),
+ ...(node.label ? { label: node.label } : {}),
+ ...(node.fromEq ? { fromEq: node.fromEq } : {}),
...(node.enabled === false ? { enabled: false } : {}),
params: normalizeAudioFxParams(node.type, node.params),
})),
diff --git a/packages/core/src/audioFxEq.test.ts b/packages/core/src/audioFxEq.test.ts
new file mode 100644
index 0000000000..ff7b52d938
--- /dev/null
+++ b/packages/core/src/audioFxEq.test.ts
@@ -0,0 +1,157 @@
+import { describe, expect, it } from "vitest";
+import {
+ HF_AUDIO_FX_CHAIN_VERSION,
+ parseAudioFxChain,
+ serializeAudioFxChain,
+ type HfAudioFxChain,
+} from "./audioFx.js";
+import {
+ addAudioEq,
+ audioEqIds,
+ audioEqSummary,
+ HF_AUDIO_EQ_3,
+ HF_AUDIO_EQ_5,
+ HF_AUDIO_EQ_RANGE_DB,
+ readAudioEqBands,
+ removeAudioEq,
+ setAudioEqBandGain,
+} from "./audioFxEq.js";
+
+const empty = (): HfAudioFxChain => ({ version: HF_AUDIO_FX_CHAIN_VERSION, nodes: [] });
+
+describe("adding an EQ", () => {
+ it("writes one ordinary filter per band, in band order", () => {
+ const { chain } = addAudioEq(empty());
+ expect(chain.nodes.map((n) => n.type)).toEqual(["lowshelf", "peaking", "highshelf"]);
+ // Ordinary nodes: an author who opens the details finds filters they could
+ // have added by hand, not an opaque "eq" the graph has to special-case.
+ expect(chain.nodes.every((n) => n.enabled)).toBe(true);
+ expect(chain.nodes.map((n) => n.label)).toEqual(["Bass", "Middle", "Treble"]);
+ });
+
+ it("gives every band an id, because a lane addresses effects by id", () => {
+ const { chain } = addAudioEq(empty(), HF_AUDIO_EQ_5);
+ const ids = chain.nodes.map((n) => n.id);
+ expect(ids.every(Boolean)).toBe(true);
+ expect(new Set(ids).size).toBe(ids.length);
+ });
+
+ it("starts flat, so adding one changes nothing until a fader moves", () => {
+ const { chain, eqId } = addAudioEq(empty());
+ for (const band of readAudioEqBands(chain, eqId)) expect(band.gain).toBe(0);
+ expect(audioEqSummary(readAudioEqBands(chain, eqId))).toMatch(/^Flat/);
+ });
+
+ it("keeps two EQs apart", () => {
+ const first = addAudioEq(empty());
+ const second = addAudioEq(first.chain, HF_AUDIO_EQ_5);
+ expect(second.eqId).not.toBe(first.eqId);
+ expect(audioEqIds(second.chain)).toEqual([first.eqId, second.eqId]);
+ expect(readAudioEqBands(second.chain, first.eqId)).toHaveLength(3);
+ expect(readAudioEqBands(second.chain, second.eqId)).toHaveLength(5);
+ expect(new Set(second.chain.nodes.map((n) => n.id)).size).toBe(second.chain.nodes.length);
+ });
+
+ it("leaves effects that were already there alone", () => {
+ const before: HfAudioFxChain = {
+ version: HF_AUDIO_FX_CHAIN_VERSION,
+ nodes: [{ type: "reverb", id: "mine", enabled: true }],
+ };
+ const { chain } = addAudioEq(before);
+ expect(chain.nodes[0]?.id).toBe("mine");
+ expect(chain.nodes).toHaveLength(4);
+ });
+});
+
+describe("moving a fader", () => {
+ it("changes only that band", () => {
+ const { chain, eqId } = addAudioEq(empty());
+ const next = setAudioEqBandGain(chain, eqId, "Bass", 4.5);
+ const bands = readAudioEqBands(next, eqId);
+ expect(bands.find((b) => b.name === "Bass")?.gain).toBe(4.5);
+ expect(bands.find((b) => b.name === "Middle")?.gain).toBe(0);
+ expect(bands.find((b) => b.name === "Treble")?.gain).toBe(0);
+ });
+
+ it("leaves the band's frequency and width alone", () => {
+ // The fader is one control. Moving it must not quietly re-seed the rest of
+ // the band, or an author who set a frequency by hand loses it on the next drag.
+ const { chain, eqId } = addAudioEq(empty(), HF_AUDIO_EQ_5);
+ const before = readAudioEqBands(chain, eqId).find((b) => b.name === "Clarity")!;
+ const next = setAudioEqBandGain(chain, eqId, "Clarity", -3);
+ const after = readAudioEqBands(next, eqId).find((b) => b.name === "Clarity")!;
+ expect(after.frequency).toBe(before.frequency);
+ expect(after.q).toBe(before.q);
+ expect(after.gain).toBe(-3);
+ });
+
+ it("holds the fader to a tone control's range, not a repair tool's", () => {
+ // The filters themselves allow ±40 dB. A tone control that can bury a
+ // track under 40 dB of bass is not a tone control.
+ const { chain, eqId } = addAudioEq(empty());
+ const hot = setAudioEqBandGain(chain, eqId, "Bass", 40);
+ const cold = setAudioEqBandGain(chain, eqId, "Bass", -40);
+ expect(readAudioEqBands(hot, eqId)[0]?.gain).toBe(HF_AUDIO_EQ_RANGE_DB);
+ expect(readAudioEqBands(cold, eqId)[0]?.gain).toBe(-HF_AUDIO_EQ_RANGE_DB);
+ });
+
+ it("ignores a band name that is not in this EQ", () => {
+ const { chain, eqId } = addAudioEq(empty());
+ const next = setAudioEqBandGain(chain, eqId, "Nonsense", 6);
+ expect(readAudioEqBands(next, eqId).every((b) => b.gain === 0)).toBe(true);
+ });
+});
+
+describe("the chain is the truth", () => {
+ it("reads a frequency the author moved by hand", () => {
+ // The nodes are authoritative, not a cached band list: opening the details
+ // and moving a frequency has to show up on the fader's own band.
+ const { chain, eqId } = addAudioEq(empty());
+ const edited: HfAudioFxChain = {
+ ...chain,
+ nodes: chain.nodes.map((n) =>
+ n.label === "Middle" ? { ...n, params: { ...n.params, frequency: 700 } } : n,
+ ),
+ };
+ expect(readAudioEqBands(edited, eqId).find((b) => b.name === "Middle")?.frequency).toBe(700);
+ });
+
+ it("survives being written to an attribute and read back", () => {
+ const { chain, eqId } = addAudioEq(empty(), HF_AUDIO_EQ_5);
+ const moved = setAudioEqBandGain(chain, eqId, "Air", 2.5);
+ const back = parseAudioFxChain(serializeAudioFxChain(moved));
+ // Without fromEq surviving, the module cannot find its own bands after a
+ // reload and the EQ silently becomes five loose filters.
+ expect(audioEqIds(back)).toEqual([eqId]);
+ expect(readAudioEqBands(back, eqId).map((b) => b.name)).toEqual([
+ "Bass",
+ "Warmth",
+ "Middle",
+ "Clarity",
+ "Air",
+ ]);
+ expect(readAudioEqBands(back, eqId).find((b) => b.name === "Air")?.gain).toBe(2.5);
+ });
+
+ it("removes a whole EQ without touching anything else", () => {
+ const before: HfAudioFxChain = {
+ version: HF_AUDIO_FX_CHAIN_VERSION,
+ nodes: [{ type: "reverb", id: "mine", enabled: true }],
+ };
+ const { chain, eqId } = addAudioEq(before);
+ const gone = removeAudioEq(chain, eqId);
+ expect(gone.nodes.map((n) => n.id)).toEqual(["mine"]);
+ });
+});
+
+describe("what it says when closed", () => {
+ it("names only the bands that were moved", () => {
+ const { chain, eqId } = addAudioEq(empty());
+ const next = setAudioEqBandGain(setAudioEqBandGain(chain, eqId, "Bass", 3), eqId, "Treble", -2);
+ expect(audioEqSummary(readAudioEqBands(next, eqId))).toBe("Bass +3, Treble −2");
+ });
+
+ it("says so when nothing has been touched", () => {
+ expect(audioEqSummary(HF_AUDIO_EQ_3)).toMatch(/^Flat/);
+ });
+});
diff --git a/packages/core/src/audioFxEq.ts b/packages/core/src/audioFxEq.ts
new file mode 100644
index 0000000000..c1fbcea6aa
--- /dev/null
+++ b/packages/core/src/audioFxEq.ts
@@ -0,0 +1,192 @@
+/**
+ * A multi-band EQ, as a composite over effects that already ship.
+ *
+ * Bass, middle and treble is the most widely understood audio control there is
+ * — everyone has used one — which makes it the right answer for an author who
+ * would never reach for a parametric filter. It also removes a real failure:
+ * without it, a chain shaping two ranges holds two peaking filters that look
+ * identical in the rack.
+ *
+ * Built the way the carve is: one module owning several tagged nodes, rather
+ * than a new effect type. Three bands ARE a low shelf, a peaking and a high
+ * shelf, so there is nothing new in the graph, nothing new in the render, and
+ * an author who opens the details finds exactly the filters they could have
+ * added by hand.
+ *
+ * That is also forced by the registry: parameters are a flat key/value record,
+ * so an `eq` effect *type* carrying N bands would need array-shaped params it
+ * has no way to express.
+ */
+
+import {
+ HF_AUDIO_FX_CHAIN_VERSION,
+ mintAudioFxNodeId,
+ normalizeAudioFxParams,
+ type HfAudioFxChain,
+ type HfAudioFxNode,
+} from "./audioFx.js";
+
+/** A band is one node. `name` is what the fader is labelled, and its handle. */
+export interface HfAudioEqBand {
+ name: string;
+ /** Corner for a shelf, centre for a peak. */
+ frequency: number;
+ /** The only value a fader moves. Everything else is fixed when the band is made. */
+ gain: number;
+ q?: number;
+ kind: "lowshelf" | "peaking" | "highshelf";
+}
+
+/**
+ * How far a fader travels. The registry allows ±40 dB on these filters, which
+ * is a repair tool's range — a tone control that can bury a track under 40 dB
+ * of bass is not a tone control. ±12 is the span a hi-fi offers, and it is
+ * enough to fix a voice.
+ */
+export const HF_AUDIO_EQ_RANGE_DB = 12;
+
+/** Bass, middle, treble — the set nobody needs taught. */
+export const HF_AUDIO_EQ_3: readonly HfAudioEqBand[] = [
+ { name: "Bass", frequency: 200, gain: 0, kind: "lowshelf" },
+ { name: "Middle", frequency: 1000, gain: 0, q: 0.9, kind: "peaking" },
+ { name: "Treble", frequency: 4000, gain: 0, kind: "highshelf" },
+];
+
+/**
+ * Five bands, named from the shared vocabulary the rest of the rack uses — so
+ * reaching for the EQ is also how an author learns the words.
+ */
+export const HF_AUDIO_EQ_5: readonly HfAudioEqBand[] = [
+ { name: "Bass", frequency: 160, gain: 0, kind: "lowshelf" },
+ { name: "Warmth", frequency: 350, gain: 0, q: 1, kind: "peaking" },
+ { name: "Middle", frequency: 1000, gain: 0, q: 0.9, kind: "peaking" },
+ { name: "Clarity", frequency: 3000, gain: 0, q: 1, kind: "peaking" },
+ { name: "Air", frequency: 9000, gain: 0, kind: "highshelf" },
+];
+
+const clampGain = (db: number): number =>
+ Number.isFinite(db) ? Math.max(-HF_AUDIO_EQ_RANGE_DB, Math.min(HF_AUDIO_EQ_RANGE_DB, db)) : 0;
+
+/** Realise bands as ordinary nodes, tagged so the module can find them again. */
+export function audioEqNodes(
+ bands: readonly HfAudioEqBand[],
+ eqId: string,
+ chain: HfAudioFxChain,
+): HfAudioFxNode[] {
+ const out: HfAudioFxNode[] = [];
+ let running: HfAudioFxChain = { ...chain, nodes: [...chain.nodes] };
+ for (const band of bands) {
+ const made: HfAudioFxNode = {
+ type: band.kind,
+ id: mintAudioFxNodeId(running),
+ fromEq: eqId,
+ // The band name IS the node's job name, so a rack showing the bands
+ // individually still reads as words rather than as three filter types.
+ label: band.name,
+ enabled: true,
+ params: normalizeAudioFxParams(band.kind, {
+ frequency: band.frequency,
+ gain: clampGain(band.gain),
+ ...(band.kind === "peaking" ? { q: band.q ?? 1 } : {}),
+ }),
+ };
+ out.push(made);
+ running = { ...running, nodes: [...running.nodes, made] };
+ }
+ return out;
+}
+
+/** Add an EQ to a chain. Returns the chain and the id the module addresses it by. */
+export function addAudioEq(
+ chain: HfAudioFxChain,
+ bands: readonly HfAudioEqBand[] = HF_AUDIO_EQ_3,
+): { chain: HfAudioFxChain; eqId: string } {
+ const taken = new Set(chain.nodes.map((n) => n.fromEq).filter(Boolean));
+ let eqId = "eq1";
+ for (let i = 1; taken.has(eqId); i += 1) eqId = `eq${i + 1}`;
+ return {
+ chain: { ...chain, nodes: [...chain.nodes, ...audioEqNodes(bands, eqId, chain)] },
+ eqId,
+ };
+}
+
+/** Every EQ in a chain, in the order their first band appears. */
+export function audioEqIds(chain: HfAudioFxChain): string[] {
+ const seen: string[] = [];
+ for (const node of chain.nodes) {
+ if (node.fromEq && !seen.includes(node.fromEq)) seen.push(node.fromEq);
+ }
+ return seen;
+}
+
+/**
+ * Read one EQ's bands back out of the chain.
+ *
+ * The nodes are the truth, not a cached band list: an author can open the
+ * details and move a frequency by hand, and the faders have to reflect that
+ * rather than silently overwrite it on the next drag.
+ */
+export function readAudioEqBands(chain: HfAudioFxChain, eqId: string): HfAudioEqBand[] {
+ const out: HfAudioEqBand[] = [];
+ for (const node of chain.nodes) {
+ if (node.fromEq !== eqId) continue;
+ if (node.type !== "lowshelf" && node.type !== "peaking" && node.type !== "highshelf") continue;
+ const params = node.params ?? {};
+ const freq = params["frequency"];
+ const gain = params["gain"];
+ const q = params["q"];
+ out.push({
+ name: node.label ?? node.type,
+ frequency: typeof freq === "number" ? freq : 1000,
+ gain: typeof gain === "number" ? gain : 0,
+ ...(typeof q === "number" ? { q } : {}),
+ kind: node.type,
+ });
+ }
+ return out;
+}
+
+/** Move one fader. Everything else about the band is left alone. */
+export function setAudioEqBandGain(
+ chain: HfAudioFxChain,
+ eqId: string,
+ bandName: string,
+ gain: number,
+): HfAudioFxChain {
+ return {
+ ...chain,
+ nodes: chain.nodes.map((node) =>
+ node.fromEq === eqId && node.label === bandName
+ ? {
+ ...node,
+ params: normalizeAudioFxParams(node.type, {
+ ...(node.params ?? {}),
+ gain: clampGain(gain),
+ }),
+ }
+ : node,
+ ),
+ };
+}
+
+/** Remove a whole EQ, bands and all. */
+export function removeAudioEq(chain: HfAudioFxChain, eqId: string): HfAudioFxChain {
+ return { ...chain, nodes: chain.nodes.filter((n) => n.fromEq !== eqId) };
+}
+
+/**
+ * What the module says when it is closed.
+ *
+ * Named for the bands that were actually moved, so a rack of collapsed modules
+ * still reads as a sentence — and an untouched EQ says so rather than listing
+ * three zeroes.
+ */
+export function audioEqSummary(bands: readonly HfAudioEqBand[]): string {
+ const moved = bands.filter((b) => Math.abs(b.gain) >= 0.1);
+ if (moved.length === 0) return "Flat — nothing changed yet";
+ return moved
+ .map((b) => `${b.name} ${b.gain > 0 ? "+" : "−"}${Math.abs(Number(b.gain.toFixed(1)))}`)
+ .join(", ");
+}
+
+export const HF_AUDIO_EQ_CHAIN_VERSION = HF_AUDIO_FX_CHAIN_VERSION;
diff --git a/packages/core/src/audioFxPresets.test.ts b/packages/core/src/audioFxPresets.test.ts
index 40c8742093..2f187ce814 100644
--- a/packages/core/src/audioFxPresets.test.ts
+++ b/packages/core/src/audioFxPresets.test.ts
@@ -94,14 +94,58 @@ describe("the catalogue is internally valid", () => {
}
});
- it("survives being written to an attribute and read back", () => {
+ it("survives being written to an attribute and read back, TAGS AND ALL", () => {
+ // Comparing only types is what let `fromPreset` be silently dropped by the
+ // parser: every preset round-tripped its effects while losing the tag that
+ // lets it find its own nodes again. Compare what the rack actually needs.
for (const p of HF_AUDIO_FX_PRESETS) {
const chain = applyAudioFxPreset(empty(), p);
const back = parseAudioFxChain(serializeAudioFxChain(chain));
expect(
- back.nodes.map((n) => n.type),
+ back.nodes.map((x) => ({
+ type: x.type,
+ id: x.id,
+ fromPreset: x.fromPreset,
+ label: x.label,
+ })),
`${p.id} did not round-trip`,
- ).toEqual(chain.nodes.map((n) => n.type));
+ ).toEqual(
+ chain.nodes.map((x) => ({
+ type: x.type,
+ id: x.id,
+ fromPreset: x.fromPreset,
+ label: x.label,
+ })),
+ );
+ }
+ });
+
+ it("names every node for the job it is doing", () => {
+ for (const p of HF_AUDIO_FX_PRESETS) {
+ for (const node of p.nodes) {
+ expect(node.label, `${p.id}: a ${node.type} node has no job name`).toBeTruthy();
+ }
+ }
+ });
+
+ it("never shows the same name twice in one chain", () => {
+ // The failure this exists to prevent: a rack reading "Shape One Range"
+ // twice, once cutting mud and once adding clarity, with nothing to tell
+ // them apart. Identical CONSECUTIVE nodes are exempt — a stacked pair is
+ // one stage built from two biquads, not two jobs.
+ for (const p of HF_AUDIO_FX_PRESETS) {
+ const seen = new Map<string, number>();
+ p.nodes.forEach((node, i) => {
+ const key = node.label ?? node.type;
+ const prev = seen.get(key);
+ const stackedPair =
+ prev === i - 1 && JSON.stringify(p.nodes[prev]?.params) === JSON.stringify(node.params);
+ expect(
+ prev === undefined || stackedPair,
+ `${p.id} shows "${key}" twice — an author cannot tell the two apart`,
+ ).toBe(true);
+ seen.set(key, i);
+ });
}
});
@@ -156,6 +200,7 @@ describe("applying a preset", () => {
// complete node rather than a partial one the graph has to guess at.
expect(node.params).toEqual({ ...normalizeAudioFxParams("highpass", {}), frequency: 100 });
expect(node.fromPreset).toBe("rumble-cut");
+ expect(node.label).toBe("Cut Rumble");
expect(node.enabled).toBe(true);
});
diff --git a/packages/core/src/audioFxPresets.ts b/packages/core/src/audioFxPresets.ts
index be74eec939..4f49d45772 100644
--- a/packages/core/src/audioFxPresets.ts
+++ b/packages/core/src/audioFxPresets.ts
@@ -44,6 +44,15 @@ export type HfAudioFxPresetFamily = "voice" | "repair" | "character" | "space";
export interface HfAudioFxPresetNode {
/** Effect id from HF_AUDIO_FX. */
type: string;
+ /**
+ * What the rack calls this node — the JOB it is doing, not its filter type.
+ *
+ * A peaking filter is "Shape One Range" wherever it appears, so a chain that
+ * cuts mud and then lifts clarity shows the same words twice and an author
+ * cannot follow it. Naming each node for its job is what lets a preset read
+ * as a list of things that were done.
+ */
+ label?: string;
/** Only what this preset means to set; the rest come from the effect's defaults. */
params?: HfAudioFxParamValues;
}
@@ -70,9 +79,13 @@ const preset = (
* because a BiquadFilterNode is two-pole and that is the honest maximum for one
* node. The telephone band wants the steeper slope, so it pays for two.
*/
-const steep = (type: "highpass" | "lowpass", frequency: number): HfAudioFxPresetNode[] => [
- { type, params: { frequency, q: 0.707, poles: "2" } },
- { type, params: { frequency, q: 0.707, poles: "2" } },
+const steep = (
+ type: "highpass" | "lowpass",
+ frequency: number,
+ label: string,
+): HfAudioFxPresetNode[] => [
+ { type, label, params: { frequency, q: 0.707, poles: "2" } },
+ { type, label, params: { frequency, q: 0.707, poles: "2" } },
];
export const HF_AUDIO_FX_PRESETS: readonly HfAudioFxPreset[] = [
@@ -83,14 +96,15 @@ export const HF_AUDIO_FX_PRESETS: readonly HfAudioFxPreset[] = [
"Clean Voice",
"Cuts rumble and mud, evens out the level, adds a little clarity.",
[
- { type: "highpass", params: { frequency: 80, q: 0.707, poles: "2" } },
- { type: "peaking", params: { frequency: 250, gain: -3, q: 1.2 } },
+ { type: "highpass", label: "Remove Rumble", params: { frequency: 80, q: 0.707, poles: "2" } },
+ { type: "peaking", label: "Reduce Mud", params: { frequency: 250, gain: -3, q: 1.2 } },
{
type: "compressor",
+ label: "Even Out Loudness",
params: { threshold: -20, ratio: 3, attack: 12, release: 180, makeup: 3 },
},
- { type: "peaking", params: { frequency: 3000, gain: 2.5, q: 1 } },
- { type: "limiter", params: { limit: -1, attack: 5, release: 50 } },
+ { type: "peaking", label: "Add Clarity", params: { frequency: 3000, gain: 2.5, q: 1 } },
+ { type: "limiter", label: "Peak Ceiling", params: { limit: -1, attack: 5, release: 50 } },
],
),
preset(
@@ -99,16 +113,17 @@ export const HF_AUDIO_FX_PRESETS: readonly HfAudioFxPreset[] = [
"Broadcast",
"Denser and more forward — a radio-presenter sound.",
[
- { type: "highpass", params: { frequency: 90, q: 0.707, poles: "2" } },
- { type: "peaking", params: { frequency: 400, gain: -3, q: 1.4 } },
+ { type: "highpass", label: "Remove Rumble", params: { frequency: 90, q: 0.707, poles: "2" } },
+ { type: "peaking", label: "Reduce Boxiness", params: { frequency: 400, gain: -3, q: 1.4 } },
{
type: "compressor",
+ label: "Even Out Loudness",
params: { threshold: -24, ratio: 4, attack: 8, release: 150, makeup: 5 },
},
- { type: "peaking", params: { frequency: 2500, gain: 3, q: 0.9 } },
- { type: "highshelf", params: { frequency: 8000, gain: 2 } },
- { type: "saturate", params: { type: "tanh", threshold: -12, output: 0 } },
- { type: "limiter", params: { limit: -1, attack: 5, release: 60 } },
+ { type: "peaking", label: "Add Clarity", params: { frequency: 2500, gain: 3, q: 0.9 } },
+ { type: "highshelf", label: "Add Air", params: { frequency: 8000, gain: 2 } },
+ { type: "saturate", label: "Warmth", params: { type: "tanh", threshold: -12, output: 0 } },
+ { type: "limiter", label: "Peak Ceiling", params: { limit: -1, attack: 5, release: 60 } },
],
),
preset(
@@ -117,14 +132,15 @@ export const HF_AUDIO_FX_PRESETS: readonly HfAudioFxPreset[] = [
"Close & Warm",
"Intimate and lightly handled, for a voice close to the mic.",
[
- { type: "highpass", params: { frequency: 70, q: 0.707, poles: "2" } },
- { type: "lowshelf", params: { frequency: 180, gain: 2 } },
+ { type: "highpass", label: "Remove Rumble", params: { frequency: 70, q: 0.707, poles: "2" } },
+ { type: "lowshelf", label: "Add Weight", params: { frequency: 180, gain: 2 } },
{
type: "compressor",
+ label: "Even Out Loudness",
params: { threshold: -18, ratio: 2.5, attack: 20, release: 250, makeup: 2 },
},
- { type: "peaking", params: { frequency: 3000, gain: 1.5, q: 0.8 } },
- { type: "limiter", params: { limit: -1.5 } },
+ { type: "peaking", label: "Add Clarity", params: { frequency: 3000, gain: 1.5, q: 0.8 } },
+ { type: "limiter", label: "Peak Ceiling", params: { limit: -1.5 } },
],
),
@@ -137,28 +153,34 @@ export const HF_AUDIO_FX_PRESETS: readonly HfAudioFxPreset[] = [
"repair",
"Cut Rumble",
"Removes traffic, handling and air-conditioning from under a voice.",
- [{ type: "highpass", params: { frequency: 100, q: 0.707, poles: "2" } }],
+ [{ type: "highpass", label: "Cut Rumble", params: { frequency: 100, q: 0.707, poles: "2" } }],
),
preset(
"room-gate",
"repair",
"Quiet Between Phrases",
"Silences the gaps between words. Room tone under speech stays — this closes the pauses, it does not remove noise.",
- [{ type: "gate", params: { threshold: -45, range: -18, ratio: 10, attack: 2, release: 180 } }],
+ [
+ {
+ type: "gate",
+ label: "Silence the Gaps",
+ params: { threshold: -45, range: -18, ratio: 10, attack: 2, release: 180 },
+ },
+ ],
),
preset(
"boom-tame",
"repair",
"Tame Boominess",
"Takes out the chestiness of a voice too close to the mic.",
- [{ type: "peaking", params: { frequency: 200, gain: -4, q: 1.4 } }],
+ [{ type: "peaking", label: "Tame Boominess", params: { frequency: 200, gain: -4, q: 1.4 } }],
),
preset(
"harsh-tame",
"repair",
"Soften Harshness",
"Rounds off a brittle upper-mid. Broad and always-on; sibilance proper wants the measuring version.",
- [{ type: "peaking", params: { frequency: 3200, gain: -3, q: 1.6 } }],
+ [{ type: "peaking", label: "Soften Harshness", params: { frequency: 3200, gain: -3, q: 1.6 } }],
),
// ------------------------------------------------------------ character --
@@ -168,18 +190,26 @@ export const HF_AUDIO_FX_PRESETS: readonly HfAudioFxPreset[] = [
"Telephone",
"Down the line — the narrow band of a phone call.",
[
- ...steep("highpass", 300),
- ...steep("lowpass", 3400),
- { type: "peaking", params: { frequency: 1200, gain: 6, q: 1.2 } },
- { type: "peaking", params: { frequency: 550, gain: -4, q: 1 } },
- { type: "saturate", params: { type: "tanh", threshold: -18, output: -2 } },
+ ...steep("highpass", 300, "Strip the Bass"),
+ ...steep("lowpass", 3400, "Strip the Treble"),
+ { type: "peaking", label: "Phone Honk", params: { frequency: 1200, gain: 6, q: 1.2 } },
+ { type: "peaking", label: "De-mud", params: { frequency: 550, gain: -4, q: 1 } },
+ {
+ type: "saturate",
+ label: "Circuit Grit",
+ params: { type: "tanh", threshold: -18, output: -2 },
+ },
],
),
preset("radio-am", "character", "AM Radio", "Narrow, gritty and a little crushed.", [
- { type: "highpass", params: { frequency: 400, q: 0.707, poles: "2" } },
- { type: "lowpass", params: { frequency: 3000, q: 0.707, poles: "2" } },
- { type: "saturate", params: { type: "tanh", threshold: -15, output: -2 } },
- { type: "bitcrush", params: { bits: 10, samples: 1, mix: 0.25 } },
+ { type: "highpass", label: "Strip the Bass", params: { frequency: 400, q: 0.707, poles: "2" } },
+ {
+ type: "lowpass",
+ label: "Strip the Treble",
+ params: { frequency: 3000, q: 0.707, poles: "2" },
+ },
+ { type: "saturate", label: "Radio Grit", params: { type: "tanh", threshold: -15, output: -2 } },
+ { type: "bitcrush", label: "Crunch", params: { bits: 10, samples: 1, mix: 0.25 } },
]),
preset(
"megaphone",
@@ -187,11 +217,23 @@ export const HF_AUDIO_FX_PRESETS: readonly HfAudioFxPreset[] = [
"Megaphone",
"Shouted through a horn, with the slap that comes with it.",
[
- { type: "highpass", params: { frequency: 500, q: 0.707, poles: "2" } },
- { type: "lowpass", params: { frequency: 4000, q: 0.707, poles: "2" } },
- { type: "peaking", params: { frequency: 1800, gain: 8, q: 1.5 } },
- { type: "saturate", params: { type: "hard", threshold: -12, output: -3 } },
- { type: "delay", params: { time: 40, feedback: 0.15, mix: 0.15 } },
+ {
+ type: "highpass",
+ label: "Strip the Bass",
+ params: { frequency: 500, q: 0.707, poles: "2" },
+ },
+ {
+ type: "lowpass",
+ label: "Strip the Treble",
+ params: { frequency: 4000, q: 0.707, poles: "2" },
+ },
+ { type: "peaking", label: "Horn Honk", params: { frequency: 1800, gain: 8, q: 1.5 } },
+ {
+ type: "saturate",
+ label: "Overdrive",
+ params: { type: "hard", threshold: -12, output: -3 },
+ },
+ { type: "delay", label: "Horn Slap", params: { time: 40, feedback: 0.15, mix: 0.15 } },
],
),
preset(
@@ -200,48 +242,86 @@ export const HF_AUDIO_FX_PRESETS: readonly HfAudioFxPreset[] = [
"Tape",
"Worn, warm and slightly unsteady, like a played-out cassette.",
[
- { type: "lowpass", params: { frequency: 6500, q: 0.707, poles: "2" } },
- { type: "lowshelf", params: { frequency: 120, gain: 2 } },
- { type: "saturate", params: { type: "tanh", threshold: -14, output: 0 } },
- { type: "bitcrush", params: { bits: 12, samples: 2, mix: 0.35 } },
+ { type: "lowpass", label: "Tape Rolloff", params: { frequency: 6500, q: 0.707, poles: "2" } },
+ { type: "lowshelf", label: "Add Weight", params: { frequency: 120, gain: 2 } },
+ {
+ type: "saturate",
+ label: "Tape Warmth",
+ params: { type: "tanh", threshold: -14, output: 0 },
+ },
+ { type: "bitcrush", label: "Tape Noise", params: { bits: 12, samples: 2, mix: 0.35 } },
// A slow, shallow chorus is what wow and flutter actually are.
- { type: "chorus", params: { delay: 6, depth: 0.6, speed: 0.4, mix: 0.15 } },
+ {
+ type: "chorus",
+ label: "Wow & Flutter",
+ params: { delay: 6, depth: 0.6, speed: 0.4, mix: 0.15 },
+ },
],
),
preset("pa-system", "character", "Tannoy", "Announced across a concourse.", [
- { type: "highpass", params: { frequency: 350, q: 0.707, poles: "2" } },
- { type: "lowpass", params: { frequency: 3500, q: 0.707, poles: "2" } },
- { type: "peaking", params: { frequency: 1500, gain: 5, q: 1.2 } },
- { type: "saturate", params: { type: "tanh", threshold: -16, output: -1 } },
- { type: "reverb", params: { size: 0.5, damping: 0.7, wet: 0.25, dry: 0.8 } },
+ { type: "highpass", label: "Strip the Bass", params: { frequency: 350, q: 0.707, poles: "2" } },
+ {
+ type: "lowpass",
+ label: "Strip the Treble",
+ params: { frequency: 3500, q: 0.707, poles: "2" },
+ },
+ { type: "peaking", label: "Tannoy Honk", params: { frequency: 1500, gain: 5, q: 1.2 } },
+ {
+ type: "saturate",
+ label: "Driver Grit",
+ params: { type: "tanh", threshold: -16, output: -1 },
+ },
+ {
+ type: "reverb",
+ label: "Concourse",
+ params: { size: 0.5, damping: 0.7, wet: 0.25, dry: 0.8 },
+ },
]),
preset("intercom", "character", "Intercom", "Buzzed through a door panel, squelch and all.", [
- { type: "gate", params: { threshold: -40, range: -30, ratio: 10, attack: 1, release: 120 } },
- { type: "highpass", params: { frequency: 500, q: 0.707, poles: "2" } },
- { type: "lowpass", params: { frequency: 3000, q: 0.707, poles: "2" } },
- { type: "peaking", params: { frequency: 2000, gain: 6, q: 2 } },
- { type: "bitcrush", params: { bits: 11, samples: 1, mix: 0.3 } },
+ {
+ type: "gate",
+ label: "Squelch",
+ params: { threshold: -40, range: -30, ratio: 10, attack: 1, release: 120 },
+ },
+ { type: "highpass", label: "Strip the Bass", params: { frequency: 500, q: 0.707, poles: "2" } },
+ {
+ type: "lowpass",
+ label: "Strip the Treble",
+ params: { frequency: 3000, q: 0.707, poles: "2" },
+ },
+ { type: "peaking", label: "Panel Honk", params: { frequency: 2000, gain: 6, q: 2 } },
+ { type: "bitcrush", label: "Crunch", params: { bits: 11, samples: 1, mix: 0.3 } },
]),
// ---------------------------------------------------------------- space --
preset("room-tight", "space", "Tight Room", "A small hard room — presence without wash.", [
- { type: "reverb", params: { size: 0.25, damping: 0.6, wet: 0.18, dry: 0.9 } },
+ {
+ type: "reverb",
+ label: "Tight Room",
+ params: { size: 0.25, damping: 0.6, wet: 0.18, dry: 0.9 },
+ },
]),
preset(
"room-natural",
"space",
"Natural Room",
"Sounds recorded somewhere rather than nowhere.",
- [{ type: "reverb", params: { size: 0.5, damping: 0.5, wet: 0.25, dry: 0.85 } }],
+ [
+ {
+ type: "reverb",
+ label: "Natural Room",
+ params: { size: 0.5, damping: 0.5, wet: 0.25, dry: 0.85 },
+ },
+ ],
),
preset("hall", "space", "Hall", "Long and open, for something that should sit far back.", [
- { type: "reverb", params: { size: 0.9, damping: 0.3, wet: 0.4, dry: 0.75 } },
+ { type: "reverb", label: "Hall", params: { size: 0.9, damping: 0.3, wet: 0.4, dry: 0.75 } },
]),
preset("slap-echo", "space", "Slap Echo", "One quick repeat — rockabilly vocal, not a wash.", [
- { type: "delay", params: { time: 110, feedback: 0.12, mix: 0.22 } },
+ { type: "delay", label: "Slap Echo", params: { time: 110, feedback: 0.12, mix: 0.22 } },
]),
preset("dub-throw", "space", "Dub Throw", "Repeats that trail off well behind the beat.", [
- { type: "delay", params: { time: 375, feedback: 0.55, mix: 0.3 } },
+ { type: "delay", label: "Dub Throw", params: { time: 375, feedback: 0.55, mix: 0.3 } },
]),
];
@@ -289,6 +369,7 @@ export function audioFxPresetNodes(
type: node.type,
id: mintAudioFxNodeId(running),
fromPreset: preset.id,
+ ...(node.label ? { label: node.label } : {}),
enabled: true,
params: normalizeAudioFxParams(node.type, node.params),
};
diff --git a/packages/studio/src/components/editor/propertyPanelFxSection.test.tsx b/packages/studio/src/components/editor/propertyPanelFxSection.test.tsx
index 6428f05c67..8b3ee12306 100644
--- a/packages/studio/src/components/editor/propertyPanelFxSection.test.tsx
+++ b/packages/studio/src/components/editor/propertyPanelFxSection.test.tsx
@@ -252,6 +252,38 @@ describe("FxSection chain", () => {
expect(next.nodes.map((n) => n.type)).toEqual(["reverb", "highpass"]);
});
+ it("shows a preset node by the job it is doing, not its filter type", () => {
+ const { host } = mount({
+ chain: {
+ version: 1,
+ nodes: [
+ {
+ type: "peaking",
+ id: "a",
+ label: "Reduce Mud",
+ enabled: true,
+ params: defaultAudioFxParams("peaking"),
+ },
+ {
+ type: "peaking",
+ id: "b",
+ label: "Add Clarity",
+ enabled: true,
+ params: defaultAudioFxParams("peaking"),
+ },
+ ],
+ } as HfAudioFxChain,
+ });
+ const names = Array.from(host.querySelectorAll(".hf-fx-node-name")).map((e) =>
+ e.textContent?.trim(),
+ );
+ // Without the label both rows read "Peaking EQ" and an author cannot tell
+ // which one is cutting and which is lifting.
+ expect(names).toContain("Reduce Mud");
+ expect(names).toContain("Add Clarity");
+ expect(names).not.toContain("Peaking EQ");
+ });
+
it("cannot move the ends past themselves", () => {
const { host } = mount({ chain: chainOf("peaking", "reverb") });
const ups = host.querySelectorAll('.hf-fx-move[title="Move up"]');
diff --git a/packages/studio/src/components/editor/propertyPanelFxSection.tsx b/packages/studio/src/components/editor/propertyPanelFxSection.tsx
index 1c51a84300..dfab7346bd 100644
--- a/packages/studio/src/components/editor/propertyPanelFxSection.tsx
+++ b/packages/studio/src/components/editor/propertyPanelFxSection.tsx
@@ -591,7 +591,9 @@ function FxNodeRow({
data-fx-node={node.type}
>
<FxNodeHeader
- label={def.label}
+ // The node's own job name when a preset gave it one: a chain that cuts
+ // mud and then lifts clarity must not show "Peaking EQ" twice.
+ label={node.label ?? def.label}
open={open}
bypassed={bypassed}
first={index === 0}