More mixer FX improvements

This commit is contained in:
patben8 committed 2026-11-03 10:43:44 +01:00
1 parent 717685f621
commit 4799eaef17
9 files changed
+69 -57

No files matched your search

+7 -4
View File
@@ -1174,7 +1174,7 @@ Two independent apps that talk over HTTP:
/ 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
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 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),
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`, `fxFlangerBeats` (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
devices. TanStack Table + **virtualized** grid; per-row play button,
configurable columns, header sorting, inline double-click editing, and
@@ -2812,11 +2812,14 @@ The prep strip plays every track through the **Web Audio API** (a plain
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
signal), Flanger (a 0.7–7 ms delay swept by a beat-synced LFO, with
feedback that deepens with the knob; replaced the Phaser 2026-11-03), 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
2026-11-03): the delay's length and the flanger'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),
SHORTEST delay and SLOWEST sweep, up to ×8, every step a musical length;
measured: the flanger sweeps every 2 / 0.5 / 0.25 s at 15 / 60 / 95% of
the knob, 4-beat setting at 120 BPM),
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
+1 -1
View File
@@ -42,7 +42,7 @@ export const APP_SETTING_DEFAULTS = {
fxReverbSize: 2,
fxDelayBeats: 0.25,
fxCrusherDrive: 2,
fxPhaserBeats: 4,
fxFlangerBeats: 4,
}
type AppSettingKey = keyof typeof APP_SETTING_DEFAULTS
@@ -45,7 +45,7 @@ export function PerformanceSettings({ onClose }: { onClose: () => void }) {
const fxReverbSize = useAppSetting('fxReverbSize')
const fxDelayBeats = useAppSetting('fxDelayBeats')
const fxCrusherDrive = useAppSetting('fxCrusherDrive')
const fxPhaserBeats = useAppSetting('fxPhaserBeats')
const fxFlangerBeats = useAppSetting('fxFlangerBeats')
const [error, setError] = useState<string | null>(null)
// The curve moves with the slider at once — mixer included, so it can be
@@ -151,7 +151,7 @@ export function PerformanceSettings({ onClose }: { onClose: () => void }) {
<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)
one three times as long, the delay gets longer and the flanger faster (each up to ×8)
from the settings below. These apply to both channels.
</span>
<Choice
@@ -206,8 +206,8 @@ export function PerformanceSettings({ onClose }: { onClose: () => void }) {
onChange={(v) => void set({ fxCrusherDrive: Number(v) })}
/>
<Choice
title="Phaser sweep (slowest)"
value={String(fxPhaserBeats)}
title="Flanger sweep (slowest)"
value={String(fxFlangerBeats)}
options={[
['1', 'Every beat'],
['2', 'Every 2 beats'],
@@ -215,7 +215,7 @@ export function PerformanceSettings({ onClose }: { onClose: () => void }) {
['8', 'Every 8 beats'],
['16', 'Every 16 beats'],
]}
onChange={(v) => void set({ fxPhaserBeats: Number(v) })}
onChange={(v) => void set({ fxFlangerBeats: Number(v) })}
/>
</section>
{error && <div className="text-xs text-pink">{error}</div>}
+3 -3
View File
@@ -130,14 +130,14 @@ export function PrepStrip({
const reverbSize = useAppSetting('fxReverbSize')
const delayBeats = useAppSetting('fxDelayBeats')
const crusherDrive = useAppSetting('fxCrusherDrive')
const phaserBeats = useAppSetting('fxPhaserBeats')
const flangerBeats = useAppSetting('fxFlangerBeats')
useEffect(() => {
setMixer({
eqKill,
sharpness,
fx: { filterRange, effectRange, filterResonance, reverbSize, delayBeats, crusherDrive, phaserBeats },
fx: { filterRange, effectRange, filterResonance, reverbSize, delayBeats, crusherDrive, flangerBeats },
})
}, [eqKill, sharpness, filterRange, effectRange, filterResonance, reverbSize, delayBeats, crusherDrive, phaserBeats])
}, [eqKill, sharpness, filterRange, effectRange, filterResonance, reverbSize, delayBeats, crusherDrive, flangerBeats])
const lead: DeckId = performance ? focused : 'A'
const playingA = useCallback((p: boolean) => onPlayingChange('A', p), [onPlayingChange])
const playingB = useCallback((p: boolean) => onPlayingChange('B', p), [onPlayingChange])
+3 -3
View File
@@ -1,6 +1,6 @@
import { useEffect, useRef, useState, type RefObject } from 'react'
import { mixer } from '../../lib/audio/mixer'
import { delayBeatsAt, faderGain, filterSweep, eqGain, gainToDb, phaserBeatsAt, REVERB_GROWTH, TRIM_RANGE_DB, EQ_CUT_DB } from '../../lib/audio/mixerMath'
import { delayBeatsAt, faderGain, filterSweep, eqGain, gainToDb, REVERB_GROWTH, sweepBeatsAt, TRIM_RANGE_DB, EQ_CUT_DB } from '../../lib/audio/mixerMath'
import {
FX_LABELS,
FX_SHORT,
@@ -45,8 +45,8 @@ function describeFx(fx: FxType, c: number, set: FxSettings): string {
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}`
case 'flanger':
return `Flanger ${a} (a sweep every ${beatsLabel(sweepBeatsAt(set.flangerBeats, Math.abs(c)))}) + ${filter}`
}
}
+32 -23
View File
@@ -31,7 +31,7 @@ import {
delayBeatsAt,
faderGain,
filterSweep,
phaserBeatsAt,
sweepBeatsAt,
REVERB_GROWTH,
FX_CENTRE,
TRIM_RANGE_DB,
@@ -47,6 +47,10 @@ const LIMIT_RATIO = 20
* gain at 0 dBFS, to the power 0.6), in dB. */
const MAKEUP_DB = -0.6 * (LIMIT_DB + (0 - LIMIT_DB) / LIMIT_RATIO)
/** The flanger's delay sweeps between these (s). */
const FLANGE_MIN = 0.0007
const FLANGE_MAX = 0.007
/** The longest delay (s): 8 × a 1-beat setting at 120 BPM. */
const MAX_DELAY_S = 4
@@ -112,10 +116,10 @@ function crushCurve(bits: number): Float32Array<ArrayBuffer> {
* the musical range under an effect (`rangeFor`) — and the channel's
* 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
* the faster the flanger: 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`).
* filtered signal with a crushed copy; Flanger mixes it with a few-ms delay
* swept by a beat-synced LFO, with feedback.
* `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`).
@@ -149,9 +153,11 @@ class FilterFx {
private readonly shaper: WaveShaperNode
private readonly crushWet: GainNode
private crushBits = -1
// Phaser: all-pass stages swept by one LFO.
// Flanger: a few-ms delay swept by one LFO, with feedback.
private readonly lfo: OscillatorNode
private readonly phaserWet: GainNode
private readonly flange: DelayNode
private readonly flangeFeedback: GainNode
private readonly flangerWet: GainNode
constructor(ctx: AudioContext) {
this.ctx = ctx
@@ -192,21 +198,22 @@ class FilterFx {
this.crushWet.gain.value = 0
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.
// A delay swept between FLANGE_MIN and FLANGE_MAX by the LFO, fed back
// into itself; mixed with the filtered music its comb notches sweep.
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)
this.flange = ctx.createDelay(0.05)
this.flange.delayTime.value = (FLANGE_MIN + FLANGE_MAX) / 2
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)
depth.gain.value = (FLANGE_MAX - FLANGE_MIN) / 2
this.lfo.connect(depth).connect(this.flange.delayTime)
this.flangeFeedback = ctx.createGain()
this.flangeFeedback.gain.value = 0
this.flangerWet = ctx.createGain()
this.flangerWet.gain.value = 0
this.filter.connect(this.flange)
this.flange.connect(this.flangeFeedback).connect(this.flange)
this.flange.connect(this.flangerWet).connect(this.output)
this.lfo.start()
}
@@ -232,14 +239,16 @@ class FilterFx {
ramp(this.dry.gain, 1 - take, ctx)
// How much of the filtered music stays: all of it, but half under the
// phaser (whose notches come from mixing the two) and none under the
// flanger (whose notches come from mixing the two) and none under the
// crusher (which replaces it).
const phasing = type === 'phaser' && on
const mix = phasing ? Math.min(1, a / 0.25) : 0
const flanging = type === 'flanger' && on
const mix = flanging ? Math.min(1, a / 0.25) : 0
const crushing = type === 'crusher' && on
ramp(this.filtered.gain, crushing ? 0 : take * (1 - 0.5 * mix), ctx)
ramp(this.phaserWet.gain, take * 0.5 * mix, ctx)
if (type === 'phaser') ramp(this.lfo.frequency, 1 / beatSeconds(phaserBeatsAt(fx.phaserBeats, a), bpm), ctx, 0.05)
ramp(this.flangerWet.gain, take * 0.5 * mix, ctx)
// The sweep speeds up and the feedback (the "jet") deepens as it opens.
ramp(this.flangeFeedback.gain, flanging ? 0.3 + 0.5 * a : 0, ctx, 0.05)
if (type === 'flanger') ramp(this.lfo.frequency, 1 / beatSeconds(sweepBeatsAt(fx.flangerBeats, 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.
+8 -8
View File
@@ -1,5 +1,5 @@
import { describe, expect, it } from 'vitest'
import { beatSeconds, delayBeatsAt, eqGain, phaserBeatsAt, faderGain, filterSweep, gainToDb, xfadeGains } from './mixerMath'
import { beatSeconds, delayBeatsAt, eqGain, sweepBeatsAt, faderGain, filterSweep, gainToDb, xfadeGains } from './mixerMath'
describe('eqGain', () => {
it('is flat at the centre, +6 dB at full right', () => {
@@ -87,14 +87,14 @@ describe('filterSweep', () => {
})
})
describe('phaserBeatsAt', () => {
describe('sweepBeatsAt', () => {
it('starts at the slowest sweep and halves at each quarter of the knob', () => {
expect(phaserBeatsAt(4, 0.05)).toBe(4)
expect(phaserBeatsAt(4, 0.3)).toBe(2)
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)
expect(sweepBeatsAt(4, 0.05)).toBe(4)
expect(sweepBeatsAt(4, 0.3)).toBe(2)
expect(sweepBeatsAt(4, 0.6)).toBe(1)
expect(sweepBeatsAt(4, 0.8)).toBe(0.5)
expect(sweepBeatsAt(4, 1)).toBe(0.5)
expect(sweepBeatsAt(8, 1)).toBe(1)
})
})
+3 -3
View File
@@ -96,9 +96,9 @@ export function filterSweep(
*/
export const knobStep = (a: number): number => Math.min(3, Math.floor(clamp(a, 0, 1) * 4))
/** The phaser's sweep (beats): `slowest` (the setting), then ½, ¼, ⅛ of it —
/** The flanger's sweep (beats): `slowest` (the setting), then ½, ¼, ⅛ of it —
* faster as the filter opens. */
export const phaserBeatsAt = (slowest: number, a: number): number => slowest / 2 ** knobStep(a)
export const sweepBeatsAt = (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. */
@@ -109,7 +109,7 @@ export const delayBeatsAt = (shortest: number, a: number): number => shortest *
export const REVERB_GROWTH = 3
/** Seconds for `beats` at `bpm` (120 when the tempo is unknown) — the delay's
* length, the phaser's sweep. */
* length, the flanger's sweep. */
export function beatSeconds(beats: number, bpm: number): number {
return (beats * 60) / (bpm > 0 ? bpm : 120)
}
+7 -7
View File
@@ -16,14 +16,14 @@ export const CHANNELS: Channel[] = ['A', 'B']
* 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 const FX_TYPES = ['filter', 'reverb', 'delay', 'crusher', 'flanger'] as const
export type FxType = (typeof FX_TYPES)[number]
export const FX_LABELS: Record<FxType, string> = {
filter: 'Filter',
reverb: 'Reverb',
delay: 'Delay',
crusher: 'Bit crusher',
phaser: 'Phaser',
flanger: 'Flanger',
}
/** For the channel's narrow picker. */
export const FX_SHORT: Record<FxType, string> = {
@@ -31,7 +31,7 @@ export const FX_SHORT: Record<FxType, string> = {
reverb: 'Reverb',
delay: 'Delay',
crusher: 'Crush',
phaser: 'Phaser',
flanger: 'Flange',
}
/**
@@ -54,9 +54,9 @@ export interface FxSettings {
delayBeats: number
/** Bit crusher drive, 1..4. */
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
/** The flanger's SLOWEST sweep, in beats of the deck's tempo — near the
* centre; it halves as the knob opens (`sweepBeatsAt`). */
flangerBeats: number
}
export const DEFAULT_FX: FxSettings = {
@@ -66,7 +66,7 @@ export const DEFAULT_FX: FxSettings = {
reverbSize: 2,
delayBeats: 0.25,
crusherDrive: 2,
phaserBeats: 4,
flangerBeats: 4,
}
/** The filter's range under `type`: one setting for the Filter alone (Full by