From 1b1ed7e2b3e49f749911a0fa8c193806eed2b3e5 Mon Sep 17 00:00:00 2001 From: Benjamin Hardy Date: Tue, 3 Nov 2026 09:25:04 +0100 Subject: [PATCH] Improved mixer layout --- CLAUDE.md | 9 +- frontend/src/components/ContextMenu.tsx | 7 +- frontend/src/components/mixer/Controls.tsx | 17 ++-- frontend/src/components/mixer/MixerPanel.tsx | 102 +++++++++++-------- 4 files changed, 81 insertions(+), 54 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index 329d35b..f550bae 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -2795,7 +2795,8 @@ The prep strip plays every track through the **Web Audio API** (a plain rate 1 the stretcher is bypassed. **The mixer** (`lib/audio/mixer.ts`, performance mode phase 4): each deck's engine plays into its CHANNEL (`DeckEngine.create(mixer().input(ch))`): - trim (the track's `auto_gain_db` + the knob, ±12 dB) → a 3-band ISOLATOR + GAIN (the state's `trim`: the track's `auto_gain_db` + the knob, ±12 dB) → + a 3-band ISOLATOR (LR4 crossovers at 250 Hz / 2.5 kHz, the low band through a 2.5 kHz all-pass, so the bands sum flat — measured 0.0000 dB; Web Audio's lowpass/highpass Q is in DB, Butterworth = -3.01, its allpass Q linear) → @@ -2814,8 +2815,10 @@ The prep strip plays every track through the **Web Audio API** (a plain is BYPASSED (A straight through, B silent, no limiter): prep listening is unchanged. Controls live in `mixerState.ts` (an external store, not persisted; a MIDI mapping would write the same setters); the curves in - `mixerMath.ts` (tested). `components/mixer/`: `MixerPanel` (meters written - from one rAF loop, never through React state) and `Controls` (`Knob`, + `mixerMath.ts` (tested). `components/mixer/`: `MixerPanel` (26rem; per + channel a 2×2 block — GAIN HI / MID LOW, 40 px knobs — and toward the fader + the FX picker over a 48 px COLOR knob, mirrored on B; meters written from + one rAF loop, never through React state) and `Controls` (`Knob`, `Fader`: drag, Shift = fine, wheel, double-click resets; not focusable, so the deck keys never land on them). The graph itself was measured offline in Chrome (tones in, levels out) — flat EQ, kills, crossfader, fader, trim, diff --git a/frontend/src/components/ContextMenu.tsx b/frontend/src/components/ContextMenu.tsx index 4ac2068..d96bbf2 100644 --- a/frontend/src/components/ContextMenu.tsx +++ b/frontend/src/components/ContextMenu.tsx @@ -31,6 +31,8 @@ interface Props { y: number items: MenuItem[] onClose: () => void + /** The panel's minimum width (px); 0 lets a short list fit its labels. */ + minWidth?: number } const SUBMENU_WIDTH = 240 @@ -40,7 +42,7 @@ const SUBMENU_MAX_HEIGHT = 288 const MENU_MAX_HEIGHT = 400 // Lightweight fixed-position menu. Closes on outside click, scroll, or Escape. -export function ContextMenu({ x, y, items, onClose }: Props) { +export function ContextMenu({ x, y, items, onClose, minWidth = 160 }: Props) { const rootRef = useRef(null) // Read through a ref so the listeners are attached ONCE. Callers pass an // inline `onClose`; if the effect depended on it, a click that re-renders the @@ -102,8 +104,7 @@ export function ContextMenu({ x, y, items, onClose }: Props) { , document.body, diff --git a/frontend/src/components/mixer/Controls.tsx b/frontend/src/components/mixer/Controls.tsx index c7102e4..9b48447 100644 --- a/frontend/src/components/mixer/Controls.tsx +++ b/frontend/src/components/mixer/Controls.tsx @@ -56,8 +56,9 @@ export function Knob({ const angle = -135 + ((clamp(value, min, max) - min) / range) * 270 const start = bipolar ? -135 + ((defaultValue - min) / range) * 270 : -135 const c = size / 2 - const r = c - 3 - const [px, py] = polar(r - 4, angle, c) + const stroke = size >= 36 ? 3.5 : 2.5 + const r = c - stroke + const [px, py] = polar(r - stroke - 2, angle, c) const onPointerDown = (e: PointerEvent) => { if (e.button !== 0) return @@ -93,19 +94,23 @@ export function Knob({ > - + - + = 36 ? 2.5 : 2} strokeLinecap="round" /> - {label} + = 36 ? 'text-[9.5px]' : 'text-[8.5px]'}`} + > + {label} + ) } diff --git a/frontend/src/components/mixer/MixerPanel.tsx b/frontend/src/components/mixer/MixerPanel.tsx index 4fcde03..b0e97c1 100644 --- a/frontend/src/components/mixer/MixerPanel.tsx +++ b/frontend/src/components/mixer/MixerPanel.tsx @@ -19,6 +19,11 @@ import { Fader, Knob } from './Controls' const METER_FLOOR = -48 const METER_TOP = 3 +/** Knob sizes (px): as large as the column allows — the EQ block is two + * across, the colour knob beside it larger. */ +const EQ_KNOB = 40 +const COLOR_KNOB = 48 + const fmtDb = (db: number, places = 1) => !isFinite(db) ? '−∞ dB' : `${db > 0 ? '+' : db < 0 ? '−' : ''}${Math.abs(db).toFixed(places)} dB` @@ -80,7 +85,10 @@ export function MixerPanel({ autoGain }: { autoGain: Record -1 ? 'var(--color-pink)' : held[k] > -9 ? 'var(--color-gold)' : 'var(--color-mint)' } } - if (lv.limiting > 0.5) limitUntil = now + 600 + // Only while the master carries sound: on silence, Chrome's compressor + // reports a phantom reduction (14 dB, decaying over ~2 s, measured just + // after performance mode opens) that limits nothing. + if (lv.limiting > 0.5 && lv.master > -60) limitUntil = now + 600 if (limitRef.current) limitRef.current.dataset.on = String(now < limitUntil) raf = requestAnimationFrame(tick) } @@ -94,7 +102,7 @@ export function MixerPanel({ autoGain }: { autoGain: Record s.sharpness) return ( -
+
@@ -171,51 +179,61 @@ function Strip({ max={1} defaultValue={0} bipolar + size={EQ_KNOB} onChange={(v) => set({ [band]: Math.abs(v) < 0.03 ? 0 : v })} label={label} describe={describeEq(name)} /> ) + // GAIN (the state's `trim`: on top of the track's auto gain) and the EQ as a + // 2×2 block; beside it, toward the fader, the colour effect: its picker + // above a larger COLOR knob (decided 2026-11-03). const knobs = ( -
- set({ trim: Math.abs(v) < 0.3 ? 0 : v })} - label="Trim" - describe={(v) => - `Trim ${fmtDb(v)}${autoGain != null ? ` on the track's auto gain (${fmtDb(autoGain)})` : ' (this track has no auto gain)'}` - } - /> - {eq('high', 'Hi', 'High')} - {eq('mid', 'Mid', 'Mid')} - {eq('low', 'Low', 'Low')} - - set({ color: Math.abs(v) < 0.02 ? 0 : v })} - label="Color" - describe={(v) => describeFx(s.fx, v, fxSettings)} - /> +
+
+ set({ trim: Math.abs(v) < 0.3 ? 0 : v })} + label="Gain" + describe={(v) => + `Gain ${fmtDb(v)}${autoGain != null ? ` on the track's auto gain (${fmtDb(autoGain)})` : ' (this track has no auto gain)'}` + } + /> + {eq('high', 'Hi', 'High')} + {eq('mid', 'Mid', 'Mid')} + {eq('low', 'Low', 'Low')} +
+
+ + set({ color: Math.abs(v) < 0.02 ? 0 : v })} + label="Color" + describe={(v) => describeFx(s.fx, v, fxSettings)} + /> +
) const fader = ( @@ -248,9 +266,9 @@ function Strip({ setFxMenu(null)} items={[ - { heading: `Channel ${ch} · colour effect` }, ...FX_TYPES.map((t) => ({ label: FX_LABELS[t], hint: t === s.fx ? '✓' : undefined,