import React from 'react'; import { RotateCcw } from 'lucide-react'; import type { TFunction } from 'i18next'; import { useAuthStore } from '../../../store/authStore'; import { DEFAULT_LOUDNESS_PRE_ANALYSIS_ATTENUATION_DB } from '../../../store/authStoreDefaults'; import { LoudnessLufsButtonGroup } from '../LoudnessLufsButtonGroup'; interface Props { preAnalysisEffectiveDb: number; t: TFunction; } /** * Normalization engine picker (Off / ReplayGain / LUFS) plus the * engine-specific configuration blocks. * * - ReplayGain → mode (auto/track/album), pre-gain slider, fallback gain. * `auto` mode toggles between track/album based on what the playlist * provides; the help line explains that. * - Loudness → target LUFS button group + pre-analysis attenuation slider * with reset-to-default. The effective dB readout reflects how much * headroom is being applied for the current target. * * Switching engines clears the other engine's enabled flag so only one * can be live at a time. */ export function NormalizationBlock({ preAnalysisEffectiveDb, t }: Props) { const auth = useAuthStore(); return ( <>
{t('settings.normalization', { defaultValue: 'Normalization' })}
{t('settings.normalizationDesc')}
{auth.normalizationEngine === 'replaygain' && (
{t('settings.replayGainMode')}
{auth.replayGainMode === 'auto' && (
{t('settings.replayGainAutoDesc')}
)}
{t('settings.replayGainPreGain')} auth.setReplayGainPreGainDb(Number(e.target.value))} /> {auth.replayGainPreGainDb > 0 ? `+${auth.replayGainPreGainDb}` : auth.replayGainPreGainDb} dB
{t('settings.replayGainPreGainDesc')}
{t('settings.replayGainFallback')} auth.setReplayGainFallbackDb(Number(e.target.value))} /> {auth.replayGainFallbackDb > 0 ? `+${auth.replayGainFallbackDb}` : auth.replayGainFallbackDb} dB
{t('settings.replayGainFallbackDesc')}
)} {auth.normalizationEngine === 'loudness' && (
{t('settings.loudnessTargetLufs')}
{t('settings.loudnessTargetLufsDesc')}
{t('settings.loudnessPreAnalysisAttenuation')} auth.setLoudnessPreAnalysisAttenuationDb(Number(e.target.value))} /> {preAnalysisEffectiveDb} dB
{t('settings.loudnessPreAnalysisAttenuationDesc')}{' '} {t('settings.loudnessPreAnalysisAttenuationRef', { ref: auth.loudnessPreAnalysisAttenuationDb, eff: preAnalysisEffectiveDb, tgt: auth.loudnessTargetLufs, })}
{t('settings.loudnessFirstPlayNote')}
)} ); }