mirror of
https://github.com/cookiengineer/audacity
synced 2025-07-12 14:47:43 +02:00
Add output gain control to Wahwah effect
This commit is contained in:
parent
9bbbf555c5
commit
193c2c839c
@ -34,17 +34,19 @@ enum
|
|||||||
ID_Phase,
|
ID_Phase,
|
||||||
ID_Depth,
|
ID_Depth,
|
||||||
ID_Res,
|
ID_Res,
|
||||||
ID_FreqOfs
|
ID_FreqOfs,
|
||||||
|
ID_OutGain
|
||||||
};
|
};
|
||||||
|
|
||||||
// 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( Freq, double, XO("Freq"), 1.5, 0.1, 4.0, 10 );
|
Param( Freq, double, XO("Freq"), 1.5, 0.1, 4.0, 10 );
|
||||||
Param( Phase, double, XO("Phase"), 0.0, 0.0, 359.0, 1 );
|
Param( Phase, double, XO("Phase"), 0.0, 0.0, 360.0, 1 );
|
||||||
Param( Depth, int, XO("Depth"), 70, 0, 100, 1 ); // scaled to 0-1 before processing
|
Param( Depth, int, XO("Depth"), 70, 0, 100, 1 ); // scaled to 0-1 before processing
|
||||||
Param( Res, double, XO("Resonance"), 2.5, 0.1, 10.0, 10 );
|
Param( Res, double, XO("Resonance"), 2.5, 0.1, 10.0, 10 );
|
||||||
Param( FreqOfs, int, XO("Offset"), 30, 0, 100, 1 ); // scaled to 0-1 before processing
|
Param( FreqOfs, int, XO("Offset"), 30, 0, 100, 1 ); // scaled to 0-1 before processing
|
||||||
|
Param( OutGain, double, XO("Gain"), -6.0, -30.0, 30.0, 1 );
|
||||||
|
|
||||||
// How many samples are processed before recomputing the lfo value again
|
// How many samples are processed before recomputing the lfo value again
|
||||||
#define lfoskipsamples 30
|
#define lfoskipsamples 30
|
||||||
@ -62,11 +64,13 @@ BEGIN_EVENT_TABLE(EffectWahwah, wxEvtHandler)
|
|||||||
EVT_SLIDER(ID_Depth, EffectWahwah::OnDepthSlider)
|
EVT_SLIDER(ID_Depth, EffectWahwah::OnDepthSlider)
|
||||||
EVT_SLIDER(ID_Res, EffectWahwah::OnResonanceSlider)
|
EVT_SLIDER(ID_Res, EffectWahwah::OnResonanceSlider)
|
||||||
EVT_SLIDER(ID_FreqOfs, EffectWahwah::OnFreqOffSlider)
|
EVT_SLIDER(ID_FreqOfs, EffectWahwah::OnFreqOffSlider)
|
||||||
|
EVT_SLIDER(ID_OutGain, EffectWahwah::OnGainSlider)
|
||||||
EVT_TEXT(ID_Freq, EffectWahwah::OnFreqText)
|
EVT_TEXT(ID_Freq, EffectWahwah::OnFreqText)
|
||||||
EVT_TEXT(ID_Phase, EffectWahwah::OnPhaseText)
|
EVT_TEXT(ID_Phase, EffectWahwah::OnPhaseText)
|
||||||
EVT_TEXT(ID_Depth, EffectWahwah::OnDepthText)
|
EVT_TEXT(ID_Depth, EffectWahwah::OnDepthText)
|
||||||
EVT_TEXT(ID_Res, EffectWahwah::OnResonanceText)
|
EVT_TEXT(ID_Res, EffectWahwah::OnResonanceText)
|
||||||
EVT_TEXT(ID_FreqOfs, EffectWahwah::OnFreqOffText)
|
EVT_TEXT(ID_FreqOfs, EffectWahwah::OnFreqOffText)
|
||||||
|
EVT_TEXT(ID_OutGain, EffectWahwah::OnGainText)
|
||||||
END_EVENT_TABLE();
|
END_EVENT_TABLE();
|
||||||
|
|
||||||
EffectWahwah::EffectWahwah()
|
EffectWahwah::EffectWahwah()
|
||||||
@ -76,6 +80,7 @@ EffectWahwah::EffectWahwah()
|
|||||||
mDepth = DEF_Depth;
|
mDepth = DEF_Depth;
|
||||||
mRes = DEF_Res;
|
mRes = DEF_Res;
|
||||||
mFreqOfs = DEF_FreqOfs;
|
mFreqOfs = DEF_FreqOfs;
|
||||||
|
mOutGain = DEF_OutGain;
|
||||||
|
|
||||||
SetLinearEffectFlag(true);
|
SetLinearEffectFlag(true);
|
||||||
}
|
}
|
||||||
@ -184,6 +189,7 @@ bool EffectWahwah::GetAutomationParameters(EffectAutomationParameters & parms)
|
|||||||
parms.Write(KEY_Depth, mDepth);
|
parms.Write(KEY_Depth, mDepth);
|
||||||
parms.Write(KEY_Res, mRes);
|
parms.Write(KEY_Res, mRes);
|
||||||
parms.Write(KEY_FreqOfs, mFreqOfs);
|
parms.Write(KEY_FreqOfs, mFreqOfs);
|
||||||
|
parms.Write(KEY_OutGain, mOutGain);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -195,12 +201,14 @@ bool EffectWahwah::SetAutomationParameters(EffectAutomationParameters & parms)
|
|||||||
ReadAndVerifyInt(Depth);
|
ReadAndVerifyInt(Depth);
|
||||||
ReadAndVerifyDouble(Res);
|
ReadAndVerifyDouble(Res);
|
||||||
ReadAndVerifyInt(FreqOfs);
|
ReadAndVerifyInt(FreqOfs);
|
||||||
|
ReadAndVerifyDouble(OutGain);
|
||||||
|
|
||||||
mFreq = Freq;
|
mFreq = Freq;
|
||||||
mPhase = Phase;
|
mPhase = Phase;
|
||||||
mDepth = Depth;
|
mDepth = Depth;
|
||||||
mRes = Res;
|
mRes = Res;
|
||||||
mFreqOfs = FreqOfs;
|
mFreqOfs = FreqOfs;
|
||||||
|
mOutGain = OutGain;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -266,6 +274,16 @@ void EffectWahwah::PopulateOrExchange(ShuttleGui & S)
|
|||||||
mFreqOfsS = S.Id(ID_FreqOfs).AddSlider(wxT(""), DEF_FreqOfs * SCL_FreqOfs, MAX_FreqOfs * SCL_FreqOfs, MIN_FreqOfs * SCL_FreqOfs);
|
mFreqOfsS = S.Id(ID_FreqOfs).AddSlider(wxT(""), DEF_FreqOfs * SCL_FreqOfs, MAX_FreqOfs * SCL_FreqOfs, MIN_FreqOfs * SCL_FreqOfs);
|
||||||
mFreqOfsT->SetName(_("Wah frequency offset in percent"));
|
mFreqOfsT->SetName(_("Wah frequency offset in percent"));
|
||||||
mFreqOfsT->SetMinSize(wxSize(100, -1));
|
mFreqOfsT->SetMinSize(wxSize(100, -1));
|
||||||
|
|
||||||
|
FloatingPointValidator<double> vldoutgain(1, &mOutGain);
|
||||||
|
vldoutgain.SetRange(MIN_OutGain, MAX_OutGain);
|
||||||
|
mOutGainT = S.Id(ID_OutGain).AddTextBox(_("Output gain (dB):"), wxT(""), 12);
|
||||||
|
mOutGainT->SetValidator(vldoutgain);
|
||||||
|
|
||||||
|
S.SetStyle(wxSL_HORIZONTAL);
|
||||||
|
mOutGainS = S.Id(ID_OutGain).AddSlider(wxT(""), DEF_OutGain * SCL_OutGain, MAX_OutGain * SCL_OutGain, MIN_OutGain * SCL_OutGain);
|
||||||
|
mOutGainS->SetName(_("Output gain (dB)"));
|
||||||
|
mOutGainS->SetMinSize(wxSize(100, -1));
|
||||||
}
|
}
|
||||||
S.EndMultiColumn();
|
S.EndMultiColumn();
|
||||||
}
|
}
|
||||||
@ -282,6 +300,7 @@ bool EffectWahwah::TransferDataToWindow()
|
|||||||
mDepthS->SetValue((int) (mDepth * SCL_Depth));
|
mDepthS->SetValue((int) (mDepth * SCL_Depth));
|
||||||
mResS->SetValue((int) (mRes * SCL_Res));
|
mResS->SetValue((int) (mRes * SCL_Res));
|
||||||
mFreqOfsS->SetValue((int) (mFreqOfs * SCL_FreqOfs));
|
mFreqOfsS->SetValue((int) (mFreqOfs * SCL_FreqOfs));
|
||||||
|
mOutGainS->SetValue((int) (mOutGain * SCL_OutGain));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -316,8 +335,8 @@ void EffectWahwah::InstanceInit(EffectWahwahState & data, float sampleRate)
|
|||||||
|
|
||||||
data.depth = mDepth / 100.0;
|
data.depth = mDepth / 100.0;
|
||||||
data.freqofs = mFreqOfs / 100.0;
|
data.freqofs = mFreqOfs / 100.0;
|
||||||
|
|
||||||
data.phase = mPhase * M_PI / 180.0;
|
data.phase = mPhase * M_PI / 180.0;
|
||||||
|
data.outgain = DB_TO_LINEAR(mOutGain);
|
||||||
}
|
}
|
||||||
|
|
||||||
sampleCount EffectWahwah::InstanceProcess(EffectWahwahState & data, float **inBlock, float **outBlock, sampleCount blockLen)
|
sampleCount EffectWahwah::InstanceProcess(EffectWahwahState & data, float **inBlock, float **outBlock, sampleCount blockLen)
|
||||||
@ -332,6 +351,7 @@ sampleCount EffectWahwah::InstanceProcess(EffectWahwahState & data, float **inBl
|
|||||||
data.freqofs = mFreqOfs / 100.0;
|
data.freqofs = mFreqOfs / 100.0;
|
||||||
|
|
||||||
data.phase = mPhase * M_PI / 180.0;
|
data.phase = mPhase * M_PI / 180.0;
|
||||||
|
data.outgain = DB_TO_LINEAR(mOutGain);
|
||||||
|
|
||||||
for (int i = 0; i < blockLen; i++)
|
for (int i = 0; i < blockLen; i++)
|
||||||
{
|
{
|
||||||
@ -358,6 +378,7 @@ sampleCount EffectWahwah::InstanceProcess(EffectWahwahState & data, float **inBl
|
|||||||
data.xn1 = in;
|
data.xn1 = in;
|
||||||
data.yn2 = data.yn1;
|
data.yn2 = data.yn1;
|
||||||
data.yn1 = out;
|
data.yn1 = out;
|
||||||
|
out *= data.outgain;
|
||||||
|
|
||||||
obuf[i] = (float) out;
|
obuf[i] = (float) out;
|
||||||
}
|
}
|
||||||
@ -403,6 +424,13 @@ void EffectWahwah::OnFreqOffSlider(wxCommandEvent & evt)
|
|||||||
EnableApply(mUIParent->Validate());
|
EnableApply(mUIParent->Validate());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EffectWahwah::OnGainSlider(wxCommandEvent & evt)
|
||||||
|
{
|
||||||
|
mOutGain = evt.GetInt() / SCL_OutGain;
|
||||||
|
mOutGainT->GetValidator()->TransferToWindow();
|
||||||
|
EnableApply(mUIParent->Validate());
|
||||||
|
}
|
||||||
|
|
||||||
void EffectWahwah::OnFreqText(wxCommandEvent & WXUNUSED(evt))
|
void EffectWahwah::OnFreqText(wxCommandEvent & WXUNUSED(evt))
|
||||||
{
|
{
|
||||||
if (!EnableApply(mUIParent->TransferDataFromWindow()))
|
if (!EnableApply(mUIParent->TransferDataFromWindow()))
|
||||||
@ -452,3 +480,13 @@ void EffectWahwah::OnFreqOffText(wxCommandEvent & WXUNUSED(evt))
|
|||||||
|
|
||||||
mFreqOfsS->SetValue((int) (mFreqOfs * SCL_FreqOfs));
|
mFreqOfsS->SetValue((int) (mFreqOfs * SCL_FreqOfs));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EffectWahwah::OnGainText(wxCommandEvent & WXUNUSED(evt))
|
||||||
|
{
|
||||||
|
if (!EnableApply(mUIParent->TransferDataFromWindow()))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
mOutGainS->SetValue((int) (mOutGain * SCL_OutGain));
|
||||||
|
}
|
||||||
|
@ -34,6 +34,7 @@ public:
|
|||||||
double depth;
|
double depth;
|
||||||
double freqofs;
|
double freqofs;
|
||||||
double phase;
|
double phase;
|
||||||
|
double outgain;
|
||||||
double lfoskip;
|
double lfoskip;
|
||||||
unsigned long skipcount;
|
unsigned long skipcount;
|
||||||
double xn1, xn2, yn1, yn2;
|
double xn1, xn2, yn1, yn2;
|
||||||
@ -91,12 +92,14 @@ private:
|
|||||||
void OnDepthSlider(wxCommandEvent & evt);
|
void OnDepthSlider(wxCommandEvent & evt);
|
||||||
void OnResonanceSlider(wxCommandEvent & evt);
|
void OnResonanceSlider(wxCommandEvent & evt);
|
||||||
void OnFreqOffSlider(wxCommandEvent & evt);
|
void OnFreqOffSlider(wxCommandEvent & evt);
|
||||||
|
void OnGainSlider(wxCommandEvent & evt);
|
||||||
|
|
||||||
void OnFreqText(wxCommandEvent & evt);
|
void OnFreqText(wxCommandEvent & evt);
|
||||||
void OnPhaseText(wxCommandEvent & evt);
|
void OnPhaseText(wxCommandEvent & evt);
|
||||||
void OnDepthText(wxCommandEvent & evt);
|
void OnDepthText(wxCommandEvent & evt);
|
||||||
void OnResonanceText(wxCommandEvent & evt);
|
void OnResonanceText(wxCommandEvent & evt);
|
||||||
void OnFreqOffText(wxCommandEvent & evt);
|
void OnFreqOffText(wxCommandEvent & evt);
|
||||||
|
void OnGainText(wxCommandEvent & evt);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
EffectWahwahState mMaster;
|
EffectWahwahState mMaster;
|
||||||
@ -108,6 +111,7 @@ private:
|
|||||||
mDepth - Wah depth
|
mDepth - Wah depth
|
||||||
mRes - Resonance
|
mRes - Resonance
|
||||||
mFreqOfs - Wah frequency offset
|
mFreqOfs - Wah frequency offset
|
||||||
|
mOutGain - output gain
|
||||||
|
|
||||||
!!!!!!!!!!!!! IMPORTANT!!!!!!!!! :
|
!!!!!!!!!!!!! IMPORTANT!!!!!!!!! :
|
||||||
mDepth and mFreqOfs should be from 0(min) to 1(max) !
|
mDepth and mFreqOfs should be from 0(min) to 1(max) !
|
||||||
@ -118,18 +122,21 @@ private:
|
|||||||
int mDepth;
|
int mDepth;
|
||||||
double mRes;
|
double mRes;
|
||||||
int mFreqOfs;
|
int mFreqOfs;
|
||||||
|
double mOutGain;
|
||||||
|
|
||||||
wxTextCtrl *mFreqT;
|
wxTextCtrl *mFreqT;
|
||||||
wxTextCtrl *mPhaseT;
|
wxTextCtrl *mPhaseT;
|
||||||
wxTextCtrl *mDepthT;
|
wxTextCtrl *mDepthT;
|
||||||
wxTextCtrl *mResT;
|
wxTextCtrl *mResT;
|
||||||
wxTextCtrl *mFreqOfsT;
|
wxTextCtrl *mFreqOfsT;
|
||||||
|
wxTextCtrl *mOutGainT;
|
||||||
|
|
||||||
wxSlider *mFreqS;
|
wxSlider *mFreqS;
|
||||||
wxSlider *mPhaseS;
|
wxSlider *mPhaseS;
|
||||||
wxSlider *mDepthS;
|
wxSlider *mDepthS;
|
||||||
wxSlider *mResS;
|
wxSlider *mResS;
|
||||||
wxSlider *mFreqOfsS;
|
wxSlider *mFreqOfsS;
|
||||||
|
wxSlider *mOutGainS;
|
||||||
|
|
||||||
DECLARE_EVENT_TABLE();
|
DECLARE_EVENT_TABLE();
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user