import { ENGINE_CONTROLS } from '../config/effects' import { getComplexityLabel, getBitDepthLabel, getSampleRateLabel } from '../utils/formatters' import type { EffectValues } from '../types/effects' import { Knob } from './Knob' interface EngineControlsProps { values: EffectValues onChange: (parameterId: string, value: number) => void onMapClick?: (paramId: string, lfoIndex: number) => void getMappedLFOs?: (paramId: string) => number[] } const KNOB_PARAMS = ['masterVolume', 'pitch', 'a', 'b', 'c', 'd'] export function EngineControls({ values, onChange, onMapClick, getMappedLFOs }: EngineControlsProps) { const formatValue = (id: string, value: number): string => { switch (id) { case 'sampleRate': return getSampleRateLabel(value) case 'complexity': return getComplexityLabel(value) case 'bitDepth': return getBitDepthLabel(value) default: { const param = ENGINE_CONTROLS[0].parameters.find(p => p.id === id) return `${value}${param?.unit || ''}` } } } return (
{ENGINE_CONTROLS[0].parameters.map(param => { const useKnob = KNOB_PARAMS.includes(param.id) if (useKnob) { return ( onChange(param.id, value)} formatValue={formatValue} valueId={param.id} paramId={param.id} onMapClick={onMapClick} mappedLFOs={getMappedLFOs ? getMappedLFOs(param.id) : []} /> ) } return (
{formatValue(param.id, (values[param.id] as number) ?? param.default)}
onChange(param.id, Number(e.target.value))} className="w-full h-[2px] bg-white appearance-none cursor-pointer" />
) })}
) }