From d867f12fcd46c21d1a2603991dac3b5ae81fb935 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Forment?= Date: Tue, 30 Sep 2025 16:56:14 +0200 Subject: [PATCH] reorganization --- src/App.tsx | 4 +- src/components/EffectsBar.tsx | 53 +++++--- src/components/EngineControls.tsx | 4 +- src/components/Switch.tsx | 29 +++++ src/config/effects.ts | 90 ++++++++------ src/domain/audio/effects/BitcrushEffect.ts | 92 ++++++++++++++ src/domain/audio/effects/DelayEffect.ts | 23 +++- src/domain/audio/effects/Effect.interface.ts | 1 + src/domain/audio/effects/EffectsChain.ts | 28 +++-- src/domain/audio/effects/PassThroughEffect.ts | 3 + src/domain/audio/effects/ReverbEffect.ts | 23 +++- src/domain/audio/effects/WavefolderEffect.ts | 116 ++++++++++++++++++ src/lib/bytebeat/EffectsChain.ts | 24 ++-- src/types/effects.ts | 3 +- 14 files changed, 413 insertions(+), 80 deletions(-) create mode 100644 src/components/Switch.tsx create mode 100644 src/domain/audio/effects/BitcrushEffect.ts create mode 100644 src/domain/audio/effects/WavefolderEffect.ts diff --git a/src/App.tsx b/src/App.tsx index bc2fc0da..4f6889a0 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -114,8 +114,8 @@ function App() { } } - const handleEffectChange = (parameterId: string, value: number) => { - effectSettings.setKey(parameterId as keyof typeof effectValues, value) + const handleEffectChange = (parameterId: string, value: number | boolean) => { + effectSettings.setKey(parameterId as any, value as any) if (playbackManagerRef.current) { playbackManagerRef.current.setEffects(effectValues) } diff --git a/src/components/EffectsBar.tsx b/src/components/EffectsBar.tsx index 8a3dc86a..7207c1f2 100644 --- a/src/components/EffectsBar.tsx +++ b/src/components/EffectsBar.tsx @@ -1,11 +1,12 @@ import { Slider } from './Slider' +import { Switch } from './Switch' import { EFFECTS } from '../config/effects' import { getClipModeLabel } from '../utils/formatters' import type { EffectValues } from '../types/effects' interface EffectsBarProps { values: EffectValues - onChange: (parameterId: string, value: number) => void + onChange: (parameterId: string, value: number | boolean) => void } export function EffectsBar({ values, onChange }: EffectsBarProps) { @@ -18,23 +19,39 @@ export function EffectsBar({ values, onChange }: EffectsBarProps) { return (
-
- {EFFECTS.flatMap(effect => - effect.parameters.map(param => ( - onChange(param.id, value)} - formatValue={param.id === 'clipMode' ? formatValue : undefined} - valueId={param.id} - /> - )) - )} +
+ {EFFECTS.map(effect => ( +
+
+

+ {effect.name.toUpperCase()} +

+ {effect.bypassable && ( + onChange(`${effect.id}Bypass`, !checked)} + label={Boolean(values[`${effect.id}Bypass`]) ? 'OFF' : 'ON'} + /> + )} +
+
+ {effect.parameters.map(param => ( + onChange(param.id, value)} + formatValue={param.id === 'clipMode' ? formatValue : undefined} + valueId={param.id} + /> + ))} +
+
+ ))}
) diff --git a/src/components/EngineControls.tsx b/src/components/EngineControls.tsx index 20109295..36e4c0b6 100644 --- a/src/components/EngineControls.tsx +++ b/src/components/EngineControls.tsx @@ -31,7 +31,7 @@ export function EngineControls({ values, onChange }: EngineControlsProps) { {param.label.toUpperCase()} - {formatValue(param.id, values[param.id] ?? param.default)} + {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" /> diff --git a/src/components/Switch.tsx b/src/components/Switch.tsx new file mode 100644 index 00000000..1b5df511 --- /dev/null +++ b/src/components/Switch.tsx @@ -0,0 +1,29 @@ +interface SwitchProps { + checked: boolean + onChange: (checked: boolean) => void + label?: string +} + +export function Switch({ checked, onChange, label }: SwitchProps) { + return ( +