function normalized(value: number) { return Math.max(0, Math.min(1, value)); } export function delayEffectValues(x: number, y: number) { const length = normalized(x); return { time: Math.max(0.001, 0.017397 * (287.725 ** length - 1)), feedback: normalized(y) * 0.95, }; } export function reverbEffectValues(x: number, y: number) { const color = normalized(y); const dark = Math.max(0, (0.5 - color) * 2); const bright = Math.max(0, (color - 0.5) * 2); return { decayTime: 200 + normalized(x) * 7800, highShelfOn: dark > 0, highShelfGain: 1 - dark * 0.8, lowShelfOn: bright > 0, lowShelfGain: 1 - bright * 0.8, }; } export function distortionEffectValues(x: number, y: number) { return { drive: normalized(x) * 50, tone: normalized(y) * 100, }; } export function chorusEffectValues(x: number, y: number) { return { rate: 0.1 * 100 ** normalized(x), feedback: normalized(y) * 0.95, }; } export function filterEffectValues(x: number, y: number) { const cutoff = normalized(x); const highPass = cutoff > 0.5; return { filterType: highPass ? 1 : 0, cutoff: highPass ? 20 + (cutoff - 0.5) * 230 : 20 + cutoff * 230, resonance: normalized(y) * 1.25, }; } export function compressorEffectValues(x: number, y: number) { const drive = normalized(x); const speed = normalized(y); return { threshold: 10 ** ((drive * -36) / 20), ratio: 4, attack: 50 * (0.1 / 50) ** speed, release: 500 * (30 / 500) ** speed, }; }