import { Circle, Hand, Lock, Play, Plus, Square } from "lucide-react" import { useState } from "react" import { useTranslation } from "react-i18next" import { Button } from "@/components/ui/button" import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select" import { cn } from "@/lib/utils" import { AutomationLane, AutomationMode } from "../../services/automation-engine" interface AutomationPanelProps { mode: AutomationMode isRecording: boolean lanes: AutomationLane[] onModeChange: (mode: AutomationMode) => void onStartRecording: () => void onStopRecording: () => void onAddLane: (channelId: string, parameterId: string) => void onClearLane: (laneId: string) => void className?: string } export function AutomationPanel({ mode, isRecording, lanes, onModeChange, onStartRecording, onStopRecording, onAddLane, className, }: AutomationPanelProps) { const { t } = useTranslation() const [selectedChannel, setSelectedChannel] = useState("") const [selectedParameter, setSelectedParameter] = useState("") const availableParameters = [ { id: "volume", name: t("fairlightAudio.automation.parameters.volume") }, { id: "pan", name: t("fairlightAudio.automation.parameters.pan") }, { id: "eq.lowGain", name: t("fairlightAudio.automation.parameters.eqLow") }, { id: "eq.midGain", name: t("fairlightAudio.automation.parameters.eqMid") }, { id: "eq.highGain", name: t("fairlightAudio.automation.parameters.eqHigh") }, { id: "compressor.threshold", name: t("fairlightAudio.automation.parameters.compThreshold") }, { id: "compressor.ratio", name: t("fairlightAudio.automation.parameters.compRatio") }, { id: "reverb.wetLevel", name: t("fairlightAudio.automation.parameters.reverbWet") }, ] const modeButtons = [ { mode: "off" as const, icon: Square, label: t("fairlightAudio.automation.modes.off.name"), description: t("fairlightAudio.automation.modes.off.description"), }, { mode: "read" as const, icon: Play, label: t("fairlightAudio.automation.modes.read.name"), description: t("fairlightAudio.automation.modes.read.description"), }, { mode: "write" as const, icon: Circle, label: t("fairlightAudio.automation.modes.write.name"), description: t("fairlightAudio.automation.modes.write.description"), }, { mode: "touch" as const, icon: Hand, label: t("fairlightAudio.automation.modes.touch.name"), description: t("fairlightAudio.automation.modes.touch.description"), }, { mode: "latch" as const, icon: Lock, label: t("fairlightAudio.automation.modes.latch.name"), description: t("fairlightAudio.automation.modes.latch.description"), }, ] const uniqueChannels = Array.from(new Set(lanes.map((lane) => lane.channelId))) const handleAddLane = () => { if (selectedChannel && selectedParameter) { onAddLane(selectedChannel, selectedParameter) setSelectedParameter("") } } return (
{/* Automation Mode Buttons */}
{t("fairlightAudio.automation.controls.mode")} {modeButtons.map(({ mode: buttonMode, icon: Icon, label }) => ( ))}
{/* Recording Controls */}
{isRecording ? ( ) : ( )}
{/* Add Lane Controls */}
{/* Status Bar */}
{t("fairlightAudio.automation.status.lanes", { count: lanes.length })} •{" "} {t("fairlightAudio.automation.status.mode", { mode })} {isRecording && ` • ${t("fairlightAudio.automation.status.recording")}`} {mode !== "off" && ( {mode === "read" && t("fairlightAudio.automation.status.reading")} {mode === "write" && t("fairlightAudio.automation.status.willOverwrite")} {mode === "touch" && t("fairlightAudio.automation.status.touchToStart")} {mode === "latch" && t("fairlightAudio.automation.status.touchToLatch")} )}
) }