feat: remove state and let rust handle

This commit is contained in:
2026-09-12 19:37:59 +02:00
parent 2717dfe99a
commit 1e00ca3a7c
17 changed files with 221 additions and 1426 deletions
@@ -10,6 +10,9 @@
box-sizing: border-box;
background: var(--bg-panel);
user-select: none;
-webkit-user-select: none;
}
.input-graph-panel {
@@ -40,6 +43,9 @@
min-height: 0;
}
/* Bottom control bar — same pattern as .compressor-section: absolute,
bottom-anchored, panels flow in a row and scroll horizontally instead
of squeezing into a fixed max-width. */
.input-control-section {
container-type: size;
position: absolute;
@@ -50,7 +56,7 @@
height: var(--dsp-control-heigth);
display: flex;
align-items: center;
align-items: flex-end;
justify-content: center;
box-sizing: border-box;
@@ -60,104 +66,23 @@
z-index: 20;
border-top: var(--border-width) solid var(--border-hairline);
user-select: none;
-webkit-user-select: none;
}
.input-control-panel {
display: grid;
grid-auto-flow: column;
height: 100%;
width: 100%;
max-width: 60cqw;
display: flex;
align-items: stretch;
justify-content: center; /* ← add this */
gap: var(--space-4);
gap: var(--space-2);
overflow-x: auto;
justify-content: center;
box-sizing: border-box;
padding: 2cqh;
}
.input-control-panel__sliders {
flex: 1 1 auto;
min-width: 0;
display: grid;
grid-template-columns: repeat(2, 1fr);
gap: 4cqh;
}
.input-control-panel__cell {
display: flex;
flex-direction: column;
align-items: center;
justify-content: flex-start;
min-height: 0;
min-width: 0;
gap: 1cqh;
}
.input-control-panel__cell-label {
flex: 0 0 auto;
font-family: var(--font-ui);
font-size: 2.5cqh;
color: var(--text-muted);
white-space: nowrap;
}
.input-control-panel__side {
flex: 0 0 auto;
width: 16cqh;
display: flex;
flex-direction: column;
justify-content: flex-end;
gap: 2cqh;
}
.input-control-panel__select {
display: flex;
flex-direction: column;
gap: 0.5cqh;
}
.input-control-panel__select-label {
font-family: var(--font-ui);
font-size: 2.2cqh;
color: var(--text-muted);
}
.input-control-panel__select select {
font-family: var(--font-ui);
font-size: 2.5cqh;
padding: 0.8cqh;
background: var(--bg-void);
color: var(--text-primary);
border: var(--border-width) solid var(--border-hairline);
border-radius: var(--radius-md);
}
.input-control-panel__select select:disabled {
opacity: 0.5;
}
.input-control-panel__bypass-btn {
font-family: var(--font-ui);
font-size: 2.5cqh;
font-weight: var(--font-weight-semibold);
padding: 1cqh;
background: var(--bg-void);
color: var(--text-primary);
border: var(--border-width) solid var(--border-hairline);
border-radius: var(--radius-md);
cursor: pointer;
}
.input-control-panel__bypass-btn--active {
background: var(--accent, #f87171);
color: var(--bg-void);
border-color: var(--accent, #f87171);
}
/* Peq Sliders */
.input-panel {
position: relative;
@@ -260,16 +185,26 @@
text-overflow: ellipsis;
}
/* Now the root of a ChoiceSelect rather than a native <select>. */
.crossover-panel__select {
flex: 0 0 auto;
width: 85%;
font-family: var(--font-ui);
font-size: 3cqh;
padding: 1cqh;
background: var(--bg-panel);
color: inherit;
border: var(--border-width) solid var(--border-hairline);
border-radius: var(--radius-sm);
}
.crossover-panel__select .choice-select__input,
.crossover-panel__select .choice-select__input option {
font-size: 4cqh;
color: var(--accent-brand);
/* padding-left: 1cqh; */
}
.crossover-panel__select {
font-size: 4cqh;
}
.crossover-panel__select .choice-select__input {
font-size: 4cqh;
}
.peq-band-list {
@@ -298,7 +233,7 @@
min-width: 0;
display: grid;
grid-template-columns: 1fr 1.2fr 1fr 1fr 1.4fr 1.2fr;
grid-template-columns: 1fr 1.2fr 1fr 1fr 1.6fr 1.2fr;
align-items: stretch;
gap: 1cqh;
@@ -340,8 +275,7 @@
text-align: center;
}
.peq-band-list__input,
.peq-band-list__select {
.peq-band-list__input {
width: 100%;
height: 100%;
min-width: 0;
@@ -362,6 +296,17 @@
box-sizing: border-box;
}
.peq-band-list__stepper,
.peq-band-list__select {
width: 100%;
height: 100%;
min-width: 0;
min-height: 0;
font-family: var(--font-ui);
font-size: 4cqh;
}
.input-graph-panel__magnitude-wrap {
flex: 1 1 0;
min-height: 0;
@@ -405,3 +350,15 @@
background: var(--accent, #4dd0e1);
color: var(--bg-void);
}
.peq-band-list__stepper .choice-stepper__input,
.peq-band-list__select .choice-select__input {
height: 100%;
min-height: 0;
font-family: var(--font-mono);
font-size: 4cqh;
color: var(--accent-brand);
background: transparent;
}
@@ -3,6 +3,8 @@ import VerticalSlider, {
makeLogStep,
makeLogQuantize,
} from '../../../../components/VerticalSlider/VerticalSlider';
import ChoiceStepper from '../../../../components/ChoiceStepper/ChoiceStepper';
import ChoiceSelect from '../../../../components/ChoiceSelect/ChoiceSelect';
import {
CROSSOVER_FILTER_LABEL,
PEQ_BANDS_ORDER,
@@ -18,7 +20,6 @@ import { useRef, useState } from 'react';
import './InputSection.css';
import ChannelGroup from '../../../../components/ChannelGroup/ChannelGroup';
import Button from '../../../../components/Button/Button';
// import { buildTotalCurveDraw, buildTotalPhaseCurveDraw } from '../../utils/totalCurve';
import {
FREQUENCY_MAX,
FREQUENCY_MIN,
@@ -258,17 +259,15 @@ function CrossoverPanel({
style={{ width: '100%', flex: '1 1 auto' }}
/>
<select
<ChoiceSelect
className="crossover-panel__select"
value={bypass ? lastFilterType.current : filter_type}
onChange={(e) => commit({ filter_type: e.target.value as CrossoverFilter })}
>
{CROSSOVER_FILTER_LABEL.map((opt) => (
<option key={opt.value} value={opt.value}>
{opt.label}
</option>
))}
</select>
options={CROSSOVER_FILTER_LABEL.map((opt) => opt.value)}
formatLabel={(v) =>
CROSSOVER_FILTER_LABEL.find((opt) => opt.value === v)?.label ?? String(v)
}
onChange={(value) => commit({ filter_type: value })}
/>
<Button
variant="toggle"
@@ -331,6 +330,9 @@ function PeqBandList({
const peq = liveBands[band] ?? bands[band];
const isActive = band === activeBand;
const [qMin, qMax] = PEQ_Q_RANGES[peq.filter_type];
const qValues = PEAK_Q_VALUES.filter((q) => q >= qMin && q <= qMax);
return (
<div
className={`peq-band-list__row${isActive ? ' peq-band-list__row--active' : ''}`}
@@ -338,62 +340,56 @@ function PeqBandList({
>
<Button
variant="toggle"
className={isActive ? 'active' : ''}
className={isActive ? 'active-info' : ''}
onClick={() => setActiveBand(band)}
style={{ minHeight: 0 }}
style={{
minHeight: 0,
fontSize: '4cqh',
}}
>
{`B${i + 1}`}
</Button>
{/* Frequency */}
<input
className="peq-band-list__input"
type="text"
value={
peq.frequency >= 1000 ? (peq.frequency / 1000).toFixed(2) : peq.frequency.toFixed(1)
<ChoiceStepper
className="peq-band-list__stepper"
value={peq.frequency}
min={FREQUENCY_MIN}
max={FREQUENCY_MAX}
step={FREQUENCY_QUANTIZATION}
formatLabel={(v) =>
v >= 1000 ? `${(v / 1000).toFixed(2)} kHz` : `${v.toFixed(1)} Hz`
}
onChange={(e) => {
const value = Number(e.target.value);
if (!Number.isNaN(value)) {
commit(band, {
frequency: peq.frequency >= 1000 ? value * 1000 : value,
});
}
}}
onChange={(value) => commit(band, { frequency: value })}
/>
<input
className="peq-band-list__input"
type="number"
step={1}
min={1}
max={999}
<ChoiceStepper
className="peq-band-list__stepper"
value={peq.q}
onChange={(e) => commit(band, { q: Number(e.target.value) })}
values={qValues}
formatLabel={(v) => v.toFixed(2)}
onChange={(value) => commit(band, { q: value })}
/>
<input
className="peq-band-list__input"
type="number"
step={0.1}
<ChoiceStepper
className="peq-band-list__stepper"
value={peq.gain}
min={-12}
max={12}
value={peq.gain}
onChange={(e) => commit(band, { gain: Number(e.target.value) })}
step={0.1}
formatLabel={(v) => `${v > 0 ? '+' : ''}${v.toFixed(1)} dB`}
onChange={(value) => commit(band, { gain: value })}
/>
<select
<ChoiceSelect<PEQFilter>
className="peq-band-list__select"
value={peq.filter_type}
onChange={(e) => commit(band, { filter_type: e.target.value as PEQFilter, q: 3.0 })}
>
{PEQ_FILTERS_LABEL.map((opt) => (
<option key={opt.value} value={opt.value}>
{opt.label}
</option>
))}
</select>
options={PEQ_FILTERS_LABEL.map((opt) => opt.value)}
formatLabel={(v) =>
PEQ_FILTERS_LABEL.find((opt) => opt.value === v)?.label ?? String(v)
}
onChange={(value) => commit(band, { filter_type: value, q: 3.0 })}
/>
<Button
variant="toggle"
@@ -416,75 +412,6 @@ type SetFilterFn = (
filterType: CrossoverFilter
) => Promise<boolean>;
/** Small DOM-overlay markers positioned on top of the magnitude graph via its exposed toPxX/toPxY. */
// function GraphMarkers({
// graphRef,
// bands,
// activeBand,
// setActiveBand,
// hpFreq,
// hpBypassed,
// lpFreq,
// lpBypassed,
// }: {
// graphRef: React.RefObject<LinearGraphHandle>;
// bands: Record<PEQBand, PEQ>;
// activeBand: PEQBand;
// setActiveBand: (band: PEQBand) => void;
// hpFreq: number;
// hpBypassed: boolean;
// lpFreq: number;
// lpBypassed: boolean;
// }) {
// const g = graphRef.current;
// if (!g) return null;
// return (
// <>
// {PEQ_BANDS_ORDER.map((band, i) => {
// const peq = bands[band];
// const left = g.toPxX(peq.frequency);
// const top = g.toPxY(peq.gain);
// const isActive = band === activeBand;
// return (
// <button
// key={band}
// type="button"
// className={`graph-marker graph-marker--peq${isActive ? ' graph-marker--active' : ''}${
// peq.bypass ? ' graph-marker--bypassed' : ''
// }`}
// style={{ left, top }}
// onClick={() => setActiveBand(band)}
// title={`B${i + 1} · ${Math.round(peq.frequency)} Hz · ${peq.gain.toFixed(1)} dB`}
// >
// {`B${i + 1}`}
// </button>
// );
// })}
// <div
// className={`graph-marker graph-marker--crossover graph-marker--hp${
// hpBypassed ? ' graph-marker--bypassed' : ''
// }`}
// style={{ left: g.toPxX(hpFreq), top: g.toPxY(0) }}
// title={`HPF · ${Math.round(hpFreq)} Hz`}
// >
// HP
// </div>
// <div
// className={`graph-marker graph-marker--crossover graph-marker--lp${
// lpBypassed ? ' graph-marker--bypassed' : ''
// }`}
// style={{ left: g.toPxX(lpFreq), top: g.toPxY(0) }}
// title={`LPF · ${Math.round(lpFreq)} Hz`}
// >
// LP
// </div>
// </>
// );
// }
function InputSection({
dsp,
channel,
@@ -626,8 +553,8 @@ function InputSection({
yMin={GRAPH_Y_MIN}
yMax={GRAPH_Y_MAX}
yStep={3}
xLabel="Hz"
yLabel="dB"
xLabel="Frequency - Hz"
yLabel="Magnituded - dB"
showGrid={true}
formatX={(v) => Math.round(v).toString()}
formatY={(v) => Math.round(v).toString()}
@@ -635,7 +562,6 @@ function InputSection({
drawCurves({
ctx,
toPx,
xMin: GRAPH_X_MIN,
xMax: GRAPH_X_MAX,
yMin: GRAPH_Y_MIN,
@@ -667,8 +593,8 @@ function InputSection({
yMin={-180}
yMax={180}
yStep={45}
xLabel="Hz"
yLabel="°"
xLabel="Frequency - Hz"
yLabel="Phase - Deg"
showGrid={true}
formatX={(v) => Math.round(v).toString()}
formatY={(v) => Math.round(v).toString()}
@@ -676,7 +602,6 @@ function InputSection({
drawCurves({
ctx,
toPx,
xMin: GRAPH_X_MIN,
xMax: GRAPH_X_MAX,
yMin: GRAPH_Y_MIN,
@@ -109,4 +109,4 @@
.matrix-gain-stepper .choice-stepper__input {
font-size: 2.8cqh;
}
}