Files
psysonic/src/utils/audio/loudnessPlaceholder.ts
T
Frank Stellmacher 7a7a9f5e6b refactor(utils): group utils/ files into topic folders (Phase L, part 1) (#689)
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.
2026-05-14 14:27:44 +02:00

16 lines
587 B
TypeScript

/**
* Before SQLite has integrated LUFS, match Rust `loudness_gain_placeholder_until_cache`:
* pivot at -14 LUFS, `true_peak = 0` (no EBU headroom cap), then add pre-attenuation from settings.
*/
const PLACEHOLDER_INTEGRATED_LUFS = -14;
export function loudnessGainPlaceholderUntilCacheDb(
targetLufs: number,
preAnalysisAttenuationDb: number,
): number {
const pre = Math.min(0, Math.max(-24, preAnalysisAttenuationDb));
let pivot = targetLufs - PLACEHOLDER_INTEGRATED_LUFS;
pivot = Math.max(-24, Math.min(24, pivot));
return Math.max(-24, Math.min(24, pivot + pre));
}