From e1d6398d57265ba3d6c1e741bb0194904c2d9d84 Mon Sep 17 00:00:00 2001 From: LucasDLTG Date: Tue, 22 Sep 2026 21:05:59 +0200 Subject: [PATCH] feat: dont draw geq/peq curves if bypass --- README.md | 3 -- .../components/GainSection/GainSection.tsx | 52 +++++++++++++++---- 2 files changed, 41 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index c183784..a045103 100644 --- a/README.md +++ b/README.md @@ -9,9 +9,6 @@ This template should help get you started developing with Tauri, React and Types # TODO - Move meters polling logic outside dsp state because it causes re-render of everything tied to dsp constantly - Check render to improve perfoormances -- Dont draw geq/peq on gain if bypass -- Diplay windows on reset geq, peq -- Preset change dont reset - Disbale slider on peq when filter dont use it - Check end to end behavioour \ No newline at end of file diff --git a/src/features/dsp408/components/GainSection/GainSection.tsx b/src/features/dsp408/components/GainSection/GainSection.tsx index 1e083d2..5d3c913 100644 --- a/src/features/dsp408/components/GainSection/GainSection.tsx +++ b/src/features/dsp408/components/GainSection/GainSection.tsx @@ -1,5 +1,5 @@ import VerticalSlider from '../../../../components/VerticalSlider/VerticalSlider'; -import { InputChannel, Channel, OutputChannel } from '../../types'; +import { InputChannel, Channel, OutputChannel, CrossoverFilter, PEQBand, PEQ } from '../../types'; import { DSP408 as DSP } from '../../../../types'; import Button from '../../../../components/Button/Button'; import ChannelGroup from '../../../../components/ChannelGroup/ChannelGroup'; @@ -58,23 +58,33 @@ function getGainCurvePoints(freqs: number[], gainDb: number): CurvePoint[] { function getPeqCrossoverPoints( freqs: number[], - peqChain: { bands: Record }, + peqChain: { + bypass: boolean; + bands: Record; + }, crossover: { - high_pass: { frequency: number; slope: unknown }; - low_pass: { frequency: number; slope: unknown }; + high_pass: { frequency: number; slope: CrossoverFilter }; + low_pass: { frequency: number; slope: CrossoverFilter }; } ) { return sumCurvePoints([ - getPeqCurvePoints({ freqs, bands: peqChain.bands as any }), + ...(peqChain.bypass + ? [] + : [ + getPeqCurvePoints({ + freqs, + bands: peqChain.bands, + }), + ]), getCrossoverCurvePoints({ freqs, highPass: { frequency: crossover.high_pass.frequency, - filter_type: crossover.high_pass.slope as any, + filter_type: crossover.high_pass.slope, }, lowPass: { frequency: crossover.low_pass.frequency, - filter_type: crossover.low_pass.slope as any, + filter_type: crossover.low_pass.slope, }, }), ]); @@ -86,10 +96,30 @@ function getInputChannelCurves( liveGain: number | undefined ): ChannelCurves { const gain = liveGain ?? state.gain; - const geqValues = GEQ_BANDS_LABEL.map(({ frequency }) => state.geq.gains[frequency] ?? 0); - const geq = getGeqCurvePoints({ freqs, values: geqValues, q: GEQ_CURVE_Q }); - const peqCrossover = getPeqCrossoverPoints(freqs, state.peq_chain, state.crossover); - const total = sumCurvePoints([geq, peqCrossover, getGainCurvePoints(freqs, gain)]); + + const geqValues = GEQ_BANDS_LABEL.map( + ({ frequency }) => state.geq.gains[frequency] ?? 0 + ); + + const geq = state.geq.bypass + ? [] + : getGeqCurvePoints({ + freqs, + values: geqValues, + q: GEQ_CURVE_Q, + }); + + const peqCrossover = getPeqCrossoverPoints( + freqs, + state.peq_chain, + state.crossover + ); + + const total = sumCurvePoints([ + geq, + peqCrossover, + getGainCurvePoints(freqs, gain), + ]); return { geq, peqCrossover, total }; }