Show a Chip node as a device with its wave and its pitch (#386)
game-maker / gate (push) Successful in 4m5s
game-maker / suite (push) Failing after 16m5s

The Chip had eleven numbers in rows and nothing that showed what they
do to a note. Its node is now a device of one size like the
Compressor's, and two screens draw the wave and the pitch from the
settings, worked right in the instrument graph.

- ChipPanel is 840x280 in the warm grey of a handheld console. A
  button per wave, the "follow note" lever and a chrome knob per
  number, grouped Oscillator, Slide, Vibrato, Arpeggio and Repeat.
- The wave screen draws two periods as loud as the Chip plays them,
  a square at its duty. toneValue and periodicSteps come out of
  chip.ts, so the screen and the worklet share one formula.
- The pitch screen draws what slide, delta slide, vibrato, arpeggio
  and repeat make of the pitch over a note. It ends where the note
  falls below "min frequency" and starts from A4 while the Chip
  follows the note.
- Idle settings are faded, wired ones greyed and locked, as the rows
  were. Every change is one undo step.
- Knobs take a bipolar range: 0 straight up, the taper bends each
  half. Slide, delta slide, duty sweep and arpeggio use it.
- The Compressor's auto-gain lever is now a Lever with a name of its
  own, which the Chip uses for "follow note".
- Presets give a Chip five columns, as a Filter has four since #385.

Found on the way:

- With the Chip this wide the Laser preset is about 3060 units. In a
  1280 px window Fit stops at the least zoom of 0.25 and cuts the
  Notes node off. The zoom limit is left as it is.

Tests:
- Unit: chip-view (9 new), knob (1 new), chip, chip-presets and
  hardware-view, 53 green
- e2e 34 on melektaus-atx: ALL PASSED, 131 checks (1 new). The
  first run was red on the check itself: a Laser's "min frequency"
  can lie above A4, and the screen then rightly says the note ends
  at once.
- Gate on melektaus-atx: CHECK EXIT 0, 285 files, 4377 tests
- Counter-check: a square drawn with its duty mirrored turns the wave
  test red

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
adminandClaude Opus 5.5 committed 2026-10-10 14:55:35 +02:00
1 parent c087993000
commit eb78f3cbf3
14 files changed
+1190 -26

No files matched your search

+52
View File
@@ -3,6 +3,7 @@ import { NameTransitionCommand } from '../../core/commands/graphCommands';
import { soundLibrary } from '../../viewport/SoundLibrary';
import type { Widget } from '../../ui';
import { currentNodePalette } from '../graph/NodePalette';
import { ChipPanel } from '../soundfx/ChipPanel';
import { CompressorPanel } from '../soundfx/CompressorPanel';
import { GainPanel } from '../soundfx/GainPanel';
import { CurvePanel } from '../soundfx/CurvePanel';
@@ -271,6 +272,51 @@ export function graphHooks({ state, editor }: HookContext) {
};
},
},
/**
* The panel a Chip node shows in the instrument graph (#386): whether it is shown and where, its
* knobs, which settings are idle, the picked wave, the lever, both screens and the node's ports.
*/
chip: {
panel: (nodeId: string) => {
const canvas = editor.instrumentEditor.canvas;
const panel = canvas.faceOf(nodeId)?.widget;
if (!(panel instanceof ChipPanel)) return null;
const node = canvas.nodeScreen(nodeId);
const ports = (keys: string[], isOutput: boolean) =>
Object.fromEntries(keys.map((key) => [key, canvas.portGlobal(nodeId, key, isOutput)]));
const trace = panel.pitchScreen.trace;
return {
shown: shownOnScreen(panel),
rect: screenRect(panel),
size: { w: panel.w, h: panel.h },
node: node?.rect ?? null,
inputs: ports(node?.inputs ?? [], false),
outputs: ports(node?.outputs ?? [], true),
knobs: Object.fromEntries(
Object.entries(panel.knobs).map(([key, knob]) => [
key,
{ value: knob.value, number: knob.shown, enabled: knob.enabled, dial: knob.dialGlobal() },
]),
),
idle: [...panel.idle],
wave: panel.waveButtons.find((b) => b.picked)?.wave ?? null,
waves: Object.fromEntries(panel.waveButtons.map((b) => [b.wave, screenCentre(b)])),
follow: { on: panel.follow.lit, at: screenCentre(panel.follow) },
waveScreen: panel.waveScreen.says.text,
pitch: trace && {
from: panel.pitchScreen.from.text,
span: trace.span,
end: trace.end,
low: trace.low,
high: trace.high,
restarts: trace.restarts.length,
points: trace.points.length,
/** Semitones from the start where the trace stops. */
last: trace.points.at(-1)?.st ?? null,
},
};
},
},
instrument: {
current: () => editor.instrumentEditor.currentAssetId,
info: () => editor.instrumentEditor.shownInfo,
@@ -379,6 +425,12 @@ function screenRect(widget: Widget): { x: number; y: number; w: number; h: numbe
return { x: from.x, y: from.y, w: to.x - from.x, h: to.y - from.y };
}
/** A widget's middle on screen, at the graph's zoom: `centreOf` adds its size unscaled. */
function screenCentre(widget: Widget): { x: number; y: number } {
const r = screenRect(widget);
return { x: r.x + r.w / 2, y: r.y + r.h / 2 };
}
/** The picked band's numbers as an EQ panel shows them; null for one its band type has not. */
function eqFields(panel: CurvePanel) {
return {