mirror of
https://github.com/MrPatben8/konduktor.git
synced 2026-11-27 10:22:51 +01:00
Moved performance settings to their own panel
This commit is contained in:
1 parent
af02b1fc1c
commit
341f12e275
11 files changed
+319
-139
No files matched your search
@@ -21,7 +21,8 @@ export const APP_SETTING_DEFAULTS = {
|
||||
levelMeasure: 'lufs' as 'lufs' | 'rms',
|
||||
levelTarget: -9,
|
||||
levelCeiling: -1,
|
||||
// Performance mode (decided 2026-11-02 / -03).
|
||||
// Performance mode (decided 2026-11-02 / -03) — its own panel,
|
||||
// PerformanceSettings.tsx.
|
||||
/** Stem tracks load as stems into a performance deck (else their mix: one
|
||||
* time-stretcher instead of four). Read when a track loads. */
|
||||
perfStems: true,
|
||||
@@ -29,7 +30,8 @@ export const APP_SETTING_DEFAULTS = {
|
||||
keylockDefault: true,
|
||||
/** EQ full left kills the band (else -26 dB, DJM-style). */
|
||||
eqKill: false,
|
||||
crossfaderCurve: 'smooth' as 'smooth' | 'sharp',
|
||||
/** The crossfader curve: 0 smooth (constant power) .. 1 sharp (a cut). */
|
||||
crossfaderSharpness: 0,
|
||||
/** The colour effects' one parameter each (the mixer has no knob for it). */
|
||||
fxFilterResonance: 0.3,
|
||||
fxEchoBeats: 0.5,
|
||||
@@ -55,15 +57,6 @@ export function AppSettings({ onClose }: { onClose: () => void }) {
|
||||
const levelMeasure = useAppSetting('levelMeasure')
|
||||
const levelTarget = useAppSetting('levelTarget')
|
||||
const levelCeiling = useAppSetting('levelCeiling')
|
||||
const perfStems = useAppSetting('perfStems')
|
||||
const keylockDefault = useAppSetting('keylockDefault')
|
||||
const eqKill = useAppSetting('eqKill')
|
||||
const crossfaderCurve = useAppSetting('crossfaderCurve')
|
||||
const fxFilterResonance = useAppSetting('fxFilterResonance')
|
||||
const fxEchoBeats = useAppSetting('fxEchoBeats')
|
||||
const fxSpaceSize = useAppSetting('fxSpaceSize')
|
||||
const fxNoiseResonance = useAppSetting('fxNoiseResonance')
|
||||
const fxCrushDrive = useAppSetting('fxCrushDrive')
|
||||
const [error, setError] = useState<string | null>(null)
|
||||
|
||||
const set = async (patch: Partial<typeof APP_SETTING_DEFAULTS>) => {
|
||||
@@ -84,7 +77,7 @@ export function AppSettings({ onClose }: { onClose: () => void }) {
|
||||
×
|
||||
</button>
|
||||
</div>
|
||||
<div className="max-h-[70vh] space-y-4 overflow-y-auto px-5 py-4 text-sm">
|
||||
<div className="space-y-4 px-5 py-4 text-sm">
|
||||
<section className="space-y-2">
|
||||
<h3 className="text-[11px] font-semibold uppercase tracking-wider text-faint">Sidebar</h3>
|
||||
<label className="flex cursor-pointer items-start gap-2.5">
|
||||
@@ -172,87 +165,6 @@ export function AppSettings({ onClose }: { onClose: () => void }) {
|
||||
onCommit={(v) => void set({ levelCeiling: v })} />
|
||||
</label>
|
||||
</section>
|
||||
<section className="space-y-2">
|
||||
<h3 className="text-[11px] font-semibold uppercase tracking-wider text-faint">Performance mode</h3>
|
||||
<Check
|
||||
checked={perfStems}
|
||||
onChange={(v) => void set({ perfStems: v })}
|
||||
title="Load stem tracks as stems"
|
||||
text="A stem track loaded into a deck in performance mode plays its four stems (mute and solo work). Off, it plays its mix: lighter on an older computer, since keylock then stretches one stream instead of four. Applies to the next track loaded."
|
||||
/>
|
||||
<Check
|
||||
checked={keylockDefault}
|
||||
onChange={(v) => void set({ keylockDefault: v })}
|
||||
title="Keylock on"
|
||||
text="Each deck starts with keylock on: a tempo change keeps the pitch. Each deck's KEY button still switches it."
|
||||
/>
|
||||
<Choice
|
||||
title="EQ full left"
|
||||
value={eqKill ? 'kill' : 'cut'}
|
||||
options={[
|
||||
['cut', 'Cut to −26 dB'],
|
||||
['kill', 'Kill (silence)'],
|
||||
]}
|
||||
onChange={(v) => void set({ eqKill: v === 'kill' })}
|
||||
/>
|
||||
<Choice
|
||||
title="Crossfader curve"
|
||||
value={crossfaderCurve}
|
||||
options={[
|
||||
['smooth', 'Smooth — for blends'],
|
||||
['sharp', 'Sharp — for cuts'],
|
||||
]}
|
||||
onChange={(v) => void set({ crossfaderCurve: v as 'smooth' | 'sharp' })}
|
||||
/>
|
||||
<span className="block pt-1 text-xs text-faint">
|
||||
The colour effects: what each one's setting is, on both channels.
|
||||
</span>
|
||||
<Choice
|
||||
title="Filter resonance"
|
||||
value={String(fxFilterResonance)}
|
||||
options={LEVELS}
|
||||
onChange={(v) => void set({ fxFilterResonance: Number(v) })}
|
||||
/>
|
||||
<Choice
|
||||
title="Echo length"
|
||||
value={String(fxEchoBeats)}
|
||||
options={[
|
||||
['0.125', '1/8 beat'],
|
||||
['0.25', '1/4 beat'],
|
||||
['0.5', '1/2 beat'],
|
||||
['0.75', '3/4 beat'],
|
||||
['1', '1 beat'],
|
||||
]}
|
||||
onChange={(v) => void set({ fxEchoBeats: Number(v) })}
|
||||
/>
|
||||
<Choice
|
||||
title="Space size"
|
||||
value={String(fxSpaceSize)}
|
||||
options={[
|
||||
['1', 'Small (1 s)'],
|
||||
['2.5', 'Medium (2.5 s)'],
|
||||
['4', 'Large (4 s)'],
|
||||
['6', 'Huge (6 s)'],
|
||||
]}
|
||||
onChange={(v) => void set({ fxSpaceSize: Number(v) })}
|
||||
/>
|
||||
<Choice
|
||||
title="Noise resonance"
|
||||
value={String(fxNoiseResonance)}
|
||||
options={LEVELS}
|
||||
onChange={(v) => void set({ fxNoiseResonance: Number(v) })}
|
||||
/>
|
||||
<Choice
|
||||
title="Crush drive"
|
||||
value={String(fxCrushDrive)}
|
||||
options={[
|
||||
['1', 'Clean (×1)'],
|
||||
['2', 'Warm (×2)'],
|
||||
['4', 'Hot (×4)'],
|
||||
]}
|
||||
onChange={(v) => void set({ fxCrushDrive: Number(v) })}
|
||||
/>
|
||||
</section>
|
||||
{error && <div className="text-xs text-pink">{error}</div>}
|
||||
</div>
|
||||
<div className="flex justify-end gap-2 border-t border-line px-5 py-3">
|
||||
@@ -265,15 +177,7 @@ export function AppSettings({ onClose }: { onClose: () => void }) {
|
||||
)
|
||||
}
|
||||
|
||||
/** Resonance amounts offered (0..1 of the effect's maximum). */
|
||||
const LEVELS: [string, string][] = [
|
||||
['0', 'None'],
|
||||
['0.3', 'Gentle'],
|
||||
['0.6', 'Medium'],
|
||||
['1', 'Strong'],
|
||||
]
|
||||
|
||||
function Check({ checked, onChange, title, text }: {
|
||||
export function Check({ checked, onChange, title, text }: {
|
||||
checked: boolean; onChange: (v: boolean) => void; title: string; text: string
|
||||
}) {
|
||||
return (
|
||||
@@ -289,7 +193,7 @@ function Check({ checked, onChange, title, text }: {
|
||||
|
||||
/** A setting picked from a list. A stored value not in the list (an older
|
||||
* build's) shows as the list's first entry until changed. */
|
||||
function Choice({ title, value, options, onChange }: {
|
||||
export function Choice({ title, value, options, onChange }: {
|
||||
title: string; value: string; options: [string, string][]; onChange: (v: string) => void
|
||||
}) {
|
||||
return (
|
||||
|
||||
@@ -0,0 +1,196 @@
|
||||
import { useEffect, useState } from 'react'
|
||||
import { useQueryClient } from '@tanstack/react-query'
|
||||
import { api } from '../api'
|
||||
import { setMixer } from '../lib/audio/mixerState'
|
||||
import { usePrefsWriter } from '../lib/prefs'
|
||||
import { APP_SETTING_DEFAULTS, Check, Choice, useAppSetting } from './AppSettings'
|
||||
import { Modal } from './Modal'
|
||||
import { Fader } from './mixer/Controls'
|
||||
import { CrossfaderCurveGraph } from './mixer/CrossfaderCurve'
|
||||
|
||||
/** Resonance amounts offered (0..1 of the effect's maximum). */
|
||||
const LEVELS: [string, string][] = [
|
||||
['0', 'None'],
|
||||
['0.3', 'Gentle'],
|
||||
['0.6', 'Medium'],
|
||||
['1', 'Strong'],
|
||||
]
|
||||
|
||||
const section = 'text-[11px] font-semibold uppercase tracking-wider text-faint'
|
||||
|
||||
/**
|
||||
* Settings ▸ Performance mode… (its own panel, decided 2026-11-03): the decks,
|
||||
* the mixer and the colour effects' parameters. Values live in the app
|
||||
* settings (userprefs.json, `APP_SETTING_DEFAULTS`); PrepStrip copies the
|
||||
* mixer's into `mixerState`.
|
||||
*/
|
||||
export function PerformanceSettings({ onClose }: { onClose: () => void }) {
|
||||
const qc = useQueryClient()
|
||||
const writePrefs = usePrefsWriter()
|
||||
const perfStems = useAppSetting('perfStems')
|
||||
const keylockDefault = useAppSetting('keylockDefault')
|
||||
const eqKill = useAppSetting('eqKill')
|
||||
const sharpnessSetting = useAppSetting('crossfaderSharpness')
|
||||
const fxFilterResonance = useAppSetting('fxFilterResonance')
|
||||
const fxEchoBeats = useAppSetting('fxEchoBeats')
|
||||
const fxSpaceSize = useAppSetting('fxSpaceSize')
|
||||
const fxNoiseResonance = useAppSetting('fxNoiseResonance')
|
||||
const fxCrushDrive = useAppSetting('fxCrushDrive')
|
||||
const [error, setError] = useState<string | null>(null)
|
||||
|
||||
// The curve moves with the slider at once — mixer included, so it can be
|
||||
// heard while dragging — and is saved through the debounced prefs writer.
|
||||
const [sharpness, setSharpness] = useState(sharpnessSetting)
|
||||
useEffect(() => setSharpness(sharpnessSetting), [sharpnessSetting])
|
||||
const changeSharpness = (v: number) => {
|
||||
const s = Math.round(v * 100) / 100
|
||||
setSharpness(s)
|
||||
setMixer({ sharpness: s })
|
||||
writePrefs({ crossfaderSharpness: s })
|
||||
}
|
||||
|
||||
const set = async (patch: Partial<typeof APP_SETTING_DEFAULTS>) => {
|
||||
setError(null)
|
||||
try {
|
||||
qc.setQueryData(['prefs'], await api.patchPrefs(patch))
|
||||
} catch (e) {
|
||||
setError((e as Error).message)
|
||||
}
|
||||
}
|
||||
|
||||
const curveName =
|
||||
sharpness === 0 ? 'Smooth' : sharpness === 1 ? 'Sharp' : sharpness < 0.52 ? 'Blend' : 'Cut'
|
||||
|
||||
return (
|
||||
<Modal onDismiss={onClose}>
|
||||
<div className="flex w-full max-w-md flex-col overflow-hidden glass-overlay">
|
||||
<div className="flex items-center justify-between border-b border-line px-5 py-3">
|
||||
<h2 className="text-sm font-semibold text-text">Performance mode</h2>
|
||||
<button onClick={onClose} className="rounded px-1.5 text-faint hover:text-text" aria-label="Close">
|
||||
×
|
||||
</button>
|
||||
</div>
|
||||
<div className="max-h-[70vh] space-y-4 overflow-y-auto px-5 py-4 text-sm">
|
||||
<p className="text-xs text-faint">
|
||||
The second deck and the mixer (P, or the decks button in the deck's header).
|
||||
</p>
|
||||
<section className="space-y-2">
|
||||
<h3 className={section}>Decks</h3>
|
||||
<Check
|
||||
checked={perfStems}
|
||||
onChange={(v) => void set({ perfStems: v })}
|
||||
title="Load stem tracks as stems"
|
||||
text="A stem track loaded into a deck in performance mode plays its four stems (mute and solo work). Off, it plays its mix: lighter on an older computer, since keylock then stretches one stream instead of four. Applies to the next track loaded."
|
||||
/>
|
||||
<Check
|
||||
checked={keylockDefault}
|
||||
onChange={(v) => void set({ keylockDefault: v })}
|
||||
title="Keylock on"
|
||||
text="Each deck starts with keylock on: a tempo change keeps the pitch. Each deck's KEY button still switches it."
|
||||
/>
|
||||
</section>
|
||||
<section className="space-y-2">
|
||||
<h3 className={section}>Mixer</h3>
|
||||
<Choice
|
||||
title="EQ full left"
|
||||
value={eqKill ? 'kill' : 'cut'}
|
||||
options={[
|
||||
['cut', 'Cut to −26 dB'],
|
||||
['kill', 'Kill (silence)'],
|
||||
]}
|
||||
onChange={(v) => void set({ eqKill: v === 'kill' })}
|
||||
/>
|
||||
<div className="space-y-1.5 pt-1">
|
||||
<div className="flex items-baseline justify-between">
|
||||
<span className="text-sm text-text">Crossfader curve</span>
|
||||
<span className="font-mono text-xs text-muted">
|
||||
{curveName} · {Math.round(sharpness * 100)}%
|
||||
</span>
|
||||
</div>
|
||||
<div className="flex items-center gap-4">
|
||||
<CrossfaderCurveGraph sharpness={sharpness} />
|
||||
<div className="min-w-0 flex-1 space-y-1">
|
||||
<Fader
|
||||
orientation="horizontal"
|
||||
value={sharpness}
|
||||
min={0}
|
||||
max={1}
|
||||
defaultValue={0}
|
||||
onChange={changeSharpness}
|
||||
label="Crossfader curve sharpness"
|
||||
describe={(v) => `${Math.round(v * 100)}% sharp — double-click for smooth`}
|
||||
className="w-full"
|
||||
/>
|
||||
<div className="flex justify-between text-[10px] uppercase tracking-wider text-faint">
|
||||
<span>Smooth</span>
|
||||
<span>Sharp</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<span className="block text-xs text-faint">
|
||||
Smooth blends: each channel fades across the whole travel, both at −3 dB in the middle.
|
||||
Sharper keeps both at full level across a widening middle and fades only near the ends —
|
||||
at full, a cut over the last few percent, for scratching.
|
||||
</span>
|
||||
</div>
|
||||
</section>
|
||||
<section className="space-y-2">
|
||||
<h3 className={section}>Colour effects</h3>
|
||||
<span className="block text-xs text-faint">Each effect's setting, on both channels.</span>
|
||||
<Choice
|
||||
title="Filter resonance"
|
||||
value={String(fxFilterResonance)}
|
||||
options={LEVELS}
|
||||
onChange={(v) => void set({ fxFilterResonance: Number(v) })}
|
||||
/>
|
||||
<Choice
|
||||
title="Echo length"
|
||||
value={String(fxEchoBeats)}
|
||||
options={[
|
||||
['0.125', '1/8 beat'],
|
||||
['0.25', '1/4 beat'],
|
||||
['0.5', '1/2 beat'],
|
||||
['0.75', '3/4 beat'],
|
||||
['1', '1 beat'],
|
||||
]}
|
||||
onChange={(v) => void set({ fxEchoBeats: Number(v) })}
|
||||
/>
|
||||
<Choice
|
||||
title="Space size"
|
||||
value={String(fxSpaceSize)}
|
||||
options={[
|
||||
['1', 'Small (1 s)'],
|
||||
['2.5', 'Medium (2.5 s)'],
|
||||
['4', 'Large (4 s)'],
|
||||
['6', 'Huge (6 s)'],
|
||||
]}
|
||||
onChange={(v) => void set({ fxSpaceSize: Number(v) })}
|
||||
/>
|
||||
<Choice
|
||||
title="Noise resonance"
|
||||
value={String(fxNoiseResonance)}
|
||||
options={LEVELS}
|
||||
onChange={(v) => void set({ fxNoiseResonance: Number(v) })}
|
||||
/>
|
||||
<Choice
|
||||
title="Crush drive"
|
||||
value={String(fxCrushDrive)}
|
||||
options={[
|
||||
['1', 'Clean (×1)'],
|
||||
['2', 'Warm (×2)'],
|
||||
['4', 'Hot (×4)'],
|
||||
]}
|
||||
onChange={(v) => void set({ fxCrushDrive: Number(v) })}
|
||||
/>
|
||||
</section>
|
||||
{error && <div className="text-xs text-pink">{error}</div>}
|
||||
</div>
|
||||
<div className="flex justify-end gap-2 border-t border-line px-5 py-3">
|
||||
<button onClick={onClose} className="rounded-full btn-primary px-4 py-1.5 text-sm font-semibold">
|
||||
Done
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</Modal>
|
||||
)
|
||||
}
|
||||
@@ -118,19 +118,19 @@ export function PrepStrip({
|
||||
onEditTags,
|
||||
}: Props) {
|
||||
const view = useDeckView()
|
||||
// Performance-mode settings (Settings ▸ Performance mode).
|
||||
// Performance-mode settings (Settings ▸ Performance mode…).
|
||||
const perfStems = useAppSetting('perfStems')
|
||||
const keylockDefault = useAppSetting('keylockDefault')
|
||||
const eqKill = useAppSetting('eqKill')
|
||||
const curve = useAppSetting('crossfaderCurve')
|
||||
const sharpness = useAppSetting('crossfaderSharpness')
|
||||
const filterResonance = useAppSetting('fxFilterResonance')
|
||||
const echoBeats = useAppSetting('fxEchoBeats')
|
||||
const spaceSize = useAppSetting('fxSpaceSize')
|
||||
const noiseResonance = useAppSetting('fxNoiseResonance')
|
||||
const crushDrive = useAppSetting('fxCrushDrive')
|
||||
useEffect(() => {
|
||||
setMixer({ eqKill, curve, fx: { filterResonance, echoBeats, spaceSize, noiseResonance, crushDrive } })
|
||||
}, [eqKill, curve, filterResonance, echoBeats, spaceSize, noiseResonance, crushDrive])
|
||||
setMixer({ eqKill, sharpness, fx: { filterResonance, echoBeats, spaceSize, noiseResonance, crushDrive } })
|
||||
}, [eqKill, sharpness, filterResonance, echoBeats, spaceSize, noiseResonance, crushDrive])
|
||||
const lead: DeckId = performance ? focused : 'A'
|
||||
const playingA = useCallback((p: boolean) => onPlayingChange('A', p), [onPlayingChange])
|
||||
const playingB = useCallback((p: boolean) => onPlayingChange('B', p), [onPlayingChange])
|
||||
|
||||
@@ -4,6 +4,7 @@ import { api } from '../api'
|
||||
import { AppSettings } from './AppSettings'
|
||||
import { useCaps } from '../lib/capabilities'
|
||||
import { LocalLibrariesSettings } from './LocalLibrariesSettings'
|
||||
import { PerformanceSettings } from './PerformanceSettings'
|
||||
import { RemoteCacheSettings } from './RemoteCacheSettings'
|
||||
import { ShortcutsDialog } from './ShortcutsDialog'
|
||||
import { StemsSettings } from './StemsSettings'
|
||||
@@ -15,7 +16,7 @@ interface Props {
|
||||
}
|
||||
|
||||
/** Overflow menu for low-frequency settings: the app's own (Konduktor
|
||||
* settings), path remapping, Stems and the shortcut list. The dialogs are owned
|
||||
* settings), path remapping, Stems, Performance mode and the shortcut list. The dialogs are owned
|
||||
* here, since nothing else opens them. */
|
||||
export function SettingsMenu({ onOpenPathMapping, up = false }: Props) {
|
||||
const [open, setOpen] = useState(false)
|
||||
@@ -24,6 +25,7 @@ export function SettingsMenu({ onOpenPathMapping, up = false }: Props) {
|
||||
const [showCache, setShowCache] = useState(false)
|
||||
const [showApp, setShowApp] = useState(false)
|
||||
const [showLocal, setShowLocal] = useState(false)
|
||||
const [showPerformance, setShowPerformance] = useState(false)
|
||||
const ref = useRef<HTMLDivElement>(null)
|
||||
// Path remapping is a library on THIS computer's business; a remote's
|
||||
// mapping is its server's configuration.
|
||||
@@ -145,6 +147,16 @@ export function SettingsMenu({ onOpenPathMapping, up = false }: Props) {
|
||||
<span className="text-sm text-text">Stems…</span>
|
||||
<span className="text-[11px] text-faint">The stem engine, device and conversion defaults</span>
|
||||
</button>
|
||||
<button
|
||||
onClick={() => {
|
||||
setShowPerformance(true)
|
||||
setOpen(false)
|
||||
}}
|
||||
className={item}
|
||||
>
|
||||
<span className="text-sm text-text">Performance mode…</span>
|
||||
<span className="text-[11px] text-faint">The second deck, the mixer and its effects</span>
|
||||
</button>
|
||||
<button
|
||||
onClick={() => {
|
||||
setShowShortcuts(true)
|
||||
@@ -162,6 +174,7 @@ export function SettingsMenu({ onOpenPathMapping, up = false }: Props) {
|
||||
{showCache && <RemoteCacheSettings onClose={() => setShowCache(false)} />}
|
||||
{showApp && <AppSettings onClose={() => setShowApp(false)} />}
|
||||
{showLocal && <LocalLibrariesSettings onClose={() => setShowLocal(false)} />}
|
||||
{showPerformance && <PerformanceSettings onClose={() => setShowPerformance(false)} />}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
import { xfadeGains } from '../../lib/audio/mixerMath'
|
||||
import { useMixer } from '../../lib/audio/mixerState'
|
||||
|
||||
const W = 200
|
||||
const H = 72
|
||||
const PAD = 6
|
||||
const STEPS = 120
|
||||
|
||||
/** The crossfader's two gain curves at `sharpness`: A falling left to right,
|
||||
* B rising, over the whole travel, with where the crossfader is now. */
|
||||
export function CrossfaderCurveGraph({ sharpness }: { sharpness: number }) {
|
||||
const position = useMixer((m) => m.crossfader)
|
||||
const x = (t: number) => PAD + t * (W - 2 * PAD)
|
||||
const y = (g: number) => H - PAD - g * (H - 2 * PAD)
|
||||
const line = (ch: 0 | 1) =>
|
||||
Array.from({ length: STEPS + 1 }, (_, i) => {
|
||||
const t = i / STEPS
|
||||
const g = xfadeGains(t * 2 - 1, sharpness)[ch]
|
||||
return `${i ? 'L' : 'M'}${x(t).toFixed(1)} ${y(g).toFixed(1)}`
|
||||
}).join(' ')
|
||||
const at = (position + 1) / 2
|
||||
return (
|
||||
<svg
|
||||
width={W}
|
||||
height={H}
|
||||
viewBox={`0 0 ${W} ${H}`}
|
||||
className="well shrink-0 rounded-lg"
|
||||
role="img"
|
||||
aria-label={`Crossfader curve, ${Math.round(sharpness * 100)}% sharp`}
|
||||
>
|
||||
{/* full level, the -3 dB line, the centre */}
|
||||
<line x1={PAD} x2={W - PAD} y1={y(1)} y2={y(1)} stroke="rgb(255 255 255 / 0.08)" />
|
||||
<line x1={PAD} x2={W - PAD} y1={y(Math.SQRT1_2)} y2={y(Math.SQRT1_2)} stroke="rgb(255 255 255 / 0.06)" strokeDasharray="2 3" />
|
||||
<line x1={x(0.5)} x2={x(0.5)} y1={PAD} y2={H - PAD} stroke="rgb(255 255 255 / 0.08)" />
|
||||
<path d={line(0)} fill="none" stroke="var(--color-accent)" strokeWidth={2} strokeLinejoin="round" />
|
||||
<path d={line(1)} fill="none" stroke="var(--color-gold)" strokeWidth={2} strokeLinejoin="round" />
|
||||
<line x1={x(at)} x2={x(at)} y1={PAD} y2={H - PAD} stroke="var(--color-text)" strokeOpacity={0.5} />
|
||||
<text x={PAD + 2} y={H - PAD - 3} fontSize={9} fill="var(--color-accent)" fontWeight={600}>A</text>
|
||||
<text x={W - PAD - 8} y={H - PAD - 3} fontSize={9} fill="var(--color-gold)" fontWeight={600}>B</text>
|
||||
</svg>
|
||||
)
|
||||
}
|
||||
@@ -49,8 +49,8 @@ function beatsLabel(b: number): string {
|
||||
/**
|
||||
* The mixer, between the decks in performance mode (decided 2026-11-02): per
|
||||
* channel TRIM (on top of the track's auto gain), HI / MID / LOW, a colour
|
||||
* effect with its own selector (its one parameter is an app setting, under
|
||||
* Performance mode in Settings), a fader and its meter; between
|
||||
* effect with its own selector (its one parameter is an app setting, in
|
||||
* Settings ▸ Performance mode…), a fader and its meter; between
|
||||
* them the master meter and the limiter's light; the crossfader beneath. The
|
||||
* values live in `mixerState` and the audio in `mixer.ts`.
|
||||
*/
|
||||
@@ -91,7 +91,7 @@ export function MixerPanel({ autoGain }: { autoGain: Record<Channel, number | nu
|
||||
}, [])
|
||||
|
||||
const crossfader = useMixer((s) => s.crossfader)
|
||||
const curve = useMixer((s) => s.curve)
|
||||
const sharpness = useMixer((s) => s.sharpness)
|
||||
|
||||
return (
|
||||
<div className="well flex w-[24rem] shrink-0 flex-col gap-1.5 rounded-2xl px-2.5 pb-1.5 pt-2.5">
|
||||
@@ -121,7 +121,7 @@ export function MixerPanel({ autoGain }: { autoGain: Record<Channel, number | nu
|
||||
onChange={(v) => setMixer({ crossfader: Math.abs(v) < 0.03 ? 0 : v })}
|
||||
label="Crossfader"
|
||||
describe={(v) =>
|
||||
`Crossfader (${curve === 'smooth' ? 'smooth' : 'sharp'} curve) — ${
|
||||
`Crossfader (curve ${Math.round(sharpness * 100)}% sharp — Settings ▸ Performance mode…) — ${
|
||||
Math.abs(v) < 0.03 ? 'centre' : v < 0 ? `toward A ${Math.round(-v * 100)}%` : `toward B ${Math.round(v * 100)}%`
|
||||
}`
|
||||
}
|
||||
|
||||
@@ -395,7 +395,7 @@ export class Mixer {
|
||||
|
||||
private apply(): void {
|
||||
const s = getMixerState()
|
||||
const [ga, gb] = xfadeGains(s.crossfader, s.curve)
|
||||
const [ga, gb] = xfadeGains(s.crossfader, s.sharpness)
|
||||
this.strips.A.apply(s.A, ga, s.eqKill, s.fx)
|
||||
this.strips.B.apply(s.B, gb, s.eqKill, s.fx)
|
||||
}
|
||||
|
||||
@@ -25,19 +25,35 @@ describe('eqGain', () => {
|
||||
})
|
||||
|
||||
describe('xfadeGains', () => {
|
||||
it('smooth: constant power, -3 dB each at the centre', () => {
|
||||
it('sharpness 0: constant power, -3 dB each at the centre', () => {
|
||||
for (const x of [-1, -0.4, 0, 0.3, 1]) {
|
||||
const [a, b] = xfadeGains(x, 'smooth')
|
||||
const [a, b] = xfadeGains(x, 0)
|
||||
expect(a * a + b * b).toBeCloseTo(1, 9)
|
||||
}
|
||||
expect(gainToDb(xfadeGains(0, 'smooth')[0])).toBeCloseTo(-3.01, 2)
|
||||
expect(xfadeGains(-1, 'smooth')).toEqual([1, expect.closeTo(0, 9)])
|
||||
expect(gainToDb(xfadeGains(0, 0)[0])).toBeCloseTo(-3.01, 2)
|
||||
expect(xfadeGains(-1, 0)).toEqual([1, expect.closeTo(0, 9)])
|
||||
})
|
||||
it('sharp: both full until the last tenth', () => {
|
||||
expect(xfadeGains(0, 'sharp')).toEqual([1, 1])
|
||||
expect(xfadeGains(0.9, 'sharp')).toEqual([1, 1])
|
||||
expect(xfadeGains(1, 'sharp')).toEqual([0, 1])
|
||||
expect(xfadeGains(-0.95, 'sharp')[1]).toBeCloseTo(0.5, 9)
|
||||
it('sharpness 1: both full until the last 4%, then a cut', () => {
|
||||
expect(xfadeGains(0, 1)).toEqual([1, 1])
|
||||
expect(xfadeGains(0.9, 1)).toEqual([1, 1])
|
||||
expect(xfadeGains(1, 1)).toEqual([expect.closeTo(0, 9), 1])
|
||||
expect(xfadeGains(-0.96, 1)[1]).toBeCloseTo(Math.SQRT1_2, 9) // halfway through its fade
|
||||
})
|
||||
it('in between: the centre rises from -3 dB to full, and every curve falls monotonically', () => {
|
||||
let centre = 0
|
||||
for (let s = 0; s <= 1; s += 0.1) {
|
||||
const c = xfadeGains(0, s)[0]
|
||||
expect(c).toBeGreaterThanOrEqual(centre - 1e-12)
|
||||
centre = c
|
||||
let prev = Infinity
|
||||
for (let x = -1; x <= 1; x += 0.05) {
|
||||
const [a, b] = xfadeGains(x, s)
|
||||
expect(a).toBeLessThanOrEqual(prev + 1e-12)
|
||||
expect(b).toBeCloseTo(xfadeGains(-x, s)[0], 9) // mirror images
|
||||
prev = a
|
||||
}
|
||||
}
|
||||
expect(xfadeGains(0, 0.6)[0]).toBe(1) // past ~0.52 the fades no longer reach the middle: no dip
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
@@ -33,20 +33,26 @@ export const TRIM_RANGE_DB = 12
|
||||
/** A channel fader (0..1) as a gain: an audio taper, -6 dB at ~0.7. */
|
||||
export const faderGain = (f: number): number => clamp(f, 0, 1) ** 2
|
||||
|
||||
export type CrossfaderCurve = 'smooth' | 'sharp'
|
||||
/** The narrowest fade a fully sharp crossfader leaves (of its whole travel). */
|
||||
export const XF_MIN_WIDTH = 0.04
|
||||
|
||||
/** How much of the travel a channel takes to fade out, at `sharpness` 0..1. */
|
||||
export const xfadeWidth = (sharpness: number): number => 1 - clamp(sharpness, 0, 1) * (1 - XF_MIN_WIDTH)
|
||||
|
||||
/**
|
||||
* The crossfader (-1 = all A, 1 = all B) as the two channels' gains. Smooth is
|
||||
* constant-power: both at -3 dB in the middle, for blends. Sharp keeps both at
|
||||
* full until the last tenth of the travel, for cuts and scratching.
|
||||
* The crossfader (-1 = all A, 1 = all B) as the two channels' gains, at a
|
||||
* SHARPNESS from 0 to 1 (decided 2026-11-03: fully adjustable). Each channel
|
||||
* fades on a quarter-cosine over the last `xfadeWidth` of the travel toward the
|
||||
* other side and is at full level before it. At 0 that is the whole travel —
|
||||
* constant power, both at -3 dB in the middle, for blends; turned up, both stay
|
||||
* full across a widening middle (no dip), until at 1 a channel cuts over the
|
||||
* last 4%, for cuts and scratching.
|
||||
*/
|
||||
export function xfadeGains(x: number, curve: CrossfaderCurve): [number, number] {
|
||||
x = clamp(x, -1, 1)
|
||||
if (curve === 'smooth') {
|
||||
const t = ((x + 1) / 2) * (Math.PI / 2)
|
||||
return [Math.cos(t), Math.sin(t)]
|
||||
}
|
||||
return [x <= 0.9 ? 1 : (1 - x) / 0.1, x >= -0.9 ? 1 : (1 + x) / 0.1]
|
||||
export function xfadeGains(x: number, sharpness: number): [number, number] {
|
||||
const t = (clamp(x, -1, 1) + 1) / 2 // 0 = all A
|
||||
const w = xfadeWidth(sharpness)
|
||||
const fade = (u: number) => Math.cos((Math.PI / 2) * clamp((u - (1 - w)) / w, 0, 1))
|
||||
return [fade(t), fade(1 - t)]
|
||||
}
|
||||
|
||||
/** The colour knob's dead centre: inside it, the effect is out of the path. */
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
// mixer starts flat.
|
||||
|
||||
import { useSyncExternalStore } from 'react'
|
||||
import type { CrossfaderCurve } from './mixerMath'
|
||||
|
||||
export type Channel = 'A' | 'B'
|
||||
export const CHANNELS: Channel[] = ['A', 'B']
|
||||
@@ -63,7 +62,8 @@ export interface MixerState {
|
||||
B: ChannelState
|
||||
/** -1 = all A, 1 = all B. */
|
||||
crossfader: number
|
||||
curve: CrossfaderCurve
|
||||
/** The crossfader curve, 0 (smooth) .. 1 (sharp): `mixerMath.xfadeGains`. */
|
||||
sharpness: number
|
||||
/** EQ cuts to silence at full left (else to -26 dB). */
|
||||
eqKill: boolean
|
||||
fx: FxSettings
|
||||
@@ -83,7 +83,7 @@ let state: MixerState = {
|
||||
A: DEFAULT_CHANNEL,
|
||||
B: DEFAULT_CHANNEL,
|
||||
crossfader: 0,
|
||||
curve: 'smooth',
|
||||
sharpness: 0,
|
||||
eqKill: false,
|
||||
fx: DEFAULT_FX,
|
||||
}
|
||||
@@ -107,7 +107,7 @@ export function setChannel(ch: Channel, patch: Partial<ChannelState>): void {
|
||||
commit({ ...state, [ch]: { ...state[ch], ...patch } })
|
||||
}
|
||||
|
||||
export function setMixer(patch: Partial<Pick<MixerState, 'crossfader' | 'curve' | 'eqKill' | 'fx'>>): void {
|
||||
export function setMixer(patch: Partial<Pick<MixerState, 'crossfader' | 'sharpness' | 'eqKill' | 'fx'>>): void {
|
||||
commit({ ...state, ...patch })
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user