import { useEffect, useState } from 'react' import { useQuery, useQueryClient } from '@tanstack/react-query' import { api } from '../api' import { Modal } from './Modal' /** * Settings → Konduktor: preferences about the app itself rather than about a * library or a feature (those have their own entries in the gear menu). Each * setting is a pref in userprefs.json, written as soon as it is changed. */ /** The prefs this dialog owns, and what each is when never set. */ export const APP_SETTING_DEFAULTS = { expandPlaylistFolders: false, /** Read by the backend when an export runs (`main.run_export`). */ exportRootFolder: false, /** Decimal places on the deck's ELAPSED / REMAIN readouts (0–3). */ timeReadoutDecimals: 1, /** Normalize's defaults (each run can change them): the measure brought to * the target, and the true-peak ceiling a raise stops at. */ levelMeasure: 'lufs' as 'lufs' | 'rms', levelTarget: -9, levelCeiling: -1, // 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, /** A deck's keylock starts on. */ keylockDefault: 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). * Default halfway: both channels full across the middle, fading over the * outer half of the travel each (decided 2026-11-03). */ crossfaderSharpness: 0.5, /** 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 /** One app setting, read from the shared ['prefs'] query (the default until it loads). */ export function useAppSetting(key: K): (typeof APP_SETTING_DEFAULTS)[K] { const prefs = useQuery({ queryKey: ['prefs'], queryFn: api.getPrefs }).data const v = prefs?.[key] return typeof v === typeof APP_SETTING_DEFAULTS[key] ? (v as (typeof APP_SETTING_DEFAULTS)[K]) : APP_SETTING_DEFAULTS[key] } export function AppSettings({ onClose }: { onClose: () => void }) { const qc = useQueryClient() const expandFolders = useAppSetting('expandPlaylistFolders') const exportRootFolder = useAppSetting('exportRootFolder') const timeDecimals = useAppSetting('timeReadoutDecimals') const levelMeasure = useAppSetting('levelMeasure') const levelTarget = useAppSetting('levelTarget') const levelCeiling = useAppSetting('levelCeiling') const [error, setError] = useState(null) const set = async (patch: Partial) => { setError(null) try { qc.setQueryData(['prefs'], await api.patchPrefs(patch)) } catch (e) { setError((e as Error).message) } } return (

Konduktor settings

Sidebar

Exports

Deck

Normalize

The defaults Mastering ▸ Normalize… starts from; each run can change them.
{error &&
{error}
}
) } export function Check({ checked, onChange, title, text }: { checked: boolean; onChange: (v: boolean) => void; title: string; text: string }) { return ( ) } /** 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. */ export function Choice({ title, value, options, onChange }: { title: string; value: string; options: [string, string][]; onChange: (v: string) => void }) { return ( ) } /** 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 }) { const [text, setText] = useState(String(value)) useEffect(() => setText(String(value)), [value]) const commit = () => { const v = Number(text.replace(',', '.')) if (!Number.isFinite(v)) return setText(String(value)) const clamped = Math.min(max, Math.max(min, Math.round(v * 10) / 10)) setText(String(clamped)) if (clamped !== value) onCommit(clamped) } return ( setText(e.target.value)} onBlur={commit} onKeyDown={(e) => e.key === 'Enter' && (e.target as HTMLInputElement).blur()} /> {unit} ) }