mirror of
https://github.com/MrPatben8/konduktor.git
synced 2026-11-27 10:22:51 +01:00
More mixer FX improvements
This commit is contained in:
1 parent
717685f621
commit
4799eaef17
9 files changed
+70
-58
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 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
|
`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
|
||||||
@@ -2812,11 +2812,14 @@ The prep strip plays every track through the **Web Audio API** (a plain
|
|||||||
effect rides with it,
|
effect rides with it,
|
||||||
fed the FILTERED signal, growing with the knob: Reverb, Delay (sends whose
|
fed the FILTERED signal, growing with the knob: Reverb, Delay (sends whose
|
||||||
tails ring out — echo- and wash-outs), Bit crusher (replaces the filtered
|
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
|
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
|
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
|
and the reverb blends from a short convolver (the setting) into one
|
||||||
`REVERB_GROWTH` (3) times as long — two convolvers, since swapping one's
|
`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
|
impulse cuts its tail (measured: 6 s after a burst -75 dB at 20% of the
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ export const APP_SETTING_DEFAULTS = {
|
|||||||
fxReverbSize: 2,
|
fxReverbSize: 2,
|
||||||
fxDelayBeats: 0.25,
|
fxDelayBeats: 0.25,
|
||||||
fxCrusherDrive: 2,
|
fxCrusherDrive: 2,
|
||||||
fxPhaserBeats: 4,
|
fxFlangerBeats: 4,
|
||||||
}
|
}
|
||||||
|
|
||||||
type AppSettingKey = keyof typeof APP_SETTING_DEFAULTS
|
type AppSettingKey = keyof typeof APP_SETTING_DEFAULTS
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ export function PerformanceSettings({ onClose }: { onClose: () => void }) {
|
|||||||
const fxReverbSize = useAppSetting('fxReverbSize')
|
const fxReverbSize = useAppSetting('fxReverbSize')
|
||||||
const fxDelayBeats = useAppSetting('fxDelayBeats')
|
const fxDelayBeats = useAppSetting('fxDelayBeats')
|
||||||
const fxCrusherDrive = useAppSetting('fxCrusherDrive')
|
const fxCrusherDrive = useAppSetting('fxCrusherDrive')
|
||||||
const fxPhaserBeats = useAppSetting('fxPhaserBeats')
|
const fxFlangerBeats = useAppSetting('fxFlangerBeats')
|
||||||
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
|
||||||
@@ -151,7 +151,7 @@ export function PerformanceSettings({ onClose }: { onClose: () => void }) {
|
|||||||
<span className="block text-xs text-faint">
|
<span className="block text-xs text-faint">
|
||||||
Each channel's FILTER knob filters — low-pass to the left, high-pass to the right — and
|
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
|
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.
|
from the settings below. These apply to both channels.
|
||||||
</span>
|
</span>
|
||||||
<Choice
|
<Choice
|
||||||
@@ -206,8 +206,8 @@ export function PerformanceSettings({ onClose }: { onClose: () => void }) {
|
|||||||
onChange={(v) => void set({ fxCrusherDrive: Number(v) })}
|
onChange={(v) => void set({ fxCrusherDrive: Number(v) })}
|
||||||
/>
|
/>
|
||||||
<Choice
|
<Choice
|
||||||
title="Phaser sweep (slowest)"
|
title="Flanger sweep (slowest)"
|
||||||
value={String(fxPhaserBeats)}
|
value={String(fxFlangerBeats)}
|
||||||
options={[
|
options={[
|
||||||
['1', 'Every beat'],
|
['1', 'Every beat'],
|
||||||
['2', 'Every 2 beats'],
|
['2', 'Every 2 beats'],
|
||||||
@@ -215,7 +215,7 @@ export function PerformanceSettings({ onClose }: { onClose: () => void }) {
|
|||||||
['8', 'Every 8 beats'],
|
['8', 'Every 8 beats'],
|
||||||
['16', 'Every 16 beats'],
|
['16', 'Every 16 beats'],
|
||||||
]}
|
]}
|
||||||
onChange={(v) => void set({ fxPhaserBeats: Number(v) })}
|
onChange={(v) => void set({ fxFlangerBeats: Number(v) })}
|
||||||
/>
|
/>
|
||||||
</section>
|
</section>
|
||||||
{error && <div className="text-xs text-pink">{error}</div>}
|
{error && <div className="text-xs text-pink">{error}</div>}
|
||||||
|
|||||||
@@ -130,14 +130,14 @@ export function PrepStrip({
|
|||||||
const reverbSize = useAppSetting('fxReverbSize')
|
const reverbSize = useAppSetting('fxReverbSize')
|
||||||
const delayBeats = useAppSetting('fxDelayBeats')
|
const delayBeats = useAppSetting('fxDelayBeats')
|
||||||
const crusherDrive = useAppSetting('fxCrusherDrive')
|
const crusherDrive = useAppSetting('fxCrusherDrive')
|
||||||
const phaserBeats = useAppSetting('fxPhaserBeats')
|
const flangerBeats = useAppSetting('fxFlangerBeats')
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setMixer({
|
setMixer({
|
||||||
eqKill,
|
eqKill,
|
||||||
sharpness,
|
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 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,6 +1,6 @@
|
|||||||
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 { 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 {
|
import {
|
||||||
FX_LABELS,
|
FX_LABELS,
|
||||||
FX_SHORT,
|
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}`
|
return `Delay ${a} (${beatsLabel(delayBeatsAt(set.delayBeats, Math.abs(c)))}) + ${filter}`
|
||||||
case 'crusher':
|
case 'crusher':
|
||||||
return `Bit crusher ${a} (drive ×${set.crusherDrive}) + ${filter}`
|
return `Bit crusher ${a} (drive ×${set.crusherDrive}) + ${filter}`
|
||||||
case 'phaser':
|
case 'flanger':
|
||||||
return `Phaser ${a} (a sweep every ${beatsLabel(phaserBeatsAt(set.phaserBeats, Math.abs(c)))}) + ${filter}`
|
return `Flanger ${a} (a sweep every ${beatsLabel(sweepBeatsAt(set.flangerBeats, Math.abs(c)))}) + ${filter}`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ import {
|
|||||||
delayBeatsAt,
|
delayBeatsAt,
|
||||||
faderGain,
|
faderGain,
|
||||||
filterSweep,
|
filterSweep,
|
||||||
phaserBeatsAt,
|
sweepBeatsAt,
|
||||||
REVERB_GROWTH,
|
REVERB_GROWTH,
|
||||||
FX_CENTRE,
|
FX_CENTRE,
|
||||||
TRIM_RANGE_DB,
|
TRIM_RANGE_DB,
|
||||||
@@ -47,6 +47,10 @@ 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 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. */
|
/** The longest delay (s): 8 × a 1-beat setting at 120 BPM. */
|
||||||
const MAX_DELAY_S = 4
|
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
|
* the musical range under an effect (`rangeFor`) — and the channel's
|
||||||
* chosen effect rides with it, fed the FILTERED signal, its amount growing
|
* 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
|
* 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
|
* 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
|
* filtered signal with a crushed copy; Flanger mixes it with a few-ms delay
|
||||||
* sweeping all-pass chain, faster as the knob opens (`phaserBeatsAt`).
|
* swept by a beat-synced LFO, with feedback.
|
||||||
* `filter` is the filter alone. Everything is built
|
* `filter` is the filter alone. Everything is built
|
||||||
* once and switched by gains, so a change never clicks. Each effect's one
|
* once and switched by gains, so a change never clicks. Each effect's one
|
||||||
* parameter is an app setting (`FxSettings`).
|
* parameter is an app setting (`FxSettings`).
|
||||||
@@ -149,9 +153,11 @@ class FilterFx {
|
|||||||
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.
|
// Flanger: a few-ms delay swept by one LFO, with feedback.
|
||||||
private readonly lfo: OscillatorNode
|
private readonly lfo: OscillatorNode
|
||||||
private readonly phaserWet: GainNode
|
private readonly flange: DelayNode
|
||||||
|
private readonly flangeFeedback: GainNode
|
||||||
|
private readonly flangerWet: GainNode
|
||||||
|
|
||||||
constructor(ctx: AudioContext) {
|
constructor(ctx: AudioContext) {
|
||||||
this.ctx = ctx
|
this.ctx = ctx
|
||||||
@@ -192,21 +198,22 @@ class FilterFx {
|
|||||||
this.crushWet.gain.value = 0
|
this.crushWet.gain.value = 0
|
||||||
this.filter.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.
|
// 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 = ctx.createOscillator()
|
||||||
this.lfo.frequency.value = 0.5
|
this.lfo.frequency.value = 0.5
|
||||||
this.phaserWet = ctx.createGain()
|
this.flange = ctx.createDelay(0.05)
|
||||||
this.phaserWet.gain.value = 0
|
this.flange.delayTime.value = (FLANGE_MIN + FLANGE_MAX) / 2
|
||||||
let stage: AudioNode = this.filter
|
const depth = ctx.createGain()
|
||||||
for (const centre of [350, 700, 1400, 2800]) {
|
depth.gain.value = (FLANGE_MAX - FLANGE_MIN) / 2
|
||||||
const ap = biquad(ctx, 'allpass', centre, 0.6)
|
this.lfo.connect(depth).connect(this.flange.delayTime)
|
||||||
const depth = ctx.createGain()
|
this.flangeFeedback = ctx.createGain()
|
||||||
depth.gain.value = centre * 0.6
|
this.flangeFeedback.gain.value = 0
|
||||||
this.lfo.connect(depth).connect(ap.frequency)
|
this.flangerWet = ctx.createGain()
|
||||||
stage.connect(ap)
|
this.flangerWet.gain.value = 0
|
||||||
stage = ap
|
this.filter.connect(this.flange)
|
||||||
}
|
this.flange.connect(this.flangeFeedback).connect(this.flange)
|
||||||
stage.connect(this.phaserWet).connect(this.output)
|
this.flange.connect(this.flangerWet).connect(this.output)
|
||||||
this.lfo.start()
|
this.lfo.start()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -232,14 +239,16 @@ class FilterFx {
|
|||||||
ramp(this.dry.gain, 1 - take, ctx)
|
ramp(this.dry.gain, 1 - take, ctx)
|
||||||
|
|
||||||
// How much of the filtered music stays: all of it, but half under the
|
// 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).
|
// crusher (which replaces it).
|
||||||
const phasing = type === 'phaser' && on
|
const flanging = type === 'flanger' && on
|
||||||
const mix = phasing ? Math.min(1, a / 0.25) : 0
|
const mix = flanging ? Math.min(1, a / 0.25) : 0
|
||||||
const crushing = type === 'crusher' && on
|
const crushing = type === 'crusher' && on
|
||||||
ramp(this.filtered.gain, crushing ? 0 : take * (1 - 0.5 * mix), ctx)
|
ramp(this.filtered.gain, crushing ? 0 : take * (1 - 0.5 * mix), ctx)
|
||||||
ramp(this.phaserWet.gain, take * 0.5 * mix, ctx)
|
ramp(this.flangerWet.gain, take * 0.5 * mix, ctx)
|
||||||
if (type === 'phaser') ramp(this.lfo.frequency, 1 / beatSeconds(phaserBeatsAt(fx.phaserBeats, a), bpm), ctx, 0.05)
|
// 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
|
// Reverb: the send grows with the knob, and moves from the short reverb
|
||||||
// into the long one — the more filter, the longer the tail.
|
// into the long one — the more filter, the longer the tail.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { describe, expect, it } from 'vitest'
|
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', () => {
|
describe('eqGain', () => {
|
||||||
it('is flat at the centre, +6 dB at full right', () => {
|
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', () => {
|
it('starts at the slowest sweep and halves at each quarter of the knob', () => {
|
||||||
expect(phaserBeatsAt(4, 0.05)).toBe(4)
|
expect(sweepBeatsAt(4, 0.05)).toBe(4)
|
||||||
expect(phaserBeatsAt(4, 0.3)).toBe(2)
|
expect(sweepBeatsAt(4, 0.3)).toBe(2)
|
||||||
expect(phaserBeatsAt(4, 0.6)).toBe(1)
|
expect(sweepBeatsAt(4, 0.6)).toBe(1)
|
||||||
expect(phaserBeatsAt(4, 0.8)).toBe(0.5)
|
expect(sweepBeatsAt(4, 0.8)).toBe(0.5)
|
||||||
expect(phaserBeatsAt(4, 1)).toBe(0.5)
|
expect(sweepBeatsAt(4, 1)).toBe(0.5)
|
||||||
expect(phaserBeatsAt(8, 1)).toBe(1)
|
expect(sweepBeatsAt(8, 1)).toBe(1)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -96,9 +96,9 @@ export function filterSweep(
|
|||||||
*/
|
*/
|
||||||
export const knobStep = (a: number): number => Math.min(3, Math.floor(clamp(a, 0, 1) * 4))
|
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. */
|
* 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 —
|
/** The delay's length (beats): `shortest` (the setting), then ×2, ×4, ×8 —
|
||||||
* longer as the filter opens. */
|
* longer as the filter opens. */
|
||||||
@@ -109,7 +109,7 @@ export const delayBeatsAt = (shortest: number, a: number): number => shortest *
|
|||||||
export const REVERB_GROWTH = 3
|
export const REVERB_GROWTH = 3
|
||||||
|
|
||||||
/** Seconds for `beats` at `bpm` (120 when the tempo is unknown) — the delay's
|
/** 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 {
|
export function beatSeconds(beats: number, bpm: number): number {
|
||||||
return (beats * 60) / (bpm > 0 ? bpm : 120)
|
return (beats * 60) / (bpm > 0 ? bpm : 120)
|
||||||
}
|
}
|
||||||
@@ -16,14 +16,14 @@ export const CHANNELS: Channel[] = ['A', 'B']
|
|||||||
* here rides with it, its amount growing with the knob. `filter` is the filter
|
* here rides with it, its amount growing with the knob. `filter` is the filter
|
||||||
* alone.
|
* 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 type FxType = (typeof FX_TYPES)[number]
|
||||||
export const FX_LABELS: Record<FxType, string> = {
|
export const FX_LABELS: Record<FxType, string> = {
|
||||||
filter: 'Filter',
|
filter: 'Filter',
|
||||||
reverb: 'Reverb',
|
reverb: 'Reverb',
|
||||||
delay: 'Delay',
|
delay: 'Delay',
|
||||||
crusher: 'Bit crusher',
|
crusher: 'Bit crusher',
|
||||||
phaser: 'Phaser',
|
flanger: 'Flanger',
|
||||||
}
|
}
|
||||||
/** For the channel's narrow picker. */
|
/** For the channel's narrow picker. */
|
||||||
export const FX_SHORT: Record<FxType, string> = {
|
export const FX_SHORT: Record<FxType, string> = {
|
||||||
@@ -31,7 +31,7 @@ export const FX_SHORT: Record<FxType, string> = {
|
|||||||
reverb: 'Reverb',
|
reverb: 'Reverb',
|
||||||
delay: 'Delay',
|
delay: 'Delay',
|
||||||
crusher: 'Crush',
|
crusher: 'Crush',
|
||||||
phaser: 'Phaser',
|
flanger: 'Flange',
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -54,9 +54,9 @@ export interface FxSettings {
|
|||||||
delayBeats: number
|
delayBeats: number
|
||||||
/** Bit crusher drive, 1..4. */
|
/** Bit crusher drive, 1..4. */
|
||||||
crusherDrive: number
|
crusherDrive: number
|
||||||
/** The phaser's SLOWEST sweep, in beats of the deck's tempo — near the
|
/** The flanger's SLOWEST sweep, in beats of the deck's tempo — near the
|
||||||
* centre; it halves as the knob opens (`phaserBeatsAt`). */
|
* centre; it halves as the knob opens (`sweepBeatsAt`). */
|
||||||
phaserBeats: number
|
flangerBeats: number
|
||||||
}
|
}
|
||||||
|
|
||||||
export const DEFAULT_FX: FxSettings = {
|
export const DEFAULT_FX: FxSettings = {
|
||||||
@@ -66,7 +66,7 @@ export const DEFAULT_FX: FxSettings = {
|
|||||||
reverbSize: 2,
|
reverbSize: 2,
|
||||||
delayBeats: 0.25,
|
delayBeats: 0.25,
|
||||||
crusherDrive: 2,
|
crusherDrive: 2,
|
||||||
phaserBeats: 4,
|
flangerBeats: 4,
|
||||||
}
|
}
|
||||||
|
|
||||||
/** The filter's range under `type`: one setting for the Filter alone (Full by
|
/** The filter's range under `type`: one setting for the Filter alone (Full by
|
||||||
|
|||||||
Reference in new issue
Block a user