import { useState } from 'react'; import { DSP } from '../../types/types'; import Sidebar from '../../components/Sidebar/Sidebar'; import { InfoIcon, KnobGainIcon } from '../../assets/icons/AudioIcons'; import ConnectionPanel from '../../components/dsp408/ConnectionSection/ConnectionSection'; import GainSection from '../../components/dsp408/GainSection/GainSection'; import { DSP408Device } from '../../hooks/useDSP408'; import './DspPage.css'; import GateSection from '../../components/dsp408/GateSection/GateSection'; import LoadingOverlay from '../../components/LoadingOverlay/LoadingOverlay'; import { InputChannel, OutputChannel } from '../../types/dsp408State'; function DSPPage({ dsp, dsp408, }: { dsp: DSP; dsp408: DSP408Device; }) { 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: `In A (${inputStates?.[InputChannel.InA]?.name})`, icon: , }, { id: 'inb', label: `In B (${inputStates?.[InputChannel.InB]?.name})`, icon: , }, { id: 'inc', label: `In C (${inputStates?.[InputChannel.InC]?.name})`, icon: , }, { id: 'ind', label: `In D (${inputStates?.[InputChannel.InD]?.name})`, icon: , }, { id: 'out1', label: `Out 1 (${outputStates?.[OutputChannel.Out1]?.name})`, icon: , }, { id: 'out2', label: `Out 2 (${outputStates?.[OutputChannel.Out2]?.name})`, icon: , }, { id: 'out3', label: `Out 3 (${outputStates?.[OutputChannel.Out3]?.name})`, icon: , }, { id: 'out4', label: `Out 4 (${outputStates?.[OutputChannel.Out4]?.name})`, icon: , }, { id: 'out5', label: `Out 5 (${outputStates?.[OutputChannel.Out5]?.name})`, icon: , }, { id: 'out6', label: `Out 6 (${outputStates?.[OutputChannel.Out6]?.name})`, icon: , }, { id: 'out7', label: `Out 7 (${outputStates?.[OutputChannel.Out7]?.name})`, icon: , }, { id: 'out8', label: `Out 8 (${outputStates?.[OutputChannel.Out8]?.name})`, icon: , }, { id: 'miscellaneous', label: 'Miscellaneous', icon: , }, ]; 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 { recallPreset, setCurrentPresetName } = useDSPPresets(dsp, setDsps, notify); const onAppChange = async (id: string) => { const presetIndex = presets.findIndex((preset) => preset.id === id); if (presetIndex === -1) return; setPresetLoading(true); const success = await dsp408.recallPreset(presetIndex); if (success) { setSelectedPreset(presetIndex); } setPresetLoading(false); }; const renderTab = () => { switch (activeSidebar) { case 'overview': return ; // case 'gain': // return ; // case 'gate': // return ; default: return null; } }; return (
setSidebarExpanded((v) => !v)} />
{renderTab()}
); } export default DSPPage;