feat: limiter section for mobile
This commit is contained in:
@@ -9,9 +9,9 @@ import { useState } from 'react';
|
||||
import './LimiterSection.css';
|
||||
|
||||
const LIMITER_SLIDER_PARAMS = [
|
||||
{ key: 'threshold', label: 'Threshold', min: -90, max: 20, step: 0.5, unit: ' dB' },
|
||||
{ key: 'attack', label: 'Attack', min: 1, max: 999, step: 1, unit: ' ms' },
|
||||
{ key: 'release', label: 'Release', min: 10, max: 3000, step: 1, unit: ' ms' },
|
||||
{ key: 'threshold', label: 'Threshold', short: 'Thr', min: -90, max: 20, step: 0.5, unit: ' dB' },
|
||||
{ key: 'attack', label: 'Attack', short: 'Atk', min: 1, max: 999, step: 1, unit: ' ms' },
|
||||
{ key: 'release', label: 'Release', short: 'Rel', min: 10, max: 3000, step: 1, unit: ' ms' },
|
||||
] as const;
|
||||
|
||||
type LimiterParamKey = 'threshold' | 'attack' | 'release';
|
||||
@@ -29,6 +29,14 @@ type SetLimiterFn = (
|
||||
release: number
|
||||
) => Promise<boolean>;
|
||||
|
||||
// Phone only: one view at a time (CSS hides the tabs on desktop)
|
||||
type LimiterView = 'controls' | 'response';
|
||||
|
||||
const LIMITER_VIEWS: { id: LimiterView; label: string }[] = [
|
||||
{ id: 'controls', label: 'Controls' },
|
||||
{ id: 'response', label: 'Limiter response' },
|
||||
];
|
||||
|
||||
function LimiterPanel({
|
||||
channel,
|
||||
dsp,
|
||||
@@ -66,7 +74,10 @@ function LimiterPanel({
|
||||
onChange={(value) => commit({ [param.key]: value } as Partial<LimiterValues>)}
|
||||
style={{ width: '100%', flex: '1 1 auto' }}
|
||||
/>
|
||||
<div className="limiter-panel__cell-label">{param.label}</div>
|
||||
<div className="limiter-panel__cell-label">
|
||||
<span className="limiter-panel__label-long">{param.label}</span>
|
||||
<span className="limiter-panel__label-short">{param.short}</span>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
@@ -88,6 +99,7 @@ function LimiterSection({ dsp, set_limiter }: { dsp: DSP; set_limiter: SetLimite
|
||||
|
||||
const [activeChannel, setActiveChannel] = useState<OutputChannel>(outputs[0]);
|
||||
const [liveLim, setLiveLim] = useState<Partial<Record<OutputChannel, LimiterValues>>>({});
|
||||
const [view, setView] = useState<LimiterView>('controls');
|
||||
|
||||
const handleLiveValue = (channel: OutputChannel, key: LimiterParamKey, value: number) => {
|
||||
setActiveChannel(channel);
|
||||
@@ -118,7 +130,28 @@ function LimiterSection({ dsp, set_limiter }: { dsp: DSP; set_limiter: SetLimite
|
||||
const activeLim = liveLim[activeChannel] ?? (activeOutputState.limiter as LimiterValues);
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="limiter-page" data-view={view}>
|
||||
{/* Phone only (hidden on desktop by CSS): one view at a time */}
|
||||
<div className="limiter-tabs" role="tablist" aria-label="Limiter views">
|
||||
{LIMITER_VIEWS.map((v) => (
|
||||
<button
|
||||
key={v.id}
|
||||
type="button"
|
||||
role="tab"
|
||||
aria-selected={view === v.id}
|
||||
className="limiter-tabs__tab"
|
||||
onClick={() => setView(v.id)}
|
||||
>
|
||||
{v.label}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
|
||||
{/* Portrait phone only (CSS): the graph needs the width of landscape */}
|
||||
<div className="limiter-rotate-hint">
|
||||
Rotate your phone to landscape to see the limiter graph.
|
||||
</div>
|
||||
|
||||
<div className="limiter-linear-graph-section">
|
||||
<div className="limiter-graph-panel">
|
||||
<div className="limiter-graph__title">{activeOutputState.name} - Limiter</div>
|
||||
@@ -135,7 +168,7 @@ function LimiterSection({ dsp, set_limiter }: { dsp: DSP; set_limiter: SetLimite
|
||||
key={output}
|
||||
label={outputState.name}
|
||||
meter={dsp.output_meters.meters[output]}
|
||||
variant='output'
|
||||
variant="output"
|
||||
/>
|
||||
);
|
||||
})}
|
||||
@@ -158,8 +191,8 @@ function LimiterSection({ dsp, set_limiter }: { dsp: DSP; set_limiter: SetLimite
|
||||
</ChannelGroup>
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default LimiterSection;
|
||||
export default LimiterSection;
|
||||
Reference in New Issue
Block a user