import { useMemo, useState } from 'react'; import { useEditorStore } from '../store/editorStore'; import { Trash2, Volume2 } from 'lucide-react'; export default function VolumePanel() { const { words, selectedWordIndices, globalGainDb, gainRanges, setGlobalGainDb, addGainRange, updateGainRange, removeGainRange, } = useEditorStore(); const [selectionGainDb, setSelectionGainDb] = useState(3); const canApplySelection = selectedWordIndices.length > 0; const selectedRange = useMemo(() => { if (!canApplySelection) return null; const sorted = [...selectedWordIndices].sort((a, b) => a - b); const startWord = words[sorted[0]]; const endWord = words[sorted[sorted.length - 1]]; if (!startWord || !endWord) return null; return { start: startWord.start, end: endWord.end, }; }, [canApplySelection, selectedWordIndices, words]); const applySelectionGain = () => { if (!selectedRange) return; addGainRange(selectedRange.start, selectedRange.end, selectionGainDb); }; return (
Apply global gain or per-selection gain ranges.
{canApplySelection ? `${selectedWordIndices.length} selected words${selectedRange ? ` (${selectedRange.start.toFixed(2)}s - ${selectedRange.end.toFixed(2)}s)` : ''}` : 'Select transcript words to apply a gain range.'}