mirror of
https://github.com/cookiengineer/audacity
synced 2025-09-19 17:40:51 +02:00
Separated peak and LUFS normalization presets.
This commit is contained in:
parent
58929e4c6c
commit
0ed9b9d34b
@ -33,7 +33,8 @@
|
|||||||
// Define keys, defaults, minimums, and maximums for the effect parameters
|
// Define keys, defaults, minimums, and maximums for the effect parameters
|
||||||
//
|
//
|
||||||
// Name Type Key Def Min Max Scale
|
// Name Type Key Def Min Max Scale
|
||||||
Param( Level, double, wxT("Level"), -23.0, -145.0, 0.0, 1 );
|
Param( PeakLevel, double, wxT("PeakLevel"), -1.0, -145.0, 0.0, 1 );
|
||||||
|
Param( LUFSLevel, double, wxT("LUFSLevel"), -23.0, -145.0, 0.0, 1 );
|
||||||
Param( RemoveDC, bool, wxT("RemoveDcOffset"), true, false, true, 1 );
|
Param( RemoveDC, bool, wxT("RemoveDcOffset"), true, false, true, 1 );
|
||||||
Param( ApplyGain, bool, wxT("ApplyGain"), true, false, true, 1 );
|
Param( ApplyGain, bool, wxT("ApplyGain"), true, false, true, 1 );
|
||||||
Param( StereoInd, bool, wxT("StereoIndependent"), false, false, true, 1 );
|
Param( StereoInd, bool, wxT("StereoIndependent"), false, false, true, 1 );
|
||||||
@ -46,7 +47,8 @@ END_EVENT_TABLE()
|
|||||||
|
|
||||||
EffectNormalize::EffectNormalize()
|
EffectNormalize::EffectNormalize()
|
||||||
{
|
{
|
||||||
mLevel = DEF_Level;
|
mPeakLevel = DEF_PeakLevel;
|
||||||
|
mLUFSLevel = DEF_LUFSLevel;
|
||||||
mDC = DEF_RemoveDC;
|
mDC = DEF_RemoveDC;
|
||||||
mGain = DEF_ApplyGain;
|
mGain = DEF_ApplyGain;
|
||||||
mStereoInd = DEF_StereoInd;
|
mStereoInd = DEF_StereoInd;
|
||||||
@ -85,7 +87,8 @@ EffectType EffectNormalize::GetType()
|
|||||||
|
|
||||||
// EffectClientInterface implementation
|
// EffectClientInterface implementation
|
||||||
bool EffectNormalize::DefineParams( ShuttleParams & S ){
|
bool EffectNormalize::DefineParams( ShuttleParams & S ){
|
||||||
S.SHUTTLE_PARAM( mLevel, Level );
|
S.SHUTTLE_PARAM( mPeakLevel, PeakLevel );
|
||||||
|
S.SHUTTLE_PARAM( mLUFSLevel, LUFSLevel );
|
||||||
S.SHUTTLE_PARAM( mGain, ApplyGain );
|
S.SHUTTLE_PARAM( mGain, ApplyGain );
|
||||||
S.SHUTTLE_PARAM( mDC, RemoveDC );
|
S.SHUTTLE_PARAM( mDC, RemoveDC );
|
||||||
S.SHUTTLE_PARAM( mStereoInd, StereoInd );
|
S.SHUTTLE_PARAM( mStereoInd, StereoInd );
|
||||||
@ -95,7 +98,8 @@ bool EffectNormalize::DefineParams( ShuttleParams & S ){
|
|||||||
|
|
||||||
bool EffectNormalize::GetAutomationParameters(CommandParameters & parms)
|
bool EffectNormalize::GetAutomationParameters(CommandParameters & parms)
|
||||||
{
|
{
|
||||||
parms.Write(KEY_Level, mLevel);
|
parms.Write(KEY_PeakLevel, mPeakLevel);
|
||||||
|
parms.Write(KEY_LUFSLevel, mLUFSLevel);
|
||||||
parms.Write(KEY_ApplyGain, mGain);
|
parms.Write(KEY_ApplyGain, mGain);
|
||||||
parms.Write(KEY_RemoveDC, mDC);
|
parms.Write(KEY_RemoveDC, mDC);
|
||||||
parms.Write(KEY_StereoInd, mStereoInd);
|
parms.Write(KEY_StereoInd, mStereoInd);
|
||||||
@ -106,13 +110,15 @@ bool EffectNormalize::GetAutomationParameters(CommandParameters & parms)
|
|||||||
|
|
||||||
bool EffectNormalize::SetAutomationParameters(CommandParameters & parms)
|
bool EffectNormalize::SetAutomationParameters(CommandParameters & parms)
|
||||||
{
|
{
|
||||||
ReadAndVerifyDouble(Level);
|
ReadAndVerifyDouble(PeakLevel);
|
||||||
|
ReadAndVerifyDouble(LUFSLevel);
|
||||||
ReadAndVerifyBool(ApplyGain);
|
ReadAndVerifyBool(ApplyGain);
|
||||||
ReadAndVerifyBool(RemoveDC);
|
ReadAndVerifyBool(RemoveDC);
|
||||||
ReadAndVerifyBool(StereoInd);
|
ReadAndVerifyBool(StereoInd);
|
||||||
ReadAndVerifyBool(UseLoudness);
|
ReadAndVerifyBool(UseLoudness);
|
||||||
|
|
||||||
mLevel = Level;
|
mPeakLevel = PeakLevel;
|
||||||
|
mLUFSLevel = LUFSLevel;
|
||||||
mGain = ApplyGain;
|
mGain = ApplyGain;
|
||||||
mDC = RemoveDC;
|
mDC = RemoveDC;
|
||||||
mStereoInd = StereoInd;
|
mStereoInd = StereoInd;
|
||||||
@ -147,12 +153,13 @@ bool EffectNormalize::Startup()
|
|||||||
mDC = (boolProxy == 1);
|
mDC = (boolProxy == 1);
|
||||||
boolProxy = gPrefs->Read(base + wxT("Normalize"), 1);
|
boolProxy = gPrefs->Read(base + wxT("Normalize"), 1);
|
||||||
mGain = (boolProxy == 1);
|
mGain = (boolProxy == 1);
|
||||||
gPrefs->Read(base + wxT("Level"), &mLevel, -1.0);
|
gPrefs->Read(base + wxT("Level"), &mPeakLevel, -1.0);
|
||||||
if(mLevel > 0.0) // this should never happen
|
if(mPeakLevel > 0.0) // this should never happen
|
||||||
mLevel = -mLevel;
|
mPeakLevel = -mPeakLevel;
|
||||||
boolProxy = gPrefs->Read(base + wxT("StereoIndependent"), 0L);
|
boolProxy = gPrefs->Read(base + wxT("StereoIndependent"), 0L);
|
||||||
mStereoInd = (boolProxy == 1);
|
mStereoInd = (boolProxy == 1);
|
||||||
mUseLoudness = false;
|
mUseLoudness = false;
|
||||||
|
mLUFSLevel = DEF_LUFSLevel;
|
||||||
|
|
||||||
SaveUserPreset(GetCurrentSettingsGroup());
|
SaveUserPreset(GetCurrentSettingsGroup());
|
||||||
|
|
||||||
@ -175,10 +182,10 @@ bool EffectNormalize::Process()
|
|||||||
if(mUseLoudness)
|
if(mUseLoudness)
|
||||||
// LU use 10*log10(...) instead of 20*log10(...)
|
// LU use 10*log10(...) instead of 20*log10(...)
|
||||||
// so multiply level by 2 and use standard DB_TO_LINEAR macro.
|
// so multiply level by 2 and use standard DB_TO_LINEAR macro.
|
||||||
ratio = DB_TO_LINEAR(TrapDouble(mLevel*2, MIN_Level, MAX_Level));
|
ratio = DB_TO_LINEAR(TrapDouble(mLUFSLevel*2, MIN_LUFSLevel, MAX_LUFSLevel));
|
||||||
else
|
else
|
||||||
// same value used for all tracks
|
// same value used for all tracks
|
||||||
ratio = DB_TO_LINEAR(TrapDouble(mLevel, MIN_Level, MAX_Level));
|
ratio = DB_TO_LINEAR(TrapDouble(mPeakLevel, MIN_PeakLevel, MAX_PeakLevel));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
ratio = 1.0;
|
ratio = 1.0;
|
||||||
@ -319,8 +326,11 @@ void EffectNormalize::PopulateOrExchange(ShuttleGui & S)
|
|||||||
mGain ? wxT("true") : wxT("false"));
|
mGain ? wxT("true") : wxT("false"));
|
||||||
mGainCheckBox->SetValidator(wxGenericValidator(&mGain));
|
mGainCheckBox->SetValidator(wxGenericValidator(&mGain));
|
||||||
|
|
||||||
FloatingPointValidator<double> vldLevel(2, &mLevel, NumValidatorStyle::ONE_TRAILING_ZERO);
|
FloatingPointValidator<double> vldLevel(2, mUseLoudness ? &mLUFSLevel : &mPeakLevel,
|
||||||
vldLevel.SetRange(MIN_Level, MAX_Level);
|
NumValidatorStyle::ONE_TRAILING_ZERO);
|
||||||
|
vldLevel.SetRange(mUseLoudness ? MIN_LUFSLevel : MIN_PeakLevel,
|
||||||
|
mUseLoudness ? MAX_LUFSLevel : MAX_PeakLevel);
|
||||||
|
|
||||||
mLevelTextCtrl = S.AddTextBox( {}, wxT(""), 10);
|
mLevelTextCtrl = S.AddTextBox( {}, wxT(""), 10);
|
||||||
mLevelTextCtrl->SetName(_("Maximum amplitude dB"));
|
mLevelTextCtrl->SetName(_("Maximum amplitude dB"));
|
||||||
mLevelTextCtrl->SetValidator(vldLevel);
|
mLevelTextCtrl->SetValidator(vldLevel);
|
||||||
@ -333,7 +343,7 @@ void EffectNormalize::PopulateOrExchange(ShuttleGui & S)
|
|||||||
|
|
||||||
mUseLoudnessCheckBox = S.AddCheckBox(_("Use integrative loudness instead of maximum amplitude"),
|
mUseLoudnessCheckBox = S.AddCheckBox(_("Use integrative loudness instead of maximum amplitude"),
|
||||||
mUseLoudness ? wxT("true") : wxT("false"));
|
mUseLoudness ? wxT("true") : wxT("false"));
|
||||||
mUseLoudnessCheckBox->SetValidator(wxGenericValidator(&mUseLoudness));
|
mUseLoudnessCheckBox->SetValidator(wxGenericValidator(&mGUIUseLoudness));
|
||||||
|
|
||||||
mStereoIndCheckBox = S.AddCheckBox(_("Normalize stereo channels independently"),
|
mStereoIndCheckBox = S.AddCheckBox(_("Normalize stereo channels independently"),
|
||||||
mStereoInd ? wxT("true") : wxT("false"));
|
mStereoInd ? wxT("true") : wxT("false"));
|
||||||
@ -678,10 +688,26 @@ void EffectNormalize::UpdateUI()
|
|||||||
}
|
}
|
||||||
mWarning->SetLabel(wxT(""));
|
mWarning->SetLabel(wxT(""));
|
||||||
|
|
||||||
if (mUseLoudness)
|
if (mUseLoudness != mGUIUseLoudness)
|
||||||
mLeveldB->SetLabel(_("LUFS"));
|
{
|
||||||
else
|
mUseLoudness = mGUIUseLoudness;
|
||||||
mLeveldB->SetLabel(_("dB"));
|
if (mUseLoudness)
|
||||||
|
{
|
||||||
|
FloatingPointValidator<double> vldLevel(2, &mLUFSLevel, NumValidatorStyle::ONE_TRAILING_ZERO);
|
||||||
|
vldLevel.SetRange(MIN_LUFSLevel, MAX_LUFSLevel);
|
||||||
|
mLevelTextCtrl->SetValidator(vldLevel);
|
||||||
|
mLevelTextCtrl->SetValue(wxString::FromDouble(mLUFSLevel));
|
||||||
|
mLeveldB->SetLabel(_("LUFS"));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
FloatingPointValidator<double> vldLevel(2, &mPeakLevel, NumValidatorStyle::ONE_TRAILING_ZERO);
|
||||||
|
vldLevel.SetRange(MIN_PeakLevel, MAX_PeakLevel);
|
||||||
|
mLevelTextCtrl->SetValidator(vldLevel);
|
||||||
|
mLevelTextCtrl->SetValue(wxString::FromDouble(mPeakLevel));
|
||||||
|
mLeveldB->SetLabel(_("dB"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Disallow level stuff if not normalizing
|
// Disallow level stuff if not normalizing
|
||||||
mLevelTextCtrl->Enable(mGain);
|
mLevelTextCtrl->Enable(mGain);
|
||||||
|
@ -83,11 +83,13 @@ private:
|
|||||||
void UpdateUI();
|
void UpdateUI();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
double mLevel;
|
double mPeakLevel;
|
||||||
|
double mLUFSLevel;
|
||||||
bool mGain;
|
bool mGain;
|
||||||
bool mDC;
|
bool mDC;
|
||||||
bool mStereoInd;
|
bool mStereoInd;
|
||||||
bool mUseLoudness;
|
bool mUseLoudness;
|
||||||
|
bool mGUIUseLoudness;
|
||||||
|
|
||||||
double mCurT0;
|
double mCurT0;
|
||||||
double mCurT1;
|
double mCurT1;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user