1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-12-16 09:31:14 +01:00

Remove Dry/Wet mix from dynamic compressor effect.

Signed-off-by: Max Maisel <max.maisel@posteo.de>
This commit is contained in:
Max Maisel
2021-02-02 19:30:32 +01:00
parent 4b4fbafb0e
commit 7a23e6a52f
3 changed files with 12 additions and 37 deletions

View File

@@ -4,9 +4,9 @@ stereo = true;
bfile = fopen("/tmp/audio.out"); bfile = fopen("/tmp/audio.out");
if stereo if stereo
width = 15; width = 14;
else else
width = 13; width = 12;
end end
raw_data = reshape(fread(bfile, 'float'), width, []).'; raw_data = reshape(fread(bfile, 'float'), width, []).';
@@ -20,18 +20,17 @@ data.release_time = raw_data(:,5);
data.lookahead_time = raw_data(:,6); data.lookahead_time = raw_data(:,6);
data.lookbehind_time = raw_data(:,7); data.lookbehind_time = raw_data(:,7);
data.makeup_gain_pct = raw_data(:,8); data.makeup_gain_pct = raw_data(:,8);
data.dry_wet_pct = raw_data(:,9);
if stereo if stereo
data.in = horzcat(raw_data(:,10), raw_data(:,11)); data.in = horzcat(raw_data(:,9), raw_data(:,10));
data.env = raw_data(:,12);
data.gain = raw_data(:,13);
data.out = horzcat(raw_data(:,14), raw_data(:,15));
else
data.in = raw_data(:,10);
data.env = raw_data(:,11); data.env = raw_data(:,11);
data.gain = raw_data(:,12); data.gain = raw_data(:,12);
data.out = raw_data(:,13); data.out = horzcat(raw_data(:,13), raw_data(:,14));
else
data.in = raw_data(:,9);
data.env = raw_data(:,10);
data.gain = raw_data(:,11);
data.out = raw_data(:,12);
end end
figure(1); figure(1);
@@ -46,7 +45,6 @@ plot(data.release_time.*10, 'c', "linewidth", 2);
plot(data.lookahead_time, 'm'); plot(data.lookahead_time, 'm');
plot(data.lookbehind_time, 'm'); plot(data.lookbehind_time, 'm');
plot(data.makeup_gain_pct, 'r'); plot(data.makeup_gain_pct, 'r');
plot(data.dry_wet_pct, 'r');
plot(data.env.*100, 'k', "linewidth", 2); plot(data.env.*100, 'k', "linewidth", 2);
plot(data.gain.*50, 'k', "linestyle", '--'); plot(data.gain.*50, 'k', "linestyle", '--');
hold off; hold off;
@@ -55,9 +53,9 @@ grid;
if stereo if stereo
legend("in*100", "in*100", "out*100", "out*100", "threshold", "ratio", ... legend("in*100", "in*100", "out*100", "out*100", "threshold", "ratio", ...
"kneewidth", "attack*10", "release*10", "lookahead", "lookbehind", ... "kneewidth", "attack*10", "release*10", "lookahead", "lookbehind", ...
"makeup", "dry/wet", "env*100", "gain*50"); "makeup", "env*100", "gain*50");
else else
legend("in*100", "out*100", "threshold", "ratio", ... legend("in*100", "out*100", "threshold", "ratio", ...
"kneewidth", "attack*10", "release*10", "lookahead", "lookbehind", ... "kneewidth", "attack*10", "release*10", "lookahead", "lookbehind", ...
"makeup", "dry/wet", "env*100", "gain*50"); "makeup", "env*100", "gain*50");
end end

View File

