mirror of
https://github.com/MrPatben8/konduktor.git
synced 2026-11-27 10:22:51 +01:00
Improved mixer layout
This commit is contained in:
1 parent
341f12e275
commit
1b1ed7e2b3
4 files changed
+81
-54
No files matched your search
@@ -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<HTMLDivElement>(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) {
|
||||
<MenuPanel
|
||||
items={items}
|
||||
onClose={onClose}
|
||||
className="min-w-[160px]"
|
||||
style={{ ...vertical, left: Math.min(x, window.innerWidth - 180) }}
|
||||
style={{ ...vertical, minWidth, left: Math.min(x, window.innerWidth - 180) }}
|
||||
/>
|
||||
</div>,
|
||||
document.body,
|
||||
|
||||
@@ -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<HTMLDivElement>) => {
|
||||
if (e.button !== 0) return
|
||||
@@ -93,19 +94,23 @@ export function Knob({
|
||||
>
|
||||
<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)" />
|
||||
<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
|
||||
d={arc(r, start, angle, c)}
|
||||
fill="none"
|
||||
stroke={color}
|
||||
strokeWidth={2.5}
|
||||
strokeWidth={stroke}
|
||||
strokeLinecap="round"
|
||||
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>
|
||||
</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>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -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<Channel, number | nu
|
||||
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)
|
||||
raf = requestAnimationFrame(tick)
|
||||
}
|
||||
@@ -94,7 +102,7 @@ export function MixerPanel({ autoGain }: { autoGain: Record<Channel, number | nu
|
||||
const sharpness = useMixer((s) => s.sharpness)
|
||||
|
||||
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">
|
||||
<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">
|
||||
@@ -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 = (
|
||||
<div className="grid grid-cols-4 content-between gap-x-1.5">
|
||||
<Knob
|
||||
value={s.trim}
|
||||
min={-TRIM_RANGE_DB}
|
||||
max={TRIM_RANGE_DB}
|
||||
defaultValue={0}
|
||||
bipolar
|
||||
color="var(--color-text)"
|
||||
onChange={(v) => 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')}
|
||||
<button
|
||||
onClick={(e) => {
|
||||
const r = e.currentTarget.getBoundingClientRect()
|
||||
setFxMenu({ x: r.left, y: r.bottom + 4 })
|
||||
}}
|
||||
title="Which effect the COLOR knob drives"
|
||||
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"
|
||||
>
|
||||
{FX_LABELS[s.fx]}
|
||||
<Icon name="chevronDown" size={11} />
|
||||
</button>
|
||||
<Knob
|
||||
value={s.color}
|
||||
min={-1}
|
||||
max={1}
|
||||
defaultValue={0}
|
||||
bipolar
|
||||
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 className={`flex items-center gap-2 self-center ${mirrored ? 'flex-row-reverse' : ''}`}>
|
||||
<div className="grid grid-cols-2 gap-x-1.5 gap-y-1.5">
|
||||
<Knob
|
||||
value={s.trim}
|
||||
min={-TRIM_RANGE_DB}
|
||||
max={TRIM_RANGE_DB}
|
||||
defaultValue={0}
|
||||
bipolar
|
||||
size={EQ_KNOB}
|
||||
color="var(--color-text)"
|
||||
onChange={(v) => 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')}
|
||||
</div>
|
||||
<div className="flex flex-col items-center gap-2" style={{ width: COLOR_KNOB }}>
|
||||
<button
|
||||
onClick={(e) => {
|
||||
const r = e.currentTarget.getBoundingClientRect()
|
||||
setFxMenu({ x: r.left, y: r.bottom + 4 })
|
||||
}}
|
||||
title={`${FX_LABELS[s.fx]} — which effect the COLOR knob drives`}
|
||||
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"
|
||||
>
|
||||
{FX_LABELS[s.fx]}
|
||||
<Icon name="chevronDown" size={9} />
|
||||
</button>
|
||||
<Knob
|
||||
value={s.color}
|
||||
min={-1}
|
||||
max={1}
|
||||
defaultValue={0}
|
||||
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>
|
||||
)
|
||||
const fader = (
|
||||
@@ -248,9 +266,9 @@ function Strip({
|
||||
<ContextMenu
|
||||
x={fxMenu.x}
|
||||
y={fxMenu.y}
|
||||
minWidth={0}
|
||||
onClose={() => setFxMenu(null)}
|
||||
items={[
|
||||
{ heading: `Channel ${ch} · colour effect` },
|
||||
...FX_TYPES.map((t) => ({
|
||||
label: FX_LABELS[t],
|
||||
hint: t === s.fx ? '✓' : undefined,
|
||||
|
||||
Reference in new issue
Block a user