mirror of
https://github.com/MrPatben8/konduktor.git
synced 2026-11-27 10:22:51 +01:00
Improved filter FX
This commit is contained in:
1 parent
832dbed341
commit
717685f621
10 files changed
+428
-217
No files matched your search
@@ -1174,7 +1174,7 @@ Two independent apps that talk over HTTP:
|
|||||||
/ Try again (`backend_restart`). The shell has no timeout of its own. Before
|
/ Try again (`backend_restart`). The shell has no timeout of its own. Before
|
||||||
ready it answers quit requests itself — nothing can be unsaved — and stops
|
ready it answers quit requests itself — nothing can be unsaved — and stops
|
||||||
at ready so it never races `QuitGuard`), `SaveBar` (+ "Discard changes…" when
|
at ready so it never races `QuitGuard`), `SaveBar` (+ "Discard changes…" when
|
||||||
dirty, and the settings gear beside it, whose menu (or `?` anywhere) opens `ShortcutsDialog` — a KEYBOARD MAP (decided 2026-10-15): keys lit in the colour of what they do, a caption explaining the key pointed at or pressed (pressing explains, it never acts: a capture-phase listener keeps the deck's and table's keys from firing), holding or picking ⇧ / Cmd-Ctrl relights it with that layer, mouse gestures listed beneath. It shrinks to fit the dialog and drops the words on the keys when too small. Its content is `lib/shortcuts.ts`, written out BY HAND, so a new or changed shortcut in `lib/deckKeys.ts` / `TrackTable` must be added there too — and `AppSettings` ("Konduktor Settings…": app-level prefs, each with its default in `APP_SETTING_DEFAULTS` and read through `useAppSetting`; today `expandPlaylistFolders` and `exportRootFolder`, both default off — the latter read by the backend at `run_export` and passed down as `ExportPayload.root_folder` — and `timeReadoutDecimals` (0–3, default 1: the deck's ELAPSED / REMAIN, truncated, never rounded)) — and its own panel, `PerformanceSettings` ("Performance mode…", decided 2026-11-03), whose values sit in the same `APP_SETTING_DEFAULTS`: `perfStems` (default on: a stem track loaded INTO performance mode plays its stems, else its mix; read at load, never reloads a deck), `keylockDefault` (on), `eqKill` (off = -26 dB), `crossfaderSharpness` (0..1, 0 = smooth, default 0.5: a slider beside `CrossfaderCurveGraph`, which draws both channels' curves and where the crossfader is; dragging it moves the mixer at once and saves through the debounced prefs writer), and the colour effects' one parameter each, `fxFilterResonance` / `fxEchoBeats` / `fxSpaceSize` / `fxNoiseResonance` / `fxCrushDrive` (the mixer's per-channel PRM knob was removed). PrepStrip copies them into `mixerState`. The Sidebar holds folder open state as per-id overrides of that setting, reset on a new library or a change of the setting, and carried to the new ids when a rename/move changes a folder's path id)), `Toolbar` (search/filters; columns are chosen by right-clicking the table header),
|
dirty, and the settings gear beside it, whose menu (or `?` anywhere) opens `ShortcutsDialog` — a KEYBOARD MAP (decided 2026-10-15): keys lit in the colour of what they do, a caption explaining the key pointed at or pressed (pressing explains, it never acts: a capture-phase listener keeps the deck's and table's keys from firing), holding or picking ⇧ / Cmd-Ctrl relights it with that layer, mouse gestures listed beneath. It shrinks to fit the dialog and drops the words on the keys when too small. Its content is `lib/shortcuts.ts`, written out BY HAND, so a new or changed shortcut in `lib/deckKeys.ts` / `TrackTable` must be added there too — and `AppSettings` ("Konduktor Settings…": app-level prefs, each with its default in `APP_SETTING_DEFAULTS` and read through `useAppSetting`; today `expandPlaylistFolders` and `exportRootFolder`, both default off — the latter read by the backend at `run_export` and passed down as `ExportPayload.root_folder` — and `timeReadoutDecimals` (0–3, default 1: the deck's ELAPSED / REMAIN, truncated, never rounded)) — and its own panel, `PerformanceSettings` ("Performance mode…", decided 2026-11-03), whose values sit in the same `APP_SETTING_DEFAULTS`: `perfStems` (default on: a stem track loaded INTO performance mode plays its stems, else its mix; read at load, never reloads a deck), `keylockDefault` (on), `eqKill` (off = -26 dB), `crossfaderSharpness` (0..1, 0 = smooth, default 0.5: a slider beside `CrossfaderCurveGraph`, which draws both channels' curves and where the crossfader is; dragging it moves the mixer at once and saves through the debounced prefs writer), and the Filter FX: `fxFilterRange` (the Filter alone) and `fxEffectRange` (under an effect), each full / musical / gentle, `fxFilterResonance`, `fxReverbSize`, `fxDelayBeats`, `fxCrusherDrive`, `fxPhaserBeats` (the mixer's per-channel PRM knob was removed). PrepStrip copies them into `mixerState`. The Sidebar holds folder open state as per-id overrides of that setting, reset on a new library or a change of the setting, and carried to the new ids when a rename/move changes a folder's path id)), `Toolbar` (search/filters; columns are chosen by right-clicking the table header),
|
||||||
`TrackTable` (**the one track list** — All Tracks, playlists, exports and
|
`TrackTable` (**the one track list** — All Tracks, playlists, exports and
|
||||||
devices. TanStack Table + **virtualized** grid; per-row play button,
|
devices. TanStack Table + **virtualized** grid; per-row play button,
|
||||||
configurable columns, header sorting, inline double-click editing, and
|
configurable columns, header sorting, inline double-click editing, and
|
||||||
@@ -2692,7 +2692,7 @@ that number and nothing else — everything derives from it:
|
|||||||
Architecture. Not yet: verified on a real TrueNAS (the image is published by
|
Architecture. Not yet: verified on a real TrueNAS (the image is published by
|
||||||
CI's `server-image` job), a web UI served by the server (decided: not now).
|
CI's `server-image` job), a web UI served by the server (decided: not now).
|
||||||
- ✅ **Performance mode** (2026-11-03) — a second deck and a mixer to try
|
- ✅ **Performance mode** (2026-11-03) — a second deck and a mixer to try
|
||||||
transitions: stacked waveforms, 3-band isolator, per-channel colour FX,
|
transitions: stacked waveforms, 3-band isolator, per-channel Filter FX,
|
||||||
crossfader, limiter, pitch with Rubber Band keylock, SYNC with a tempo
|
crossfader, limiter, pitch with Rubber Band keylock, SYNC with a tempo
|
||||||
master, a phase meter you can drag to bend. See `lib/audio/`,
|
master, a phase meter you can drag to bend. See `lib/audio/`,
|
||||||
`components/deck/`, `components/mixer/` and "Prep strip" / "Prep engine";
|
`components/deck/`, `components/mixer/` and "Prep strip" / "Prep engine";
|
||||||
@@ -2802,10 +2802,27 @@ The prep strip plays every track through the **Web Audio API** (a plain
|
|||||||
(LR4 crossovers at 250 Hz / 2.5 kHz, the low band through a 2.5 kHz
|
(LR4 crossovers at 250 Hz / 2.5 kHz, the low band through a 2.5 kHz
|
||||||
all-pass, so the bands sum flat — measured 0.0000 dB; Web Audio's
|
all-pass, so the bands sum flat — measured 0.0000 dB; Web Audio's
|
||||||
lowpass/highpass Q is in DB, Butterworth = -3.01, its allpass Q linear) →
|
lowpass/highpass Q is in DB, Butterworth = -3.01, its allpass Q linear) →
|
||||||
the colour FX (Filter / Echo / Space / Noise / Crush, chosen PER CHANNEL,
|
FILTER FX (`FilterFx`, decided 2026-11-03 after Traktor's mixer: the
|
||||||
one bipolar COLOR knob; each effect's one parameter is an APP SETTING, not
|
FILTER knob always filters — 4-pole, low-pass left / high-pass right, over
|
||||||
a knob — `mixerState.fx`, decided 2026-11-03; all built once and switched
|
a RANGE: FULL (to 20 Hz / 20 kHz: a 100 Hz bass -56 dB at full left,
|
||||||
by gains) →
|
measured; one 12 dB stage left it at -28), MUSICAL (150 Hz / 8 kHz) or
|
||||||
|
GENTLE (500 Hz / 2 kHz) — one setting for the Filter alone (default full),
|
||||||
|
another under an effect (default musical: swept to silence the filter
|
||||||
|
would starve the effect; `mixerState.rangeFor`) — and the channel's chosen
|
||||||
|
effect rides with it,
|
||||||
|
fed the FILTERED signal, growing with the knob: Reverb, Delay (sends whose
|
||||||
|
tails ring out — echo- and wash-outs), Bit crusher (replaces the filtered
|
||||||
|
signal), Phaser (four all-pass stages swept by a beat-synced LFO), or
|
||||||
|
Filter alone. THE MORE FILTER, THE BIGGER THE EFFECT (decided
|
||||||
|
2026-11-03): the delay's length and the phaser's speed step by two at
|
||||||
|
each quarter of the knob (`mixerMath.knobStep` — the settings are the
|
||||||
|
SHORTEST delay and SLOWEST sweep, up to ×8, every step a musical length),
|
||||||
|
and the reverb blends from a short convolver (the setting) into one
|
||||||
|
`REVERB_GROWTH` (3) times as long — two convolvers, since swapping one's
|
||||||
|
impulse cuts its tail (measured: 6 s after a burst -75 dB at 20% of the
|
||||||
|
knob, -54 at 60%). Resonance fades over the last stretch of the sweep (no
|
||||||
|
boom at 20 Hz). Each effect's one parameter is an APP SETTING, not a knob —
|
||||||
|
`mixerState.fx`; all built once and switched by gains) →
|
||||||
fader → crossfader (`xfadeGains(x, sharpness)`: each channel fades on a
|
fader → crossfader (`xfadeGains(x, sharpness)`: each channel fades on a
|
||||||
quarter-cosine over the last `xfadeWidth` of the travel — the whole of it
|
quarter-cosine over the last `xfadeWidth` of the travel — the whole of it
|
||||||
at 0, constant power, -3 dB in the middle; 4% at 1, a cut; no dip in the
|
at 0, constant power, -3 dB in the middle; 4% at 1, a cut; no dip in the
|
||||||
@@ -2819,7 +2836,7 @@ The prep strip plays every track through the **Web Audio API** (a plain
|
|||||||
persisted; a MIDI mapping would write the same setters); the curves in
|
persisted; a MIDI mapping would write the same setters); the curves in
|
||||||
`mixerMath.ts` (tested). `components/mixer/`: `MixerPanel` (26rem; per
|
`mixerMath.ts` (tested). `components/mixer/`: `MixerPanel` (26rem; per
|
||||||
channel a 2×2 block — GAIN HI / MID LOW, 40 px knobs — and toward the fader
|
channel a 2×2 block — GAIN HI / MID LOW, 40 px knobs — and toward the fader
|
||||||
the FX picker over a 48 px COLOR knob, mirrored on B; meters written from
|
the effect picker over a 48 px FILTER knob, mirrored on B; meters written from
|
||||||
one rAF loop, never through React state) and `Controls` (`Knob`,
|
one rAF loop, never through React state) and `Controls` (`Knob`,
|
||||||
`Fader`: drag, Shift = fine, wheel, double-click resets; not focusable, so
|
`Fader`: drag, Shift = fine, wheel, double-click resets; not focusable, so
|
||||||
the deck keys never land on them). The graph itself was measured offline in
|
the deck keys never land on them). The graph itself was measured offline in
|
||||||
|
|||||||
@@ -34,12 +34,15 @@ export const APP_SETTING_DEFAULTS = {
|
|||||||
* Default halfway: both channels full across the middle, fading over the
|
* Default halfway: both channels full across the middle, fading over the
|
||||||
* outer half of the travel each (decided 2026-11-03). */
|
* outer half of the travel each (decided 2026-11-03). */
|
||||||
crossfaderSharpness: 0.5,
|
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,
|
fxFilterResonance: 0.3,
|
||||||
fxEchoBeats: 0.5,
|
fxReverbSize: 2,
|
||||||
fxSpaceSize: 2.5,
|
fxDelayBeats: 0.25,
|
||||||
fxNoiseResonance: 0.3,
|
fxCrusherDrive: 2,
|
||||||
fxCrushDrive: 2,
|
fxPhaserBeats: 4,
|
||||||
}
|
}
|
||||||
|
|
||||||
type AppSettingKey = keyof typeof APP_SETTING_DEFAULTS
|
type AppSettingKey = keyof typeof APP_SETTING_DEFAULTS
|
||||||
|
|||||||
@@ -8,6 +8,14 @@ import { Modal } from './Modal'
|
|||||||
import { Fader } from './mixer/Controls'
|
import { Fader } from './mixer/Controls'
|
||||||
import { CrossfaderCurveGraph } from './mixer/CrossfaderCurve'
|
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). */
|
/** Resonance amounts offered (0..1 of the effect's maximum). */
|
||||||
const LEVELS: [string, string][] = [
|
const LEVELS: [string, string][] = [
|
||||||
['0', 'None'],
|
['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,
|
* 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
|
* settings (userprefs.json, `APP_SETTING_DEFAULTS`); PrepStrip copies the
|
||||||
* mixer's into `mixerState`.
|
* mixer's into `mixerState`.
|
||||||
*/
|
*/
|
||||||
@@ -31,11 +39,13 @@ export function PerformanceSettings({ onClose }: { onClose: () => void }) {
|
|||||||
const keylockDefault = useAppSetting('keylockDefault')
|
const keylockDefault = useAppSetting('keylockDefault')
|
||||||
const eqKill = useAppSetting('eqKill')
|
const eqKill = useAppSetting('eqKill')
|
||||||
const sharpnessSetting = useAppSetting('crossfaderSharpness')
|
const sharpnessSetting = useAppSetting('crossfaderSharpness')
|
||||||
|
const fxFilterRange = useAppSetting('fxFilterRange')
|
||||||
|
const fxEffectRange = useAppSetting('fxEffectRange')
|
||||||
const fxFilterResonance = useAppSetting('fxFilterResonance')
|
const fxFilterResonance = useAppSetting('fxFilterResonance')
|
||||||
const fxEchoBeats = useAppSetting('fxEchoBeats')
|
const fxReverbSize = useAppSetting('fxReverbSize')
|
||||||
const fxSpaceSize = useAppSetting('fxSpaceSize')
|
const fxDelayBeats = useAppSetting('fxDelayBeats')
|
||||||
const fxNoiseResonance = useAppSetting('fxNoiseResonance')
|
const fxCrusherDrive = useAppSetting('fxCrusherDrive')
|
||||||
const fxCrushDrive = useAppSetting('fxCrushDrive')
|
const fxPhaserBeats = useAppSetting('fxPhaserBeats')
|
||||||
const [error, setError] = useState<string | null>(null)
|
const [error, setError] = useState<string | null>(null)
|
||||||
|
|
||||||
// The curve moves with the slider at once — mixer included, so it can be
|
// 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>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
<section className="space-y-2">
|
<section className="space-y-2">
|
||||||
<h3 className={section}>Colour effects</h3>
|
<h3 className={section}>Filter FX</h3>
|
||||||
<span className="block text-xs text-faint">Each effect's setting, on both channels.</span>
|
<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
|
<Choice
|
||||||
title="Filter resonance"
|
title="Filter resonance"
|
||||||
value={String(fxFilterResonance)}
|
value={String(fxFilterResonance)}
|
||||||
@@ -146,8 +173,19 @@ export function PerformanceSettings({ onClose }: { onClose: () => void }) {
|
|||||||
onChange={(v) => void set({ fxFilterResonance: Number(v) })}
|
onChange={(v) => void set({ fxFilterResonance: Number(v) })}
|
||||||
/>
|
/>
|
||||||
<Choice
|
<Choice
|
||||||
title="Echo length"
|
title="Reverb size (shortest)"
|
||||||
value={String(fxEchoBeats)}
|
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={[
|
options={[
|
||||||
['0.125', '1/8 beat'],
|
['0.125', '1/8 beat'],
|
||||||
['0.25', '1/4 beat'],
|
['0.25', '1/4 beat'],
|
||||||
@@ -155,34 +193,29 @@ export function PerformanceSettings({ onClose }: { onClose: () => void }) {
|
|||||||
['0.75', '3/4 beat'],
|
['0.75', '3/4 beat'],
|
||||||
['1', '1 beat'],
|
['1', '1 beat'],
|
||||||
]}
|
]}
|
||||||
onChange={(v) => void set({ fxEchoBeats: Number(v) })}
|
onChange={(v) => void set({ fxDelayBeats: Number(v) })}
|
||||||
/>
|
/>
|
||||||
<Choice
|
<Choice
|
||||||
title="Space size"
|
title="Bit crusher drive"
|
||||||
value={String(fxSpaceSize)}
|
value={String(fxCrusherDrive)}
|
||||||
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)}
|
|
||||||
options={[
|
options={[
|
||||||
['1', 'Clean (×1)'],
|
['1', 'Clean (×1)'],
|
||||||
['2', 'Warm (×2)'],
|
['2', 'Warm (×2)'],
|
||||||
['4', 'Hot (×4)'],
|
['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>
|
</section>
|
||||||
{error && <div className="text-xs text-pink">{error}</div>}
|
{error && <div className="text-xs text-pink">{error}</div>}
|
||||||
|
|||||||
@@ -124,14 +124,20 @@ export function PrepStrip({
|
|||||||
const keylockDefault = useAppSetting('keylockDefault')
|
const keylockDefault = useAppSetting('keylockDefault')
|
||||||
const eqKill = useAppSetting('eqKill')
|
const eqKill = useAppSetting('eqKill')
|
||||||
const sharpness = useAppSetting('crossfaderSharpness')
|
const sharpness = useAppSetting('crossfaderSharpness')
|
||||||
|
const filterRange = useAppSetting('fxFilterRange')
|
||||||
|
const effectRange = useAppSetting('fxEffectRange')
|
||||||
const filterResonance = useAppSetting('fxFilterResonance')
|
const filterResonance = useAppSetting('fxFilterResonance')
|
||||||
const echoBeats = useAppSetting('fxEchoBeats')
|
const reverbSize = useAppSetting('fxReverbSize')
|
||||||
const spaceSize = useAppSetting('fxSpaceSize')
|
const delayBeats = useAppSetting('fxDelayBeats')
|
||||||
const noiseResonance = useAppSetting('fxNoiseResonance')
|
const crusherDrive = useAppSetting('fxCrusherDrive')
|
||||||
const crushDrive = useAppSetting('fxCrushDrive')
|
const phaserBeats = useAppSetting('fxPhaserBeats')
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setMixer({ eqKill, sharpness, fx: { filterResonance, echoBeats, spaceSize, noiseResonance, crushDrive } })
|
setMixer({
|
||||||
}, [eqKill, sharpness, filterResonance, echoBeats, spaceSize, noiseResonance, crushDrive])
|
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 lead: DeckId = performance ? focused : 'A'
|
||||||
const playingA = useCallback((p: boolean) => onPlayingChange('A', p), [onPlayingChange])
|
const playingA = useCallback((p: boolean) => onPlayingChange('A', p), [onPlayingChange])
|
||||||
const playingB = useCallback((p: boolean) => onPlayingChange('B', p), [onPlayingChange])
|
const playingB = useCallback((p: boolean) => onPlayingChange('B', p), [onPlayingChange])
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
import { useEffect, useRef, useState, type RefObject } from 'react'
|
import { useEffect, useRef, useState, type RefObject } from 'react'
|
||||||
import { mixer } from '../../lib/audio/mixer'
|
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 {
|
import {
|
||||||
FX_LABELS,
|
FX_LABELS,
|
||||||
|
FX_SHORT,
|
||||||
FX_TYPES,
|
FX_TYPES,
|
||||||
|
rangeFor,
|
||||||
setChannel,
|
setChannel,
|
||||||
setMixer,
|
setMixer,
|
||||||
useMixer,
|
useMixer,
|
||||||
@@ -20,42 +22,45 @@ const METER_FLOOR = -48
|
|||||||
const METER_TOP = 3
|
const METER_TOP = 3
|
||||||
|
|
||||||
/** Knob sizes (px): as large as the column allows — the EQ block is two
|
/** 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 EQ_KNOB = 40
|
||||||
const COLOR_KNOB = 48
|
const FILTER_KNOB = 48
|
||||||
|
|
||||||
const fmtDb = (db: number, places = 1) =>
|
const fmtDb = (db: number, places = 1) =>
|
||||||
!isFinite(db) ? '−∞ dB' : `${db > 0 ? '+' : db < 0 ? '−' : ''}${Math.abs(db).toFixed(places)} dB`
|
!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 {
|
function describeFx(fx: FxType, c: number, set: FxSettings): string {
|
||||||
const a = Math.round(Math.abs(c) * 100)
|
if (Math.abs(c) < 0.02) return `Filter${fx === 'filter' ? '' : ` + ${FX_LABELS[fx]}`}: off (turn left or right)`
|
||||||
if (Math.abs(c) < 0.02) return `${FX_LABELS[fx]}: off (turn left or right)`
|
const s = filterSweep(c, rangeFor(fx, set))!
|
||||||
switch (fx) {
|
|
||||||
case 'filter': {
|
|
||||||
const s = filterSweep(c)!
|
|
||||||
const hz = s.freq >= 1000 ? `${(s.freq / 1000).toFixed(1)} kHz` : `${Math.round(s.freq)} Hz`
|
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)}%`
|
const filter = `${s.type === 'lowpass' ? 'low-pass' : 'high-pass'} at ${hz}`
|
||||||
}
|
const a = `${Math.round(Math.abs(c) * 100)}%`
|
||||||
case 'echo':
|
switch (fx) {
|
||||||
return `Echo ${a}% · ${beatsLabel(set.echoBeats)} · ${c < 0 ? 'darker' : 'thinner'} repeats`
|
case 'filter':
|
||||||
case 'space':
|
return `Filter: ${filter} · resonance ${Math.round(set.filterResonance * 100)}%`
|
||||||
return `Space ${a}% · ${set.spaceSize} s · ${c < 0 ? 'darker' : 'thinner'}`
|
case 'reverb':
|
||||||
case 'noise':
|
return `Reverb ${a} (${set.reverbSize}–${set.reverbSize * REVERB_GROWTH} s, longer as it opens) + ${filter}`
|
||||||
return `Noise ${a}% · ${c < 0 ? 'low-pass' : 'high-pass'} sweep`
|
case 'delay':
|
||||||
case 'crush':
|
return `Delay ${a} (${beatsLabel(delayBeatsAt(set.delayBeats, Math.abs(c)))}) + ${filter}`
|
||||||
return `Crush ${a}% · drive ×${set.crushDrive}`
|
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 {
|
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
|
* 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
|
* channel GAIN (on top of the track's auto gain), HI / MID / LOW, the FILTER
|
||||||
* effect with its own selector (its one parameter is an app setting, in
|
* knob with the effect that rides with it (its picker above; each effect's one
|
||||||
* Settings ▸ Performance mode…), a fader and its meter; between
|
* 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
|
* them the master meter and the limiter's light; the crossfader beneath. The
|
||||||
* values live in `mixerState` and the audio in `mixer.ts`.
|
* 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
|
// 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
|
// 2×2 block; beside it, toward the fader, the Filter FX: the effect's picker
|
||||||
// above a larger COLOR knob (decided 2026-11-03).
|
// above a larger FILTER knob (decided 2026-11-03).
|
||||||
const knobs = (
|
const knobs = (
|
||||||
<div className={`flex items-center gap-2 self-center ${mirrored ? 'flex-row-reverse' : ''}`}>
|
<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">
|
<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('mid', 'Mid', 'Mid')}
|
||||||
{eq('low', 'Low', 'Low')}
|
{eq('low', 'Low', 'Low')}
|
||||||
</div>
|
</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
|
<button
|
||||||
onClick={(e) => {
|
onClick={(e) => {
|
||||||
const r = e.currentTarget.getBoundingClientRect()
|
const r = e.currentTarget.getBoundingClientRect()
|
||||||
setFxMenu({ x: r.left, y: r.bottom + 4 })
|
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"
|
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} />
|
<Icon name="chevronDown" size={9} />
|
||||||
</button>
|
</button>
|
||||||
<Knob
|
<Knob
|
||||||
@@ -227,10 +232,10 @@ function Strip({
|
|||||||
max={1}
|
max={1}
|
||||||
defaultValue={0}
|
defaultValue={0}
|
||||||
bipolar
|
bipolar
|
||||||
size={COLOR_KNOB}
|
size={FILTER_KNOB}
|
||||||
color="var(--color-gold)"
|
color="var(--color-gold)"
|
||||||
onChange={(v) => set({ color: Math.abs(v) < 0.02 ? 0 : v })}
|
onChange={(v) => set({ color: Math.abs(v) < 0.02 ? 0 : v })}
|
||||||
label="Color"
|
label="Filter"
|
||||||
describe={(v) => describeFx(s.fx, v, fxSettings)}
|
describe={(v) => describeFx(s.fx, v, fxSettings)}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
+135
-99
@@ -1,11 +1,11 @@
|
|||||||
// The mixer's audio graph (performance mode, decided 2026-11-02). Both decks
|
// The mixer's audio graph (performance mode, decided 2026-11-02). Both decks
|
||||||
// play into it; it follows the controls in `mixerState.ts`.
|
// play into it; it follows the controls in `mixerState.ts`.
|
||||||
//
|
//
|
||||||
// deck → trim → 3-band isolator → colour FX → fader ─┬→ crossfader → bus
|
// deck → gain → 3-band isolator → filter FX → fader ─┬→ crossfader → bus
|
||||||
// └→ meter
|
// └→ meter
|
||||||
// bus → limiter → master meter → speakers
|
// bus → limiter → master meter → speakers
|
||||||
//
|
//
|
||||||
// TRIM starts at the track's own auto gain (the DJ app's, `Track.auto_gain_db`;
|
// GAIN (`trim` in the state) starts at the track's own auto gain (the DJ app's, `Track.auto_gain_db`;
|
||||||
// none = 0 dB) plus the knob. The ISOLATOR splits at 250 Hz / 2.5 kHz with
|
// none = 0 dB) plus the knob. The ISOLATOR splits at 250 Hz / 2.5 kHz with
|
||||||
// Linkwitz-Riley (LR4) crossovers, the low band through an all-pass matching
|
// Linkwitz-Riley (LR4) crossovers, the low band through an all-pass matching
|
||||||
// the upper crossover, so the three bands sum back to flat — measured to 0.0001
|
// the upper crossover, so the three bands sum back to flat — measured to 0.0001
|
||||||
@@ -23,18 +23,21 @@
|
|||||||
|
|
||||||
import { audioContext } from './context'
|
import { audioContext } from './context'
|
||||||
import {
|
import {
|
||||||
|
beatSeconds,
|
||||||
dbToGain,
|
dbToGain,
|
||||||
echoSeconds,
|
|
||||||
eqGain,
|
eqGain,
|
||||||
EQ_HIGH_HZ,
|
EQ_HIGH_HZ,
|
||||||
EQ_LOW_HZ,
|
EQ_LOW_HZ,
|
||||||
|
delayBeatsAt,
|
||||||
faderGain,
|
faderGain,
|
||||||
filterSweep,
|
filterSweep,
|
||||||
|
phaserBeatsAt,
|
||||||
|
REVERB_GROWTH,
|
||||||
FX_CENTRE,
|
FX_CENTRE,
|
||||||
TRIM_RANGE_DB,
|
TRIM_RANGE_DB,
|
||||||
xfadeGains,
|
xfadeGains,
|
||||||
} from './mixerMath'
|
} from './mixerMath'
|
||||||
import { getMixerState, subscribeMixer, type Channel, type ChannelState, type FxSettings, type FxType } from './mixerState'
|
import { getMixerState, rangeFor, subscribeMixer, type Channel, type ChannelState, type FxSettings, type FxType } from './mixerState'
|
||||||
|
|
||||||
/** Butterworth Q in Web Audio's lowpass/highpass units (dB). */
|
/** Butterworth Q in Web Audio's lowpass/highpass units (dB). */
|
||||||
const BUTTERWORTH_DB = 20 * Math.log10(Math.SQRT1_2)
|
const BUTTERWORTH_DB = 20 * Math.log10(Math.SQRT1_2)
|
||||||
@@ -44,6 +47,9 @@ const LIMIT_RATIO = 20
|
|||||||
* gain at 0 dBFS, to the power 0.6), in dB. */
|
* gain at 0 dBFS, to the power 0.6), in dB. */
|
||||||
const MAKEUP_DB = -0.6 * (LIMIT_DB + (0 - LIMIT_DB) / LIMIT_RATIO)
|
const MAKEUP_DB = -0.6 * (LIMIT_DB + (0 - LIMIT_DB) / LIMIT_RATIO)
|
||||||
|
|
||||||
|
/** The longest delay (s): 8 × a 1-beat setting at 120 BPM. */
|
||||||
|
const MAX_DELAY_S = 4
|
||||||
|
|
||||||
/** Parameter smoothing (s): fast enough to feel direct, slow enough not to click. */
|
/** Parameter smoothing (s): fast enough to feel direct, slow enough not to click. */
|
||||||
const GLIDE = 0.012
|
const GLIDE = 0.012
|
||||||
|
|
||||||
@@ -100,38 +106,52 @@ function crushCurve(bits: number): Float32Array<ArrayBuffer> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* One channel's colour effect: ONE knob, -1..1, out of the path at the centre;
|
* One channel's FILTER FX (decided 2026-11-03, after Traktor's mixer): ONE
|
||||||
* which effect it drives is the channel's own choice (decided 2026-11-02), its
|
* knob, -1..1, out of the path at the centre. It always FILTERS — low-pass
|
||||||
* one parameter an app setting (`FxSettings`, decided 2026-11-03).
|
* left, high-pass right; over the `filterRange` setting for the Filter alone,
|
||||||
* Every effect is built once and switched by gains, so a change never clicks;
|
* the musical range under an effect (`rangeFor`) — and the channel's
|
||||||
* echo and reverb tails ring out after the knob returns.
|
* chosen effect rides with it, fed the FILTERED signal, its amount growing
|
||||||
|
* with the knob — and the more filter, the longer the reverb and delay and
|
||||||
|
* the faster the phaser: Reverb and Delay are sends whose tails ring out
|
||||||
|
* after the knob returns (echo- and wash-outs); Bit crusher replaces the
|
||||||
|
* filtered signal with a crushed copy; Phaser mixes it with a beat-synced
|
||||||
|
* sweeping all-pass chain, faster as the knob opens (`phaserBeatsAt`).
|
||||||
|
* `filter` is the filter alone. Everything is built
|
||||||
|
* once and switched by gains, so a change never clicks. Each effect's one
|
||||||
|
* parameter is an app setting (`FxSettings`).
|
||||||
*/
|
*/
|
||||||
class ColorFx {
|
class FilterFx {
|
||||||
readonly input: GainNode
|
readonly input: GainNode
|
||||||
readonly output: GainNode
|
readonly output: GainNode
|
||||||
private readonly ctx: AudioContext
|
private readonly ctx: AudioContext
|
||||||
private readonly dry: GainNode
|
private readonly dry: GainNode
|
||||||
// Filter (also the music's path for Crush's tone).
|
/** Two stages, 24 dB/octave: the first Butterworth, the second carrying the
|
||||||
|
* resonance. One 12 dB stage left a 100 Hz bass only 28 dB down at the end
|
||||||
|
* of a full-range low-pass (measured) — not the near-silence asked for. */
|
||||||
|
private readonly filterIn: BiquadFilterNode
|
||||||
private readonly filter: BiquadFilterNode
|
private readonly filter: BiquadFilterNode
|
||||||
private readonly filterWet: GainNode
|
/** The filtered music itself (every effect but Bit crusher keeps it). */
|
||||||
// Echo: a send into a delay with filtered feedback.
|
private readonly filtered: GainNode
|
||||||
private readonly echoSend: GainNode
|
// Reverb: sends into a SHORT and a LONG convolver; the knob blends from one
|
||||||
|
// into the other (re-generating one impulse instead would cut its tail).
|
||||||
|
private readonly reverbShort: GainNode
|
||||||
|
private readonly reverbLong: GainNode
|
||||||
|
private readonly convShort: ConvolverNode
|
||||||
|
private readonly convLong: ConvolverNode
|
||||||
|
private reverbSize = -1
|
||||||
|
// Delay: a send into a delay with filtered feedback.
|
||||||
|
private readonly delaySend: GainNode
|
||||||
private readonly delay: DelayNode
|
private readonly delay: DelayNode
|
||||||
private readonly echoTone: BiquadFilterNode
|
private readonly delayTone: BiquadFilterNode
|
||||||
private readonly feedback: GainNode
|
private readonly feedback: GainNode
|
||||||
// Space: a send into a convolver.
|
// Bit crusher.
|
||||||
private readonly spaceSend: GainNode
|
|
||||||
private readonly spaceTone: BiquadFilterNode
|
|
||||||
private readonly convolver: ConvolverNode
|
|
||||||
private spaceSize = -1
|
|
||||||
// Noise: filtered white noise mixed in.
|
|
||||||
private readonly noiseFilter: BiquadFilterNode
|
|
||||||
private readonly noiseGain: GainNode
|
|
||||||
// Crush.
|
|
||||||
private readonly crushDrive: GainNode
|
private readonly crushDrive: GainNode
|
||||||
private readonly shaper: WaveShaperNode
|
private readonly shaper: WaveShaperNode
|
||||||
private readonly crushWet: GainNode
|
private readonly crushWet: GainNode
|
||||||
private crushBits = -1
|
private crushBits = -1
|
||||||
|
// Phaser: all-pass stages swept by one LFO.
|
||||||
|
private readonly lfo: OscillatorNode
|
||||||
|
private readonly phaserWet: GainNode
|
||||||
|
|
||||||
constructor(ctx: AudioContext) {
|
constructor(ctx: AudioContext) {
|
||||||
this.ctx = ctx
|
this.ctx = ctx
|
||||||
@@ -140,108 +160,124 @@ class ColorFx {
|
|||||||
this.dry = ctx.createGain()
|
this.dry = ctx.createGain()
|
||||||
this.input.connect(this.dry).connect(this.output)
|
this.input.connect(this.dry).connect(this.output)
|
||||||
|
|
||||||
|
this.filterIn = biquad(ctx, 'lowpass', 20000, BUTTERWORTH_DB)
|
||||||
this.filter = biquad(ctx, 'lowpass', 20000, 0)
|
this.filter = biquad(ctx, 'lowpass', 20000, 0)
|
||||||
this.filterWet = ctx.createGain()
|
this.input.connect(this.filterIn).connect(this.filter)
|
||||||
this.filterWet.gain.value = 0
|
this.filtered = ctx.createGain()
|
||||||
this.input.connect(this.filter).connect(this.filterWet).connect(this.output)
|
this.filtered.gain.value = 0
|
||||||
|
this.filter.connect(this.filtered).connect(this.output)
|
||||||
|
|
||||||
this.echoSend = ctx.createGain()
|
this.reverbShort = ctx.createGain()
|
||||||
this.echoSend.gain.value = 0
|
this.reverbShort.gain.value = 0
|
||||||
this.delay = ctx.createDelay(4)
|
this.reverbLong = ctx.createGain()
|
||||||
this.echoTone = biquad(ctx, 'lowpass', 2500, 0)
|
this.reverbLong.gain.value = 0
|
||||||
|
this.convShort = ctx.createConvolver()
|
||||||
|
this.convLong = ctx.createConvolver()
|
||||||
|
this.filter.connect(this.reverbShort).connect(this.convShort).connect(this.output)
|
||||||
|
this.filter.connect(this.reverbLong).connect(this.convLong).connect(this.output)
|
||||||
|
|
||||||
|
this.delaySend = ctx.createGain()
|
||||||
|
this.delaySend.gain.value = 0
|
||||||
|
this.delay = ctx.createDelay(MAX_DELAY_S + 0.1)
|
||||||
|
this.delayTone = biquad(ctx, 'lowpass', 2500, 0)
|
||||||
this.feedback = ctx.createGain()
|
this.feedback = ctx.createGain()
|
||||||
this.feedback.gain.value = 0.45
|
this.feedback.gain.value = 0.45
|
||||||
this.input.connect(this.echoSend).connect(this.delay)
|
this.filter.connect(this.delaySend).connect(this.delay)
|
||||||
this.delay.connect(this.echoTone).connect(this.feedback).connect(this.delay)
|
this.delay.connect(this.delayTone).connect(this.feedback).connect(this.delay)
|
||||||
this.delay.connect(this.output)
|
this.delay.connect(this.output)
|
||||||
|
|
||||||
this.spaceSend = ctx.createGain()
|
|
||||||
this.spaceSend.gain.value = 0
|
|
||||||
this.spaceTone = biquad(ctx, 'lowpass', 20000, 0)
|
|
||||||
this.convolver = ctx.createConvolver()
|
|
||||||
this.input.connect(this.spaceSend).connect(this.spaceTone).connect(this.convolver).connect(this.output)
|
|
||||||
|
|
||||||
const noise = ctx.createBufferSource()
|
|
||||||
noise.buffer = noiseBuffer(ctx, 2)
|
|
||||||
noise.loop = true
|
|
||||||
this.noiseFilter = biquad(ctx, 'lowpass', 20000, 0)
|
|
||||||
this.noiseGain = ctx.createGain()
|
|
||||||
this.noiseGain.gain.value = 0
|
|
||||||
noise.connect(this.noiseFilter).connect(this.noiseGain).connect(this.output)
|
|
||||||
noise.start()
|
|
||||||
|
|
||||||
this.crushDrive = ctx.createGain()
|
this.crushDrive = ctx.createGain()
|
||||||
this.shaper = ctx.createWaveShaper()
|
this.shaper = ctx.createWaveShaper()
|
||||||
this.crushWet = ctx.createGain()
|
this.crushWet = ctx.createGain()
|
||||||
this.crushWet.gain.value = 0
|
this.crushWet.gain.value = 0
|
||||||
this.input.connect(this.crushDrive).connect(this.shaper).connect(this.crushWet).connect(this.output)
|
this.filter.connect(this.crushDrive).connect(this.shaper).connect(this.crushWet).connect(this.output)
|
||||||
|
|
||||||
|
// Four all-pass stages an octave apart, each swept ±60% around its centre.
|
||||||
|
this.lfo = ctx.createOscillator()
|
||||||
|
this.lfo.frequency.value = 0.5
|
||||||
|
this.phaserWet = ctx.createGain()
|
||||||
|
this.phaserWet.gain.value = 0
|
||||||
|
let stage: AudioNode = this.filter
|
||||||
|
for (const centre of [350, 700, 1400, 2800]) {
|
||||||
|
const ap = biquad(ctx, 'allpass', centre, 0.6)
|
||||||
|
const depth = ctx.createGain()
|
||||||
|
depth.gain.value = centre * 0.6
|
||||||
|
this.lfo.connect(depth).connect(ap.frequency)
|
||||||
|
stage.connect(ap)
|
||||||
|
stage = ap
|
||||||
|
}
|
||||||
|
stage.connect(this.phaserWet).connect(this.output)
|
||||||
|
this.lfo.start()
|
||||||
}
|
}
|
||||||
|
|
||||||
apply(type: FxType, color: number, fx: FxSettings, bpm: number): void {
|
apply(type: FxType, knob: number, fx: FxSettings, bpm: number): void {
|
||||||
const ctx = this.ctx
|
const ctx = this.ctx
|
||||||
const a = Math.min(1, Math.abs(color))
|
const a = Math.min(1, Math.abs(knob))
|
||||||
const on = a >= FX_CENTRE
|
const on = a >= FX_CENTRE
|
||||||
// Whatever replaces the dry signal (filter, crush) fades in over the first
|
// The filtered path replaces the dry one over the first few percent of
|
||||||
// few percent of the knob, so leaving the centre never jumps.
|
// the knob, so leaving the centre never jumps.
|
||||||
const take = on ? Math.min(1, a / 0.06) : 0
|
const take = on ? Math.min(1, a / 0.06) : 0
|
||||||
const sweep = filterSweep(color)
|
const sweep = filterSweep(knob, rangeFor(type, fx))
|
||||||
|
if (sweep) {
|
||||||
// Filter: the music itself, swept.
|
if (this.filter.type !== sweep.type) {
|
||||||
const filtering = type === 'filter' && sweep != null
|
this.filterIn.type = sweep.type
|
||||||
if (filtering) {
|
this.filter.type = sweep.type
|
||||||
if (this.filter.type !== sweep.type) this.filter.type = sweep.type
|
}
|
||||||
|
ramp(this.filterIn.frequency, sweep.freq, ctx)
|
||||||
ramp(this.filter.frequency, sweep.freq, ctx)
|
ramp(this.filter.frequency, sweep.freq, ctx)
|
||||||
ramp(this.filter.Q, fx.filterResonance * 15, ctx)
|
// Resonance fades over the last stretch: a resonant peak at 20 Hz (or
|
||||||
|
// 20 kHz) at the end of a full sweep would be a boom (or a whistle).
|
||||||
|
ramp(this.filter.Q, fx.filterResonance * 15 * (1 - a ** 4), ctx)
|
||||||
}
|
}
|
||||||
ramp(this.filterWet.gain, filtering ? take : 0, ctx)
|
ramp(this.dry.gain, 1 - take, ctx)
|
||||||
|
|
||||||
// Echo: send + feedback grow with the knob; left darker, right thinner.
|
// How much of the filtered music stays: all of it, but half under the
|
||||||
const echoing = type === 'echo' && on
|
// phaser (whose notches come from mixing the two) and none under the
|
||||||
ramp(this.echoSend.gain, echoing ? a * 0.8 : 0, ctx)
|
// crusher (which replaces it).
|
||||||
ramp(this.feedback.gain, echoing ? 0.35 + 0.5 * a : 0.45, ctx, 0.05)
|
const phasing = type === 'phaser' && on
|
||||||
if (type === 'echo') {
|
const mix = phasing ? Math.min(1, a / 0.25) : 0
|
||||||
ramp(this.delay.delayTime, echoSeconds(fx.echoBeats, bpm), ctx, 0.05)
|
const crushing = type === 'crusher' && on
|
||||||
const tone = color < 0 ? 'lowpass' : 'highpass'
|
ramp(this.filtered.gain, crushing ? 0 : take * (1 - 0.5 * mix), ctx)
|
||||||
if (this.echoTone.type !== tone) this.echoTone.type = tone
|
ramp(this.phaserWet.gain, take * 0.5 * mix, ctx)
|
||||||
ramp(this.echoTone.frequency, color < 0 ? 2500 : 600, ctx)
|
if (type === 'phaser') ramp(this.lfo.frequency, 1 / beatSeconds(phaserBeatsAt(fx.phaserBeats, a), bpm), ctx, 0.05)
|
||||||
|
|
||||||
|
// Reverb: the send grows with the knob, and moves from the short reverb
|
||||||
|
// into the long one — the more filter, the longer the tail.
|
||||||
|
const reverbing = type === 'reverb' && on
|
||||||
|
ramp(this.reverbShort.gain, reverbing ? a * (1 - a) : 0, ctx)
|
||||||
|
ramp(this.reverbLong.gain, reverbing ? a * a : 0, ctx)
|
||||||
|
if (type === 'reverb') {
|
||||||
|
const size = Math.round(Math.max(0.3, Math.min(6, fx.reverbSize)) * 10) / 10
|
||||||
|
if (size !== this.reverbSize) {
|
||||||
|
this.reverbSize = size
|
||||||
|
this.convShort.buffer = impulse(ctx, size)
|
||||||
|
this.convLong.buffer = impulse(ctx, Math.min(12, size * REVERB_GROWTH))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Space: a reverb send; left darker, right thinner.
|
// Delay: send, feedback AND length grow with the knob (the length in
|
||||||
const spacing = type === 'space' && on
|
// doubling steps, `delayBeatsAt`); the repeats darken (left) or thin
|
||||||
ramp(this.spaceSend.gain, spacing ? a : 0, ctx)
|
// (right) as they go round.
|
||||||
if (type === 'space') {
|
const delaying = type === 'delay' && on
|
||||||
const size = Math.round(Math.max(0.3, Math.min(8, fx.spaceSize)) * 10) / 10
|
ramp(this.delaySend.gain, delaying ? a * 0.8 : 0, ctx)
|
||||||
if (size !== this.spaceSize) {
|
ramp(this.feedback.gain, delaying ? 0.35 + 0.5 * a : 0.45, ctx, 0.05)
|
||||||
this.spaceSize = size
|
if (type === 'delay') {
|
||||||
this.convolver.buffer = impulse(ctx, size)
|
ramp(this.delay.delayTime, Math.min(MAX_DELAY_S, beatSeconds(delayBeatsAt(fx.delayBeats, a), bpm)), ctx, 0.05)
|
||||||
}
|
const tone = knob < 0 ? 'lowpass' : 'highpass'
|
||||||
const tone = color < 0 ? 'lowpass' : 'highpass'
|
if (this.delayTone.type !== tone) this.delayTone.type = tone
|
||||||
if (this.spaceTone.type !== tone) this.spaceTone.type = tone
|
ramp(this.delayTone.frequency, knob < 0 ? 2500 : 600, ctx)
|
||||||
ramp(this.spaceTone.frequency, color < 0 ? 1500 : 700, ctx)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Noise: white noise swept the way the filter is, the music untouched.
|
// Bit crusher: fewer bits as the knob opens (16 → 3), driven by the setting.
|
||||||
const noising = type === 'noise' && sweep != null
|
|
||||||
if (noising) {
|
|
||||||
if (this.noiseFilter.type !== sweep.type) this.noiseFilter.type = sweep.type
|
|
||||||
ramp(this.noiseFilter.frequency, sweep.freq, ctx)
|
|
||||||
ramp(this.noiseFilter.Q, fx.noiseResonance * 15, ctx)
|
|
||||||
}
|
|
||||||
ramp(this.noiseGain.gain, noising ? a * 0.25 : 0, ctx)
|
|
||||||
|
|
||||||
// Crush: fewer bits as the knob opens (16 → 3), driven by the setting.
|
|
||||||
const crushing = type === 'crush' && on
|
|
||||||
if (crushing) {
|
if (crushing) {
|
||||||
const bits = Math.round(16 - a * 13)
|
const bits = Math.round(16 - a * 13)
|
||||||
if (bits !== this.crushBits) {
|
if (bits !== this.crushBits) {
|
||||||
this.crushBits = bits
|
this.crushBits = bits
|
||||||
this.shaper.curve = crushCurve(bits)
|
this.shaper.curve = crushCurve(bits)
|
||||||
}
|
}
|
||||||
ramp(this.crushDrive.gain, fx.crushDrive, ctx)
|
ramp(this.crushDrive.gain, fx.crusherDrive, ctx)
|
||||||
}
|
}
|
||||||
ramp(this.crushWet.gain, crushing ? take / Math.max(1, fx.crushDrive) ** 0.5 : 0, ctx)
|
ramp(this.crushWet.gain, crushing ? take / Math.max(1, fx.crusherDrive) ** 0.5 : 0, ctx)
|
||||||
|
|
||||||
ramp(this.dry.gain, filtering || crushing ? 1 - take : 1, ctx)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -251,7 +287,7 @@ class Strip {
|
|||||||
private readonly ctx: AudioContext
|
private readonly ctx: AudioContext
|
||||||
private readonly trim: GainNode
|
private readonly trim: GainNode
|
||||||
private readonly bands: [GainNode, GainNode, GainNode]
|
private readonly bands: [GainNode, GainNode, GainNode]
|
||||||
private readonly fx: ColorFx
|
private readonly fx: FilterFx
|
||||||
private readonly fader: GainNode
|
private readonly fader: GainNode
|
||||||
private readonly xfade: GainNode
|
private readonly xfade: GainNode
|
||||||
/** In circuit (performance mode) vs straight through (prep). */
|
/** In circuit (performance mode) vs straight through (prep). */
|
||||||
@@ -284,7 +320,7 @@ class Strip {
|
|||||||
mlB.connect(this.bands[1]).connect(eqOut)
|
mlB.connect(this.bands[1]).connect(eqOut)
|
||||||
mhB.connect(this.bands[2]).connect(eqOut)
|
mhB.connect(this.bands[2]).connect(eqOut)
|
||||||
|
|
||||||
this.fx = new ColorFx(ctx)
|
this.fx = new FilterFx(ctx)
|
||||||
eqOut.connect(this.fx.input)
|
eqOut.connect(this.fx.input)
|
||||||
this.fader = ctx.createGain()
|
this.fader = ctx.createGain()
|
||||||
this.fx.output.connect(this.fader)
|
this.fx.output.connect(this.fader)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { describe, expect, it } from 'vitest'
|
import { describe, expect, it } from 'vitest'
|
||||||
import { echoSeconds, eqGain, faderGain, filterSweep, gainToDb, xfadeGains } from './mixerMath'
|
import { beatSeconds, delayBeatsAt, eqGain, phaserBeatsAt, faderGain, filterSweep, gainToDb, xfadeGains } from './mixerMath'
|
||||||
|
|
||||||
describe('eqGain', () => {
|
describe('eqGain', () => {
|
||||||
it('is flat at the centre, +6 dB at full right', () => {
|
it('is flat at the centre, +6 dB at full right', () => {
|
||||||
@@ -70,18 +70,47 @@ describe('filterSweep', () => {
|
|||||||
expect(filterSweep(0)).toBeNull()
|
expect(filterSweep(0)).toBeNull()
|
||||||
expect(filterSweep(0.01)).toBeNull()
|
expect(filterSweep(0.01)).toBeNull()
|
||||||
})
|
})
|
||||||
it('low-passes left and high-passes right, on a log scale', () => {
|
it('full range (the default): low-pass to 20 Hz, high-pass to 20 kHz, on a log scale', () => {
|
||||||
expect(filterSweep(-1)).toEqual({ type: 'lowpass', freq: expect.closeTo(150, 6) })
|
expect(filterSweep(-1)).toEqual({ type: 'lowpass', freq: expect.closeTo(20, 6) })
|
||||||
expect(filterSweep(1)).toEqual({ type: 'highpass', freq: expect.closeTo(8000, 6) })
|
expect(filterSweep(1)).toEqual({ type: 'highpass', freq: expect.closeTo(20000, 6) })
|
||||||
const half = filterSweep(-0.5)!
|
expect(filterSweep(-0.5)!.freq).toBeCloseTo(Math.sqrt(20000 * 20), 3)
|
||||||
expect(half.freq).toBeCloseTo(Math.sqrt(20000 * 150), 3)
|
expect(filterSweep(0.03)!.freq).toBeCloseTo(20 * 1000 ** 0.03, 6) // starts at the bottom
|
||||||
|
})
|
||||||
|
it('gentle range: stops at 500 Hz / 2 kHz', () => {
|
||||||
|
expect(filterSweep(-1, 'gentle')).toEqual({ type: 'lowpass', freq: expect.closeTo(500, 6) })
|
||||||
|
expect(filterSweep(1, 'gentle')).toEqual({ type: 'highpass', freq: expect.closeTo(2000, 6) })
|
||||||
|
})
|
||||||
|
it('musical range: stops at 150 Hz / 8 kHz', () => {
|
||||||
|
expect(filterSweep(-1, 'musical')).toEqual({ type: 'lowpass', freq: expect.closeTo(150, 6) })
|
||||||
|
expect(filterSweep(1, 'musical')).toEqual({ type: 'highpass', freq: expect.closeTo(8000, 6) })
|
||||||
|
expect(filterSweep(-0.5, 'musical')!.freq).toBeCloseTo(Math.sqrt(20000 * 150), 3)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('echo', () => {
|
describe('phaserBeatsAt', () => {
|
||||||
it('is its length in beats at the deck’s tempo', () => {
|
it('starts at the slowest sweep and halves at each quarter of the knob', () => {
|
||||||
expect(echoSeconds(1, 120)).toBeCloseTo(0.5, 9)
|
expect(phaserBeatsAt(4, 0.05)).toBe(4)
|
||||||
expect(echoSeconds(0.5, 128)).toBeCloseTo(60 / 128 / 2, 9)
|
expect(phaserBeatsAt(4, 0.3)).toBe(2)
|
||||||
expect(echoSeconds(1, 0)).toBeCloseTo(0.5, 9) // unknown tempo: 120
|
expect(phaserBeatsAt(4, 0.6)).toBe(1)
|
||||||
|
expect(phaserBeatsAt(4, 0.8)).toBe(0.5)
|
||||||
|
expect(phaserBeatsAt(4, 1)).toBe(0.5)
|
||||||
|
expect(phaserBeatsAt(8, 1)).toBe(1)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
describe('delayBeatsAt', () => {
|
||||||
|
it('starts at the shortest echo and doubles at each quarter of the knob', () => {
|
||||||
|
expect(delayBeatsAt(0.25, 0.1)).toBe(0.25)
|
||||||
|
expect(delayBeatsAt(0.25, 0.4)).toBe(0.5)
|
||||||
|
expect(delayBeatsAt(0.25, 0.7)).toBe(1)
|
||||||
|
expect(delayBeatsAt(0.25, 1)).toBe(2)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
describe('beatSeconds', () => {
|
||||||
|
it('is a length in beats at the deck’s tempo', () => {
|
||||||
|
expect(beatSeconds(1, 120)).toBeCloseTo(0.5, 9)
|
||||||
|
expect(beatSeconds(0.5, 128)).toBeCloseTo(60 / 128 / 2, 9)
|
||||||
|
expect(beatSeconds(4, 0)).toBeCloseTo(2, 9) // unknown tempo: 120
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@@ -59,23 +59,57 @@ export function xfadeGains(x: number, sharpness: number): [number, number] {
|
|||||||
export const FX_CENTRE = 0.02
|
export const FX_CENTRE = 0.02
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The filter at colour `c` (-1..1): left a low-pass falling from 20 kHz to
|
* How far the FILTER knob sweeps (settings, decided 2026-11-03): `full` runs
|
||||||
* 150 Hz, right a high-pass rising from 20 Hz to 8 kHz, both on a log scale so
|
* the low-pass down to 20 Hz and the high-pass up to 20 kHz, so either end is
|
||||||
* the sweep sounds even. Null at the centre (bypassed).
|
* near silence; `musical` stops at 150 Hz / 8 kHz, where the track is thinned
|
||||||
|
* but still there; `gentle` at 500 Hz / 2 kHz, where it stays clearly heard.
|
||||||
*/
|
*/
|
||||||
export function filterSweep(c: number): { type: 'lowpass' | 'highpass'; freq: number } | null {
|
export type FilterRange = 'full' | 'musical' | 'gentle'
|
||||||
|
export const FILTER_RANGES: Record<FilterRange, { low: number; high: number }> = {
|
||||||
|
full: { low: 20, high: 20000 },
|
||||||
|
musical: { low: 150, high: 8000 },
|
||||||
|
gentle: { low: 500, high: 2000 },
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The filter at knob `c` (-1..1): left a low-pass falling from 20 kHz, right a
|
||||||
|
* high-pass rising from 20 Hz, to the range's ends, on a log scale so the
|
||||||
|
* sweep sounds even. Null at the centre (bypassed).
|
||||||
|
*/
|
||||||
|
export function filterSweep(
|
||||||
|
c: number,
|
||||||
|
range: FilterRange = 'full',
|
||||||
|
): { type: 'lowpass' | 'highpass'; freq: number } | null {
|
||||||
c = clamp(c, -1, 1)
|
c = clamp(c, -1, 1)
|
||||||
if (Math.abs(c) < FX_CENTRE) return null
|
if (Math.abs(c) < FX_CENTRE) return null
|
||||||
const a = Math.abs(c)
|
const a = Math.abs(c)
|
||||||
|
const end = FILTER_RANGES[range]
|
||||||
return c < 0
|
return c < 0
|
||||||
? { type: 'lowpass', freq: 20000 * (150 / 20000) ** a }
|
? { type: 'lowpass', freq: 20000 * (end.low / 20000) ** a }
|
||||||
: { type: 'highpass', freq: 20 * (8000 / 20) ** a }
|
: { type: 'highpass', freq: 20 * (end.high / 20) ** a }
|
||||||
}
|
}
|
||||||
|
|
||||||
/** The echo lengths offered (beats). */
|
/**
|
||||||
export const ECHO_BEATS = [1 / 8, 1 / 4, 1 / 2, 3 / 4, 1]
|
* The Filter FX grow as the knob opens (decided 2026-11-03), in STEPS of two
|
||||||
|
* at each further quarter of its travel, so every length stays a musical one
|
||||||
|
* of the tempo: 0 near the centre, 3 in the last quarter.
|
||||||
|
*/
|
||||||
|
export const knobStep = (a: number): number => Math.min(3, Math.floor(clamp(a, 0, 1) * 4))
|
||||||
|
|
||||||
/** Seconds of echo for `beats` at `bpm` (120 when the tempo is unknown). */
|
/** The phaser's sweep (beats): `slowest` (the setting), then ½, ¼, ⅛ of it —
|
||||||
export function echoSeconds(beats: number, bpm: number): number {
|
* faster as the filter opens. */
|
||||||
|
export const phaserBeatsAt = (slowest: number, a: number): number => slowest / 2 ** knobStep(a)
|
||||||
|
|
||||||
|
/** The delay's length (beats): `shortest` (the setting), then ×2, ×4, ×8 —
|
||||||
|
* longer as the filter opens. */
|
||||||
|
export const delayBeatsAt = (shortest: number, a: number): number => shortest * 2 ** knobStep(a)
|
||||||
|
|
||||||
|
/** The long reverb is this many times the set (short) one; the knob blends
|
||||||
|
* from the short into the long as it opens. */
|
||||||
|
export const REVERB_GROWTH = 3
|
||||||
|
|
||||||
|
/** Seconds for `beats` at `bpm` (120 when the tempo is unknown) — the delay's
|
||||||
|
* length, the phaser's sweep. */
|
||||||
|
export function beatSeconds(beats: number, bpm: number): number {
|
||||||
return (beats * 60) / (bpm > 0 ? bpm : 120)
|
return (beats * 60) / (bpm > 0 ? bpm : 120)
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
import { describe, expect, it } from 'vitest'
|
||||||
|
import { DEFAULT_FX, FX_TYPES, rangeFor } from './mixerState'
|
||||||
|
|
||||||
|
describe('rangeFor', () => {
|
||||||
|
it('the Filter alone follows its setting, an effect the other', () => {
|
||||||
|
const fx = { ...DEFAULT_FX, filterRange: 'full' as const, effectRange: 'gentle' as const }
|
||||||
|
expect(rangeFor('filter', fx)).toBe('full')
|
||||||
|
for (const t of FX_TYPES.filter((x) => x !== 'filter')) expect(rangeFor(t, fx)).toBe('gentle')
|
||||||
|
})
|
||||||
|
it('defaults: Full alone, Musical with an effect', () => {
|
||||||
|
expect(rangeFor('filter', DEFAULT_FX)).toBe('full')
|
||||||
|
expect(rangeFor('reverb', DEFAULT_FX)).toBe('musical')
|
||||||
|
})
|
||||||
|
})
|
||||||
@@ -5,42 +5,75 @@
|
|||||||
// mixer starts flat.
|
// mixer starts flat.
|
||||||
|
|
||||||
import { useSyncExternalStore } from 'react'
|
import { useSyncExternalStore } from 'react'
|
||||||
|
import type { FilterRange } from './mixerMath'
|
||||||
|
|
||||||
export type Channel = 'A' | 'B'
|
export type Channel = 'A' | 'B'
|
||||||
export const CHANNELS: Channel[] = ['A', 'B']
|
export const CHANNELS: Channel[] = ['A', 'B']
|
||||||
|
|
||||||
export const FX_TYPES = ['filter', 'echo', 'space', 'noise', 'crush'] as const
|
/**
|
||||||
|
* FILTER FX (decided 2026-11-03, after Traktor's mixer): each channel's FILTER
|
||||||
|
* knob always filters — low-pass left, high-pass right — and the effect chosen
|
||||||
|
* here rides with it, its amount growing with the knob. `filter` is the filter
|
||||||
|
* alone.
|
||||||
|
*/
|
||||||
|
export const FX_TYPES = ['filter', 'reverb', 'delay', 'crusher', 'phaser'] as const
|
||||||
export type FxType = (typeof FX_TYPES)[number]
|
export type FxType = (typeof FX_TYPES)[number]
|
||||||
export const FX_LABELS: Record<FxType, string> = {
|
export const FX_LABELS: Record<FxType, string> = {
|
||||||
filter: 'Filter',
|
filter: 'Filter',
|
||||||
echo: 'Echo',
|
reverb: 'Reverb',
|
||||||
space: 'Space',
|
delay: 'Delay',
|
||||||
noise: 'Noise',
|
crusher: 'Bit crusher',
|
||||||
crush: 'Crush',
|
phaser: 'Phaser',
|
||||||
}
|
}
|
||||||
|
/** For the channel's narrow picker. */
|
||||||
|
export const FX_SHORT: Record<FxType, string> = {
|
||||||
|
filter: 'Filter',
|
||||||
|
reverb: 'Reverb',
|
||||||
|
delay: 'Delay',
|
||||||
|
crusher: 'Crush',
|
||||||
|
phaser: 'Phaser',
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Each effect's one setting — app settings, not knobs (decided 2026-11-03: the
|
* The filter and each effect's one setting — app settings, not knobs (the
|
||||||
* per-channel parameter knob was removed), the same for both channels.
|
* per-channel parameter knob was removed, decided 2026-11-03), the same for
|
||||||
|
* both channels.
|
||||||
*/
|
*/
|
||||||
export interface FxSettings {
|
export interface FxSettings {
|
||||||
|
/** The filter's range for the Filter alone … */
|
||||||
|
filterRange: FilterRange
|
||||||
|
/** … and with an effect riding along. */
|
||||||
|
effectRange: FilterRange
|
||||||
/** Filter resonance, 0..1. */
|
/** Filter resonance, 0..1. */
|
||||||
filterResonance: number
|
filterResonance: number
|
||||||
/** Echo length in beats of the deck's tempo. */
|
/** The SHORT reverb's decay (s) — near the centre; the knob blends into
|
||||||
echoBeats: number
|
* one REVERB_GROWTH times as long as it opens. */
|
||||||
/** Space: the reverb's decay (s). */
|
reverbSize: number
|
||||||
spaceSize: number
|
/** The delay's SHORTEST length, in beats of the deck's tempo — near the
|
||||||
/** Noise sweep resonance, 0..1. */
|
* centre; it doubles as the knob opens (`delayBeatsAt`). */
|
||||||
noiseResonance: number
|
delayBeats: number
|
||||||
/** Crush drive, 1..4. */
|
/** Bit crusher drive, 1..4. */
|
||||||
crushDrive: number
|
crusherDrive: number
|
||||||
|
/** The phaser's SLOWEST sweep, in beats of the deck's tempo — near the
|
||||||
|
* centre; it halves as the knob opens (`phaserBeatsAt`). */
|
||||||
|
phaserBeats: number
|
||||||
}
|
}
|
||||||
|
|
||||||
export const DEFAULT_FX: FxSettings = {
|
export const DEFAULT_FX: FxSettings = {
|
||||||
|
filterRange: 'full',
|
||||||
|
effectRange: 'musical',
|
||||||
filterResonance: 0.3,
|
filterResonance: 0.3,
|
||||||
echoBeats: 0.5,
|
reverbSize: 2,
|
||||||
spaceSize: 2.5,
|
delayBeats: 0.25,
|
||||||
noiseResonance: 0.3,
|
crusherDrive: 2,
|
||||||
crushDrive: 2,
|
phaserBeats: 4,
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The filter's range under `type`: one setting for the Filter alone (Full by
|
||||||
|
* default), another with an effect riding along (Musical by default — swept
|
||||||
|
* to near silence, the filter would starve the effect it feeds). */
|
||||||
|
export function rangeFor(type: FxType, fx: FxSettings): FilterRange {
|
||||||
|
return type === 'filter' ? fx.filterRange : fx.effectRange
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ChannelState {
|
export interface ChannelState {
|
||||||
@@ -51,7 +84,8 @@ export interface ChannelState {
|
|||||||
mid: number
|
mid: number
|
||||||
high: number
|
high: number
|
||||||
fx: FxType
|
fx: FxType
|
||||||
/** The colour knob, -1..1 (centre = effect off). */
|
/** The FILTER knob, -1..1 (centre = filter and effect off). Named `color`
|
||||||
|
* from before the rename to Filter FX. */
|
||||||
color: number
|
color: number
|
||||||
/** The channel fader, 0..1. */
|
/** The channel fader, 0..1. */
|
||||||
fader: number
|
fader: number
|
||||||
|
|||||||
Reference in new issue
Block a user