Improved mixer layout

This commit is contained in:
patben8 committed 2026-11-03 09:25:04 +01:00
1 parent 341f12e275
commit 1b1ed7e2b3
4 files changed
+81 -54

No files matched your search

+6 -3
View File
@@ -2795,7 +2795,8 @@ The prep strip plays every track through the **Web Audio API** (a plain
rate 1 the stretcher is bypassed. rate 1 the stretcher is bypassed.
**The mixer** (`lib/audio/mixer.ts`, performance mode phase 4): each deck's **The mixer** (`lib/audio/mixer.ts`, performance mode phase 4): each deck's
engine plays into its CHANNEL (`DeckEngine.create(mixer().input(ch))`): 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 (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 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) → 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 is BYPASSED (A straight through, B silent, no limiter): prep listening is
unchanged. Controls live in `mixerState.ts` (an external store, not unchanged. Controls live in `mixerState.ts` (an external store, not
persisted; a MIDI mapping would write the same setters); the curves in persisted; a MIDI mapping would write the same setters); the curves in
`mixerMath.ts` (tested). `components/mixer/`: `MixerPanel` (meters written `mixerMath.ts` (tested). `components/mixer/`: `MixerPanel` (26rem; per
from one rAF loop, never through React state) and `Controls` (`Knob`, 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 `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 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, Chrome (tones in, levels out) — flat EQ, kills, crossfader, fader, trim,
+4 -3
View File
@@ -31,6 +31,8 @@ interface Props {
y: number y: number
items: MenuItem[] items: MenuItem[]
onClose: () => void onClose: () => void
/** The panel's minimum width (px); 0 lets a short list fit its labels. */
minWidth?: number
} }
const SUBMENU_WIDTH = 240 const SUBMENU_WIDTH = 240
@@ -40,7 +42,7 @@ const SUBMENU_MAX_HEIGHT = 288
const MENU_MAX_HEIGHT = 400 const MENU_MAX_HEIGHT = 400
// Lightweight fixed-position menu. Closes on outside click, scroll, or Escape. // 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<HTMLDivElement>(null) const rootRef = useRef<HTMLDivElement>(null)
// Read through a ref so the listeners are attached ONCE. Callers pass an // 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 // 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) {
<MenuPanel <MenuPanel
items={items} items={items}
onClose={onClose} onClose={onClose}
className="min-w-[160px]" style={{ ...vertical, minWidth, left: Math.min(x, window.innerWidth - 180) }}
style={{ ...vertical, left: Math.min(x, window.innerWidth - 180) }}
/> />
</div>, </div>,
document.body, document.body,
+11 -6
View File
@@ -56,8 +56,9 @@ export function Knob({
const angle = -135 + ((clamp(value, min, max) - min) / range) * 270 const angle = -135 + ((clamp(value, min, max) - min) / range) * 270
const start = bipolar ? -135 + ((defaultValue - min) / range) * 270 : -135 const start = bipolar ? -135 + ((defaultValue - min) / range) * 270 : -135
const c = size / 2 const c = size / 2
const r = c - 3 const stroke = size >= 36 ? 3.5 : 2.5
const [px, py] = polar(r - 4, angle, c) const r = c - stroke
const [px, py] = polar(r - stroke - 2, angle, c)
const onPointerDown = (e: PointerEvent<HTMLDivElement>) => { const onPointerDown = (e: PointerEvent<HTMLDivElement>) => {
if (e.button !== 0) return if (e.button !== 0) return
@@ -93,19 +94,23 @@ export function Knob({
> >
<svg width={size} height={size}> <svg width={size} height={size}>
<circle cx={c} cy={c} r={r} fill="rgb(0 0 0 / 0.36)" stroke="rgb(255 255 255 / 0.08)" /> <circle cx={c} cy={c} r={r} fill="rgb(0 0 0 / 0.36)" stroke="rgb(255 255 255 / 0.08)" />
<path d={arc(r, -135, 135, c)} fill="none" stroke="rgb(255 255 255 / 0.1)" strokeWidth={2.5} strokeLinecap="round" /> <path d={arc(r, -135, 135, c)} fill="none" stroke="rgb(255 255 255 / 0.1)" strokeWidth={stroke} strokeLinecap="round" />
<path <path
d={arc(r, start, angle, c)} d={arc(r, start, angle, c)}
fill="none" fill="none"
stroke={color} stroke={color}
strokeWidth={2.5} strokeWidth={stroke}
strokeLinecap="round" strokeLinecap="round"
style={{ filter: `drop-shadow(0 0 3px ${color})` }} style={{ filter: `drop-shadow(0 0 3px ${color})` }}
/> />
<line x1={c} y1={c} x2={px} y2={py} stroke="var(--color-text)" strokeWidth={2} strokeLinecap="round" /> <line x1={c} y1={c} x2={px} y2={py} stroke="var(--color-text)" strokeWidth={size >= 36 ? 2.5 : 2} strokeLinecap="round" />
</svg> </svg>
</div> </div>
<span className="text-[8.5px] font-semibold uppercase leading-none tracking-[0.08em] text-faint">{label}</span> <span
className={`font-semibold uppercase leading-none tracking-[0.08em] text-faint ${size >= 36 ? 'text-[9.5px]' : 'text-[8.5px]'}`}
>
{label}
</span>
</div> </div>
) )
} }
+60 -42
View File
@@ -19,6 +19,11 @@ import { Fader, Knob } from './Controls'
const METER_FLOOR = -48 const METER_FLOOR = -48
const METER_TOP = 3 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) => const fmtDb = (db: number, places = 1) =>
!isFinite(db) ? '−∞ dB' : `${db > 0 ? '+' : db < 0 ? '−' : ''}${Math.abs(db).toFixed(places)} dB` !isFinite(db) ? '−∞ dB' : `${db > 0 ? '+' : db < 0 ? '−' : ''}${Math.abs(db).toFixed(places)} dB`
@@ -80,7 +85,10 @@ export function MixerPanel({ autoGain }: { autoGain: Record<Channel, number | nu
held[k] > -1 ? 'var(--color-pink)' : held[k] > -9 ? 'var(--color-gold)' : 'var(--color-mint)' held[k] > -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) if (limitRef.current) limitRef.current.dataset.on = String(now < limitUntil)
raf = requestAnimationFrame(tick) raf = requestAnimationFrame(tick)
} }
@@ -94,7 +102,7 @@ export function MixerPanel({ autoGain }: { autoGain: Record<Channel, number | nu
const sharpness = useMixer((s) => s.sharpness) const sharpness = useMixer((s) => s.sharpness)
return ( return (
<div className="well flex w-[24rem] shrink-0 flex-col gap-1.5 rounded-2xl px-2.5 pb-1.5 pt-2.5"> <div className="well flex w-[26rem] shrink-0 flex-col gap-1.5 rounded-2xl px-2.5 pb-1.5 pt-2.5">
<div className="flex min-h-0 flex-1 items-stretch gap-2"> <div className="flex min-h-0 flex-1 items-stretch gap-2">
<Strip ch="A" autoGain={autoGain.A} meterRef={meterRefs.A} /> <Strip ch="A" autoGain={autoGain.A} meterRef={meterRefs.A} />
<div className="flex w-3 flex-col items-center gap-1" title="Master — after the limiter"> <div className="flex w-3 flex-col items-center gap-1" title="Master — after the limiter">
@@ -171,51 +179,61 @@ function Strip({
max={1} max={1}
defaultValue={0} defaultValue={0}
bipolar bipolar
size={EQ_KNOB}
onChange={(v) => set({ [band]: Math.abs(v) < 0.03 ? 0 : v })} onChange={(v) => set({ [band]: Math.abs(v) < 0.03 ? 0 : v })}
label={label} label={label}
describe={describeEq(name)} 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 = ( const knobs = (
<div className="grid grid-cols-4 content-between gap-x-1.5"> <div className={`flex items-center gap-2 self-center ${mirrored ? 'flex-row-reverse' : ''}`}>
<Knob <div className="grid grid-cols-2 gap-x-1.5 gap-y-1.5">
value={s.trim} <Knob
min={-TRIM_RANGE_DB} value={s.trim}
max={TRIM_RANGE_DB} min={-TRIM_RANGE_DB}
defaultValue={0} max={TRIM_RANGE_DB}
bipolar defaultValue={0}
color="var(--color-text)" bipolar
onChange={(v) => set({ trim: Math.abs(v) < 0.3 ? 0 : v })} size={EQ_KNOB}
label="Trim" color="var(--color-text)"
describe={(v) => onChange={(v) => set({ trim: Math.abs(v) < 0.3 ? 0 : v })}
`Trim ${fmtDb(v)}${autoGain != null ? ` on the track's auto gain (${fmtDb(autoGain)})` : ' (this track has no auto gain)'}` 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')} {eq('high', 'Hi', 'High')}
<button {eq('mid', 'Mid', 'Mid')}
onClick={(e) => { {eq('low', 'Low', 'Low')}
const r = e.currentTarget.getBoundingClientRect() </div>
setFxMenu({ x: r.left, y: r.bottom + 4 }) <div className="flex flex-col items-center gap-2" style={{ width: COLOR_KNOB }}>
}} <button
title="Which effect the COLOR knob drives" onClick={(e) => {
className="btn-glass col-span-3 mt-0.5 flex h-6 items-center justify-center gap-0.5 self-start rounded-md text-[10px] font-semibold uppercase tracking-[0.06em] text-text" const r = e.currentTarget.getBoundingClientRect()
> setFxMenu({ x: r.left, y: r.bottom + 4 })
{FX_LABELS[s.fx]} }}
<Icon name="chevronDown" size={11} /> title={`${FX_LABELS[s.fx]} — which effect the COLOR knob drives`}
</button> className="btn-glass flex h-6 w-full items-center justify-center gap-px rounded-md text-[9.5px] font-semibold uppercase tracking-[0.04em] text-text"
<Knob >
value={s.color} {FX_LABELS[s.fx]}
min={-1} <Icon name="chevronDown" size={9} />
max={1} </button>
defaultValue={0} <Knob
bipolar value={s.color}
color="var(--color-gold)" min={-1}
onChange={(v) => set({ color: Math.abs(v) < 0.02 ? 0 : v })} max={1}
label="Color" defaultValue={0}
describe={(v) => describeFx(s.fx, v, fxSettings)} bipolar
/> size={COLOR_KNOB}
color="var(--color-gold)"
onChange={(v) => set({ color: Math.abs(v) < 0.02 ? 0 : v })}
label="Color"
describe={(v) => describeFx(s.fx, v, fxSettings)}
/>
</div>
</div> </div>
) )
const fader = ( const fader = (
@@ -248,9 +266,9 @@ function Strip({
<ContextMenu <ContextMenu
x={fxMenu.x} x={fxMenu.x}
y={fxMenu.y} y={fxMenu.y}
minWidth={0}
onClose={() => setFxMenu(null)} onClose={() => setFxMenu(null)}
items={[ items={[
{ heading: `Channel ${ch} · colour effect` },
...FX_TYPES.map((t) => ({ ...FX_TYPES.map((t) => ({
label: FX_LABELS[t], label: FX_LABELS[t],
hint: t === s.fx ? '✓' : undefined, hint: t === s.fx ? '✓' : undefined,