feat: custom input formatting + custom step
This commit is contained in:
@@ -400,4 +400,64 @@ pub async fn set_geq_bypass(
|
|||||||
.set_geq_bypass(input_channel, bypass)
|
.set_geq_bypass(input_channel, bypass)
|
||||||
.map_err(|e| e.to_string())
|
.map_err(|e| e.to_string())
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub async fn set_low_pass(
|
||||||
|
state: State<'_, AppState>,
|
||||||
|
id: u64,
|
||||||
|
channel: types::Channel,
|
||||||
|
freq: f32,
|
||||||
|
filter_type: types::CrossoverFilter,
|
||||||
|
) -> Result<bool, String> {
|
||||||
|
state.with_device_mut(id, |device| {
|
||||||
|
device
|
||||||
|
.dsp
|
||||||
|
.set_low_pass(channel, freq, filter_type)
|
||||||
|
.map_err(|e| e.to_string())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub async fn set_high_pass(
|
||||||
|
state: State<'_, AppState>,
|
||||||
|
id: u64,
|
||||||
|
channel: types::Channel,
|
||||||
|
freq: f32,
|
||||||
|
filter_type: types::CrossoverFilter,
|
||||||
|
) -> Result<bool, String> {
|
||||||
|
state.with_device_mut(id, |device| {
|
||||||
|
device
|
||||||
|
.dsp
|
||||||
|
.set_high_pass(channel, freq, filter_type)
|
||||||
|
.map_err(|e| e.to_string())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub async fn set_peq_band(
|
||||||
|
state: State<'_, AppState>,
|
||||||
|
id: u64,
|
||||||
|
channel: types::Channel,
|
||||||
|
band: types::PEQBand,
|
||||||
|
gain_db: f32,
|
||||||
|
freq_hz: f32,
|
||||||
|
q: f32,
|
||||||
|
filter_type: types::PEQFilter,
|
||||||
|
bypass: bool,
|
||||||
|
) -> Result<bool, String> {
|
||||||
|
state.with_device_mut(id, |device| {
|
||||||
|
device
|
||||||
|
.dsp
|
||||||
|
.set_peq_band(
|
||||||
|
channel,
|
||||||
|
band,
|
||||||
|
gain_db,
|
||||||
|
freq_hz,
|
||||||
|
q,
|
||||||
|
filter_type,
|
||||||
|
bypass,
|
||||||
|
)
|
||||||
|
.map_err(|e| e.to_string())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|||||||
@@ -29,6 +29,9 @@ pub fn run() {
|
|||||||
commands::set_matrix_gain,
|
commands::set_matrix_gain,
|
||||||
commands::set_geq_band,
|
commands::set_geq_band,
|
||||||
commands::set_geq_bypass,
|
commands::set_geq_bypass,
|
||||||
|
commands::set_low_pass,
|
||||||
|
commands::set_high_pass,
|
||||||
|
commands::set_peq_band,
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
.run(tauri::generate_context!())
|
.run(tauri::generate_context!())
|
||||||
|
|||||||
@@ -64,3 +64,23 @@ export function KnobGainIcon(props: React.SVGProps<SVGSVGElement>) {
|
|||||||
</svg>
|
</svg>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function TextIcon({
|
||||||
|
children,
|
||||||
|
...props
|
||||||
|
}: React.SVGProps<SVGSVGElement> & { children: React.ReactNode }) {
|
||||||
|
return (
|
||||||
|
<svg viewBox="0 0 24 24" {...props}>
|
||||||
|
<text
|
||||||
|
x="12"
|
||||||
|
y="12"
|
||||||
|
textAnchor="middle"
|
||||||
|
dominantBaseline="middle"
|
||||||
|
fontSize="9.5"
|
||||||
|
fill="currentColor"
|
||||||
|
>
|
||||||
|
{children}
|
||||||
|
</text>
|
||||||
|
</svg>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|||||||
@@ -220,7 +220,7 @@ function CompressorPanel({
|
|||||||
<VerticalSlider
|
<VerticalSlider
|
||||||
min={param.min}
|
min={param.min}
|
||||||
max={param.max}
|
max={param.max}
|
||||||
step={param.step}
|
step={() => param.step}
|
||||||
unit={param.unit}
|
unit={param.unit}
|
||||||
value={comp[param.key]}
|
value={comp[param.key]}
|
||||||
onInput={(value) => onLiveValue(channel, param.key, value)}
|
onInput={(value) => onLiveValue(channel, param.key, value)}
|
||||||
|
|||||||
@@ -31,7 +31,7 @@
|
|||||||
.delay-panel {
|
.delay-panel {
|
||||||
position: relative;
|
position: relative;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
aspect-ratio: 1 / 4;
|
aspect-ratio: 0.26;
|
||||||
flex: 0 0 auto;
|
flex: 0 0 auto;
|
||||||
|
|
||||||
display: flex;
|
display: flex;
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ function DelayPanel({
|
|||||||
<VerticalSlider
|
<VerticalSlider
|
||||||
min={min}
|
min={min}
|
||||||
max={max}
|
max={max}
|
||||||
step={DELAY_STEP[unit]}
|
step={() => DELAY_STEP[unit]}
|
||||||
unit={' ' + UNIT_LABEL[unit]}
|
unit={' ' + UNIT_LABEL[unit]}
|
||||||
value={state.delay}
|
value={state.delay}
|
||||||
onInput={(value) => onLiveValue(channel, value)}
|
onInput={(value) => onLiveValue(channel, value)}
|
||||||
|
|||||||
@@ -45,9 +45,7 @@ function GainPanel({
|
|||||||
<VerticalSlider
|
<VerticalSlider
|
||||||
min={-60}
|
min={-60}
|
||||||
max={12}
|
max={12}
|
||||||
step={0.5}
|
step={(v) => (v >= -20 ? 0.1 : 0.5)}
|
||||||
switchStepValue={-10}
|
|
||||||
switchStep={0.1}
|
|
||||||
unit=" dB"
|
unit=" dB"
|
||||||
value={gain}
|
value={gain}
|
||||||
onChange={(value) => setGain(channel, value)}
|
onChange={(value) => setGain(channel, value)}
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ function GatePanel({
|
|||||||
<VerticalSlider
|
<VerticalSlider
|
||||||
min={param.min}
|
min={param.min}
|
||||||
max={param.max}
|
max={param.max}
|
||||||
step={param.step}
|
step={() => param.step}
|
||||||
unit={param.unit}
|
unit={param.unit}
|
||||||
value={gate[param.key]}
|
value={gate[param.key]}
|
||||||
onInput={(value) => onLiveValue(channel, param.key, value)}
|
onInput={(value) => onLiveValue(channel, param.key, value)}
|
||||||
|
|||||||
@@ -83,10 +83,11 @@ function GeqBandPanel({
|
|||||||
<VerticalSlider
|
<VerticalSlider
|
||||||
min={GEQ_GAIN_MIN}
|
min={GEQ_GAIN_MIN}
|
||||||
max={GEQ_GAIN_MAX}
|
max={GEQ_GAIN_MAX}
|
||||||
step={GEQ_GAIN_STEP}
|
step={() => GEQ_GAIN_STEP}
|
||||||
unit=""
|
unit=""
|
||||||
showTicks={false}
|
showTicks={false}
|
||||||
value={geq.gains[frequency]}
|
value={geq.gains[frequency]}
|
||||||
|
formatValue={(v, d) => (v > 0 ? `+${v.toFixed(d)}` : v.toFixed(d))}
|
||||||
onInput={(value) => onLiveValue(channel, frequency, value)}
|
onInput={(value) => onLiveValue(channel, frequency, value)}
|
||||||
onChange={(value) => setBand(channel, frequency, value)}
|
onChange={(value) => setBand(channel, frequency, value)}
|
||||||
style={{ width: '100%', flex: '1 1 auto' }}
|
style={{ width: '100%', flex: '1 1 auto' }}
|
||||||
|
|||||||
@@ -0,0 +1,225 @@
|
|||||||
|
/* InputSection.css */
|
||||||
|
.input-graph-section {
|
||||||
|
flex: 0 0 calc(100% - var(--dsp-control-heigth));
|
||||||
|
min-height: 0;
|
||||||
|
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
gap: 1cqh;
|
||||||
|
padding: 0.5cqh;
|
||||||
|
|
||||||
|
box-sizing: border-box;
|
||||||
|
background: var(--bg-panel);
|
||||||
|
}
|
||||||
|
|
||||||
|
.input-graph-panel {
|
||||||
|
flex: 1 1 auto;
|
||||||
|
min-width: 0;
|
||||||
|
min-height: 0;
|
||||||
|
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
|
||||||
|
border: var(--border-width) solid var(--border-hairline);
|
||||||
|
border-radius: var(--radius-md);
|
||||||
|
}
|
||||||
|
|
||||||
|
.input-graph__title {
|
||||||
|
flex: 0 0 auto;
|
||||||
|
|
||||||
|
text-align: center;
|
||||||
|
padding: 1cqh;
|
||||||
|
|
||||||
|
font-family: var(--font-ui);
|
||||||
|
font-size: 2.5cqh;
|
||||||
|
font-weight: var(--font-weight-semibold);
|
||||||
|
}
|
||||||
|
|
||||||
|
.input-graph-panel > .container {
|
||||||
|
flex: 1;
|
||||||
|
min-height: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.input-control-section {
|
||||||
|
container-type: size;
|
||||||
|
position: absolute;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
bottom: 0;
|
||||||
|
|
||||||
|
height: var(--dsp-control-heigth);
|
||||||
|
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
|
||||||
|
box-sizing: border-box;
|
||||||
|
|
||||||
|
background: var(--bg-panel);
|
||||||
|
|
||||||
|
z-index: 20;
|
||||||
|
|
||||||
|
border-top: var(--border-width) solid var(--border-hairline);
|
||||||
|
}
|
||||||
|
|
||||||
|
.input-control-panel {
|
||||||
|
height: 100%;
|
||||||
|
width: 100%;
|
||||||
|
max-width: 60cqw;
|
||||||
|
|
||||||
|
display: flex;
|
||||||
|
align-items: stretch;
|
||||||
|
gap: var(--space-4);
|
||||||
|
|
||||||
|
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;
|
||||||
|
height: 10;
|
||||||
|
|
||||||
|
aspect-ratio: 0.75;
|
||||||
|
flex: 0 0 auto;
|
||||||
|
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: stretch;
|
||||||
|
justify-content: flex-start;
|
||||||
|
|
||||||
|
border: var(--border-width) solid var(--border-hairline);
|
||||||
|
border-radius: var(--radius-md);
|
||||||
|
box-sizing: border-box;
|
||||||
|
background: var(--bg-void);
|
||||||
|
}
|
||||||
|
|
||||||
|
.input-panel__title {
|
||||||
|
flex: 0 0 auto;
|
||||||
|
width: 100%;
|
||||||
|
text-align: center;
|
||||||
|
font-family: var(--font-ui);
|
||||||
|
font-size: 4cqh;
|
||||||
|
font-weight: var(--font-weight-semibold);
|
||||||
|
padding-top: 2cqh;
|
||||||
|
padding-bottom: 2cqh;
|
||||||
|
border-bottom: var(--border-width) solid var(--border-hairline);
|
||||||
|
|
||||||
|
min-width: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
}
|
||||||
|
|
||||||
|
.input-panel__grid {
|
||||||
|
flex: 1 1 auto;
|
||||||
|
min-height: 0;
|
||||||
|
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(3, 1fr);
|
||||||
|
grid-template-rows: 1fr;
|
||||||
|
|
||||||
|
gap: 2cqh;
|
||||||
|
|
||||||
|
padding: 2cqh;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
.input-panel__cell {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: flex-start;
|
||||||
|
min-height: 0;
|
||||||
|
min-width: 0;
|
||||||
|
gap: 1cqh;
|
||||||
|
}
|
||||||
|
|
||||||
|
.input-panel__cell-label {
|
||||||
|
flex: 0 0 auto;
|
||||||
|
font-family: var(--font-ui);
|
||||||
|
font-size: 2.5cqh;
|
||||||
|
color: var(--text-muted);
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
@@ -0,0 +1,292 @@
|
|||||||
|
// InputSection.tsx
|
||||||
|
import VerticalSlider from '../VerticalSlider/VerticalSlider';
|
||||||
|
// ASSUMPTION: an InputChannel enum exists alongside OutputChannel, mapping
|
||||||
|
// input pages 1-8 similarly (In1 -> 0, In2 -> 1, ...). Adjust import/values
|
||||||
|
// if the actual enum differs.
|
||||||
|
import { InputChannel, Channel, PEQBand, PEQFilter, PEQ } from '../../../types/dsp408State';
|
||||||
|
import { DSP } from '../../../types/types';
|
||||||
|
import { CrossoverFilter } from '../../../types/dsp408State';
|
||||||
|
import { LinearGraph } from '../LinearGraph/LinearGraph';
|
||||||
|
import { useRef, useState } from 'react';
|
||||||
|
import './InputSection.css';
|
||||||
|
import ChannelGroup from '../ChannelGroup/ChannelGroup';
|
||||||
|
|
||||||
|
const FREQ_MIN = 20;
|
||||||
|
const FREQ_MAX = 20000;
|
||||||
|
const FREQ_STEP = 1;
|
||||||
|
|
||||||
|
const FILTER_TYPE_OPTIONS: { value: CrossoverFilter; label: string }[] = [
|
||||||
|
{ value: CrossoverFilter.Bw6, label: 'BW 6 dB/oct' },
|
||||||
|
{ value: CrossoverFilter.Bw12, label: 'BW 12 dB/oct' },
|
||||||
|
{ value: CrossoverFilter.Bw18, label: 'BW 18 dB/oct' },
|
||||||
|
{ value: CrossoverFilter.Bw24, label: 'BW 24 dB/oct' },
|
||||||
|
{ value: CrossoverFilter.Bw30, label: 'BW 30 dB/oct' },
|
||||||
|
{ value: CrossoverFilter.Bw36, label: 'BW 36 dB/oct' },
|
||||||
|
{ value: CrossoverFilter.Bw42, label: 'BW 42 dB/oct' },
|
||||||
|
{ value: CrossoverFilter.Bw48, label: 'BW 48 dB/oct' },
|
||||||
|
{ value: CrossoverFilter.Lk12, label: 'LR 12 dB/oct' },
|
||||||
|
{ value: CrossoverFilter.Lk24, label: 'LR 24 dB/oct' },
|
||||||
|
{ value: CrossoverFilter.Lk36, label: 'LR 36 dB/oct' },
|
||||||
|
{ value: CrossoverFilter.Lk48, label: 'LR 48 dB/oct' },
|
||||||
|
];
|
||||||
|
|
||||||
|
const DEFAULT_FILTER_TYPE = CrossoverFilter.Bw12;
|
||||||
|
|
||||||
|
const PEQ_SLIDER_PARAMS = [
|
||||||
|
{ key: 'frequency', label: 'Frequency', min: 19.7, max: 20.16, step: 0.5, unit: ' Hz' },
|
||||||
|
{ key: 'q', label: 'Q', min: 1, max: 999, step: 1, unit: '' },
|
||||||
|
{ key: 'gain', label: 'Gain', min: -12, max: +12, step: 0.1, unit: ' dB' },
|
||||||
|
] as const;
|
||||||
|
|
||||||
|
type SetPEQFn = (
|
||||||
|
channel: Channel,
|
||||||
|
band: PEQBand,
|
||||||
|
gainDb: number,
|
||||||
|
freqHz: number,
|
||||||
|
q: number,
|
||||||
|
filterType: PEQFilter,
|
||||||
|
bypass: boolean
|
||||||
|
) => Promise<boolean>;
|
||||||
|
|
||||||
|
type PeqParamKey = 'frequency' | 'q' | 'gain';
|
||||||
|
|
||||||
|
type PEQValues = {
|
||||||
|
frequency: number;
|
||||||
|
q: number;
|
||||||
|
gain: number;
|
||||||
|
filter_type: PEQFilter;
|
||||||
|
bypass: boolean;
|
||||||
|
};
|
||||||
|
|
||||||
|
function PeqPanelSliders({
|
||||||
|
channel,
|
||||||
|
dsp,
|
||||||
|
band,
|
||||||
|
setPEQ,
|
||||||
|
// onLiveValue,
|
||||||
|
}: {
|
||||||
|
channel: InputChannel;
|
||||||
|
dsp: DSP;
|
||||||
|
band: PEQBand;
|
||||||
|
setPEQ: SetPEQFn;
|
||||||
|
// onLiveValue: (channel: InputChannel, key: PeqParamKey, value: number) => void;
|
||||||
|
}) {
|
||||||
|
const inputState = dsp.state.current_config.input_states[channel];
|
||||||
|
const peq = inputState.peq_chain.bands[band] as PEQ;
|
||||||
|
|
||||||
|
const commit = (overrides: Partial<PEQValues>) => {
|
||||||
|
const next = { ...peq, ...overrides };
|
||||||
|
return setPEQ(
|
||||||
|
{ Input: channel },
|
||||||
|
band,
|
||||||
|
next.gain,
|
||||||
|
next.frequency,
|
||||||
|
next.q,
|
||||||
|
next.filter_type,
|
||||||
|
next.bypass
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="input-panel">
|
||||||
|
<div className="input-panel__title">{'PEQ Parameters'}</div>
|
||||||
|
|
||||||
|
<div className="input-panel__grid">
|
||||||
|
{PEQ_SLIDER_PARAMS.map((param) => (
|
||||||
|
<div className={`input-panel__cell input-panel__cell--${param.key}`} key={param.key}>
|
||||||
|
<VerticalSlider
|
||||||
|
min={param.min}
|
||||||
|
max={param.max}
|
||||||
|
step={() => param.step}
|
||||||
|
unit={param.unit}
|
||||||
|
value={peq[param.key]}
|
||||||
|
// onInput={(value) => onLiveValue(channel, param.key, value)}
|
||||||
|
onChange={(value) => commit({ [param.key]: value } as Partial<PEQValues>)}
|
||||||
|
style={{ width: '100%', flex: '1 1 auto' }}
|
||||||
|
/>
|
||||||
|
<div className="input-panel__cell-label">{param.label}</div>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
type SetFilterFn = (
|
||||||
|
channel: Channel,
|
||||||
|
freq: number,
|
||||||
|
filterType: CrossoverFilter
|
||||||
|
) => Promise<boolean>;
|
||||||
|
|
||||||
|
type setPeqBandFn = (
|
||||||
|
channel: Channel,
|
||||||
|
band: PEQBand,
|
||||||
|
gainDb: number,
|
||||||
|
freqHz: number,
|
||||||
|
q: number,
|
||||||
|
filterType: PEQFilter,
|
||||||
|
bypass: boolean
|
||||||
|
) => Promise<boolean>;
|
||||||
|
|
||||||
|
function InputSection({
|
||||||
|
dsp,
|
||||||
|
channel,
|
||||||
|
set_high_pass,
|
||||||
|
set_low_pass,
|
||||||
|
setPeq,
|
||||||
|
// setPeqBypass,
|
||||||
|
}: {
|
||||||
|
dsp: DSP;
|
||||||
|
channel: InputChannel;
|
||||||
|
set_high_pass: SetFilterFn;
|
||||||
|
set_low_pass: SetFilterFn;
|
||||||
|
setPeq: setPeqBandFn;
|
||||||
|
// setPeqBypass;
|
||||||
|
}) {
|
||||||
|
const [activeBand, setActiveBand] = useState<PEQBand>(PEQBand.B1);
|
||||||
|
|
||||||
|
const [liveHpFreq, setLiveHpFreq] = useState<number>(19.7);
|
||||||
|
const [liveLpFreq, setLiveLpFreq] = useState<number>(20.16);
|
||||||
|
const [livePeq, setLivePeq] = useState<Partial<Record<PEQBand, PEQValues>>>({});
|
||||||
|
|
||||||
|
const inputState = dsp.state.current_config.input_states[channel];
|
||||||
|
|
||||||
|
const hp = inputState.crossover.high_pass;
|
||||||
|
const lp = inputState.crossover.low_pass;
|
||||||
|
const activePeq = livePeq[activeBand] ?? (inputState.peq_chain.bands[activeBand] as PEQValues);
|
||||||
|
|
||||||
|
const bypassed = hp.slope === CrossoverFilter.Bypass;
|
||||||
|
const activeFilterType = bypassed && lp.slope !== CrossoverFilter.Bypass ? lp.slope : hp.slope;
|
||||||
|
|
||||||
|
// Remembers the last non-bypass slope so the Bypass button can restore it.
|
||||||
|
const lastNonBypassType = useRef<CrossoverFilter>(
|
||||||
|
activeFilterType === CrossoverFilter.Bypass ? DEFAULT_FILTER_TYPE : activeFilterType
|
||||||
|
);
|
||||||
|
if (activeFilterType !== CrossoverFilter.Bypass) {
|
||||||
|
lastNonBypassType.current = activeFilterType;
|
||||||
|
}
|
||||||
|
|
||||||
|
const hpFreq = liveHpFreq ?? hp.frequency;
|
||||||
|
const lpFreq = liveLpFreq ?? lp.frequency;
|
||||||
|
|
||||||
|
// const commitHighPass = async (freq: number, filterType: CrossoverFilter) => {
|
||||||
|
// const success = await set_high_pass({ Input: channel }, freq, filterType);
|
||||||
|
// if (success) setLiveHpFreq(null);
|
||||||
|
// return success;
|
||||||
|
// };
|
||||||
|
|
||||||
|
// const commitLowPass = async (freq: number, filterType: CrossoverFilter) => {
|
||||||
|
// const success = await set_low_pass({ Input: channel }, freq, filterType);
|
||||||
|
// if (success) setLiveLpFreq(null);
|
||||||
|
// return success;
|
||||||
|
// };
|
||||||
|
|
||||||
|
// const handleFilterTypeChange = (filterType: CrossoverFilter) => {
|
||||||
|
// // Applying a slope change always takes the crossover out of bypass.
|
||||||
|
// void commitHighPass(hpFreq, filterType);
|
||||||
|
// void commitLowPass(lpFreq, filterType);
|
||||||
|
// };
|
||||||
|
|
||||||
|
// const handleBypassToggle = () => {
|
||||||
|
// if (bypassed) {
|
||||||
|
// const restore = lastNonBypassType.current;
|
||||||
|
// void commitHighPass(hpFreq, restore);
|
||||||
|
// void commitLowPass(lpFreq, restore);
|
||||||
|
// } else {
|
||||||
|
// void commitHighPass(hpFreq, CrossoverFilter.Bypass);
|
||||||
|
// void commitLowPass(lpFreq, CrossoverFilter.Bypass);
|
||||||
|
// }
|
||||||
|
// };
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<div className="input-graph-section">
|
||||||
|
<div className="input-graph-panel">
|
||||||
|
<div className="input-graph__title">{inputState.name} - Filters</div>
|
||||||
|
|
||||||
|
{/* TODO: draw HP/LP transfer curves here once filter math is defined,
|
||||||
|
same pattern as LimiterSection's `draw` prop. */}
|
||||||
|
<LinearGraph
|
||||||
|
xMin={20}
|
||||||
|
xMax={20000}
|
||||||
|
yMin={-30}
|
||||||
|
yMax={6}
|
||||||
|
xLabel="Hz"
|
||||||
|
yLabel="dB"
|
||||||
|
formatX={(v) => Math.round(v).toString()}
|
||||||
|
formatY={(v) => Math.round(v).toString()}
|
||||||
|
draw={() => {}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="input-control-section">
|
||||||
|
<div className="input-control-panel">
|
||||||
|
<ChannelGroup title="PEQ">
|
||||||
|
<PeqPanelSliders channel={channel} dsp={dsp} band={PEQBand.B1} setPEQ={setPeq} />
|
||||||
|
</ChannelGroup>
|
||||||
|
{/* <div className="input-control-panel__sliders">
|
||||||
|
<div className="input-control-panel__cell input-control-panel__cell--high-pass">
|
||||||
|
<VerticalSlider
|
||||||
|
min={FREQ_MIN}
|
||||||
|
max={FREQ_MAX}
|
||||||
|
step={FREQ_STEP}
|
||||||
|
unit=" Hz"
|
||||||
|
value={hpFreq}
|
||||||
|
// disabled={bypassed}
|
||||||
|
onInput={(value) => setLiveHpFreq(value)}
|
||||||
|
onChange={(value) => commitHighPass(value, activeFilterType)}
|
||||||
|
style={{ width: '100%', flex: '1 1 auto' }}
|
||||||
|
/>
|
||||||
|
<div className="input-control-panel__cell-label">High Pass</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="input-control-panel__cell input-control-panel__cell--low-pass">
|
||||||
|
<VerticalSlider
|
||||||
|
min={FREQ_MIN}
|
||||||
|
max={FREQ_MAX}
|
||||||
|
step={FREQ_STEP}
|
||||||
|
unit=" Hz"
|
||||||
|
value={lpFreq}
|
||||||
|
// disabled={bypassed}
|
||||||
|
onInput={(value) => setLiveLpFreq(value)}
|
||||||
|
onChange={(value) => commitLowPass(value, activeFilterType)}
|
||||||
|
style={{ width: '100%', flex: '1 1 auto' }}
|
||||||
|
/>
|
||||||
|
<div className="input-control-panel__cell-label">Low Pass</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="input-control-panel__side">
|
||||||
|
<label className="input-control-panel__select">
|
||||||
|
<span className="input-control-panel__select-label">Filter Type</span>
|
||||||
|
<select
|
||||||
|
value={activeFilterType}
|
||||||
|
disabled={bypassed}
|
||||||
|
onChange={(e) => handleFilterTypeChange(e.target.value as CrossoverFilter)}
|
||||||
|
>
|
||||||
|
{FILTER_TYPE_OPTIONS.map((opt) => (
|
||||||
|
<option key={opt.value} value={opt.value}>
|
||||||
|
{opt.label}
|
||||||
|
</option>
|
||||||
|
))}
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className={`input-control-panel__bypass-btn${
|
||||||
|
bypassed ? ' input-control-panel__bypass-btn--active' : ''
|
||||||
|
}`}
|
||||||
|
onClick={handleBypassToggle}
|
||||||
|
>
|
||||||
|
{bypassed ? 'Bypassed' : 'Bypass'}
|
||||||
|
</button>
|
||||||
|
</div> */}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default InputSection;
|
||||||
@@ -73,7 +73,7 @@ function LimiterPanel({
|
|||||||
<VerticalSlider
|
<VerticalSlider
|
||||||
min={param.min}
|
min={param.min}
|
||||||
max={param.max}
|
max={param.max}
|
||||||
step={param.step}
|
step={() => param.step}
|
||||||
unit={param.unit}
|
unit={param.unit}
|
||||||
value={lim[param.key]}
|
value={lim[param.key]}
|
||||||
onInput={(value) => onLiveValue(channel, param.key, value)}
|
onInput={(value) => onLiveValue(channel, param.key, value)}
|
||||||
|
|||||||
@@ -1,20 +1,20 @@
|
|||||||
import { useEffect, useMemo, useRef, useState } from 'react';
|
import { useEffect, useMemo, useRef, useState } from 'react';
|
||||||
|
|
||||||
import './VerticalSlider.css';
|
import './VerticalSlider.css';
|
||||||
|
|
||||||
|
type StepFn = (value: number) => number;
|
||||||
|
|
||||||
type VerticalSliderProps = {
|
type VerticalSliderProps = {
|
||||||
min: number;
|
min: number;
|
||||||
max: number;
|
max: number;
|
||||||
step: number;
|
|
||||||
|
|
||||||
switchStepValue?: number;
|
step?: StepFn;
|
||||||
switchStep?: number;
|
|
||||||
|
|
||||||
value: number;
|
value: number;
|
||||||
onChange?: (value: number) => Promise<boolean>;
|
onChange?: (value: number) => Promise<boolean>;
|
||||||
onInput?: (value: number) => void;
|
onInput?: (value: number) => void;
|
||||||
|
|
||||||
unit?: string;
|
unit?: string;
|
||||||
|
formatValue?: (value: number, decimals: number) => string;
|
||||||
|
|
||||||
showTicks?: boolean;
|
showTicks?: boolean;
|
||||||
|
|
||||||
@@ -22,6 +22,12 @@ type VerticalSliderProps = {
|
|||||||
style?: React.CSSProperties;
|
style?: React.CSSProperties;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const defaultStep: StepFn = () => 0.1;
|
||||||
|
|
||||||
|
function formatValueDefault(v: number, decimals: number) {
|
||||||
|
return v.toFixed(decimals);
|
||||||
|
}
|
||||||
|
|
||||||
const MIN_TICKS = 3;
|
const MIN_TICKS = 3;
|
||||||
const MAX_TICK_SPACING_PX = 16;
|
const MAX_TICK_SPACING_PX = 16;
|
||||||
|
|
||||||
@@ -34,13 +40,12 @@ function getDecimals(n: number) {
|
|||||||
export default function VerticalSlider({
|
export default function VerticalSlider({
|
||||||
min,
|
min,
|
||||||
max,
|
max,
|
||||||
step,
|
step = defaultStep,
|
||||||
switchStepValue,
|
|
||||||
switchStep,
|
|
||||||
value,
|
value,
|
||||||
onChange,
|
onChange,
|
||||||
onInput,
|
onInput,
|
||||||
unit = '',
|
unit = '',
|
||||||
|
formatValue,
|
||||||
showTicks = true,
|
showTicks = true,
|
||||||
className,
|
className,
|
||||||
style,
|
style,
|
||||||
@@ -85,26 +90,16 @@ export default function VerticalSlider({
|
|||||||
return () => observer.disconnect();
|
return () => observer.disconnect();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
function getStep(value: number) {
|
|
||||||
if (switchStepValue !== undefined && switchStep !== undefined && value >= switchStepValue) {
|
|
||||||
return switchStep;
|
|
||||||
}
|
|
||||||
|
|
||||||
return step;
|
|
||||||
}
|
|
||||||
|
|
||||||
const decimals = useMemo(
|
const decimals = useMemo(
|
||||||
() =>
|
() => Math.min(3, getDecimals(step(displayValue))),
|
||||||
Math.min(
|
[step, displayValue]
|
||||||
3,
|
|
||||||
Math.max(getDecimals(step), switchStep !== undefined ? getDecimals(switchStep) : 0)
|
|
||||||
),
|
|
||||||
[step, switchStep]
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const formattedValue = (formatValue ?? formatValueDefault)(displayValue, decimals);
|
||||||
|
|
||||||
function normalizeValue(input: number) {
|
function normalizeValue(input: number) {
|
||||||
const clamped = Math.min(max, Math.max(min, input));
|
const clamped = Math.min(max, Math.max(min, input));
|
||||||
const currentStep = getStep(clamped);
|
const currentStep = step(clamped);
|
||||||
const snapped = min + Math.round((clamped - min) / currentStep) * currentStep;
|
const snapped = min + Math.round((clamped - min) / currentStep) * currentStep;
|
||||||
return Number(Math.min(max, Math.max(min, snapped)).toFixed(6));
|
return Number(Math.min(max, Math.max(min, snapped)).toFixed(6));
|
||||||
}
|
}
|
||||||
@@ -125,17 +120,11 @@ export default function VerticalSlider({
|
|||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
const base = keyboardValue.current ?? value;
|
const base = keyboardValue.current ?? value;
|
||||||
const currentStep = getStep(base);
|
const currentStep = step(base);
|
||||||
|
|
||||||
let next = base;
|
let next = base;
|
||||||
|
if (e.key === 'ArrowUp' || e.key === 'ArrowRight') next += currentStep;
|
||||||
if (e.key === 'ArrowUp' || e.key === 'ArrowRight') {
|
if (e.key === 'ArrowDown' || e.key === 'ArrowLeft') next -= currentStep;
|
||||||
next += currentStep;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (e.key === 'ArrowDown' || e.key === 'ArrowLeft') {
|
|
||||||
next -= currentStep;
|
|
||||||
}
|
|
||||||
|
|
||||||
next = normalizeValue(next);
|
next = normalizeValue(next);
|
||||||
keyboardValue.current = next;
|
keyboardValue.current = next;
|
||||||
@@ -265,9 +254,9 @@ export default function VerticalSlider({
|
|||||||
ref={inputRef}
|
ref={inputRef}
|
||||||
type="text"
|
type="text"
|
||||||
inputMode="decimal"
|
inputMode="decimal"
|
||||||
value={editingText ?? displayValue.toFixed(decimals)}
|
value={editingText ?? formattedValue}
|
||||||
style={{ width: '100%' }}
|
style={{ width: '100%' }}
|
||||||
onFocus={() => setEditingText(value.toFixed(decimals))}
|
onFocus={() => setEditingText(value.toFixed(decimals))} // plain number while editing
|
||||||
onChange={(e) => setEditingText(e.target.value)}
|
onChange={(e) => setEditingText(e.target.value)}
|
||||||
onBlur={commitEditing}
|
onBlur={commitEditing}
|
||||||
onKeyDown={(e) => {
|
onKeyDown={(e) => {
|
||||||
|
|||||||
+288
-3
@@ -15,6 +15,9 @@ import {
|
|||||||
Meters,
|
Meters,
|
||||||
DSPState,
|
DSPState,
|
||||||
DiscreteFrequency,
|
DiscreteFrequency,
|
||||||
|
CrossoverFilter,
|
||||||
|
PEQFilter,
|
||||||
|
PEQBand,
|
||||||
} from '../types/dsp408State';
|
} from '../types/dsp408State';
|
||||||
|
|
||||||
type NotifyFunction = (message: string, type: 'success' | 'error', dspName?: string) => void;
|
type NotifyFunction = (message: string, type: 'success' | 'error', dspName?: string) => void;
|
||||||
@@ -70,6 +73,17 @@ export type DSP408Device = {
|
|||||||
gain: number
|
gain: number
|
||||||
) => Promise<boolean>;
|
) => Promise<boolean>;
|
||||||
setGeqBypass: (inputChannel: InputChannel, bypass: boolean) => Promise<boolean>;
|
setGeqBypass: (inputChannel: InputChannel, bypass: boolean) => Promise<boolean>;
|
||||||
|
setLowPass: (channel: Channel, freq: number, filterType: CrossoverFilter) => Promise<boolean>;
|
||||||
|
setHighPass: (channel: Channel, freq: number, filterType: CrossoverFilter) => Promise<boolean>;
|
||||||
|
setPeqBand: (
|
||||||
|
channel: Channel,
|
||||||
|
band: PEQBand,
|
||||||
|
gainDb: number,
|
||||||
|
freqHz: number,
|
||||||
|
q: number,
|
||||||
|
filterType: PEQFilter,
|
||||||
|
bypass: boolean
|
||||||
|
) => Promise<boolean>;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Polling
|
// Polling
|
||||||
@@ -1127,6 +1141,267 @@ export function useDSP408(
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function setLowPass(
|
||||||
|
dsp: DSP,
|
||||||
|
channel: Channel,
|
||||||
|
freq: number,
|
||||||
|
filterType: CrossoverFilter
|
||||||
|
): Promise<boolean> {
|
||||||
|
return withPollingPaused(dsp, async () => {
|
||||||
|
try {
|
||||||
|
const success = await invoke<boolean>('set_low_pass', {
|
||||||
|
id: dsp.id,
|
||||||
|
channel,
|
||||||
|
freq,
|
||||||
|
filterType,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!success) {
|
||||||
|
notify('Failed to set low-pass filter', 'error', dsp.name);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
updateDSP(setDsps, dsp.id, (d) => {
|
||||||
|
if (!d.state) return d;
|
||||||
|
|
||||||
|
const currentConfig = d.state.current_config;
|
||||||
|
|
||||||
|
if ('Input' in channel) {
|
||||||
|
return {
|
||||||
|
...d,
|
||||||
|
state: {
|
||||||
|
...d.state,
|
||||||
|
current_config: {
|
||||||
|
...currentConfig,
|
||||||
|
input_states: {
|
||||||
|
...currentConfig.input_states,
|
||||||
|
[channel.Input]: {
|
||||||
|
...currentConfig.input_states[channel.Input],
|
||||||
|
low_pass: {
|
||||||
|
frequency: freq,
|
||||||
|
filter_type: filterType,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
...d,
|
||||||
|
state: {
|
||||||
|
...d.state,
|
||||||
|
current_config: {
|
||||||
|
...currentConfig,
|
||||||
|
output_states: {
|
||||||
|
...currentConfig.output_states,
|
||||||
|
[channel.Output]: {
|
||||||
|
...currentConfig.output_states[channel.Output],
|
||||||
|
low_pass: {
|
||||||
|
frequency: freq,
|
||||||
|
filter_type: filterType,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
notify('Low-pass filter updated', 'success', dsp.name);
|
||||||
|
return true;
|
||||||
|
} catch (err) {
|
||||||
|
notify(`Low-pass update failed: ${String(err)}`, 'error', dsp.name);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async function setHighPass(
|
||||||
|
dsp: DSP,
|
||||||
|
channel: Channel,
|
||||||
|
freq: number,
|
||||||
|
filterType: CrossoverFilter
|
||||||
|
): Promise<boolean> {
|
||||||
|
return withPollingPaused(dsp, async () => {
|
||||||
|
try {
|
||||||
|
const success = await invoke<boolean>('set_high_pass', {
|
||||||
|
id: dsp.id,
|
||||||
|
channel,
|
||||||
|
freq,
|
||||||
|
filterType,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!success) {
|
||||||
|
notify('Failed to set high-pass filter', 'error', dsp.name);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
updateDSP(setDsps, dsp.id, (d) => {
|
||||||
|
if (!d.state) return d;
|
||||||
|
|
||||||
|
const currentConfig = d.state.current_config;
|
||||||
|
|
||||||
|
if ('Input' in channel) {
|
||||||
|
return {
|
||||||
|
...d,
|
||||||
|
state: {
|
||||||
|
...d.state,
|
||||||
|
current_config: {
|
||||||
|
...currentConfig,
|
||||||
|
input_states: {
|
||||||
|
...currentConfig.input_states,
|
||||||
|
[channel.Input]: {
|
||||||
|
...currentConfig.input_states[channel.Input],
|
||||||
|
high_pass: {
|
||||||
|
frequency: freq,
|
||||||
|
filter_type: filterType,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
...d,
|
||||||
|
state: {
|
||||||
|
...d.state,
|
||||||
|
current_config: {
|
||||||
|
...currentConfig,
|
||||||
|
output_states: {
|
||||||
|
...currentConfig.output_states,
|
||||||
|
[channel.Output]: {
|
||||||
|
...currentConfig.output_states[channel.Output],
|
||||||
|
high_pass: {
|
||||||
|
frequency: freq,
|
||||||
|
filter_type: filterType,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
notify('High-pass filter updated', 'success', dsp.name);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
} catch (err) {
|
||||||
|
notify(`High-pass update failed: ${String(err)}`, 'error', dsp.name);
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async function setPeqBand(
|
||||||
|
dsp: DSP,
|
||||||
|
channel: Channel,
|
||||||
|
band: PEQBand,
|
||||||
|
gainDb: number,
|
||||||
|
freqHz: number,
|
||||||
|
q: number,
|
||||||
|
filterType: PEQFilter,
|
||||||
|
bypass: boolean
|
||||||
|
): Promise<boolean> {
|
||||||
|
return withPollingPaused(dsp, async () => {
|
||||||
|
try {
|
||||||
|
const success = await invoke<boolean>('set_peq_band', {
|
||||||
|
id: dsp.id,
|
||||||
|
channel,
|
||||||
|
band,
|
||||||
|
gainDb,
|
||||||
|
freqHz,
|
||||||
|
q,
|
||||||
|
filterType,
|
||||||
|
bypass,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!success) {
|
||||||
|
notify('Failed to set PEQ band', 'error', dsp.name);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
updateDSP(setDsps, dsp.id, (d) => {
|
||||||
|
if (!d.state) return d;
|
||||||
|
|
||||||
|
const currentConfig = d.state.current_config;
|
||||||
|
|
||||||
|
const peqBand = {
|
||||||
|
gain: gainDb,
|
||||||
|
frequency: freqHz,
|
||||||
|
q,
|
||||||
|
filter_type: filterType,
|
||||||
|
bypass,
|
||||||
|
};
|
||||||
|
|
||||||
|
if ('Input' in channel) {
|
||||||
|
const inputState = currentConfig.input_states[channel.Input];
|
||||||
|
|
||||||
|
return {
|
||||||
|
...d,
|
||||||
|
state: {
|
||||||
|
...d.state,
|
||||||
|
current_config: {
|
||||||
|
...currentConfig,
|
||||||
|
input_states: {
|
||||||
|
...currentConfig.input_states,
|
||||||
|
[channel.Input]: {
|
||||||
|
...inputState,
|
||||||
|
peq_chain: {
|
||||||
|
...inputState.peq_chain,
|
||||||
|
bands: {
|
||||||
|
...inputState.peq_chain.bands,
|
||||||
|
[band]: peqBand,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
const outputState = currentConfig.output_states[channel.Output];
|
||||||
|
|
||||||
|
return {
|
||||||
|
...d,
|
||||||
|
state: {
|
||||||
|
...d.state,
|
||||||
|
current_config: {
|
||||||
|
...currentConfig,
|
||||||
|
output_states: {
|
||||||
|
...currentConfig.output_states,
|
||||||
|
[channel.Output]: {
|
||||||
|
...outputState,
|
||||||
|
peq_chain: {
|
||||||
|
...outputState.peq_chain,
|
||||||
|
bands: {
|
||||||
|
...outputState.peq_chain.bands,
|
||||||
|
[band]: peqBand,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
notify('PEQ band updated', 'success', dsp.name);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
} catch (err) {
|
||||||
|
notify(`PEQ update failed: ${String(err)}`, 'error', dsp.name);
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// Return API
|
// Return API
|
||||||
function forDSP(dsp: DSP): DSP408Device {
|
function forDSP(dsp: DSP): DSP408Device {
|
||||||
return {
|
return {
|
||||||
@@ -1169,6 +1444,19 @@ export function useDSP408(
|
|||||||
setGeqBand(dsp, inputChannel, frequencyBand, gain),
|
setGeqBand(dsp, inputChannel, frequencyBand, gain),
|
||||||
setGeqBypass: (inputChannel: InputChannel, bypass: boolean) =>
|
setGeqBypass: (inputChannel: InputChannel, bypass: boolean) =>
|
||||||
setGeqBypass(dsp, inputChannel, bypass),
|
setGeqBypass(dsp, inputChannel, bypass),
|
||||||
|
setLowPass: (channel: Channel, freq: number, filterType: CrossoverFilter) =>
|
||||||
|
setLowPass(dsp, channel, freq, filterType),
|
||||||
|
setHighPass: (channel: Channel, freq: number, filterType: CrossoverFilter) =>
|
||||||
|
setHighPass(dsp, channel, freq, filterType),
|
||||||
|
setPeqBand: (
|
||||||
|
channel: Channel,
|
||||||
|
band: PEQBand,
|
||||||
|
gainDb: number,
|
||||||
|
freqHz: number,
|
||||||
|
q: number,
|
||||||
|
filterType: PEQFilter,
|
||||||
|
bypass: boolean
|
||||||
|
) => setPeqBand(dsp, channel, band, gainDb, freqHz, q, filterType, bypass),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1181,9 +1469,6 @@ export function useDSP408(
|
|||||||
connectDSP,
|
connectDSP,
|
||||||
disconnectDSP,
|
disconnectDSP,
|
||||||
|
|
||||||
recallPreset,
|
|
||||||
setCurrentPresetName,
|
|
||||||
|
|
||||||
setDSPState,
|
setDSPState,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import { DSP } from '../../types/types';
|
import { DSP } from '../../types/types';
|
||||||
import Sidebar from '../../components/Sidebar/Sidebar';
|
import Sidebar from '../../components/Sidebar/Sidebar';
|
||||||
import { InfoIcon, KnobGainIcon } from '../../assets/icons/AudioIcons';
|
import { InfoIcon, KnobGainIcon, TextIcon } from '../../assets/icons/AudioIcons';
|
||||||
import ConnectionPanel from '../../components/dsp408/ConnectionSection/ConnectionSection';
|
import ConnectionPanel from '../../components/dsp408/ConnectionSection/ConnectionSection';
|
||||||
import GainSection from '../../components/dsp408/GainSection/GainSection';
|
import GainSection from '../../components/dsp408/GainSection/GainSection';
|
||||||
import CompressorSection from '../../components/dsp408/CompressorSection/CompressorSection';
|
import CompressorSection from '../../components/dsp408/CompressorSection/CompressorSection';
|
||||||
@@ -14,6 +14,7 @@ import LoadingOverlay from '../../components/LoadingOverlay/LoadingOverlay';
|
|||||||
import { InputChannel, OutputChannel } from '../../types/dsp408State';
|
import { InputChannel, OutputChannel } from '../../types/dsp408State';
|
||||||
import MatrixSection from '../../components/dsp408/Matrixsection/Matrixsection';
|
import MatrixSection from '../../components/dsp408/Matrixsection/Matrixsection';
|
||||||
import GeqSection from '../../components/dsp408/GeqSection/GeqSection';
|
import GeqSection from '../../components/dsp408/GeqSection/GeqSection';
|
||||||
|
import InputSection from '../../components/dsp408/InputSection/InputSection';
|
||||||
|
|
||||||
function DSPPage({ dsp, dsp408 }: { dsp: DSP; dsp408: DSP408Device }) {
|
function DSPPage({ dsp, dsp408 }: { dsp: DSP; dsp408: DSP408Device }) {
|
||||||
const [activeSidebar, setActiveSidebar] = useState('overview');
|
const [activeSidebar, setActiveSidebar] = useState('overview');
|
||||||
@@ -65,69 +66,69 @@ function DSPPage({ dsp, dsp408 }: { dsp: DSP; dsp408: DSP408Device }) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'ina',
|
id: 'ina',
|
||||||
label: `In A (${inputStates?.[InputChannel.InA]?.name})`,
|
label: `${inputStates?.[InputChannel.InA]?.name}`,
|
||||||
icon: <KnobGainIcon />,
|
icon: <TextIcon>In A</TextIcon>,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'inb',
|
id: 'inb',
|
||||||
label: `In B (${inputStates?.[InputChannel.InB]?.name})`,
|
label: `${inputStates?.[InputChannel.InB]?.name}`,
|
||||||
icon: <KnobGainIcon />,
|
icon: <TextIcon>In B</TextIcon>,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'inc',
|
id: 'inc',
|
||||||
label: `In C (${inputStates?.[InputChannel.InC]?.name})`,
|
label: `${inputStates?.[InputChannel.InC]?.name}`,
|
||||||
icon: <KnobGainIcon />,
|
icon: <TextIcon>In C</TextIcon>,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'ind',
|
id: 'ind',
|
||||||
label: `In D (${inputStates?.[InputChannel.InD]?.name})`,
|
label: `${inputStates?.[InputChannel.InD]?.name}`,
|
||||||
icon: <KnobGainIcon />,
|
icon: <TextIcon>In D</TextIcon>,
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
id: 'out1',
|
id: 'out1',
|
||||||
label: `Out 1 (${outputStates?.[OutputChannel.Out1]?.name})`,
|
label: `${outputStates?.[OutputChannel.Out1]?.name}`,
|
||||||
icon: <KnobGainIcon />,
|
icon: <TextIcon>Out 1</TextIcon>,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'out2',
|
id: 'out2',
|
||||||
label: `Out 2 (${outputStates?.[OutputChannel.Out2]?.name})`,
|
label: `${outputStates?.[OutputChannel.Out2]?.name}`,
|
||||||
icon: <KnobGainIcon />,
|
icon: <TextIcon>Out 2</TextIcon>,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'out3',
|
id: 'out3',
|
||||||
label: `Out 3 (${outputStates?.[OutputChannel.Out3]?.name})`,
|
label: `${outputStates?.[OutputChannel.Out3]?.name}`,
|
||||||
icon: <KnobGainIcon />,
|
icon: <TextIcon>Out 3</TextIcon>,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'out4',
|
id: 'out4',
|
||||||
label: `Out 4 (${outputStates?.[OutputChannel.Out4]?.name})`,
|
label: `${outputStates?.[OutputChannel.Out4]?.name}`,
|
||||||
icon: <KnobGainIcon />,
|
icon: <TextIcon>Out 4</TextIcon>,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'out5',
|
id: 'out5',
|
||||||
label: `Out 5 (${outputStates?.[OutputChannel.Out5]?.name})`,
|
label: `${outputStates?.[OutputChannel.Out5]?.name}`,
|
||||||
icon: <KnobGainIcon />,
|
icon: <TextIcon>Out 5</TextIcon>,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'out6',
|
id: 'out6',
|
||||||
label: `Out 6 (${outputStates?.[OutputChannel.Out6]?.name})`,
|
label: `${outputStates?.[OutputChannel.Out6]?.name}`,
|
||||||
icon: <KnobGainIcon />,
|
icon: <TextIcon>Out 6</TextIcon>,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'out7',
|
id: 'out7',
|
||||||
label: `Out 7 (${outputStates?.[OutputChannel.Out7]?.name})`,
|
label: `${outputStates?.[OutputChannel.Out7]?.name}`,
|
||||||
icon: <KnobGainIcon />,
|
icon: <TextIcon>Out 7</TextIcon>,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'out8',
|
id: 'out8',
|
||||||
label: `Out 8 (${outputStates?.[OutputChannel.Out8]?.name})`,
|
label: `${outputStates?.[OutputChannel.Out8]?.name}`,
|
||||||
icon: <KnobGainIcon />,
|
icon: <TextIcon>Out 8</TextIcon>,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'miscellaneous',
|
id: 'miscellaneous',
|
||||||
label: 'Miscellaneous',
|
label: 'Miscellaneous',
|
||||||
icon: <KnobGainIcon />,
|
icon: <TextIcon>Out 1</TextIcon>,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
const presets = dsp.state?.presets.names
|
const presets = dsp.state?.presets.names
|
||||||
@@ -200,6 +201,17 @@ function DSPPage({ dsp, dsp408 }: { dsp: DSP; dsp408: DSP408Device }) {
|
|||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
case 'ina':
|
||||||
|
return (
|
||||||
|
<InputSection
|
||||||
|
dsp={dsp}
|
||||||
|
channel={InputChannel.InA}
|
||||||
|
set_low_pass={dsp408.setLowPass}
|
||||||
|
set_high_pass={dsp408.setHighPass}
|
||||||
|
setPeq={dsp408.setPeqBand}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
|
||||||
case 'matrix':
|
case 'matrix':
|
||||||
return (
|
return (
|
||||||
<MatrixSection
|
<MatrixSection
|
||||||
|
|||||||
@@ -105,6 +105,18 @@ export enum DiscreteFrequency {
|
|||||||
F20000 = 'F20000',
|
F20000 = 'F20000',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export enum PEQBand {
|
||||||
|
B1 = 1,
|
||||||
|
B2 = 2,
|
||||||
|
B3 = 3,
|
||||||
|
B4 = 4,
|
||||||
|
B5 = 5,
|
||||||
|
B6 = 6,
|
||||||
|
B7 = 7,
|
||||||
|
B8 = 8,
|
||||||
|
B9 = 9,
|
||||||
|
}
|
||||||
|
|
||||||
// ---------------- STATE ----------------
|
// ---------------- STATE ----------------
|
||||||
|
|
||||||
export type Gate = {
|
export type Gate = {
|
||||||
@@ -157,7 +169,7 @@ export type MatrixRoutes = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export type PEQChain = {
|
export type PEQChain = {
|
||||||
bands: PEQ[];
|
bands: Record<PEQBand, PEQ>;
|
||||||
bypass: boolean;
|
bypass: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -291,7 +303,11 @@ const createDefaultPEQ = (): PEQ => ({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const createDefaultPEQChain = (): PEQChain => ({
|
const createDefaultPEQChain = (): PEQChain => ({
|
||||||
bands: Array.from({ length: 8 }, createDefaultPEQ),
|
bands: Object.fromEntries(
|
||||||
|
Object.values(PEQBand)
|
||||||
|
.filter((band): band is PEQBand => typeof band === 'number')
|
||||||
|
.map((band) => [band, createDefaultPEQ()])
|
||||||
|
) as Record<PEQBand, PEQ>,
|
||||||
bypass: false,
|
bypass: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user