Implemented performance mode settings

This commit is contained in:
patben8 committed 2026-11-03 08:49:26 +01:00
1 parent fe91a46bae
commit af02b1fc1c
11 files changed
+290 -85

No files matched your search

+151 -1
View File
@@ -21,6 +21,21 @@ export const APP_SETTING_DEFAULTS = {
levelMeasure: 'lufs' as 'lufs' | 'rms',
levelTarget: -9,
levelCeiling: -1,
// Performance mode (decided 2026-11-02 / -03).
/** 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,
/** A deck's keylock starts on. */
keylockDefault: true,
/** EQ full left kills the band (else -26 dB, DJM-style). */
eqKill: false,
crossfaderCurve: 'smooth' as 'smooth' | 'sharp',
/** The colour effects' one parameter each (the mixer has no knob for it). */
fxFilterResonance: 0.3,
fxEchoBeats: 0.5,
fxSpaceSize: 2.5,
fxNoiseResonance: 0.3,
fxCrushDrive: 2,
}
type AppSettingKey = keyof typeof APP_SETTING_DEFAULTS
@@ -40,6 +55,15 @@ 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>) => {
@@ -60,7 +84,7 @@ export function AppSettings({ onClose }: { onClose: () => void }) {
×
</button>
</div>
<div className="space-y-4 px-5 py-4 text-sm">
<div className="max-h-[70vh] space-y-4 overflow-y-auto 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">
@@ -148,6 +172,87 @@ 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">
@@ -160,6 +265,51 @@ 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 }: {
checked: boolean; onChange: (v: boolean) => void; title: string; text: string
}) {
return (
<label className="flex cursor-pointer items-start gap-2.5">
<input type="checkbox" className="mt-0.5" checked={checked} onChange={(e) => onChange(e.target.checked)} />
<span className="min-w-0">
<span className="block text-sm text-text">{title}</span>
<span className="block text-xs text-faint">{text}</span>
</span>
</label>
)
}
/** 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 }: {
title: string; value: string; options: [string, string][]; onChange: (v: string) => void
}) {
return (
<label className="flex items-center justify-between gap-4">
<span className="text-sm text-text">{title}</span>
<select
className="shrink-0 rounded-lg well px-2 py-1 text-sm text-text outline-none"
value={options.some(([v]) => v === value) ? value : options[0][0]}
onChange={(e) => onChange(e.target.value)}
>
{options.map(([v, label]) => (
<option key={v} value={v}>
{label}
</option>
))}
</select>
</label>
)
}
/** A dB value typed in place, committed on blur / Enter, clamped to its range. */
export function LevelInput({ value, unit, min, max, onCommit }: {
value: number; unit: string; min: number; max: number; onCommit: (v: number) => void
+25 -3
View File
@@ -6,6 +6,8 @@ import { useDropTarget, type DragPayload } from '../lib/drag'
import { Icon } from '../lib/icons'
import { usePrefsWriter } from '../lib/prefs'
import { mixer } from '../lib/audio/mixer'
import { setMixer } from '../lib/audio/mixerState'
import { useAppSetting } from './AppSettings'
import { alignedPosition, effectiveBpm, octaveFor, phaseOffset, syncRate, type DeckTempo as Tempo } from '../lib/sync'
import { DeckControls } from './deck/DeckControls'
import { DeckHeader } from './deck/DeckHeader'
@@ -116,17 +118,38 @@ export function PrepStrip({
onEditTags,
}: Props) {
const view = useDeckView()
// Performance-mode settings (Settings ▸ Performance mode).
const perfStems = useAppSetting('perfStems')
const keylockDefault = useAppSetting('keylockDefault')
const eqKill = useAppSetting('eqKill')
const curve = useAppSetting('crossfaderCurve')
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])
const lead: DeckId = performance ? focused : 'A'
const playingA = useCallback((p: boolean) => onPlayingChange('A', p), [onPlayingChange])
const playingB = useCallback((p: boolean) => onPlayingChange('B', p), [onPlayingChange])
const common = { secPerView: view.secPerView, onError, onNotify }
const common = {
secPerView: view.secPerView,
onError,
onNotify,
tempoActive: performance,
// A stem track loaded INTO performance mode follows the setting; the prep
// deck always loads stems.
stemsAllowed: !performance || perfStems,
keylockDefault,
}
const editTags = (slot: DeckSlot) => (onEditTags && slot.origin === 'collection' ? onEditTags : undefined)
const a = useDeck({
...common,
...decks.A,
caps: caps.A,
channel: 'A',
tempoActive: performance,
onPlayingChange: playingA,
onEditTags: editTags(decks.A),
persist: true,
@@ -137,7 +160,6 @@ export function PrepStrip({
...decks.B,
caps: caps.B,
channel: 'B',
tempoActive: performance,
onPlayingChange: playingB,
onEditTags: editTags(decks.B),
persist: false,
+3 -3
View File
@@ -55,7 +55,7 @@ export function ShortcutsDialog({ onClose }: Props) {
const [pressed, setPressed] = useState<string | null>(null)
const [query, setQuery] = useState('')
const [areas, setAreas] = useState<ReadonlySet<Area>>(new Set(ALL_AREAS))
const layer: Layer = held.has('mod') ? 'mod' : held.has('shift') ? 'shift' : sticky
const layer: Layer = held.has('mod') ? 'mod' : held.has('alt') ? 'alt' : held.has('shift') ? 'shift' : sticky
const q = query.trim().toLowerCase()
// ---- fit: one key unit from the width the map has ----
@@ -424,8 +424,8 @@ function Caption({
<>
<span className="text-text">Point at a key, or press it, to see what it does.</span>
<span className="text-xs">
Hold <Kbd>{MODIFIER_KEY.shift}</Kbd> or <Kbd>{MODIFIER_KEY.mod}</Kbd>, or pick one above, to see what each
modifier changes.
Hold <Kbd>{MODIFIER_KEY.shift}</Kbd>, <Kbd>{MODIFIER_KEY.mod}</Kbd> or <Kbd>{MODIFIER_KEY.alt}</Kbd>, or pick
one above, to see what each modifier changes.
</span>
<span className="text-xs">
{padRange(slots)} are this library's {slots} hotcue pads; Q W E R are the stems of a stem track.
+14 -2
View File
@@ -79,6 +79,11 @@ export interface DeckOptions {
/** Performance mode: the pitch fader and keylock apply (else the deck plays
* at the file's own tempo). */
tempoActive?: boolean
/** Load a stem track as its stems (else its mix). Read when a track loads,
* so changing it never reloads the deck. */
stemsAllowed?: boolean
/** Keylock's starting state (the `keylockDefault` setting). */
keylockDefault?: boolean
/** The mixer channel this deck plays into (default A). */
channel?: Channel
/** Persist this deck's loop size and cue bank (deck A; default true). */
@@ -99,6 +104,8 @@ export function useDeck({
onPlayingChange,
onEditTags,
tempoActive = false,
stemsAllowed = true,
keylockDefault = true,
channel = 'A',
persist = true,
leadsAmbient = true,
@@ -265,6 +272,9 @@ export function useDeck({
void setAmbientFromArt(trackId && origin === 'collection' ? api.artUrl(trackId) : null)
}, [trackId, origin, leadsAmbient])
const stemsAllowedRef = useRef(stemsAllowed)
stemsAllowedRef.current = stemsAllowed
// Analyse once per track; the decoded buffer feeds both the playback and
// scratch engines (no re-decode) and both waveform views share the columns.
useEffect(() => {
@@ -284,7 +294,7 @@ export function useDeck({
setWaveStatus('loading')
// A stem FILE loads its four stems and plays their sum (decided: always,
// for every stem track); anything else loads as one buffer, as before.
const load = trackStemsFor(origin, trackId)
const load = (stemsAllowedRef.current ? trackStemsFor(origin, trackId) : Promise.resolve([] as StemInfo[]))
.catch(() => [] as StemInfo[])
.then(async (found) => {
if (found.length) {
@@ -1198,7 +1208,9 @@ export function useDeck({
// coming back to performance mode finds the fader where it was.
const [pitch, setPitchState] = useState(0)
const [pitchRange, setPitchRange] = useState(PITCH_RANGES[0])
const [keylock, setKeylock] = useState(true)
const [keylock, setKeylock] = useState(keylockDefault)
// The setting changing (or arriving with the prefs) sets every deck.
useEffect(() => setKeylock(keylockDefault), [keylockDefault])
// A pitch BEND: a momentary push or drag on top of the fader (the phase
// meter's drag), 1 = none. Part of `rate`, so the readout and a follower see it.
const [bend, setBend] = useState(1)
+12 -23
View File
@@ -1,15 +1,14 @@
import { useEffect, useRef, useState, type RefObject } from 'react'
import { mixer } from '../../lib/audio/mixer'
import { faderGain, filterSweep, echoBeats, eqGain, gainToDb, TRIM_RANGE_DB, EQ_CUT_DB } from '../../lib/audio/mixerMath'
import { faderGain, filterSweep, eqGain, gainToDb, TRIM_RANGE_DB, EQ_CUT_DB } from '../../lib/audio/mixerMath'
import {
DEFAULT_CHANNEL,
FX_LABELS,
FX_PARAM,
FX_TYPES,
setChannel,
setMixer,
useMixer,
type Channel,
type FxSettings,
type FxType,
} from '../../lib/audio/mixerState'
import { Icon } from '../../lib/icons'
@@ -23,23 +22,23 @@ const METER_TOP = 3
const fmtDb = (db: number, places = 1) =>
!isFinite(db) ? '−∞ dB' : `${db > 0 ? '+' : db < 0 ? '−' : ''}${Math.abs(db).toFixed(places)} dB`
function describeFx(fx: FxType, c: number, param: number): 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 `${FX_LABELS[fx]}: off (turn left or right)`
switch (fx) {
case 'filter': {
const s = filterSweep(c)!
const hz = s.freq >= 1000 ? `${(s.freq / 1000).toFixed(1)} kHz` : `${Math.round(s.freq)} Hz`
return `Filter: ${s.type === 'lowpass' ? 'low-pass' : 'high-pass'} at ${hz}`
return `Filter: ${s.type === 'lowpass' ? 'low-pass' : 'high-pass'} at ${hz} · resonance ${Math.round(set.filterResonance * 100)}%`
}
case 'echo':
return `Echo ${a}% · ${beatsLabel(echoBeats(param))} · ${c < 0 ? 'darker' : 'thinner'} repeats`
return `Echo ${a}% · ${beatsLabel(set.echoBeats)} · ${c < 0 ? 'darker' : 'thinner'} repeats`
case 'space':
return `Space ${a}% · ${c < 0 ? 'darker' : 'thinner'}`
return `Space ${a}% · ${set.spaceSize} s · ${c < 0 ? 'darker' : 'thinner'}`
case 'noise':
return `Noise ${a}% · ${c < 0 ? 'low-pass' : 'high-pass'} sweep`
case 'crush':
return `Crush ${a}%`
return `Crush ${a}% · drive ×${set.crushDrive}`
}
}
@@ -50,7 +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 and parameter, a fader and its meter; between
* effect with its own selector (its one parameter is an app setting, under
* Performance mode in Settings), 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`.
*/
@@ -155,6 +155,7 @@ function Strip({
}) {
const s = useMixer((m) => m[ch])
const eqKill = useMixer((m) => m.eqKill)
const fxSettings = useMixer((m) => m.fx)
const [fxMenu, setFxMenu] = useState<{ x: number; y: number } | null>(null)
const set = (patch: Parameters<typeof setChannel>[1]) => setChannel(ch, patch)
const describeEq = (band: string) => (v: number) => {
@@ -199,7 +200,7 @@ function Strip({
setFxMenu({ x: r.left, y: r.bottom + 4 })
}}
title="Which effect the COLOR knob drives"
className="btn-glass col-span-2 mt-0.5 flex h-6 items-center justify-center gap-0.5 self-start rounded-md text-[10px] font-semibold uppercase tracking-[0.06em] text-text"
className="btn-glass col-span-3 mt-0.5 flex h-6 items-center justify-center gap-0.5 self-start rounded-md text-[10px] font-semibold uppercase tracking-[0.06em] text-text"
>
{FX_LABELS[s.fx]}
<Icon name="chevronDown" size={11} />
@@ -213,19 +214,7 @@ function Strip({
color="var(--color-gold)"
onChange={(v) => set({ color: Math.abs(v) < 0.02 ? 0 : v })}
label="Color"
describe={(v) => describeFx(s.fx, v, s.param)}
/>
<Knob
value={s.param}
min={0}
max={1}
defaultValue={DEFAULT_CHANNEL.param}
color="var(--color-gold)"
onChange={(v) => set({ param: v })}
label="Prm"
describe={(v) =>
`${FX_PARAM[s.fx]}: ${s.fx === 'echo' ? beatsLabel(echoBeats(v)) : `${Math.round(v * 100)}%`}`
}
describe={(v) => describeFx(s.fx, v, fxSettings)}
/>
</div>
)