Files
feuerwerk/src/editor/soundfx/EqEditor.ts
T
adminandClaude Opus 5.5 79a04e6764 Edit a Parametric EQ in its node, let the wheel only zoom graphs (#381)
The small curve below the EQ node's rows (#375) only showed the bands.
Like the Compressor since #380, the node now shows the editor of its
tab between its inputs and its output, and is worked right there. A
double-click on the node still opens the same editor in a tab.

Two wishes for the nodes with a panel came on top and share the same
files, so they are in this commit as well: the numbers below the
Compressor's knobs read as plain labels (#382), and the wheel over a
node zooms the graph instead of turning a value (#383).

#381, the EQ in its node:
- EqPanel holds the curve, the band's numbers and the help line, taken
  out of EqEditor. The tab puts its one panel under a header, each EQ
  node has a panel of its own at 720 x 360 (EqFace).
- A press on the curve neither picks nor moves the node. A
  double-click on the curve adds a band, one on the title or the edge
  opens the tab.
- In the node a press on the Type or Slope button stays with the
  button, so the node is not picked or moved.
- The spectrum runs in the node while it is in the picture. The tab
  lets go of the tap once, like the Compressor's, and Editor.tick lets
  every unseen tab and graph go before any seen one listens.
- The count of bands moved from the tab's header into the band row,
  so the node shows it as well.
- The node picture of #375 is gone with its only user: NodePicture,
  EQ_PICTURE and NodeView's drawing of it.

#382, the numbers below the Compressor's knobs in its node:
- A Knob with typed: false shows its number as a centred Label without
  a box, in the panel's ink. The ratio reads 4:1 (ratioText).
- The label is as high as its text and sits up in the dial's open
  bottom, right under the ends of the scale.
- Label takes a colour of its own.

#383, the wheel in a graph:
- GraphCanvas takes the wheel on the way down and stops it there. It
  zooms over a node too, and no knob or curve in a node sees it.
- The tabs keep their wheel: a knob's step, a band's Q and the zoom
  of the EQ's dB.

Found on the way:
- A Menu opened below a button in the zoomed graph would have been
  placed by the button's own height. openBelow now takes the bottom
  edge as drawn.
- The band row did not lay out its labels after a text change when
  its own size stayed. In the tab a later resize hid it, in the node
  "Band 1" and the count were missing. The row now lays out itself.
- Handle and point positions for the checks were unscaled. They now
  go through toGlobal and hold at the graph's zoom.

Tests:
- Unit parametric-eq: 16 tests. The #375 tests now check
  eqCurvePoints and eqRangeOf directly. compressor-view: ratioText.
- e2e 34 (atx): ALL PASSED, 125 checks (3 new: the EQ panel and its
  ports, editing in the node, the spectrum in the node with the tab
  open). The Compressor node's check reads its numbers as labels and
  8:1. Both node checks now expect the wheel to zoom the graph and
  leave the ratio, the Q and the dB zoom alone.
- The unseen-tab check now leaves for the Scene tab, since the node
  in the graph listens to the same tap.
- Counter-check: the tab letting go of the tap every unseen frame
  stalls the node's spectrum with the tab open (1 frame against 22,
  probe on stein2).
- Gate (atx): CHECK EXIT 0, 283 files, 4357 tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-10 12:40:11 +02:00

98 lines
3.5 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* The tab of a Parametric EQ node (#370): the panel of `EqPanel.ts` under a header, pointed at the
* node whose tab is showing. While the tab is seen, the spectrum of what passes the node is drawn
* behind the curve (#374).
*/
import { findGraphAsset, type Project } from '../../core/model/Project';
import { SoundFxParametricEq, tapId } from '../../core/soundfx/nodes';
import { soundLibrary } from '../../viewport/SoundLibrary';
import { Label, Spacer, VStack } from '../../ui';
import type { EditorState } from '../state';
import { TabHeader } from '../TabHeader';
import { EqPanel } from './EqPanel';
/** One editor, pointed at the node whose tab is showing; once the node is gone the tab row is told. */
export class EqEditor extends VStack {
readonly panel: EqPanel;
private readonly title = new Label('Parametric EQ', { style: 'bodyBold' });
private readonly header = new TabHeader();
/** Whether the tab holds the node's tap; the node in the graph listens to the same one (#381). */
private listening = false;
constructor(private readonly state: EditorState) {
super();
this.panel = new EqPanel(state);
this.header.add(this.title);
this.header.add(new Spacer(), 1);
this.add(this.header);
this.add(this.panel, 1);
state.on('project', () => this.sync());
}
show(assetId: string, nodeId: string): void {
const shown = this.panel.shownFor;
if (shown && (shown.assetId !== assetId || shown.nodeId !== nodeId)) this.hideSpectrum();
this.panel.show(assetId, nodeId);
this.sync();
}
/** The tab is closed: the editor lets go of its node. */
close(): void {
this.hideSpectrum();
this.panel.close();
}
get shownFor(): { assetId: string; nodeId: string } | null {
return this.panel.shownFor;
}
/** Only called while the tab is seen: the spectrum of what passes the node, a frame on (#374). */
tick(): void {
const shown = this.panel.shownFor;
if (!shown) return;
const id = tapId(shown.assetId, shown.nodeId);
soundLibrary.listen(id);
this.listening = true;
this.panel.curve.showSpectrum(soundLibrary.spectrum(id));
}
/** The tab is not seen: it lets go of the tap once, so the node in the graph keeps it. */
hideSpectrum(): void {
const shown = this.panel.shownFor;
if (this.listening && shown) soundLibrary.unlisten(tapId(shown.assetId, shown.nodeId));
this.listening = false;
this.panel.curve.showSpectrum(null);
}
/** Whether the spectrum is moving, so the tab has to be drawn every frame. */
get hasSpectrum(): boolean {
return this.panel.curve.hasSpectrum;
}
/** Delete in the tab takes the picked band – never the node the tab is about. */
removePicked(): void {
this.panel.removePicked();
}
private sync(): void {
const shown = this.panel.shownFor;
if (!shown) return;
this.panel.sync();
const title = `Parametric EQ – ${findGraphAsset(this.state.project, shown.assetId)?.name ?? ''}`;
if (title === this.title.text) return;
this.title.setText(title);
this.relayout();
}
}
/**
* What an EQ's tab says: its asset's name, and which EQ it is when the asset has more than one.
*/
export function eqTabLabel(project: Project, assetId: string, nodeId: string): string {
const asset = findGraphAsset(project, assetId);
if (!asset) return '';
const eqs = asset.graph.nodes.filter((n) => n.type === SoundFxParametricEq.type);
const index = eqs.findIndex((n) => n.id === nodeId);
return eqs.length > 1 ? `${asset.name} · EQ ${index + 1}` : `${asset.name} · EQ`;
}