import { useState } from "react" import { useTranslation } from "react-i18next" import { Button } from "@/components/ui/button" import { Dialog, DialogContent, DialogFooter, DialogHeader, DialogTitle } from "@/components/ui/dialog" import { Label } from "@/components/ui/label" import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select" import { Slider } from "@/components/ui/slider" import { MidiMapping } from "../../services/midi/midi-engine" interface MidiMappingEditorProps { mapping: MidiMapping onSave: (updates: Partial) => void onClose: () => void } export function MidiMappingEditor({ mapping, onSave, onClose }: MidiMappingEditorProps) { const { t } = useTranslation() const [min, setMin] = useState(mapping.min) const [max, setMax] = useState(mapping.max) const [curve, setCurve] = useState(mapping.curve) const handleSave = () => { onSave({ min, max, curve, }) } return ( {t("fairlightAudio.midi.mappingEditor.title")}
{/* Mapping Info */}

{mapping.targetParameter}

{mapping.messageType.toUpperCase()} {mapping.controller !== undefined && ` CC${mapping.controller}`} {mapping.channel && ` CH${mapping.channel}`}

{/* Min Value */}
{min.toFixed(2)}
setMin(v)} min={0} max={1} step={0.01} className="w-full" />
{/* Max Value */}
{max.toFixed(2)}
setMax(v)} min={0} max={1} step={0.01} className="w-full" />
{/* Curve Type */}
{/* Curve Preview */}
{/* Grid */} {/* Curve */} {/* Min/Max indicators */}

{t("fairlightAudio.midi.mappingEditor.responseCurvePreview")}

) } function generateCurvePath(curve: string, min: number, max: number): string { const points: string[] = [] const steps = 50 for (let i = 0; i <= steps; i++) { const x = (i / steps) * 100 const t = i / steps let y: number switch (curve) { case "exponential": y = min + (max - min) * (t * t) break case "logarithmic": y = min + ((max - min) * Math.log(t + 1)) / Math.log(2) break default: // linear y = min + (max - min) * t } points.push(`${x},${100 - y * 100}`) } return `M ${points.join(" L ")}` }