feat: add peq foor input

This commit is contained in:
2026-08-31 14:12:03 +02:00
parent a0c9fbb674
commit d6d0215e09
14 changed files with 1989 additions and 396 deletions
+43 -9
View File
@@ -15,8 +15,8 @@ import {
} from './types';
import { SetDsps, NotifyFn, updateDSP, setPollingPaused } from '../../dsp/dspShared';
import { registerPollStopper } from '../../dsp/pollRegistry';
import { defaultDSPState, defaultMeters } from './types';
import { DELAY_RANGES } from './types';
import { defaultDSPState, defaultMeters } from './defaults';
import { DELAY_RANGES, PEQ_Q_RANGES } from './constants';
type DSP408 = Extract<DSP, { type: 'DSP408' }>;
@@ -1325,20 +1325,40 @@ export function forDSP408(dsp: DSP408, setDsps: SetDsps, notify: NotifyFn) {
bypass: boolean
): Promise<boolean> {
const updatePeqBand = () => {
function convertPeqQ(value: number, from: PEQFilter, to: PEQFilter): number {
if (from === to) return value;
const [fromMin, fromMax] = PEQ_Q_RANGES[from];
const [toMin, toMax] = PEQ_Q_RANGES[to];
if (fromMax === fromMin) return toMin;
const ratio = (value - fromMin) / (fromMax - fromMin);
return toMin + ratio * (toMax - toMin);
}
updateDSP(setDsps, dsp.id, (d) => {
if (!d.state) return d;
const cfg = d.state.current_config;
const peqBand = {
gain: gainDb,
frequency: freqHz,
q,
filter_type: filterType,
bypass,
};
if ('Input' in channel) {
const inputState = cfg.input_states[channel.Input];
const existingBand = inputState.peq_chain.bands[band];
const nextQ =
existingBand.filter_type !== filterType
? convertPeqQ(existingBand.q, existingBand.filter_type, filterType)
: q;
const peqBand = {
gain: gainDb,
frequency: freqHz,
q: nextQ,
filter_type: filterType,
bypass,
};
return {
...d,
@@ -1365,6 +1385,20 @@ export function forDSP408(dsp: DSP408, setDsps: SetDsps, notify: NotifyFn) {
}
const outputState = cfg.output_states[channel.Output];
const existingBand = outputState.peq_chain.bands[band];
const nextQ =
existingBand.filter_type !== filterType
? convertPeqQ(existingBand.q, existingBand.filter_type, filterType)
: q;
const peqBand = {
gain: gainDb,
frequency: freqHz,
q: nextQ,
filter_type: filterType,
bypass,
};
return {
...d,