@@ -90,7 +90,6 @@ Param( ReleaseTime, double, wxT("ReleaseTime"), 1.0, 0.00001, 30.
Param( LookaheadTime, double, wxT("LookaheadTime"), 0.0, 0.0, 10.0, 200.0 ); Param( LookaheadTime, double, wxT("LookaheadTime"), 0.0, 0.0, 10.0, 200.0 );
Param( LookbehindTime, double, wxT("LookbehindTime"), 0.1, 0.0, 10.0, 200.0 ); Param( LookbehindTime, double, wxT("LookbehindTime"), 0.1, 0.0, 10.0, 200.0 );
Param( MakeupGain, double, wxT("MakeupGain"), 0.0, 0.0, 100.0, 1.0 ); Param( MakeupGain, double, wxT("MakeupGain"), 0.0, 0.0, 100.0, 1.0 );
Param( DryWet, double, wxT("DryWet"), 100.0, 0.0, 100.0, 1.0 );
inline int ScaleToPrecision(double scale) inline int ScaleToPrecision(double scale)
{ {
@@ -530,7 +529,6 @@ EffectCompressor2::EffectCompressor2()
mLookaheadTime = DEF_LookaheadTime; mLookaheadTime = DEF_LookaheadTime;
mLookbehindTime = DEF_LookbehindTime; mLookbehindTime = DEF_LookbehindTime;
mMakeupGainPct = DEF_MakeupGain; mMakeupGainPct = DEF_MakeupGain;
mDryWetPct = DEF_DryWet;
SetLinearEffectFlag(false); SetLinearEffectFlag(false);
} }
@@ -665,7 +663,6 @@ bool EffectCompressor2::DefineParams( ShuttleParams & S )
S.SHUTTLE_PARAM(mLookaheadTime, LookaheadTime); S.SHUTTLE_PARAM(mLookaheadTime, LookaheadTime);
S.SHUTTLE_PARAM(mLookbehindTime, LookbehindTime); S.SHUTTLE_PARAM(mLookbehindTime, LookbehindTime);
S.SHUTTLE_PARAM(mMakeupGainPct, MakeupGain); S.SHUTTLE_PARAM(mMakeupGainPct, MakeupGain);
S.SHUTTLE_PARAM(mDryWetPct, DryWet);
return true; return true;
} }
@@ -684,7 +681,6 @@ bool EffectCompressor2::GetAutomationParameters(CommandParameters & parms)
parms.Write(KEY_LookaheadTime, mLookaheadTime); parms.Write(KEY_LookaheadTime, mLookaheadTime);
parms.Write(KEY_LookbehindTime, mLookbehindTime); parms.Write(KEY_LookbehindTime, mLookbehindTime);
parms.Write(KEY_MakeupGain, mMakeupGainPct); parms.Write(KEY_MakeupGain, mMakeupGainPct);
parms.Write(KEY_DryWet, mDryWetPct);
return true; return true;
} }
@@ -703,7 +699,6 @@ bool EffectCompressor2::SetAutomationParameters(CommandParameters & parms)
ReadAndVerifyDouble(LookaheadTime); ReadAndVerifyDouble(LookaheadTime);
ReadAndVerifyDouble(LookbehindTime); ReadAndVerifyDouble(LookbehindTime);
ReadAndVerifyDouble(MakeupGain); ReadAndVerifyDouble(MakeupGain);
ReadAndVerifyDouble(DryWet);
mAlgorithm = Algorithm; mAlgorithm = Algorithm;
mCompressBy = CompressBy; mCompressBy = CompressBy;
@@ -717,7 +712,6 @@ bool EffectCompressor2::SetAutomationParameters(CommandParameters & parms)
mLookaheadTime = LookaheadTime; mLookaheadTime = LookaheadTime;
mLookbehindTime = LookbehindTime; mLookbehindTime = LookbehindTime;
mMakeupGainPct = MakeupGain; mMakeupGainPct = MakeupGain;
mDryWetPct = DryWet;
return true; return true;
} }
@@ -747,7 +741,6 @@ bool EffectCompressor2::Startup()
mLookaheadTime = DEF_LookaheadTime; mLookaheadTime = DEF_LookaheadTime;
mLookbehindTime = DEF_LookbehindTime; mLookbehindTime = DEF_LookbehindTime;
mMakeupGainPct = DEF_MakeupGain; mMakeupGainPct = DEF_MakeupGain;
mDryWetPct = DEF_DryWet;
SaveUserPreset(GetCurrentSettingsGroup()); SaveUserPreset(GetCurrentSettingsGroup());
@@ -962,17 +955,6 @@ void EffectCompressor2::PopulateOrExchange(ShuttleGui & S)
ctrl->SetMinTextboxWidth(textbox_width); ctrl->SetMinTextboxWidth(textbox_width);
S.AddVariableText(XO("%"), true, S.AddVariableText(XO("%"), true,
wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL); wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL);
S.AddVariableText(XO("Dry/Wet:"), true,
wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
ctrl = S.Name(XO("Dry/Wet"))
.Style(SliderTextCtrl::HORIZONTAL)
.AddSliderTextCtrl({}, DEF_DryWet, MAX_DryWet,
MIN_DryWet, ScaleToPrecision(SCL_DryWet),
&mDryWetPct);
ctrl->SetMinTextboxWidth(textbox_width);
S.AddVariableText(XO("%"), true,
wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL);
} }
S.EndMultiColumn(); S.EndMultiColumn();
S.EndVerticalLay(); S.EndVerticalLay();
@@ -1066,7 +1048,6 @@ bool EffectCompressor2::TransferDataFromWindow()
void EffectCompressor2::InitGainCalculation() void EffectCompressor2::InitGainCalculation()
{ {
mDryWet = mDryWetPct / 100.0;
mMakeupGainDB = mMakeupGainPct / 100.0 * mMakeupGainDB = mMakeupGainPct / 100.0 *
-(mThresholdDB * (1.0 - 1.0 / mRatio)); -(mThresholdDB * (1.0 - 1.0 / mRatio));
mMakeupGain = DB_TO_LINEAR(mMakeupGainDB); mMakeupGain = DB_TO_LINEAR(mMakeupGainDB);
@@ -1480,7 +1461,7 @@ inline float EffectCompressor2::EnvelopeSample(PipelineBuffer& pbuf, size_t rp)
inline void EffectCompressor2::CompressSample(float env, size_t wp) inline void EffectCompressor2::CompressSample(float env, size_t wp)
{ {
float gain = (1.0 - mDryWet) + CompressorGain(env) * mDryWet; float gain = CompressorGain(env);
#ifdef DEBUG_COMPRESSOR2_TRACE2 #ifdef DEBUG_COMPRESSOR2_TRACE2
float ThresholdDB = mThresholdDB; float ThresholdDB = mThresholdDB;
@@ -1491,7 +1472,6 @@ inline void EffectCompressor2::CompressSample(float env, size_t wp)
float LookaheadTime = mLookaheadTime; float LookaheadTime = mLookaheadTime;
float LookbehindTime = mLookbehindTime; float LookbehindTime = mLookbehindTime;
float MakeupGainPct = mMakeupGainPct; float MakeupGainPct = mMakeupGainPct;
float DryWetPct = mDryWetPct;
debugfile.write((char*)&ThresholdDB, sizeof(float)); debugfile.write((char*)&ThresholdDB, sizeof(float));
debugfile.write((char*)&Ratio, sizeof(float)); debugfile.write((char*)&Ratio, sizeof(float));
@@ -1501,7 +1481,6 @@ inline void EffectCompressor2::CompressSample(float env, size_t wp)
debugfile.write((char*)&LookaheadTime, sizeof(float)); debugfile.write((char*)&LookaheadTime, sizeof(float));
debugfile.write((char*)&LookbehindTime, sizeof(float)); debugfile.write((char*)&LookbehindTime, sizeof(float));
debugfile.write((char*)&MakeupGainPct, sizeof(float)); debugfile.write((char*)&MakeupGainPct, sizeof(float));
debugfile.write((char*)&DryWetPct, sizeof(float));
debugfile.write((char*)&mPipeline[0][0][wp], sizeof(float)); debugfile.write((char*)&mPipeline[0][0][wp], sizeof(float));
if(mProcStereo) if(mProcStereo)
debugfile.write((char*)&mPipeline[0][1][wp], sizeof(float)); debugfile.write((char*)&mPipeline[0][1][wp], sizeof(float));

View File

@@ -267,10 +267,8 @@ private:
double mLookaheadTime; double mLookaheadTime;
double mLookbehindTime; double mLookbehindTime;
double mMakeupGainPct; double mMakeupGainPct;
double mDryWetPct;
// cached intermediate values // cached intermediate values
double mDryWet;
double mMakeupGain; double mMakeupGain;
double mMakeupGainDB; double mMakeupGainDB;
size_t mLookaheadLength; size_t mLookaheadLength;