mirror of
https://github.com/Psychotoxical/psysonic.git
synced 2026-07-22 07:15:47 +00:00
7a7a9f5e6b
111 of 122 top-level src/utils/ files move into 16 topic folders (audio, cache, cover, share, server, playback, playlist, deviceSync, waveform, mix, format, export, changelog, ui, perf, componentHelpers). True singletons with no cluster stay at the utils/ root. Pure file-move: a path-aware codemod rewrote 539 relative-import specifiers across 275 files; no logic touched. The hot-path coverage gate list (.github/frontend-hot-path-files.txt) is updated to the new paths for the 11 gated utils files — a mechanical consequence of the move, not a CI change. tsc is green.
75 lines
2.9 KiB
TypeScript
75 lines
2.9 KiB
TypeScript
import { clampStoredLoudnessPreAnalysisAttenuationRefDb } from '../utils/audio/loudnessPreAnalysisSlider';
|
|
import { DEFAULT_LOUDNESS_PRE_ANALYSIS_ATTENUATION_DB } from './authStoreDefaults';
|
|
import { usePlayerStore } from './playerStore';
|
|
import type { AuthState } from './authStoreTypes';
|
|
|
|
type SetState = (
|
|
partial: Partial<AuthState> | ((state: AuthState) => Partial<AuthState>),
|
|
) => void;
|
|
|
|
/**
|
|
* Audio/playback settings. ReplayGain/normalization/loudness mode
|
|
* toggles call `usePlayerStore.getState().updateReplayGainForCurrentTrack()`
|
|
* so a running track's engine state catches up to the new mode without
|
|
* waiting for the next play. The plain crossfade/gapless/hi-res/output
|
|
* setters skip that — they don't change the gain state, only the
|
|
* neighbouring transitions or device routing.
|
|
*/
|
|
export function createAudioSettingsActions(set: SetState): Pick<
|
|
AuthState,
|
|
| 'setReplayGainEnabled'
|
|
| 'setNormalizationEngine'
|
|
| 'setLoudnessTargetLufs'
|
|
| 'setLoudnessPreAnalysisAttenuationDb'
|
|
| 'resetLoudnessPreAnalysisAttenuationDbDefault'
|
|
| 'setReplayGainMode'
|
|
| 'setReplayGainPreGainDb'
|
|
| 'setReplayGainFallbackDb'
|
|
| 'setCrossfadeEnabled'
|
|
| 'setCrossfadeSecs'
|
|
| 'setGaplessEnabled'
|
|
| 'setEnableHiRes'
|
|
| 'setAudioOutputDevice'
|
|
> {
|
|
return {
|
|
setReplayGainEnabled: (v) => {
|
|
set({ replayGainEnabled: v });
|
|
usePlayerStore.getState().updateReplayGainForCurrentTrack();
|
|
},
|
|
setNormalizationEngine: (v) => {
|
|
set({ normalizationEngine: v });
|
|
usePlayerStore.getState().updateReplayGainForCurrentTrack();
|
|
},
|
|
setLoudnessTargetLufs: (v) => {
|
|
set({ loudnessTargetLufs: v });
|
|
usePlayerStore.getState().updateReplayGainForCurrentTrack();
|
|
},
|
|
setLoudnessPreAnalysisAttenuationDb: (v) => {
|
|
const n = typeof v === 'number' ? v : Number(v);
|
|
if (!Number.isFinite(n)) return;
|
|
set({ loudnessPreAnalysisAttenuationDb: clampStoredLoudnessPreAnalysisAttenuationRefDb(n) });
|
|
},
|
|
resetLoudnessPreAnalysisAttenuationDbDefault: () => {
|
|
set({ loudnessPreAnalysisAttenuationDb: DEFAULT_LOUDNESS_PRE_ANALYSIS_ATTENUATION_DB });
|
|
usePlayerStore.getState().updateReplayGainForCurrentTrack();
|
|
},
|
|
setReplayGainMode: (v) => {
|
|
set({ replayGainMode: v });
|
|
usePlayerStore.getState().updateReplayGainForCurrentTrack();
|
|
},
|
|
setReplayGainPreGainDb: (v) => {
|
|
set({ replayGainPreGainDb: v });
|
|
usePlayerStore.getState().updateReplayGainForCurrentTrack();
|
|
},
|
|
setReplayGainFallbackDb: (v) => {
|
|
set({ replayGainFallbackDb: v });
|
|
usePlayerStore.getState().updateReplayGainForCurrentTrack();
|
|
},
|
|
setCrossfadeEnabled: (v) => set({ crossfadeEnabled: v }),
|
|
setCrossfadeSecs: (v) => set({ crossfadeSecs: v }),
|
|
setGaplessEnabled: (v) => set({ gaplessEnabled: v }),
|
|
setEnableHiRes: (v) => set({ enableHiRes: v }),
|
|
setAudioOutputDevice: (v) => set({ audioOutputDevice: v }),
|
|
};
|
|
}
|