import { useState } from 'react'; import { DSP } from '../../../../types'; import Sidebar from '../../../../components/Sidebar/Sidebar'; import { InfoIcon, KnobGainIcon, TextIcon } from '../../../../assets/icons/AudioIcons'; import ConnectionPanel from '../ConnectionSection/ConnectionSection'; import GainSection from '../GainSection/GainSection'; import CompressorSection from '../CompressorSection/CompressorSection'; import GateSection from '../GateSection/GateSection'; import LimiterSection from '../LimiterSection/LimiterSection'; import DelaySection from '../DelaySection/DelaySection'; import LoadingOverlay from '../../../../components/LoadingOverlay/LoadingOverlay'; import { InputChannel, OutputChannel } from '../../types'; import MatrixSection from '../Matrixsection/Matrixsection'; import GeqSection from '../GeqSection/GeqSection'; import InputSection from '../InputSection/InputSection'; import { DSP408Api } from '../../dsp408'; import './DSP408Panel.css'; type DSP408 = Extract; function DSP408Panel({ dsp, api }: { dsp: DSP408; api: DSP408Api }) { const [activeSidebar, setActiveSidebar] = useState('overview'); const [sidebarExpanded, setSidebarExpanded] = useState(false); const [selectedPreset, setSelectedPreset] = useState(dsp.state?.presets.current_index ?? 0); const [presetLoading, setPresetLoading] = useState(false); const inputStates = dsp.state?.current_config.input_states; const outputStates = dsp.state?.current_config.output_states; const sidebarItems = [ { id: 'overview', label: 'Overview', icon: }, { id: 'gain', label: 'Gain', icon: }, { id: 'gate', label: 'Gate', icon: }, { id: 'compressor', label: 'Compressor', icon: }, { id: 'limiter', label: 'Limiter', icon: }, { id: 'delay', label: 'Delay', icon: }, { id: 'matrix', label: 'Matrix', icon: }, { id: 'geq', label: 'Graphic Equalizer', icon: }, { id: 'ina', label: `${inputStates[InputChannel.InA].name}`, icon: In A }, { id: 'inb', label: `${inputStates[InputChannel.InB].name}`, icon: In B }, { id: 'inc', label: `${inputStates[InputChannel.InC].name}`, icon: In C }, { id: 'ind', label: `${inputStates[InputChannel.InD].name}`, icon: In D }, { id: 'out1', label: `${outputStates[OutputChannel.Out1].name}`, icon: Out 1, }, { id: 'out2', label: `${outputStates[OutputChannel.Out2].name}`, icon: Out 2, }, { id: 'out3', label: `${outputStates[OutputChannel.Out3].name}`, icon: Out 3, }, { id: 'out4', label: `${outputStates[OutputChannel.Out4].name}`, icon: Out 4, }, { id: 'out5', label: `${outputStates[OutputChannel.Out5].name}`, icon: Out 5, }, { id: 'out6', label: `${outputStates[OutputChannel.Out6].name}`, icon: Out 6, }, { id: 'out7', label: `${outputStates[OutputChannel.Out7].name}`, icon: Out 7, }, { id: 'out8', label: `${outputStates[OutputChannel.Out8].name}`, icon: Out 8, }, { id: 'miscellaneous', label: 'Miscellaneous', icon: Out 1 }, ]; const presets = dsp.state?.presets.names ? [ { id: 'f00', name: 'Factory Preset' }, ...dsp.state.presets.names.map((name, index) => ({ id: `u${String(index + 1).padStart(2, '0')}`, name, })), ] : [ { id: 'f00', name: 'Factory Preset' }, ...Array.from({ length: 20 }, (_, index) => ({ id: `u${String(index + 1).padStart(2, '0')}`, name: 'Default Preset', })), ]; const onAppChange = async (id: string) => { const presetIndex = presets.findIndex((preset) => preset.id === id); if (presetIndex === -1) return; setPresetLoading(true); const success = await api.recallPreset(presetIndex); if (success) setSelectedPreset(presetIndex); setPresetLoading(false); }; const renderTab = () => { switch (activeSidebar) { case 'overview': return ; case 'gain': return ( ); case 'gate': return ; case 'compressor': return ; case 'limiter': return ; case 'delay': return ; case 'ina': return ( ); case 'matrix': return ( ); case 'geq': return ; default: return null; } }; return (
setSidebarExpanded((v) => !v)} />
{renderTab()}
); } export default DSP408Panel;