Improved filter FX

This commit is contained in:
patben8 committed 2026-11-03 10:37:53 +01:00
1 parent 832dbed341
commit 717685f621
10 files changed
+426 -215

No files matched your search

+8 -5
View File
@@ -34,12 +34,15 @@ export const APP_SETTING_DEFAULTS = {
* Default halfway: both channels full across the middle, fading over the
* outer half of the travel each (decided 2026-11-03). */
crossfaderSharpness: 0.5,
/** The colour effects' one parameter each (the mixer has no knob for it). */
/** Filter FX: the filter's range and resonance, and each effect's one
* parameter (the mixer has no knob for them). */
fxFilterRange: 'full' as 'full' | 'musical' | 'gentle',
fxEffectRange: 'musical' as 'full' | 'musical' | 'gentle',
fxFilterResonance: 0.3,
fxEchoBeats: 0.5,
fxSpaceSize: 2.5,
fxNoiseResonance: 0.3,
fxCrushDrive: 2,
fxReverbSize: 2,
fxDelayBeats: 0.25,
fxCrusherDrive: 2,
fxPhaserBeats: 4,
}
type AppSettingKey = keyof typeof APP_SETTING_DEFAULTS
+63 -30
View File
@@ -8,6 +8,14 @@ import { Modal } from './Modal'
import { Fader } from './mixer/Controls'
import { CrossfaderCurveGraph } from './mixer/CrossfaderCurve'
/** How far the filter sweeps (`mixerMath.FILTER_RANGES`). */
const RANGES: [string, string][] = [
['full', 'Full - 20 Hz / 20 kHz'],
['musical', 'Musical - 150 Hz / 8 kHz'],
['gentle', 'Gentle - 500 Hz / 2 kHz'],
]
type Range = 'full' | 'musical' | 'gentle'
/** Resonance amounts offered (0..1 of the effect's maximum). */
const LEVELS: [string, string][] = [
['0', 'None'],
@@ -20,7 +28,7 @@ const section = 'text-[11px] font-semibold uppercase tracking-wider text-faint'
/**
* Settings ▸ Performance mode… (its own panel, decided 2026-11-03): the decks,
* the mixer and the colour effects' parameters. Values live in the app
* the mixer and the Filter FX. Values live in the app
* settings (userprefs.json, `APP_SETTING_DEFAULTS`); PrepStrip copies the
* mixer's into `mixerState`.
*/
@@ -31,11 +39,13 @@ export function PerformanceSettings({ onClose }: { onClose: () => void }) {
const keylockDefault = useAppSetting('keylockDefault')
const eqKill = useAppSetting('eqKill')
const sharpnessSetting = useAppSetting('crossfaderSharpness')
const fxFilterRange = useAppSetting('fxFilterRange')
const fxEffectRange = useAppSetting('fxEffectRange')
const fxFilterResonance = useAppSetting('fxFilterResonance')
const fxEchoBeats = useAppSetting('fxEchoBeats')
const fxSpaceSize = useAppSetting('fxSpaceSize')
const fxNoiseResonance = useAppSetting('fxNoiseResonance')
const fxCrushDrive = useAppSetting('fxCrushDrive')
const fxReverbSize = useAppSetting('fxReverbSize')
const fxDelayBeats = useAppSetting('fxDelayBeats')
const fxCrusherDrive = useAppSetting('fxCrusherDrive')
const fxPhaserBeats = useAppSetting('fxPhaserBeats')
const [error, setError] = useState<string | null>(null)
// The curve moves with the slider at once — mixer included, so it can be
@@ -137,8 +147,25 @@ export function PerformanceSettings({ onClose }: { onClose: () => void }) {
</div>
</section>
<section className="space-y-2">
<h3 className={section}>Colour effects</h3>
<span className="block text-xs text-faint">Each effect's setting, on both channels.</span>
<h3 className={section}>Filter FX</h3>
<span className="block text-xs text-faint">
Each channel's FILTER knob filters — low-pass to the left, high-pass to the right — and
the effect picked above it rides along, growing as the knob turns: the reverb blends into
one three times as long, the delay gets longer and the phaser faster (each up to ×8)
from the settings below. These apply to both channels.
</span>
<Choice
title="Filter range (Filter alone)"
value={fxFilterRange}
options={RANGES}
onChange={(v) => void set({ fxFilterRange: v as Range })}
/>
<Choice
title="Filter range (with an effect)"
value={fxEffectRange}
options={RANGES}
onChange={(v) => void set({ fxEffectRange: v as Range })}
/>
<Choice
title="Filter resonance"
value={String(fxFilterResonance)}
@@ -146,8 +173,19 @@ export function PerformanceSettings({ onClose }: { onClose: () => void }) {
onChange={(v) => void set({ fxFilterResonance: Number(v) })}
/>
<Choice
title="Echo length"
value={String(fxEchoBeats)}
title="Reverb size (shortest)"
value={String(fxReverbSize)}
options={[
['1', 'Small (1 → 3 s)'],
['2', 'Medium (2 → 6 s)'],
['3', 'Large (3 → 9 s)'],
['4', 'Huge (4 → 12 s)'],
]}
onChange={(v) => void set({ fxReverbSize: Number(v) })}
/>
<Choice
title="Delay length (shortest)"
value={String(fxDelayBeats)}
options={[
['0.125', '1/8 beat'],
['0.25', '1/4 beat'],
@@ -155,34 +193,29 @@ export function PerformanceSettings({ onClose }: { onClose: () => void }) {
['0.75', '3/4 beat'],
['1', '1 beat'],
]}
onChange={(v) => void set({ fxEchoBeats: Number(v) })}
onChange={(v) => void set({ fxDelayBeats: Number(v) })}
/>
<Choice
title="Space size"
value={String(fxSpaceSize)}
options={[
['1', 'Small (1 s)'],
['2.5', 'Medium (2.5 s)'],
['4', 'Large (4 s)'],
['6', 'Huge (6 s)'],
]}
onChange={(v) => void set({ fxSpaceSize: Number(v) })}
/>
<Choice
title="Noise resonance"
value={String(fxNoiseResonance)}
options={LEVELS}
onChange={(v) => void set({ fxNoiseResonance: Number(v) })}
/>
<Choice
title="Crush drive"
value={String(fxCrushDrive)}
title="Bit crusher drive"
value={String(fxCrusherDrive)}
options={[
['1', 'Clean (×1)'],
['2', 'Warm (×2)'],
['4', 'Hot (×4)'],
]}
onChange={(v) => void set({ fxCrushDrive: Number(v) })}
onChange={(v) => void set({ fxCrusherDrive: Number(v) })}
/>
<Choice
title="Phaser sweep (slowest)"
value={String(fxPhaserBeats)}
options={[
['1', 'Every beat'],
['2', 'Every 2 beats'],
['4', 'Every 4 beats'],
['8', 'Every 8 beats'],
['16', 'Every 16 beats'],
]}
onChange={(v) => void set({ fxPhaserBeats: Number(v) })}
/>
</section>
{error && <div className="text-xs text-pink">{error}</div>}
+12 -6
View File
@@ -124,14 +124,20 @@ export function PrepStrip({
const keylockDefault = useAppSetting('keylockDefault')
const eqKill = useAppSetting('eqKill')
const sharpness = useAppSetting('crossfaderSharpness')
const filterRange = useAppSetting('fxFilterRange')
const effectRange = useAppSetting('fxEffectRange')
const filterResonance = useAppSetting('fxFilterResonance')
const echoBeats = useAppSetting('fxEchoBeats')
const spaceSize = useAppSetting('fxSpaceSize')
const noiseResonance = useAppSetting('fxNoiseResonance')
const crushDrive = useAppSetting('fxCrushDrive')
const reverbSize = useAppSetting('fxReverbSize')
const delayBeats = useAppSetting('fxDelayBeats')
const crusherDrive = useAppSetting('fxCrusherDrive')
const phaserBeats = useAppSetting('fxPhaserBeats')
useEffect(() => {
setMixer({ eqKill, sharpness, fx: { filterResonance, echoBeats, spaceSize, noiseResonance, crushDrive } })
}, [eqKill, sharpness, filterResonance, echoBeats, spaceSize, noiseResonance, crushDrive])
setMixer({
eqKill,
sharpness,
fx: { filterRange, effectRange, filterResonance, reverbSize, delayBeats, crusherDrive, phaserBeats },
})
}, [eqKill, sharpness, filterRange, effectRange, filterResonance, reverbSize, delayBeats, crusherDrive, phaserBeats])
const lead: DeckId = performance ? focused : 'A'
const playingA = useCallback((p: boolean) => onPlayingChange('A', p), [onPlayingChange])
const playingB = useCallback((p: boolean) => onPlayingChange('B', p), [onPlayingChange])
+34 -29
View File
@@ -1,9 +1,11 @@
import { useEffect, useRef, useState, type RefObject } from 'react'
import { mixer } from '../../lib/audio/mixer'
import { faderGain, filterSweep, eqGain, gainToDb, TRIM_RANGE_DB, EQ_CUT_DB } from '../../lib/audio/mixerMath'
import { delayBeatsAt, faderGain, filterSweep, eqGain, gainToDb, phaserBeatsAt, REVERB_GROWTH, TRIM_RANGE_DB, EQ_CUT_DB } from '../../lib/audio/mixerMath'
import {
FX_LABELS,
FX_SHORT,
FX_TYPES,
rangeFor,
setChannel,
setMixer,
useMixer,
@@ -20,42 +22,45 @@ const METER_FLOOR = -48
const METER_TOP = 3
/** Knob sizes (px): as large as the column allows — the EQ block is two
* across, the colour knob beside it larger. */
* across, the FILTER knob beside it larger. */
const EQ_KNOB = 40
const COLOR_KNOB = 48
const FILTER_KNOB = 48
const fmtDb = (db: number, places = 1) =>
!isFinite(db) ? '−∞ dB' : `${db > 0 ? '+' : db < 0 ? '−' : ''}${Math.abs(db).toFixed(places)} dB`
/** The FILTER knob's tooltip: where the filter is, and what rides with it. */
function describeFx(fx: FxType, c: number, set: FxSettings): string {
const a = Math.round(Math.abs(c) * 100)
if (Math.abs(c) < 0.02) return `${FX_LABELS[fx]}: off (turn left or right)`
if (Math.abs(c) < 0.02) return `Filter${fx === 'filter' ? '' : ` + ${FX_LABELS[fx]}`}: off (turn left or right)`
const s = filterSweep(c, rangeFor(fx, set))!
const hz = s.freq >= 1000 ? `${(s.freq / 1000).toFixed(1)} kHz` : `${Math.round(s.freq)} Hz`
const filter = `${s.type === 'lowpass' ? 'low-pass' : 'high-pass'} at ${hz}`
const a = `${Math.round(Math.abs(c) * 100)}%`
switch (fx) {
case 'filter': {
const s = filterSweep(c)!
const hz = s.freq >= 1000 ? `${(s.freq / 1000).toFixed(1)} kHz` : `${Math.round(s.freq)} Hz`
return `Filter: ${s.type === 'lowpass' ? 'low-pass' : 'high-pass'} at ${hz} · resonance ${Math.round(set.filterResonance * 100)}%`
}
case 'echo':
return `Echo ${a}% · ${beatsLabel(set.echoBeats)} · ${c < 0 ? 'darker' : 'thinner'} repeats`
case 'space':
return `Space ${a}% · ${set.spaceSize} s · ${c < 0 ? 'darker' : 'thinner'}`
case 'noise':
return `Noise ${a}% · ${c < 0 ? 'low-pass' : 'high-pass'} sweep`
case 'crush':
return `Crush ${a}% · drive ×${set.crushDrive}`
case 'filter':
return `Filter: ${filter} · resonance ${Math.round(set.filterResonance * 100)}%`
case 'reverb':
return `Reverb ${a} (${set.reverbSize}–${set.reverbSize * REVERB_GROWTH} s, longer as it opens) + ${filter}`
case 'delay':
return `Delay ${a} (${beatsLabel(delayBeatsAt(set.delayBeats, Math.abs(c)))}) + ${filter}`
case 'crusher':
return `Bit crusher ${a} (drive ×${set.crusherDrive}) + ${filter}`
case 'phaser':
return `Phaser ${a} (a sweep every ${beatsLabel(phaserBeatsAt(set.phaserBeats, Math.abs(c)))}) + ${filter}`
}
}
function beatsLabel(b: number): string {
return b === 1 ? '1 beat' : b === 0.75 ? '3/4 beat' : b === 0.5 ? '1/2 beat' : b === 0.25 ? '1/4 beat' : '1/8 beat'
const fractions: Record<number, string> = { 0.125: '1/8', 0.25: '1/4', 0.5: '1/2', 0.75: '3/4' }
return `${fractions[b] ?? b} beat${b > 1 ? 's' : ''}`
}
/**
* The mixer, between the decks in performance mode (decided 2026-11-02): per
* channel TRIM (on top of the track's auto gain), HI / MID / LOW, a colour
* effect with its own selector (its one parameter is an app setting, in
* Settings ▸ Performance mode…), a fader and its meter; between
* channel GAIN (on top of the track's auto gain), HI / MID / LOW, the FILTER
* knob with the effect that rides with it (its picker above; each effect's one
* parameter is an app setting, in Settings ▸ Performance mode…), a fader and
* its meter; between
* them the master meter and the limiter's light; the crossfader beneath. The
* values live in `mixerState` and the audio in `mixer.ts`.
*/
@@ -186,8 +191,8 @@ function Strip({
/>
)
// GAIN (the state's `trim`: on top of the track's auto gain) and the EQ as a
// 2×2 block; beside it, toward the fader, the colour effect: its picker
// above a larger COLOR knob (decided 2026-11-03).
// 2×2 block; beside it, toward the fader, the Filter FX: the effect's picker
// above a larger FILTER knob (decided 2026-11-03).
const knobs = (
<div className={`flex items-center gap-2 self-center ${mirrored ? 'flex-row-reverse' : ''}`}>
<div className="grid grid-cols-2 gap-x-1.5 gap-y-1.5">
@@ -209,16 +214,16 @@ function Strip({
{eq('mid', 'Mid', 'Mid')}
{eq('low', 'Low', 'Low')}
</div>
<div className="flex flex-col items-center gap-2" style={{ width: COLOR_KNOB }}>
<div className="flex flex-col items-center gap-2" style={{ width: FILTER_KNOB }}>
<button
onClick={(e) => {
const r = e.currentTarget.getBoundingClientRect()
setFxMenu({ x: r.left, y: r.bottom + 4 })
}}
title={`${FX_LABELS[s.fx]} — which effect the COLOR knob drives`}
title={s.fx === 'filter' ? 'Filter FX: the filter alone — pick an effect to ride with it' : `Filter FX: ${FX_LABELS[s.fx]} rides with the FILTER knob`}
className="btn-glass flex h-6 w-full items-center justify-center gap-px rounded-md text-[9.5px] font-semibold uppercase tracking-[0.04em] text-text"
>
{FX_LABELS[s.fx]}
{FX_SHORT[s.fx]}
<Icon name="chevronDown" size={9} />
</button>
<Knob
@@ -227,10 +232,10 @@ function Strip({
max={1}
defaultValue={0}
bipolar
size={COLOR_KNOB}
size={FILTER_KNOB}
color="var(--color-gold)"
onChange={(v) => set({ color: Math.abs(v) < 0.02 ? 0 : v })}
label="Color"
label="Filter"
describe={(v) => describeFx(s.fx, v, fxSettings)}
/>
</div>