Autogain is now a toggleable performance setting

This commit is contained in:
patben8 committed 2026-11-03 12:18:34 +01:00
1 parent 5d1bfcf7f1
commit f55b8f06e4
5 files changed
+36 -10

No files matched your search

+2
View File
@@ -30,6 +30,8 @@ export const APP_SETTING_DEFAULTS = {
keylockDefault: true,
/** Any press on a deck focuses it (else only its A/B badge). */
autoFocusDeck: true,
/** A channel's gain starts at the track's auto gain (else 0 dB). */
useAutoGain: true,
/** EQ full left kills the band (else -26 dB, DJM-style). */
eqKill: false,
/** The crossfader curve: 0 smooth (constant power) .. 1 sharp (a cut).
@@ -38,6 +38,7 @@ export function PerformanceSettings({ onClose }: { onClose: () => void }) {
const perfStems = useAppSetting('perfStems')
const keylockDefault = useAppSetting('keylockDefault')
const autoFocusDeck = useAppSetting('autoFocusDeck')
const useAutoGain = useAppSetting('useAutoGain')
const eqKill = useAppSetting('eqKill')
const sharpnessSetting = useAppSetting('crossfaderSharpness')
const fxFilterRange = useAppSetting('fxFilterRange')
@@ -104,6 +105,12 @@ export function PerformanceSettings({ onClose }: { onClose: () => void }) {
</section>
<section className="space-y-2">
<h3 className={section}>Mixer</h3>
<Check
checked={useAutoGain}
onChange={(v) => void set({ useAutoGain: v })}
title="Use auto gain"
text="Off: every channel starts at 0 dB."
/>
<Choice
title="EQ full left"
value={eqKill ? 'kill' : 'cut'}
+5 -3
View File
@@ -188,8 +188,10 @@ export function PrepStrip({
useEffect(() => mixer().setActive(performance), [performance])
const gainA = decks.A.track?.auto_gain_db ?? null
const gainB = decks.B.track?.auto_gain_db ?? null
useEffect(() => mixer().setAutoGain('A', gainA ?? 0), [gainA])
useEffect(() => mixer().setAutoGain('B', gainB ?? 0), [gainB])
// The `useAutoGain` setting off: every channel starts at 0 dB.
const useAutoGain = useAppSetting('useAutoGain')
useEffect(() => mixer().setAutoGain('A', useAutoGain ? (gainA ?? 0) : 0), [gainA, useAutoGain])
useEffect(() => mixer().setAutoGain('B', useAutoGain ? (gainB ?? 0) : 0), [gainB, useAutoGain])
const bpmA = (a.activeMarker?.bpm ?? 0) * a.rate
const bpmB = (b.activeMarker?.bpm ?? 0) * b.rate
useEffect(() => mixer().setTempo('A', bpmA), [bpmA])
@@ -355,7 +357,7 @@ export function PrepStrip({
</>,
'flex min-w-0 flex-1 flex-col gap-2',
)}
<MixerPanel autoGain={{ A: gainA, B: gainB }} />
<MixerPanel autoGain={{ A: gainA, B: gainB }} autoGainOn={useAutoGain} />
{pane(
'B',
<>
+19 -5
View File
@@ -64,7 +64,14 @@ function beatsLabel(b: number): string {
* them the master meter and the limiter's light; the crossfader beneath. The
* values live in `mixerState` and the audio in `mixer.ts`.
*/
export function MixerPanel({ autoGain }: { autoGain: Record<Channel, number | null> }) {
export function MixerPanel({
autoGain,
autoGainOn,
}: {
autoGain: Record<Channel, number | null>
/** The `useAutoGain` setting: off, the gain ignores the track's. */
autoGainOn: boolean
}) {
const meterRefs = {
A: useRef<HTMLDivElement>(null),
B: useRef<HTMLDivElement>(null),
@@ -109,7 +116,7 @@ export function MixerPanel({ autoGain }: { autoGain: Record<Channel, number | nu
return (
<div className="well flex w-[26rem] shrink-0 flex-col gap-1.5 rounded-2xl px-2.5 pb-1.5 pt-2.5">
<div className="flex min-h-0 flex-1 items-stretch gap-2">
<Strip ch="A" autoGain={autoGain.A} meterRef={meterRefs.A} />
<Strip ch="A" autoGain={autoGainOn ? autoGain.A : undefined} meterRef={meterRefs.A} />
<div className="flex w-3 flex-col items-center gap-1" title="Master — after the limiter">
<MeterBar fillRef={meterRefs.master} />
<span
@@ -121,7 +128,7 @@ export function MixerPanel({ autoGain }: { autoGain: Record<Channel, number | nu
LIM
</span>
</div>
<Strip ch="B" autoGain={autoGain.B} meterRef={meterRefs.B} mirrored />
<Strip ch="B" autoGain={autoGainOn ? autoGain.B : undefined} meterRef={meterRefs.B} mirrored />
</div>
<div className="flex h-6 shrink-0 items-center justify-center gap-2 px-1">
<span className="font-mono text-[11px] font-semibold text-muted">A</span>
@@ -162,7 +169,8 @@ function Strip({
mirrored = false,
}: {
ch: Channel
autoGain: number | null
/** The track's auto gain; null = it has none, undefined = the setting is off. */
autoGain: number | null | undefined
meterRef: RefObject<HTMLDivElement | null>
mirrored?: boolean
}) {
@@ -207,7 +215,13 @@ function Strip({
onChange={(v) => set({ trim: Math.abs(v) < 0.3 ? 0 : v })}
label="Gain"
describe={(v) =>
`Gain ${fmtDb(v)}${autoGain != null ? ` on the track's auto gain (${fmtDb(autoGain)})` : ' (this track has no auto gain)'}`
`Gain ${fmtDb(v)}${
autoGain === undefined
? ' (auto gain off)'
: autoGain != null
? ` on the track's auto gain (${fmtDb(autoGain)})`
: ' (this track has no auto gain)'
}`
}
/>
{eq('high', 'Hi', 'High')}