Audacity  3.0.3
Classes | Public Member Functions | Static Public Attributes | Private Types | Private Member Functions | Private Attributes | List of all members
EffectDistortion Class Referencefinal

A WaveShaper distortion effect. More...

#include <Distortion.h>

Inheritance diagram for EffectDistortion:
[legend]
Collaboration diagram for EffectDistortion:
[legend]

Classes

struct  Params
 

Public Member Functions

 EffectDistortion ()
 
virtual ~EffectDistortion ()
 
ComponentInterfaceSymbol GetSymbol () override
 
TranslatableString GetDescription () override
 
wxString ManualPage () override
 
EffectType GetType () override
 
bool SupportsRealtime () override
 
unsigned GetAudioInCount () override
 
unsigned GetAudioOutCount () override
 
bool ProcessInitialize (sampleCount totalLen, ChannelNames chanMap=NULL) override
 
size_t ProcessBlock (float **inBlock, float **outBlock, size_t blockLen) override
 
bool RealtimeInitialize () override
 
bool RealtimeAddProcessor (unsigned numChannels, float sampleRate) override
 
bool RealtimeFinalize () override
 
size_t RealtimeProcess (int group, float **inbuf, float **outbuf, size_t numSamples) override
 
bool DefineParams (ShuttleParams &S) override
 
bool GetAutomationParameters (CommandParameters &parms) override
 
bool SetAutomationParameters (CommandParameters &parms) override
 
RegistryPaths GetFactoryPresets () override
 
bool LoadFactoryPreset (int id) override
 
void PopulateOrExchange (ShuttleGui &S) override
 
bool TransferDataToWindow () override
 
bool TransferDataFromWindow () override
 
- Public Member Functions inherited from Effect
 Effect ()
 
virtual ~Effect ()
 
PluginPath GetPath () override
 
ComponentInterfaceSymbol GetSymbol () override
 
VendorSymbol GetVendor () override
 
wxString GetVersion () override
 
TranslatableString GetDescription () override
 
EffectType GetType () override
 
EffectFamilySymbol GetFamily () override
 
bool IsInteractive () override
 
bool IsDefault () override
 
bool IsLegacy () override
 
bool SupportsRealtime () override
 
bool SupportsAutomation () override
 
bool SetHost (EffectHostInterface *host) override
 
unsigned GetAudioInCount () override
 
unsigned GetAudioOutCount () override
 
int GetMidiInCount () override
 
int GetMidiOutCount () override
 
sampleCount GetLatency () override
 
size_t GetTailSize () override
 
void SetSampleRate (double rate) override
 
size_t SetBlockSize (size_t maxBlockSize) override
 
size_t GetBlockSize () const override
 
bool IsReady () override
 
bool ProcessInitialize (sampleCount totalLen, ChannelNames chanMap=NULL) override
 
bool ProcessFinalize () override
 
size_t ProcessBlock (float **inBlock, float **outBlock, size_t blockLen) override
 
bool RealtimeInitialize () override
 
bool RealtimeAddProcessor (unsigned numChannels, float sampleRate) override
 
bool RealtimeFinalize () override
 
bool RealtimeSuspend () override
 
bool RealtimeResume () override
 
bool RealtimeProcessStart () override
 
size_t RealtimeProcess (int group, float **inbuf, float **outbuf, size_t numSamples) override
 
bool RealtimeProcessEnd () override
 
bool ShowInterface (wxWindow &parent, const EffectDialogFactory &factory, bool forceModal=false) override
 
bool GetAutomationParameters (CommandParameters &parms) override
 
bool SetAutomationParameters (CommandParameters &parms) override
 
bool LoadUserPreset (const RegistryPath &name) override
 
bool SaveUserPreset (const RegistryPath &name) override
 
RegistryPaths GetFactoryPresets () override
 
bool LoadFactoryPreset (int id) override
 
bool LoadFactoryDefaults () override
 
void SetHostUI (EffectUIHostInterface *host) override
 
bool PopulateUI (ShuttleGui &S) final
 
bool IsGraphicalUI () override
 
bool ValidateUI () override
 
bool HideUI () override
 
bool CloseUI () override
 
bool CanExportPresets () override
 
void ExportPresets () override
 
void ImportPresets () override
 
bool HasOptions () override
 
void ShowOptions () override
 
double GetDefaultDuration () override
 
double GetDuration () override
 
NumericFormatSymbol GetDurationFormat () override
 
virtual NumericFormatSymbol GetSelectionFormat ()
 
void SetDuration (double duration) override
 
RegistryPath GetUserPresetsGroup (const RegistryPath &name) override
 
RegistryPath GetCurrentSettingsGroup () override
 
RegistryPath GetFactoryDefaultsGroup () override
 
virtual wxString GetSavedStateGroup ()
 
bool HasSharedConfigGroup (const RegistryPath &group) override
 
bool GetSharedConfigSubgroups (const RegistryPath &group, RegistryPaths &subgroups) override
 
bool GetSharedConfig (const RegistryPath &group, const RegistryPath &key, wxString &value, const wxString &defval={}) override
 
bool GetSharedConfig (const RegistryPath &group, const RegistryPath &key, int &value, int defval=0) override
 
bool GetSharedConfig (const RegistryPath &group, const RegistryPath &key, bool &value, bool defval=false) override
 
bool GetSharedConfig (const RegistryPath &group, const RegistryPath &key, float &value, float defval=0.0) override
 
bool GetSharedConfig (const RegistryPath &group, const RegistryPath &key, double &value, double defval=0.0) override
 
bool SetSharedConfig (const RegistryPath &group, const RegistryPath &key, const wxString &value) override
 
bool SetSharedConfig (const RegistryPath &group, const RegistryPath &key, const int &value) override
 
bool SetSharedConfig (const RegistryPath &group, const RegistryPath &key, const bool &value) override
 
bool SetSharedConfig (const RegistryPath &group, const RegistryPath &key, const float &value) override
 
bool SetSharedConfig (const RegistryPath &group, const RegistryPath &key, const double &value) override
 
bool RemoveSharedConfigSubgroup (const RegistryPath &group) override
 
bool RemoveSharedConfig (const RegistryPath &group, const RegistryPath &key) override
 
bool HasPrivateConfigGroup (const RegistryPath &group) override
 
bool GetPrivateConfigSubgroups (const RegistryPath &group, RegistryPaths &paths) override
 
bool GetPrivateConfig (const RegistryPath &group, const RegistryPath &key, wxString &value, const wxString &defval={}) override
 
bool GetPrivateConfig (const RegistryPath &group, const RegistryPath &key, int &value, int defval=0) override
 
bool GetPrivateConfig (const RegistryPath &group, const RegistryPath &key, bool &value, bool defval=false) override
 
bool GetPrivateConfig (const RegistryPath &group, const RegistryPath &key, float &value, float defval=0.0) override
 
bool GetPrivateConfig (const RegistryPath &group, const RegistryPath &key, double &value, double defval=0.0) override
 
bool SetPrivateConfig (const RegistryPath &group, const RegistryPath &key, const wxString &value) override
 
bool SetPrivateConfig (const RegistryPath &group, const RegistryPath &key, const int &value) override
 
bool SetPrivateConfig (const RegistryPath &group, const RegistryPath &key, const bool &value) override
 
bool SetPrivateConfig (const RegistryPath &group, const RegistryPath &key, const float &value) override
 
bool SetPrivateConfig (const RegistryPath &group, const RegistryPath &key, const double &value) override
 
bool RemovePrivateConfigSubgroup (const RegistryPath &group) override
 
bool RemovePrivateConfig (const RegistryPath &group, const RegistryPath &key) override
 
virtual PluginID GetID ()
 
virtual bool Startup (EffectClientInterface *client)
 
virtual bool Startup ()
 
virtual bool GetAutomationParameters (wxString &parms)
 
virtual bool SetAutomationParameters (const wxString &parms)
 
virtual RegistryPaths GetUserPresets ()
 
virtual bool HasCurrentSettings ()
 
virtual bool HasFactoryDefaults ()
 
virtual wxString HelpPage ()
 
virtual void SetUIFlags (unsigned flags)
 
virtual unsigned TestUIFlags (unsigned mask)
 
virtual bool IsBatchProcessing ()
 
virtual void SetBatchProcessing (bool start)
 
void SetPresetParameters (const wxArrayString *Names, const wxArrayString *Values)
 
bool DoEffect (double projectRate, TrackList *list, WaveTrackFactory *factory, NotifyingSelectedRegion &selectedRegion, wxWindow *pParent=nullptr, const EffectDialogFactory &dialogFactory={})
 
bool Delegate (Effect &delegate, wxWindow &parent, const EffectDialogFactory &factory)
 
virtual bool IsHidden ()
 
int MessageBox (const TranslatableString &message, long style=DefaultMessageBoxStyle, const TranslatableString &titleStr={})
 
- Public Member Functions inherited from EffectClientInterface
virtual ~EffectClientInterface ()
 
- Public Member Functions inherited from EffectDefinitionInterface
virtual ~EffectDefinitionInterface ()
 
virtual EffectType GetClassification ()
 
- Public Member Functions inherited from ComponentInterface
virtual ~ComponentInterface ()
 
TranslatableString GetName ()
 
virtual bool DefineParams (ShuttleParams &WXUNUSED(S))
 
- Public Member Functions inherited from EffectUIClientInterface
virtual ~EffectUIClientInterface ()
 
- Public Member Functions inherited from EffectHostInterface
virtual ~EffectHostInterface ()
 
- Public Member Functions inherited from ConfigClientInterface
virtual ~ConfigClientInterface ()
 

Static Public Attributes

static const ComponentInterfaceSymbol Symbol { XO("Distortion") }
 
- Static Public Attributes inherited from Effect
static const wxString kUserPresetIdent = wxT("User Preset:")
 
static const wxString kFactoryPresetIdent = wxT("Factory Preset:")
 
static const wxString kCurrentSettingsIdent = wxT("<Current Settings>")
 
static const wxString kFactoryDefaultsIdent = wxT("<Factory Defaults>")
 

Private Types

enum  control {
  ID_Type = 10000, ID_DCBlock, ID_Threshold, ID_NoiseFloor,
  ID_Param1, ID_Param2, ID_Repeats
}
 

Private Member Functions

void InstanceInit (EffectDistortionState &data, float sampleRate)
 
size_t InstanceProcess (EffectDistortionState &data, float **inBlock, float **outBlock, size_t blockLen)
 
void OnTypeChoice (wxCommandEvent &evt)
 
void OnDCBlockCheckbox (wxCommandEvent &evt)
 
void OnThresholdText (wxCommandEvent &evt)
 
void OnThresholdSlider (wxCommandEvent &evt)
 
void OnNoiseFloorText (wxCommandEvent &evt)
 
void OnNoiseFloorSlider (wxCommandEvent &evt)
 
void OnParam1Text (wxCommandEvent &evt)
 
void OnParam1Slider (wxCommandEvent &evt)
 
void OnParam2Text (wxCommandEvent &evt)
 
void OnParam2Slider (wxCommandEvent &evt)
 
void OnRepeatsText (wxCommandEvent &evt)
 
void OnRepeatsSlider (wxCommandEvent &evt)
 
void UpdateUI ()
 
void UpdateControl (control id, bool enable, TranslatableString name)
 
void UpdateControlText (wxTextCtrl *textCtrl, wxString &string, bool enabled)
 
void MakeTable ()
 
float WaveShaper (float sample)
 
float DCFilter (EffectDistortionState &data, float sample)
 
void HardClip ()
 
void SoftClip ()
 
void ExponentialTable ()
 
void LogarithmicTable ()
 
void HalfSinTable ()
 
void CubicTable ()
 
void EvenHarmonicTable ()
 
void SineTable ()
 
void Leveller ()
 
void Rectifier ()
 
void HardLimiter ()
 
void CopyHalfTable ()
 
float LogCurve (double threshold, float value, double ratio)
 
double Cubic (double x)
 

Private Attributes

EffectDistortionState mMaster
 
std::vector< EffectDistortionStatemSlaves
 
double mTable [TABLESIZE]
 
double mThreshold
 
bool mbSavedFilterState
 
double mMakeupGain
 
int mTypChoiceIndex
 
wxChoice * mTypeChoiceCtrl
 
wxTextCtrl * mThresholdT
 
wxTextCtrl * mNoiseFloorT
 
wxTextCtrl * mParam1T
 
wxTextCtrl * mParam2T
 
wxTextCtrl * mRepeatsT
 
wxSlider * mThresholdS
 
wxSlider * mNoiseFloorS
 
wxSlider * mParam1S
 
wxSlider * mParam2S
 
wxSlider * mRepeatsS
 
wxCheckBox * mDCBlockCheckBox
 
wxStaticText * mThresholdTxt
 
wxStaticText * mNoiseFloorTxt
 
wxStaticText * mParam1Txt
 
wxStaticText * mParam2Txt
 
wxStaticText * mRepeatsTxt
 
wxString mOldThresholdTxt
 
wxString mOldmNoiseFloorTxt
 
wxString mOldParam1Txt
 
wxString mOldParam2Txt
 
wxString mOldRepeatsTxt
 
Params mParams
 

Additional Inherited Members

- Public Types inherited from Effect
enum  : long { DefaultMessageBoxStyle = wxOK | wxCENTRE }
 
using VetoDialogHook = bool(*)(wxDialog *)
 
- Public Types inherited from EffectClientInterface
using EffectDialogFactory = std::function< wxDialog *(wxWindow &parent, EffectHostInterface *, EffectUIClientInterface *) >
 
- Static Public Member Functions inherited from Effect
static VetoDialogHook SetVetoDialogHook (VetoDialogHook hook)
 
static CommandID GetSquashedName (wxString name)
 
static void IncEffectCounter ()
 
- Protected Member Functions inherited from Effect
virtual bool Init ()
 
virtual bool CheckWhetherSkipEffect ()
 
virtual bool Process ()
 
virtual bool ProcessPass ()
 
virtual bool InitPass1 ()
 
virtual bool InitPass2 ()
 
virtual int GetPass ()
 
virtual void End ()
 
virtual double CalcPreviewInputLength (double previewLength)
 
virtual void Preview (bool dryOnly)
 
virtual bool EnableApply (bool enable=true)
 
virtual bool EnablePreview (bool enable=true)
 
virtual void EnableDebug (bool enable=true)
 
bool TotalProgress (double frac, const TranslatableString &={})
 
bool TrackProgress (int whichTrack, double frac, const TranslatableString &={})
 
bool TrackGroupProgress (int whichGroup, double frac, const TranslatableString &={})
 
int GetNumWaveTracks ()
 
int GetNumWaveGroups ()
 
void GetBounds (const WaveTrack &track, const WaveTrack *pRight, sampleCount *start, sampleCount *len)
 
void SetLinearEffectFlag (bool linearEffectFlag)
 
void SetPreviewFullSelectionFlag (bool previewDurationFlag)
 
bool IsPreviewing ()
 
void IncludeNotSelectedPreviewTracks (bool includeNotSelected)
 
void CopyInputTracks (bool allSyncLockSelected=false)
 
std::shared_ptr< AddedAnalysisTrackAddAnalysisTrack (const wxString &name=wxString())
 
ModifiedAnalysisTrack ModifyAnalysisTrack (const LabelTrack *pOrigTrack, const wxString &name=wxString())
 
void ReplaceProcessedTracks (const bool bGoodResult)
 
TrackAddToOutputTracks (const std::shared_ptr< Track > &t)
 
const TrackListinputTracks () const
 
const AudacityProjectFindProject () const
 
- Protected Attributes inherited from Effect
ProgressDialogmProgress
 
double mProjectRate
 
double mSampleRate
 
wxWeakRef< NotifyingSelectedRegionmpSelectedRegion {}
 
WaveTrackFactorymFactory
 
std::shared_ptr< TrackListmOutputTracks
 
double mT0
 
double mT1
 
wxArrayString mPresetNames
 
wxArrayString mPresetValues
 
int mPass
 
wxDialog * mUIDialog
 
wxWindow * mUIParent
 
int mUIResultID
 
unsigned mUIFlags
 
sampleCount mSampleCnt
 
- Static Protected Attributes inherited from Effect
static int nEffectsDone =0
 

Detailed Description

A WaveShaper distortion effect.

Definition at line 45 of file Distortion.h.

Member Enumeration Documentation

◆ control

Enumerator
ID_Type 
ID_DCBlock 
ID_Threshold 
ID_NoiseFloor 
ID_Param1 
ID_Param2 
ID_Repeats 

Definition at line 102 of file Distortion.h.

103  {
104  ID_Type = 10000,
105  ID_DCBlock,
106  ID_Threshold,
108  ID_Param1,
109  ID_Param2,
110  ID_Repeats,
111  };

Constructor & Destructor Documentation

◆ EffectDistortion()

EffectDistortion::EffectDistortion ( )

Definition at line 167 of file Distortion.cpp.

168 {
169  wxASSERT(nTableTypes == WXSIZEOF(kTableTypeStrings));
170 
171  mParams.mTableChoiceIndx = DEF_TableTypeIndx;
172  mParams.mDCBlock = DEF_DCBlock;
173  mParams.mThreshold_dB = DEF_Threshold_dB;
175  mParams.mNoiseFloor = DEF_NoiseFloor;
176  mParams.mParam1 = DEF_Param1;
177  mParams.mParam2 = DEF_Param2;
178  mParams.mRepeats = DEF_Repeats;
179  mMakeupGain = 1.0;
180  mbSavedFilterState = DEF_DCBlock;
181 
182  SetLinearEffectFlag(false);
183 }

References DB_TO_LINEAR(), kTableTypeStrings, and nTableTypes.

Here is the call graph for this function:

◆ ~EffectDistortion()

EffectDistortion::~EffectDistortion ( )
virtual

Definition at line 185 of file Distortion.cpp.

186 {
187 }

Member Function Documentation

◆ CopyHalfTable()

void EffectDistortion::CopyHalfTable ( )
private

Definition at line 1277 of file Distortion.cpp.

1278 {
1279  // Copy negative half of table from positive half
1280  int count = TABLESIZE - 1;
1281  for (int n = 0; n < STEPS; n++) {
1282  mTable[n] = -mTable[count];
1283  count--;
1284  }
1285 }

References mTable, STEPS, and TABLESIZE.

Referenced by ExponentialTable(), HalfSinTable(), Leveller(), LogarithmicTable(), SineTable(), and SoftClip().

Here is the caller graph for this function:

◆ Cubic()

double EffectDistortion::Cubic ( double  x)
inlineprivate

Definition at line 1146 of file Distortion.cpp.

1147 {
1148  if (mParams.mParam1 == 0.0)
1149  return x;
1150 
1151  return x - (std::pow(x, 3.0) / 3.0);
1152 }

References EffectDistortion::Params::mParam1, and mParams.

Referenced by CubicTable().

Here is the caller graph for this function:

◆ CubicTable()

void EffectDistortion::CubicTable ( )
private

Definition at line 1120 of file Distortion.cpp.

1121 {
1122  double amount = mParams.mParam1 * std::sqrt(3.0) / 100.0;
1123  double gain = 1.0;
1124  if (amount != 0.0)
1125  gain = 1.0 / Cubic(std::min(amount, 1.0));
1126 
1127  double stepsize = amount / STEPS;
1128  double x = -amount;
1129 
1130  if (amount == 0) {
1131  for (int i = 0; i < TABLESIZE; i++) {
1132  mTable[i] = (i / (double)STEPS) - 1.0;
1133  }
1134  }
1135  else {
1136  for (int i = 0; i < TABLESIZE; i++) {
1137  mTable[i] = gain * Cubic(x);
1138  for (int j = 0; j < mParams.mRepeats; j++) {
1139  mTable[i] = gain * Cubic(mTable[i] * amount);
1140  }
1141  x += stepsize;
1142  }
1143  }
1144 }

References Cubic(), min(), EffectDistortion::Params::mParam1, mParams, EffectDistortion::Params::mRepeats, mTable, STEPS, and TABLESIZE.

Referenced by MakeTable().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DCFilter()

float EffectDistortion::DCFilter ( EffectDistortionState data,
float  sample 
)
private

Definition at line 1318 of file Distortion.cpp.

1319 {
1320  // Rolling average gives less offset at the start than an IIR filter.
1321  const unsigned int queueLength = std::floor(data.samplerate / 20.0);
1322 
1323  data.queuetotal += sample;
1324  data.queuesamples.push(sample);
1325 
1326  if (data.queuesamples.size() > queueLength) {
1327  data.queuetotal -= data.queuesamples.front();
1328  data.queuesamples.pop();
1329  }
1330 
1331  return sample - (data.queuetotal / data.queuesamples.size());
1332 }

References EffectDistortionState::queuesamples, EffectDistortionState::queuetotal, and EffectDistortionState::samplerate.

Referenced by InstanceProcess().

Here is the caller graph for this function:

◆ DefineParams()

bool EffectDistortion::DefineParams ( ShuttleParams S)
override

Definition at line 280 of file Distortion.cpp.

280  {
281  S.SHUTTLE_ENUM_PARAM( mParams.mTableChoiceIndx, TableTypeIndx,
283  S.SHUTTLE_PARAM( mParams.mDCBlock, DCBlock );
284  S.SHUTTLE_PARAM( mParams.mThreshold_dB, Threshold_dB );
285  S.SHUTTLE_PARAM( mParams.mNoiseFloor, NoiseFloor );
286  S.SHUTTLE_PARAM( mParams.mParam1, Param1 );
287  S.SHUTTLE_PARAM( mParams.mParam2, Param2 );
288  S.SHUTTLE_PARAM( mParams.mRepeats, Repeats );
289  return true;
290 }

References kTableTypeStrings, EffectDistortion::Params::mDCBlock, EffectDistortion::Params::mNoiseFloor, EffectDistortion::Params::mParam1, EffectDistortion::Params::mParam2, mParams, EffectDistortion::Params::mRepeats, EffectDistortion::Params::mTableChoiceIndx, EffectDistortion::Params::mThreshold_dB, and nTableTypes.

◆ EvenHarmonicTable()

void EffectDistortion::EvenHarmonicTable ( )
private

Definition at line 1155 of file Distortion.cpp.

1156 {
1157  double amount = mParams.mParam1 / -100.0;
1158  // double C = std::sin(std::max(0.001, mParams.mParam2) / 100.0) * 10.0;
1159  double C = std::max(0.001, mParams.mParam2) / 10.0;
1160 
1161  double step = 1.0 / STEPS;
1162  double xval = -1.0;
1163 
1164  for (int i = 0; i < TABLESIZE; i++) {
1165  mTable[i] = ((1 + amount) * xval) -
1166  (xval * (amount / std::tanh(C)) * std::tanh(C * xval));
1167  xval += step;
1168  }
1169 }

References EffectDistortion::Params::mParam1, EffectDistortion::Params::mParam2, mParams, mTable, STEPS, and TABLESIZE.

Referenced by MakeTable().

Here is the caller graph for this function:

◆ ExponentialTable()

void EffectDistortion::ExponentialTable ( )
private

Definition at line 1068 of file Distortion.cpp.

1069 {
1070  double amount = std::min(0.999, DB_TO_LINEAR(-1 * mParams.mParam1)); // avoid divide by zero
1071 
1072  for (int n = STEPS; n < TABLESIZE; n++) {
1073  double linVal = n/(float)STEPS;
1074  double scale = -1.0 / (1.0 - amount); // unity gain at 0dB
1075  double curve = std::exp((linVal - 1) * std::log(amount));
1076  mTable[n] = scale * (curve -1);
1077  }
1078  CopyHalfTable();
1079 }

References CopyHalfTable(), DB_TO_LINEAR(), min(), EffectDistortion::Params::mParam1, mParams, mTable, STEPS, and TABLESIZE.

Referenced by MakeTable().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetAudioInCount()

unsigned EffectDistortion::GetAudioInCount ( )
overridevirtual

Implements EffectClientInterface.

Definition at line 224 of file Distortion.cpp.

225 {
226  return 1;
227 }

◆ GetAudioOutCount()

unsigned EffectDistortion::GetAudioOutCount ( )
overridevirtual

Implements EffectClientInterface.

Definition at line 229 of file Distortion.cpp.

230 {
231  return 1;
232 }

◆ GetAutomationParameters()

bool EffectDistortion::GetAutomationParameters ( CommandParameters parms)
overridevirtual

Implements EffectClientInterface.

Definition at line 292 of file Distortion.cpp.

293 {
294  parms.Write(KEY_TableTypeIndx,
296  parms.Write(KEY_DCBlock, mParams.mDCBlock);
297  parms.Write(KEY_Threshold_dB, mParams.mThreshold_dB);
298  parms.Write(KEY_NoiseFloor, mParams.mNoiseFloor);
299  parms.Write(KEY_Param1, mParams.mParam1);
300  parms.Write(KEY_Param2, mParams.mParam2);
301  parms.Write(KEY_Repeats, mParams.mRepeats);
302 
303  return true;
304 }

References ComponentInterfaceSymbol::Internal(), kTableTypeStrings, EffectDistortion::Params::mDCBlock, EffectDistortion::Params::mNoiseFloor, EffectDistortion::Params::mParam1, EffectDistortion::Params::mParam2, mParams, EffectDistortion::Params::mRepeats, EffectDistortion::Params::mTableChoiceIndx, and EffectDistortion::Params::mThreshold_dB.

Here is the call graph for this function:

◆ GetDescription()

TranslatableString EffectDistortion::GetDescription ( )
overridevirtual

Implements ComponentInterface.

Definition at line 196 of file Distortion.cpp.

197 {
198  return XO("Waveshaping distortion effect");
199 }

References XO.

◆ GetFactoryPresets()

RegistryPaths EffectDistortion::GetFactoryPresets ( )
overridevirtual

Implements EffectClientInterface.

Definition at line 327 of file Distortion.cpp.

328 {
330 
331  for (size_t i = 0; i < WXSIZEOF(FactoryPresets); i++)
332  {
333  names.push_back( FactoryPresets[i].name.Translation() );
334  }
335 
336  return names;
337 }

References FactoryPresets, name, names, and TranslatableString::Translation().

Here is the call graph for this function:

◆ GetSymbol()

ComponentInterfaceSymbol EffectDistortion::GetSymbol ( )
overridevirtual

Implements ComponentInterface.

Definition at line 191 of file Distortion.cpp.

192 {
193  return Symbol;
194 }

References Symbol.

◆ GetType()

EffectType EffectDistortion::GetType ( )
overridevirtual

Implements EffectDefinitionInterface.

Definition at line 208 of file Distortion.cpp.

209 {
210  return EffectTypeProcess;
211 }

References EffectTypeProcess.

◆ HalfSinTable()

void EffectDistortion::HalfSinTable ( )
private

Definition at line 1102 of file Distortion.cpp.

1103 {
1104  int iter = std::floor(mParams.mParam1 / 20.0);
1105  double fractionalpart = (mParams.mParam1 / 20.0) - iter;
1106  double stepsize = 1.0 / STEPS;
1107  double linVal = 0;
1108 
1109  for (int n = STEPS; n < TABLESIZE; n++) {
1110  mTable[n] = linVal;
1111  for (int i = 0; i < iter; i++) {
1112  mTable[n] = std::sin(mTable[n] * M_PI_2);
1113  }
1114  mTable[n] += ((std::sin(mTable[n] * M_PI_2) - mTable[n]) * fractionalpart);
1115  linVal += stepsize;
1116  }
1117  CopyHalfTable();
1118 }

References CopyHalfTable(), M_PI_2, EffectDistortion::Params::mParam1, mParams, mTable, STEPS, and TABLESIZE.

Referenced by MakeTable().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ HardClip()

void EffectDistortion::HardClip ( )
private

Definition at line 1028 of file Distortion.cpp.

1029 {
1030  double lowThresh = 1 - mThreshold;
1031  double highThresh = 1 + mThreshold;
1032 
1033  for (int n = 0; n < TABLESIZE; n++) {
1034  if (n < (STEPS * lowThresh))
1035  mTable[n] = - mThreshold;
1036  else if (n > (STEPS * highThresh))
1037  mTable[n] = mThreshold;
1038  else
1039  mTable[n] = n/(double)STEPS - 1;
1040 
1041  mMakeupGain = 1.0 / mThreshold;
1042  }
1043 }

References mMakeupGain, mTable, mThreshold, STEPS, and TABLESIZE.

Referenced by HardLimiter(), and MakeTable().

Here is the caller graph for this function:

◆ HardLimiter()

void EffectDistortion::HardLimiter ( )
private

Definition at line 1266 of file Distortion.cpp.

1267 {
1268  // The LADSPA "hardLimiter 1413" is basically hard clipping,
1269  // but with a 'kind of' wet/dry mix:
1270  // out = ((wet-residual)*clipped) + (residual*in)
1271  HardClip();
1272 }

References HardClip().

Referenced by MakeTable().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ InstanceInit()

void EffectDistortion::InstanceInit ( EffectDistortionState data,
float  sampleRate 
)
private

Definition at line 528 of file Distortion.cpp.

529 {
530  data.samplerate = sampleRate;
531  data.skipcount = 0;
533  data.dcblock = mParams.mDCBlock;
536  data.param1 = mParams.mParam1;
537  data.param2 = mParams.mParam2;
538  data.repeats = mParams.mRepeats;
539 
540  // DC block filter variables
541  data.queuetotal = 0.0;
542 
543  //std::queue<float>().swap(data.queuesamples);
544  while (!data.queuesamples.empty())
545  data.queuesamples.pop();
546 
547  MakeTable();
548 
549  return;
550 }

References EffectDistortionState::dcblock, MakeTable(), EffectDistortion::Params::mDCBlock, EffectDistortion::Params::mNoiseFloor, EffectDistortion::Params::mParam1, EffectDistortion::Params::mParam2, mParams, EffectDistortion::Params::mRepeats, EffectDistortion::Params::mTableChoiceIndx, EffectDistortion::Params::mThreshold_dB, EffectDistortionState::noisefloor, EffectDistortionState::param1, EffectDistortionState::param2, EffectDistortionState::queuesamples, EffectDistortionState::queuetotal, EffectDistortionState::repeats, EffectDistortionState::samplerate, EffectDistortionState::skipcount, EffectDistortionState::tablechoiceindx, and EffectDistortionState::threshold.

Referenced by ProcessInitialize(), and RealtimeAddProcessor().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ InstanceProcess()

size_t EffectDistortion::InstanceProcess ( EffectDistortionState data,
float **  inBlock,
float **  outBlock,
size_t  blockLen 
)
private

Definition at line 552 of file Distortion.cpp.

553 {
554  float *ibuf = inBlock[0];
555  float *obuf = outBlock[0];
556 
557  bool update = (mParams.mTableChoiceIndx == data.tablechoiceindx &&
558  mParams.mNoiseFloor == data.noisefloor &&
559  mParams.mThreshold_dB == data.threshold &&
560  mParams.mParam1 == data.param1 &&
561  mParams.mParam2 == data.param2 &&
562  mParams.mRepeats == data.repeats)? false : true;
563 
564  double p1 = mParams.mParam1 / 100.0;
565  double p2 = mParams.mParam2 / 100.0;
566 
570  data.param1 = mParams.mParam1;
571  data.repeats = mParams.mRepeats;
572 
573  for (decltype(blockLen) i = 0; i < blockLen; i++) {
574  if (update && ((data.skipcount++) % skipsamples == 0)) {
575  MakeTable();
576  }
577 
578  switch (mParams.mTableChoiceIndx)
579  {
580  case kHardClip:
581  // Param2 = make-up gain.
582  obuf[i] = WaveShaper(ibuf[i]) * ((1 - p2) + (mMakeupGain * p2));
583  break;
584  case kSoftClip:
585  // Param2 = make-up gain.
586  obuf[i] = WaveShaper(ibuf[i]) * ((1 - p2) + (mMakeupGain * p2));
587  break;
588  case kHalfSinCurve:
589  obuf[i] = WaveShaper(ibuf[i]) * p2;
590  break;
591  case kExpCurve:
592  obuf[i] = WaveShaper(ibuf[i]) * p2;
593  break;
594  case kLogCurve:
595  obuf[i] = WaveShaper(ibuf[i]) * p2;
596  break;
597  case kCubic:
598  obuf[i] = WaveShaper(ibuf[i]) * p2;
599  break;
600  case kEvenHarmonics:
601  obuf[i] = WaveShaper(ibuf[i]);
602  break;
603  case kSinCurve:
604  obuf[i] = WaveShaper(ibuf[i]) * p2;
605  break;
606  case kLeveller:
607  obuf[i] = WaveShaper(ibuf[i]);
608  break;
609  case kRectifier:
610  obuf[i] = WaveShaper(ibuf[i]);
611  break;
612  case kHardLimiter:
613  // Mix equivalent to LADSPA effect's "Wet / Residual" mix
614  obuf[i] = (WaveShaper(ibuf[i]) * (p1 - p2)) + (ibuf[i] * p2);
615  break;
616  default:
617  obuf[i] = WaveShaper(ibuf[i]);
618  }
619  if (mParams.mDCBlock) {
620  obuf[i] = DCFilter(data, obuf[i]);
621  }
622  }
623 
624  return blockLen;
625 }

References DCFilter(), kCubic, kEvenHarmonics, kExpCurve, kHalfSinCurve, kHardClip, kHardLimiter, kLeveller, kLogCurve, kRectifier, kSinCurve, kSoftClip, MakeTable(), EffectDistortion::Params::mDCBlock, mMakeupGain, EffectDistortion::Params::mNoiseFloor, EffectDistortion::Params::mParam1, EffectDistortion::Params::mParam2, mParams, EffectDistortion::Params::mRepeats, EffectDistortion::Params::mTableChoiceIndx, EffectDistortion::Params::mThreshold_dB, EffectDistortionState::noisefloor, EffectDistortionState::param1, EffectDistortionState::param2, EffectDistortionState::repeats, EffectDistortionState::skipcount, skipsamples, EffectDistortionState::tablechoiceindx, EffectDistortionState::threshold, and WaveShaper().

Referenced by ProcessBlock(), and RealtimeProcess().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Leveller()

void EffectDistortion::Leveller ( )
private

Definition at line 1189 of file Distortion.cpp.

1190 {
1191  double noiseFloor = DB_TO_LINEAR(mParams.mNoiseFloor);
1192  int numPasses = mParams.mRepeats;
1193  double fractionalPass = mParams.mParam1 / 100.0;
1194 
1195  const int numPoints = 6;
1196  const double gainFactors[numPoints] = { 0.80, 1.00, 1.20, 1.20, 1.00, 0.80 };
1197  double gainLimits[numPoints] = { 0.0001, 0.0, 0.1, 0.3, 0.5, 1.0 };
1198  double addOnValues[numPoints];
1199 
1200  gainLimits[1] = noiseFloor;
1201  /* In the original Leveller effect, behaviour was undefined for threshold > 20 dB.
1202  * If we want to support > 20 dB we need to scale the points to keep them non-decreasing.
1203  *
1204  * if (noiseFloor > gainLimits[2]) {
1205  * for (int i = 3; i < numPoints; i++) {
1206  * gainLimits[i] = noiseFloor + ((1 - noiseFloor)*((gainLimits[i] - 0.1) / 0.9));
1207  * }
1208  * gainLimits[2] = noiseFloor;
1209  * }
1210  */
1211 
1212  // Calculate add-on values
1213  addOnValues[0] = 0.0;
1214  for (int i = 0; i < numPoints-1; i++) {
1215  addOnValues[i+1] = addOnValues[i] + (gainLimits[i] * (gainFactors[i] - gainFactors[1 + i]));
1216  }
1217 
1218  // Positive half of table.
1219  // The original effect increased the 'strength' of the effect by
1220  // repeated passes over the audio data.
1221  // Here we model that more efficiently by repeated passes over a linear table.
1222  for (int n = STEPS; n < TABLESIZE; n++) {
1223  mTable[n] = ((double) (n - STEPS) / (double) STEPS);
1224  for (int j = 0; j < numPasses; j++) {
1225  // Find the highest index for gain adjustment
1226  int index = numPoints - 1;
1227  for (int i = index; i >= 0 && mTable[n] < gainLimits[i]; i--) {
1228  index = i;
1229  }
1230  // the whole number of 'repeats'
1231  mTable[n] = (mTable[n] * gainFactors[index]) + addOnValues[index];
1232  }
1233  // Extrapolate for fine adjustment.
1234  // tiny fractions are not worth the processing time
1235  if (fractionalPass > 0.001) {
1236  int index = numPoints - 1;
1237  for (int i = index; i >= 0 && mTable[n] < gainLimits[i]; i--) {
1238  index = i;
1239  }
1240  mTable[n] += fractionalPass * ((mTable[n] * (gainFactors[index] - 1)) + addOnValues[index]);
1241  }
1242  }
1243  CopyHalfTable();
1244 }

References CopyHalfTable(), DB_TO_LINEAR(), EffectDistortion::Params::mNoiseFloor, EffectDistortion::Params::mParam1, mParams, EffectDistortion::Params::mRepeats, mTable, STEPS, and TABLESIZE.

Referenced by MakeTable().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ LoadFactoryPreset()

bool EffectDistortion::LoadFactoryPreset ( int  id)
overridevirtual

Implements EffectClientInterface.

Definition at line 339 of file Distortion.cpp.

340 {
341  if (id < 0 || id >= (int) WXSIZEOF(FactoryPresets))
342  {
343  return false;
344  }
345 
346  mParams = FactoryPresets[id].params;
348 
349  if (mUIDialog)
350  {
352  }
353 
354  return true;
355 }

References DB_TO_LINEAR(), FactoryPresets, id, mParams, mThreshold, EffectDistortion::Params::mThreshold_dB, Effect::mUIDialog, and TransferDataToWindow().

Here is the call graph for this function:

◆ LogarithmicTable()

void EffectDistortion::LogarithmicTable ( )
private

Definition at line 1081 of file Distortion.cpp.

1082 {
1083  double amount = mParams.mParam1;
1084  double stepsize = 1.0 / STEPS;
1085  double linVal = 0;
1086 
1087  if (amount == 0){
1088  for (int n = STEPS; n < TABLESIZE; n++) {
1089  mTable[n] = linVal;
1090  linVal += stepsize;
1091  }
1092  }
1093  else {
1094  for (int n = STEPS; n < TABLESIZE; n++) {
1095  mTable[n] = std::log(1 + (amount * linVal)) / std::log(1 + amount);
1096  linVal += stepsize;
1097  }
1098  }
1099  CopyHalfTable();
1100 }

References CopyHalfTable(), EffectDistortion::Params::mParam1, mParams, mTable, STEPS, and TABLESIZE.

Referenced by MakeTable().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ LogCurve()

float EffectDistortion::LogCurve ( double  threshold,
float  value,
double  ratio 
)
inlineprivate

Definition at line 1063 of file Distortion.cpp.

1064 {
1065  return threshold + ((std::exp(ratio * (threshold - value)) - 1) / -ratio);
1066 }

Referenced by SoftClip().

Here is the caller graph for this function:

◆ MakeTable()

void EffectDistortion::MakeTable ( )
private

Definition at line 983 of file Distortion.cpp.

984 {
985  switch (mParams.mTableChoiceIndx)
986  {
987  case kHardClip:
988  HardClip();
989  break;
990  case kSoftClip:
991  SoftClip();
992  break;
993  case kHalfSinCurve:
994  HalfSinTable();
995  break;
996  case kExpCurve:
998  break;
999  case kLogCurve:
1000  LogarithmicTable();
1001  break;
1002  case kCubic:
1003  CubicTable();
1004  break;
1005  case kEvenHarmonics:
1007  break;
1008  case kSinCurve:
1009  SineTable();
1010  break;
1011  case kLeveller:
1012  Leveller();
1013  break;
1014  case kRectifier:
1015  Rectifier();
1016  break;
1017  case kHardLimiter:
1018  HardLimiter();
1019  break;
1020  }
1021 }

References CubicTable(), EvenHarmonicTable(), ExponentialTable(), HalfSinTable(), HardClip(), HardLimiter(), kCubic, kEvenHarmonics, kExpCurve, kHalfSinCurve, kHardClip, kHardLimiter, kLeveller, kLogCurve, kRectifier, kSinCurve, kSoftClip, Leveller(), LogarithmicTable(), mParams, EffectDistortion::Params::mTableChoiceIndx, Rectifier(), SineTable(), and SoftClip().

Referenced by InstanceInit(), and InstanceProcess().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ManualPage()

wxString EffectDistortion::ManualPage ( )
overridevirtual

Reimplemented from Effect.

Definition at line 201 of file Distortion.cpp.

202 {
203  return wxT("Distortion");
204 }

◆ OnDCBlockCheckbox()

void EffectDistortion::OnDCBlockCheckbox ( wxCommandEvent &  evt)
private

Definition at line 634 of file Distortion.cpp.

635 {
636  mParams.mDCBlock = mDCBlockCheckBox->GetValue();
638 }

References mbSavedFilterState, EffectDistortion::Params::mDCBlock, mDCBlockCheckBox, and mParams.

◆ OnNoiseFloorSlider()

void EffectDistortion::OnNoiseFloorSlider ( wxCommandEvent &  evt)
private

Definition at line 662 of file Distortion.cpp.

663 {
664  mParams.mNoiseFloor = (double) evt.GetInt();
665  mNoiseFloorT->GetValidator()->TransferToWindow();
666 }

References EffectDistortion::Params::mNoiseFloor, mNoiseFloorT, and mParams.

◆ OnNoiseFloorText()

void EffectDistortion::OnNoiseFloorText ( wxCommandEvent &  evt)
private

Definition at line 656 of file Distortion.cpp.

657 {
658  mNoiseFloorT->GetValidator()->TransferFromWindow();
659  mNoiseFloorS->SetValue((int) floor(mParams.mNoiseFloor + 0.5));
660 }

References EffectDistortion::Params::mNoiseFloor, mNoiseFloorS, mNoiseFloorT, and mParams.

◆ OnParam1Slider()

void EffectDistortion::OnParam1Slider ( wxCommandEvent &  evt)
private

Definition at line 675 of file Distortion.cpp.

676 {
677  mParams.mParam1 = (double) evt.GetInt();
678  mParam1T->GetValidator()->TransferToWindow();
679 }

References EffectDistortion::Params::mParam1, mParam1T, and mParams.

◆ OnParam1Text()

void EffectDistortion::OnParam1Text ( wxCommandEvent &  evt)
private

Definition at line 669 of file Distortion.cpp.

670 {
671  mParam1T->GetValidator()->TransferFromWindow();
672  mParam1S->SetValue((int) floor(mParams.mParam1 + 0.5));
673 }

References EffectDistortion::Params::mParam1, mParam1S, mParam1T, and mParams.

◆ OnParam2Slider()

void EffectDistortion::OnParam2Slider ( wxCommandEvent &  evt)
private

Definition at line 687 of file Distortion.cpp.

688 {
689  mParams.mParam2 = (double) evt.GetInt();
690  mParam2T->GetValidator()->TransferToWindow();
691 }

References EffectDistortion::Params::mParam2, mParam2T, and mParams.

◆ OnParam2Text()

void EffectDistortion::OnParam2Text ( wxCommandEvent &  evt)
private

Definition at line 681 of file Distortion.cpp.

682 {
683  mParam2T->GetValidator()->TransferFromWindow();
684  mParam2S->SetValue((int) floor(mParams.mParam2 + 0.5));
685 }

References EffectDistortion::Params::mParam2, mParam2S, mParam2T, and mParams.

◆ OnRepeatsSlider()

void EffectDistortion::OnRepeatsSlider ( wxCommandEvent &  evt)
private

Definition at line 699 of file Distortion.cpp.

700 {
701  mParams.mRepeats = evt.GetInt();
702  mRepeatsT->GetValidator()->TransferToWindow();
703 
704 }

References mParams, EffectDistortion::Params::mRepeats, and mRepeatsT.

◆ OnRepeatsText()

void EffectDistortion::OnRepeatsText ( wxCommandEvent &  evt)
private

Definition at line 693 of file Distortion.cpp.

694 {
695  mRepeatsT->GetValidator()->TransferFromWindow();
696  mRepeatsS->SetValue(mParams.mRepeats);
697 }

References mParams, EffectDistortion::Params::mRepeats, mRepeatsS, and mRepeatsT.

◆ OnThresholdSlider()

void EffectDistortion::OnThresholdSlider ( wxCommandEvent &  evt)
private

Definition at line 648 of file Distortion.cpp.

649 {
650  mThreshold = (double) evt.GetInt() / SCL_Threshold_dB;
651  mParams.mThreshold_dB = wxMax(LINEAR_TO_DB(mThreshold), MIN_Threshold_dB);
652  mThreshold = std::max(MIN_Threshold_Linear, mThreshold);
653  mThresholdT->GetValidator()->TransferToWindow();
654 }

References LINEAR_TO_DB, mParams, mThreshold, EffectDistortion::Params::mThreshold_dB, and mThresholdT.

◆ OnThresholdText()

void EffectDistortion::OnThresholdText ( wxCommandEvent &  evt)
private

Definition at line 641 of file Distortion.cpp.

642 {
643  mThresholdT->GetValidator()->TransferFromWindow();
645  mThresholdS->SetValue((int) (mThreshold * SCL_Threshold_dB + 0.5));
646 }

References DB_TO_LINEAR(), mParams, mThreshold, EffectDistortion::Params::mThreshold_dB, mThresholdS, and mThresholdT.

Here is the call graph for this function:

◆ OnTypeChoice()

void EffectDistortion::OnTypeChoice ( wxCommandEvent &  evt)
private

Definition at line 627 of file Distortion.cpp.

628 {
629  mTypeChoiceCtrl->GetValidator()->TransferFromWindow();
630 
631  UpdateUI();
632 }

References mTypeChoiceCtrl, and UpdateUI().

Here is the call graph for this function:

◆ PopulateOrExchange()

void EffectDistortion::PopulateOrExchange ( ShuttleGui S)
overridevirtual

Reimplemented from Effect.

Definition at line 360 of file Distortion.cpp.

361 {
362  S.AddSpace(0, 5);
363  S.StartVerticalLay();
364  {
365  S.StartMultiColumn(4, wxCENTER);
366  {
368  .MinSize( { -1, -1 } )
370  .AddChoice(XXO("Distortion type:"),
372 
373  mDCBlockCheckBox = S.Id(ID_DCBlock).AddCheckBox(XXO("DC blocking filter"),
374  DEF_DCBlock);
375  }
376  S.EndMultiColumn();
377  S.AddSpace(0, 10);
378 
379 
380  S.StartStatic(XO("Threshold controls"));
381  {
382  S.StartMultiColumn(4, wxEXPAND);
383  S.SetStretchyCol(2);
384  {
385  // Allow space for first Column
386  S.AddSpace(250,0); S.AddSpace(0,0); S.AddSpace(0,0); S.AddSpace(0,0);
387 
388  // Upper threshold control
390  false, wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT);
392  .Name(defaultLabel(0))
393  .Validator<FloatingPointValidator<double>>(
394  2, &mParams.mThreshold_dB, NumValidatorStyle::DEFAULT,
395  MIN_Threshold_dB, MAX_Threshold_dB)
396  .AddTextBox( {}, wxT(""), 10);
397 
399  .Name(defaultLabel(0))
400  .Style(wxSL_HORIZONTAL)
401  .AddSlider( {}, 0,
402  DB_TO_LINEAR(MAX_Threshold_dB) * SCL_Threshold_dB,
403  DB_TO_LINEAR(MIN_Threshold_dB) * SCL_Threshold_dB);
404  S.AddSpace(20, 0);
405 
406  // Noise floor control
408  false, wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT);
410  .Name(defaultLabel(1))
411  .Validator<FloatingPointValidator<double>>(
412  2, &mParams.mNoiseFloor, NumValidatorStyle::DEFAULT,
413  MIN_NoiseFloor, MAX_NoiseFloor
414  )
415  .AddTextBox( {}, wxT(""), 10);
416 
418  .Name(defaultLabel(1))
419  .Style(wxSL_HORIZONTAL)
420  .AddSlider( {}, 0, MAX_NoiseFloor, MIN_NoiseFloor);
421  S.AddSpace(20, 0);
422  }
423  S.EndMultiColumn();
424  }
425  S.EndStatic();
426 
427  S.StartStatic(XO("Parameter controls"));
428  {
429  S.StartMultiColumn(4, wxEXPAND);
430  S.SetStretchyCol(2);
431  {
432  // Allow space for first Column
433  S.AddSpace(250,0); S.AddSpace(0,0); S.AddSpace(0,0); S.AddSpace(0,0);
434 
435  // Parameter1 control
437  false, wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT);
438  mParam1T = S.Id(ID_Param1)
439  .Name(defaultLabel(2))
440  .Validator<FloatingPointValidator<double>>(
441  2, &mParams.mParam1, NumValidatorStyle::DEFAULT,
442  MIN_Param1, MAX_Param1
443  )
444  .AddTextBox( {}, wxT(""), 10);
445 
446  mParam1S = S.Id(ID_Param1)
447  .Name(defaultLabel(2))
448  .Style(wxSL_HORIZONTAL)
449  .AddSlider( {}, 0, MAX_Param1, MIN_Param1);
450  S.AddSpace(20, 0);
451 
452  // Parameter2 control
454  false, wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT);
455  mParam2T = S.Id(ID_Param2)
456  .Name(defaultLabel(3))
457  .Validator<FloatingPointValidator<double>>(
458  2, &mParams.mParam2, NumValidatorStyle::DEFAULT,
459  MIN_Param2, MAX_Param2
460  )
461  .AddTextBox( {}, wxT(""), 10);
462 
463  mParam2S = S.Id(ID_Param2)
464  .Name(defaultLabel(3))
465  .Style(wxSL_HORIZONTAL)
466  .AddSlider( {}, 0, MAX_Param2, MIN_Param2);
467  S.AddSpace(20, 0);
468 
469  // Repeats control
471  false, wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT);
472  mRepeatsT = S.Id(ID_Repeats)
473  .Name(defaultLabel(4))
474  .Validator<IntegerValidator<int>>(
475  &mParams.mRepeats, NumValidatorStyle::DEFAULT,
476  MIN_Repeats, MAX_Repeats
477  )
478  .AddTextBox( {}, wxT(""), 10);
479 
480  mRepeatsS = S.Id(ID_Repeats)
481  .Name(defaultLabel(4))
482  .Style(wxSL_HORIZONTAL)
483  .AddSlider( {}, DEF_Repeats, MAX_Repeats, MIN_Repeats);
484  S.AddSpace(20, 0);
485  }
486  S.EndMultiColumn();
487  }
488  S.EndStatic();
489  }
490  S.EndVerticalLay();
491 
492  return;
493 }

References ShuttleGuiBase::AddCheckBox(), ShuttleGuiBase::AddSlider(), ShuttleGui::AddSpace(), ShuttleGuiBase::AddVariableText(), DB_TO_LINEAR(), defaultLabel(), ShuttleGuiBase::EndMultiColumn(), ShuttleGuiBase::EndStatic(), ShuttleGuiBase::EndVerticalLay(), ShuttleGui::Id(), ID_DCBlock, ID_NoiseFloor, ID_Param1, ID_Param2, ID_Repeats, ID_Threshold, ID_Type, kTableTypeStrings, mDCBlockCheckBox, ShuttleGui::MinSize(), EffectDistortion::Params::mNoiseFloor, mNoiseFloorS, mNoiseFloorT, mNoiseFloorTxt, EffectDistortion::Params::mParam1, mParam1S, mParam1T, mParam1Txt, EffectDistortion::Params::mParam2, mParam2S, mParam2T, mParam2Txt, mParams, EffectDistortion::Params::mRepeats, mRepeatsS, mRepeatsT, mRepeatsTxt, Msgids(), EffectDistortion::Params::mTableChoiceIndx, EffectDistortion::Params::mThreshold_dB, mThresholdS, mThresholdT, mThresholdTxt, mTypeChoiceCtrl, ShuttleGui::Name(), nTableTypes, ShuttleGuiBase::SetStretchyCol(), ShuttleGuiBase::StartMultiColumn(), ShuttleGuiBase::StartStatic(), ShuttleGuiBase::StartVerticalLay(), ShuttleGui::Validator(), XO, and XXO.

Here is the call graph for this function:

◆ ProcessBlock()

size_t EffectDistortion::ProcessBlock ( float **  inBlock,
float **  outBlock,
size_t  blockLen 
)
overridevirtual

Implements EffectClientInterface.

Definition at line 240 of file Distortion.cpp.

241 {
242  return InstanceProcess(mMaster, inBlock, outBlock, blockLen);
243 }

References InstanceProcess(), and mMaster.

Here is the call graph for this function:

◆ ProcessInitialize()

bool EffectDistortion::ProcessInitialize ( sampleCount  totalLen,
ChannelNames  chanMap = NULL 
)
overridevirtual

Implements EffectClientInterface.

Definition at line 234 of file Distortion.cpp.

235 {
237  return true;
238 }

References InstanceInit(), mMaster, and Effect::mSampleRate.

Here is the call graph for this function:

◆ RealtimeAddProcessor()

bool EffectDistortion::RealtimeAddProcessor ( unsigned  numChannels,
float  sampleRate 
)
overridevirtual

Implements EffectClientInterface.

Definition at line 254 of file Distortion.cpp.

255 {
256  EffectDistortionState slave;
257 
258  InstanceInit(slave, sampleRate);
259 
260  mSlaves.push_back(slave);
261 
262  return true;
263 }

References InstanceInit(), and mSlaves.

Here is the call graph for this function:

◆ RealtimeFinalize()

bool EffectDistortion::RealtimeFinalize ( )
overridevirtual

Implements EffectClientInterface.

Definition at line 265 of file Distortion.cpp.

266 {
267  mSlaves.clear();
268 
269  return true;
270 }

References mSlaves.

◆ RealtimeInitialize()

bool EffectDistortion::RealtimeInitialize ( )
overridevirtual

Implements EffectClientInterface.

Definition at line 245 of file Distortion.cpp.

246 {
247  SetBlockSize(512);
248 
249  mSlaves.clear();
250 
251  return true;
252 }

References mSlaves, and Effect::SetBlockSize().

Here is the call graph for this function:

◆ RealtimeProcess()

size_t EffectDistortion::RealtimeProcess ( int  group,
float **  inbuf,
float **  outbuf,
size_t  numSamples 
)
overridevirtual

Implements EffectClientInterface.

Definition at line 272 of file Distortion.cpp.

276 {
277 
278  return InstanceProcess(mSlaves[group], inbuf, outbuf, numSamples);
279 }

References InstanceProcess(), and mSlaves.

Here is the call graph for this function:

◆ Rectifier()

void EffectDistortion::Rectifier ( )
private

Definition at line 1246 of file Distortion.cpp.

1247 {
1248  double amount = (mParams.mParam1 / 50.0) - 1;
1249  double stepsize = 1.0 / STEPS;
1250  int index = STEPS;
1251 
1252  // positive half of waveform is passed unaltered.
1253  for (int n = 0; n <= STEPS; n++) {
1254  mTable[index] = n * stepsize;
1255  index += 1;
1256  }
1257 
1258  // negative half of table
1259  index = STEPS - 1;
1260  for (int n = 1; n <= STEPS; n++) {
1261  mTable[index] = n * stepsize * amount;
1262  index--;
1263  }
1264 }

References EffectDistortion::Params::mParam1, mParams, mTable, and STEPS.

Referenced by MakeTable().

Here is the caller graph for this function:

◆ SetAutomationParameters()

bool EffectDistortion::SetAutomationParameters ( CommandParameters parms)
overridevirtual

◆ SineTable()

void EffectDistortion::SineTable ( )
private

Definition at line 1171 of file Distortion.cpp.

1172 {
1173  int iter = std::floor(mParams.mParam1 / 20.0);
1174  double fractionalpart = (mParams.mParam1 / 20.0) - iter;
1175  double stepsize = 1.0 / STEPS;
1176  double linVal = 0.0;
1177 
1178  for (int n = STEPS; n < TABLESIZE; n++) {
1179  mTable[n] = linVal;
1180  for (int i = 0; i < iter; i++) {
1181  mTable[n] = (1.0 + std::sin((mTable[n] * M_PI) - M_PI_2)) / 2.0;
1182  }
1183  mTable[n] += (((1.0 + std::sin((mTable[n] * M_PI) - M_PI_2)) / 2.0) - mTable[n]) * fractionalpart;
1184  linVal += stepsize;
1185  }
1186  CopyHalfTable();
1187 }

References CopyHalfTable(), M_PI, M_PI_2, EffectDistortion::Params::mParam1, mParams, mTable, STEPS, and TABLESIZE.

Referenced by MakeTable().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SoftClip()

void EffectDistortion::SoftClip ( )
private

Definition at line 1045 of file Distortion.cpp.

1046 {
1047  double threshold = 1 + mThreshold;
1048  double amount = std::pow(2.0, 7.0 * mParams.mParam1 / 100.0); // range 1 to 128
1049  double peak = LogCurve(mThreshold, 1.0, amount);
1050  mMakeupGain = 1.0 / peak;
1051  mTable[STEPS] = 0.0; // origin
1052 
1053  // positive half of table
1054  for (int n = STEPS; n < TABLESIZE; n++) {
1055  if (n < (STEPS * threshold)) // origin to threshold
1056  mTable[n] = n/(float)STEPS - 1;
1057  else
1058  mTable[n] = LogCurve(mThreshold, n/(double)STEPS - 1, amount);
1059  }
1060  CopyHalfTable();
1061 }

References CopyHalfTable(), LogCurve(), mMakeupGain, EffectDistortion::Params::mParam1, mParams, mTable, mThreshold, STEPS, and TABLESIZE.

Referenced by MakeTable().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SupportsRealtime()

bool EffectDistortion::SupportsRealtime ( )
overridevirtual

Implements EffectDefinitionInterface.

Definition at line 213 of file Distortion.cpp.

214 {
215 #if defined(EXPERIMENTAL_REALTIME_AUDACITY_EFFECTS)
216  return true;
217 #else
218  return false;
219 #endif
220 }

◆ TransferDataFromWindow()

bool EffectDistortion::TransferDataFromWindow ( )
overridevirtual

Reimplemented from Effect.

Definition at line 516 of file Distortion.cpp.

517 {
518  if (!mUIParent->Validate() || !mUIParent->TransferDataFromWindow())
519  {
520  return false;
521  }
522 
524 
525  return true;
526 }

References DB_TO_LINEAR(), mParams, mThreshold, EffectDistortion::Params::mThreshold_dB, and Effect::mUIParent.

Here is the call graph for this function:

◆ TransferDataToWindow()

bool EffectDistortion::TransferDataToWindow ( )
overridevirtual

Reimplemented from Effect.

Definition at line 495 of file Distortion.cpp.

496 {
497  if (!mUIParent->TransferDataToWindow())
498  {
499  return false;
500  }
501 
502  mThresholdS->SetValue((int) (mThreshold * SCL_Threshold_dB + 0.5));
503  mDCBlockCheckBox->SetValue(mParams.mDCBlock);
504  mNoiseFloorS->SetValue((int) mParams.mNoiseFloor + 0.5);
505  mParam1S->SetValue((int) mParams.mParam1 + 0.5);
506  mParam2S->SetValue((int) mParams.mParam2 + 0.5);
507  mRepeatsS->SetValue(mParams.mRepeats);
508 
510 
511  UpdateUI();
512 
513  return true;
514 }

References mbSavedFilterState, EffectDistortion::Params::mDCBlock, mDCBlockCheckBox, EffectDistortion::Params::mNoiseFloor, mNoiseFloorS, EffectDistortion::Params::mParam1, mParam1S, EffectDistortion::Params::mParam2, mParam2S, mParams, EffectDistortion::Params::mRepeats, mRepeatsS, mThreshold, mThresholdS, Effect::mUIParent, and UpdateUI().

Referenced by LoadFactoryPreset().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ UpdateControl()

void EffectDistortion::UpdateControl ( control  id,
bool  enable,
TranslatableString  name 
)
private

Definition at line 875 of file Distortion.cpp.

877 {
878  auto suffix = XO("(Not Used):");
879  switch (id)
880  {
881  case ID_Threshold: {
882  /* i18n-hint: Control range. */
883  if (enabled) suffix = XO("(-100 to 0 dB):");
884  name.Join( suffix, wxT(" ") );
885 
886  // Logarithmic slider is set indirectly
888  mThresholdS->SetValue((int) (mThreshold * SCL_Threshold_dB + 0.5));
889 
890  auto translated = name.Translation();
891  mThresholdTxt->SetLabel(translated);
892  mThresholdS->SetName(translated);
893  mThresholdT->SetName(translated);
894  mThresholdS->Enable(enabled);
895  mThresholdT->Enable(enabled);
896  break;
897  }
898  case ID_NoiseFloor: {
899  /* i18n-hint: Control range. */
900  if (enabled) suffix = XO("(-80 to -20 dB):");
901  name.Join( suffix, wxT(" ") );
902 
903  auto translated = name.Translation();
904  mNoiseFloorTxt->SetLabel(translated);
905  mNoiseFloorS->SetName(translated);
906  mNoiseFloorT->SetName(translated);
907  mNoiseFloorS->Enable(enabled);
908  mNoiseFloorT->Enable(enabled);
909  break;
910  }
911  case ID_Param1: {
912  /* i18n-hint: Control range. */
913  if (enabled) suffix = XO("(0 to 100):");
914  name.Join( suffix, wxT(" ") );
915 
916  auto translated = name.Translation();
917  mParam1Txt->SetLabel(translated);
918  mParam1S->SetName(translated);
919  mParam1T->SetName(translated);
920  mParam1S->Enable(enabled);
921  mParam1T->Enable(enabled);
922  break;
923  }
924  case ID_Param2: {
925  /* i18n-hint: Control range. */
926  if (enabled) suffix = XO("(0 to 100):");
927  name.Join( suffix, wxT(" ") );
928 
929  auto translated = name.Translation();
930  mParam2Txt->SetLabel(translated);
931  mParam2S->SetName(translated);
932  mParam2T->SetName(translated);
933  mParam2S->Enable(enabled);
934  mParam2T->Enable(enabled);
935  break;
936  }
937  case ID_Repeats: {
938  /* i18n-hint: Control range. */
939  if (enabled) suffix = XO("(0 to 5):");
940  name.Join( suffix, wxT(" ") );
941 
942  auto translated = name.Translation();
943  mRepeatsTxt->SetLabel(translated);
944  mRepeatsS->SetName(translated);
945  mRepeatsT->SetName(translated);
946  mRepeatsS->Enable(enabled);
947  mRepeatsT->Enable(enabled);
948  break;
949  }
950  case ID_DCBlock: {
951  if (enabled) {
954  }
955  else {
956  mDCBlockCheckBox->SetValue(false);
957  mParams.mDCBlock = false;
958  }
959 
960  mDCBlockCheckBox->Enable(enabled);
961  break;
962  }
963  default:
964  break;
965  }
966 }

References DB_TO_LINEAR(), ID_DCBlock, ID_NoiseFloor, ID_Param1, ID_Param2, ID_Repeats, ID_Threshold, TranslatableString::Join(), mbSavedFilterState, EffectDistortion::Params::mDCBlock, mDCBlockCheckBox, mNoiseFloorS, mNoiseFloorT, mNoiseFloorTxt, mParam1S, mParam1T, mParam1Txt, mParam2S, mParam2T, mParam2Txt, mParams, mRepeatsS, mRepeatsT, mRepeatsTxt, mThreshold, EffectDistortion::Params::mThreshold_dB, mThresholdS, mThresholdT, mThresholdTxt, name, TranslatableString::Translation(), and XO.

Referenced by UpdateUI().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ UpdateControlText()

void EffectDistortion::UpdateControlText ( wxTextCtrl *  textCtrl,
wxString &  string,
bool  enabled 
)
private

Definition at line 968 of file Distortion.cpp.

969 {
970  if (enabled) {
971  if (textCtrl->GetValue().empty())
972  textCtrl->SetValue(string);
973  else
974  string = textCtrl->GetValue();
975  }
976  else {
977  if (!textCtrl->GetValue().empty())
978  string = textCtrl->GetValue();
979  textCtrl->SetValue(wxT(""));
980  }
981 }

Referenced by UpdateUI().

Here is the caller graph for this function:

◆ UpdateUI()

void EffectDistortion::UpdateUI ( )
private

Definition at line 706 of file Distortion.cpp.

707 {
708  // set control text and names to match distortion type
709  switch (mParams.mTableChoiceIndx)
710  {
711  case kHardClip:
717 
718  UpdateControl(ID_Threshold, true, XO("Clipping level"));
720  UpdateControl(ID_Param1, true, XO("Drive"));
721  UpdateControl(ID_Param2, true, XO("Make-up Gain"));
723  UpdateControl(ID_DCBlock, false, {});
724  break;
725  case kSoftClip:
731 
732  UpdateControl(ID_Threshold, true, XO("Clipping threshold"));
734  UpdateControl(ID_Param1, true, XO("Hardness"));
735  UpdateControl(ID_Param2, true, XO("Make-up Gain"));
737  UpdateControl(ID_DCBlock, false, {});
738  break;
739  case kHalfSinCurve:
745 
748  UpdateControl(ID_Param1, true, XO("Distortion amount"));
749  UpdateControl(ID_Param2, true, XO("Output level"));
751  UpdateControl(ID_DCBlock, false, {});
752  break;
753  case kExpCurve:
759 
762  UpdateControl(ID_Param1, true, XO("Distortion amount"));
763  UpdateControl(ID_Param2, true, XO("Output level"));
765  UpdateControl(ID_DCBlock, false, {});
766  break;
767  case kLogCurve:
773 
776  UpdateControl(ID_Param1, true, XO("Distortion amount"));
777  UpdateControl(ID_Param2, true, XO("Output level"));
779  UpdateControl(ID_DCBlock, false, {});
780  break;
781  case kCubic:
787 
790  UpdateControl(ID_Param1, true, XO("Distortion amount"));
791  UpdateControl(ID_Param2, true, XO("Output level"));
792  UpdateControl(ID_Repeats, true, XO("Repeat processing"));
793  UpdateControl(ID_DCBlock, false, {});
794  break;
795  case kEvenHarmonics:
801 
804  UpdateControl(ID_Param1, true, XO("Distortion amount"));
805  UpdateControl(ID_Param2, true, XO("Harmonic brightness"));
807  UpdateControl(ID_DCBlock, true, {});
808  break;
809  case kSinCurve:
815 
818  UpdateControl(ID_Param1, true, XO("Distortion amount"));
819  UpdateControl(ID_Param2, true, XO("Output level"));
821  UpdateControl(ID_DCBlock, false, {});
822  break;
823  case kLeveller:
829 
832  UpdateControl(ID_Param1, true, XO("Levelling fine adjustment"));
834  UpdateControl(ID_Repeats, true, XO("Degree of Levelling"));
835  UpdateControl(ID_DCBlock, false, {});
836  break;
837  case kRectifier:
843 
846  UpdateControl(ID_Param1, true, XO("Distortion amount"));
849  UpdateControl(ID_DCBlock, true, {});
850  break;
851  case kHardLimiter:
857 
858  UpdateControl(ID_Threshold, true, XO("dB Limit"));
860  UpdateControl(ID_Param1, true, XO("Wet level"));
861  UpdateControl(ID_Param2, true, XO("Residual level"));
863  UpdateControl(ID_DCBlock, false, {});
864  break;
865  default:
871  UpdateControl(ID_DCBlock, false, {});
872  }
873 }

References defaultLabel(), ID_DCBlock, ID_NoiseFloor, ID_Param1, ID_Param2, ID_Repeats, ID_Threshold, kCubic, kEvenHarmonics, kExpCurve, kHalfSinCurve, kHardClip, kHardLimiter, kLeveller, kLogCurve, kRectifier, kSinCurve, kSoftClip, mNoiseFloorT, mOldmNoiseFloorTxt, mOldParam1Txt, mOldParam2Txt, mOldRepeatsTxt, mOldThresholdTxt, mParam1T, mParam2T, mParams, mRepeatsT, EffectDistortion::Params::mTableChoiceIndx, mThresholdT, UpdateControl(), UpdateControlText(), and XO.

Referenced by OnTypeChoice(), and TransferDataToWindow().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ WaveShaper()

float EffectDistortion::WaveShaper ( float  sample)
private

Definition at line 1288 of file Distortion.cpp.

1289 {
1290  float out;
1291  int index;
1292  double xOffset;
1293  double amount = 1;
1294 
1295  switch (mParams.mTableChoiceIndx)
1296  {
1297  // Do any pre-processing here
1298  case kHardClip:
1299  // Pre-gain
1300  amount = mParams.mParam1 / 100.0;
1301  sample *= 1+amount;
1302  break;
1303  default: break;
1304  }
1305 
1306  index = std::floor(sample * STEPS) + STEPS;
1307  index = wxMax<int>(wxMin<int>(index, 2 * STEPS - 1), 0);
1308  xOffset = ((1 + sample) * STEPS) - index;
1309  xOffset = wxMin<double>(wxMax<double>(xOffset, 0.0), 1.0); // Clip at 0dB
1310 
1311  // linear interpolation: y = y0 + (y1-y0)*(x-x0)
1312  out = mTable[index] + (mTable[index + 1] - mTable[index]) * xOffset;
1313 
1314  return out;
1315 }

References kHardClip, EffectDistortion::Params::mParam1, mParams, mTable, EffectDistortion::Params::mTableChoiceIndx, and STEPS.

Referenced by InstanceProcess().

Here is the caller graph for this function:

Member Data Documentation

◆ mbSavedFilterState

bool EffectDistortion::mbSavedFilterState
private

Definition at line 176 of file Distortion.h.

Referenced by OnDCBlockCheckbox(), TransferDataToWindow(), and UpdateControl().

◆ mDCBlockCheckBox

wxCheckBox* EffectDistortion::mDCBlockCheckBox
private

◆ mMakeupGain

double EffectDistortion::mMakeupGain
private

Definition at line 180 of file Distortion.h.

Referenced by HardClip(), InstanceProcess(), and SoftClip().

◆ mMaster

EffectDistortionState EffectDistortion::mMaster
private

Definition at line 171 of file Distortion.h.

Referenced by ProcessBlock(), and ProcessInitialize().

◆ mNoiseFloorS

wxSlider* EffectDistortion::mNoiseFloorS
private

◆ mNoiseFloorT

wxTextCtrl* EffectDistortion::mNoiseFloorT
private

◆ mNoiseFloorTxt

wxStaticText* EffectDistortion::mNoiseFloorTxt
private

Definition at line 200 of file Distortion.h.

Referenced by PopulateOrExchange(), and UpdateControl().

◆ mOldmNoiseFloorTxt

wxString EffectDistortion::mOldmNoiseFloorTxt
private

Definition at line 206 of file Distortion.h.

Referenced by UpdateUI().

◆ mOldParam1Txt

wxString EffectDistortion::mOldParam1Txt
private

Definition at line 207 of file Distortion.h.

Referenced by UpdateUI().

◆ mOldParam2Txt

wxString EffectDistortion::mOldParam2Txt
private

Definition at line 208 of file Distortion.h.

Referenced by UpdateUI().

◆ mOldRepeatsTxt

wxString EffectDistortion::mOldRepeatsTxt
private

Definition at line 209 of file Distortion.h.

Referenced by UpdateUI().

◆ mOldThresholdTxt

wxString EffectDistortion::mOldThresholdTxt
private

Definition at line 205 of file Distortion.h.

Referenced by UpdateUI().

◆ mParam1S

wxSlider* EffectDistortion::mParam1S
private

◆ mParam1T

wxTextCtrl* EffectDistortion::mParam1T
private

◆ mParam1Txt

wxStaticText* EffectDistortion::mParam1Txt
private

Definition at line 201 of file Distortion.h.

Referenced by PopulateOrExchange(), and UpdateControl().

◆ mParam2S

wxSlider* EffectDistortion::mParam2S
private

◆ mParam2T

wxTextCtrl* EffectDistortion::mParam2T
private

◆ mParam2Txt

wxStaticText* EffectDistortion::mParam2Txt
private

Definition at line 202 of file Distortion.h.

Referenced by PopulateOrExchange(), and UpdateControl().

◆ mParams

Params EffectDistortion::mParams
private

◆ mRepeatsS

wxSlider* EffectDistortion::mRepeatsS
private

◆ mRepeatsT

wxTextCtrl* EffectDistortion::mRepeatsT
private

◆ mRepeatsTxt

wxStaticText* EffectDistortion::mRepeatsTxt
private

Definition at line 203 of file Distortion.h.

Referenced by PopulateOrExchange(), and UpdateControl().

◆ mSlaves

std::vector<EffectDistortionState> EffectDistortion::mSlaves
private

◆ mTable

double EffectDistortion::mTable[TABLESIZE]
private

◆ mThreshold

double EffectDistortion::mThreshold
private

◆ mThresholdS

wxSlider* EffectDistortion::mThresholdS
private

◆ mThresholdT

wxTextCtrl* EffectDistortion::mThresholdT
private

◆ mThresholdTxt

wxStaticText* EffectDistortion::mThresholdTxt
private

Definition at line 199 of file Distortion.h.

Referenced by PopulateOrExchange(), and UpdateControl().

◆ mTypChoiceIndex

int EffectDistortion::mTypChoiceIndex
private

Definition at line 182 of file Distortion.h.

◆ mTypeChoiceCtrl

wxChoice* EffectDistortion::mTypeChoiceCtrl
private

Definition at line 184 of file Distortion.h.

Referenced by OnTypeChoice(), and PopulateOrExchange().

◆ Symbol

const ComponentInterfaceSymbol EffectDistortion::Symbol { XO("Distortion") }
static

Definition at line 48 of file Distortion.h.

Referenced by GetSymbol().


The documentation for this class was generated from the following files:
RegistryPaths
std::vector< RegistryPath > RegistryPaths
Definition: Types.h:262
EffectDistortion::mThresholdS
wxSlider * mThresholdS
Definition: Distortion.h:191
EffectDistortion::Params::mParam1
double mParam1
Definition: Distortion.h:59
EffectDistortion::mParam2S
wxSlider * mParam2S
Definition: Distortion.h:194
ShuttleGuiBase::StartVerticalLay
void StartVerticalLay(int iProp=1)
Definition: ShuttleGui.cpp:1177
EffectTypeProcess
@ EffectTypeProcess
Definition: EffectInterface.h:59
EffectDistortion::mMaster
EffectDistortionState mMaster
Definition: Distortion.h:171
DB_TO_LINEAR
const double MIN_Threshold_Linear DB_TO_LINEAR(MIN_Threshold_dB)
ShuttleGuiBase::AddCheckBox
wxCheckBox * AddCheckBox(const TranslatableString &Prompt, bool Selected)
Definition: ShuttleGui.cpp:302
Effect::mUIDialog
wxDialog * mUIDialog
Definition: Effect.h:476
Effect::SetLinearEffectFlag
void SetLinearEffectFlag(bool linearEffectFlag)
Definition: Effect.cpp:2000
EffectDistortion::mParam1Txt
wxStaticText * mParam1Txt
Definition: Distortion.h:201
EffectDistortion::Params::mDCBlock
bool mDCBlock
Definition: Distortion.h:56
EffectDistortion::CubicTable
void CubicTable()
Definition: Distortion.cpp:1120
kRectifier
@ kRectifier
Definition: Distortion.cpp:59
EffectDistortion::mDCBlockCheckBox
wxCheckBox * mDCBlockCheckBox
Definition: Distortion.h:197
kCubic
@ kCubic
Definition: Distortion.cpp:55
EffectDistortion::LogCurve
float LogCurve(double threshold, float value, double ratio)
Definition: Distortion.cpp:1063
EffectDistortion::UpdateUI
void UpdateUI()
Definition: Distortion.cpp:706
EffectDistortion::Rectifier
void Rectifier()
Definition: Distortion.cpp:1246
EffectDistortionState::samplerate
float samplerate
Definition: Distortion.h:30
EffectDistortion::Params::mNoiseFloor
double mNoiseFloor
Definition: Distortion.h:58
EffectDistortionState::param2
double param2
Definition: Distortion.h:37
EffectDistortion::mThresholdTxt
wxStaticText * mThresholdTxt
Definition: Distortion.h:199
EffectDistortionState::queuetotal
double queuetotal
Definition: Distortion.h:42
EffectDistortion::mRepeatsTxt
wxStaticText * mRepeatsTxt
Definition: Distortion.h:203
EffectDistortion::mTable
double mTable[TABLESIZE]
Definition: Distortion.h:174
Validator
A Validator is an object which checks whether a wxVariant satisfies a certain criterion....
Definition: Validators.h:53
ShuttleGui::AddSpace
wxSizerItem * AddSpace(int width, int height, int prop=0)
Definition: ShuttleGui.cpp:2421
EffectDistortion::ID_Repeats
@ ID_Repeats
Definition: Distortion.h:110
ShuttleGui::MinSize
ShuttleGui & MinSize()
Definition: ShuttleGui.h:740
XO
#define XO(s)
Definition: Internat.h:32
EffectDistortion::CopyHalfTable
void CopyHalfTable()
Definition: Distortion.cpp:1277
EffectDistortion::HalfSinTable
void HalfSinTable()
Definition: Distortion.cpp:1102
EffectDistortion::mbSavedFilterState
bool mbSavedFilterState
Definition: Distortion.h:176
ShuttleGuiBase::EndMultiColumn
void EndMultiColumn()
Definition: ShuttleGui.cpp:1212
EffectDistortion::InstanceInit
void InstanceInit(EffectDistortionState &data, float sampleRate)
Definition: Distortion.cpp:528
kSinCurve
@ kSinCurve
Definition: Distortion.cpp:57
kHalfSinCurve
@ kHalfSinCurve
Definition: Distortion.cpp:52
kHardClip
@ kHardClip
Definition: Distortion.cpp:50
EffectDistortion::mNoiseFloorS
wxSlider * mNoiseFloorS
Definition: Distortion.h:192
STEPS
#define STEPS
Definition: Distortion.h:24
EffectDistortion::ID_Type
@ ID_Type
Definition: Distortion.h:104
nTableTypes
@ nTableTypes
Definition: Distortion.cpp:61
EffectDistortion::mThresholdT
wxTextCtrl * mThresholdT
Definition: Distortion.h:185
kLeveller
@ kLeveller
Definition: Distortion.cpp:58
EffectDistortionState::param1
double param1
Definition: Distortion.h:36
ShuttleGui::Id
ShuttleGui & Id(int id)
Definition: ShuttleGui.cpp:2248
EffectDistortion::mSlaves
std::vector< EffectDistortionState > mSlaves
Definition: Distortion.h:172
kEvenHarmonics
@ kEvenHarmonics
Definition: Distortion.cpp:56
EffectDistortion::mOldRepeatsTxt
wxString mOldRepeatsTxt
Definition: Distortion.h:209
EffectDistortion::mRepeatsS
wxSlider * mRepeatsS
Definition: Distortion.h:195
EffectDistortion::mThreshold
double mThreshold
Definition: Distortion.h:175
EffectDistortionState
Definition: Distortion.h:28
ReadAndVerifyEnum
#define ReadAndVerifyEnum(name, list, listSize)
Definition: Effect.h:620
ReadAndVerifyInt
#define ReadAndVerifyInt(name)
Definition: Effect.h:631
EffectDistortion::ID_NoiseFloor
@ ID_NoiseFloor
Definition: Distortion.h:107
XXO
#define XXO(s)
Definition: Internat.h:45
EffectDistortion::Cubic
double Cubic(double x)
Definition: Distortion.cpp:1146
EffectDistortion::mParams
Params mParams
Definition: Distortion.h:211
EffectDistortion::Params::mTableChoiceIndx
int mTableChoiceIndx
Definition: Distortion.h:55
EffectDistortion::SineTable
void SineTable()
Definition: Distortion.cpp:1171
EffectDistortion::ExponentialTable
void ExponentialTable()
Definition: Distortion.cpp:1068
EffectDistortion::mOldThresholdTxt
wxString mOldThresholdTxt
Definition: Distortion.h:205
ShuttleGuiBase::StartMultiColumn
void StartMultiColumn(int nCols, int PositionFlags=wxALIGN_LEFT)
Definition: ShuttleGui.cpp:1203
ShuttleGuiBase::EndVerticalLay
void EndVerticalLay()
Definition: ShuttleGui.cpp:1196
EffectDistortion::TransferDataToWindow
bool TransferDataToWindow() override
Definition: Distortion.cpp:495
Msgids
TranslatableStrings Msgids(const EnumValueSymbol strings[], size_t nStrings)
Definition: Internat.cpp:267
name
const TranslatableString name
Definition: Distortion.cpp:98
EffectDistortion::MakeTable
void MakeTable()
Definition: Distortion.cpp:983
EffectDistortion::ID_Threshold
@ ID_Threshold
Definition: Distortion.h:106
EffectDistortion::mMakeupGain
double mMakeupGain
Definition: Distortion.h:180
EffectDistortion::Params::mThreshold_dB
double mThreshold_dB
Definition: Distortion.h:57
EffectDistortion::LogarithmicTable
void LogarithmicTable()
Definition: Distortion.cpp:1081
EffectDistortion::mOldParam2Txt
wxString mOldParam2Txt
Definition: Distortion.h:208
ShuttleGui::Validator
ShuttleGui & Validator(const Factory &f)
Definition: ShuttleGui.h:685
EffectDistortion::HardClip
void HardClip()
Definition: Distortion.cpp:1028
kSoftClip
@ kSoftClip
Definition: Distortion.cpp:51
defaultLabel
TranslatableString defaultLabel(int index)
Definition: Distortion.cpp:130
kExpCurve
@ kExpCurve
Definition: Distortion.cpp:53
EffectDistortion::mNoiseFloorT
wxTextCtrl * mNoiseFloorT
Definition: Distortion.h:186
ReadAndVerifyDouble
#define ReadAndVerifyDouble(name)
Definition: Effect.h:632
EffectDistortionState::noisefloor
double noisefloor
Definition: Distortion.h:35
EffectDistortion::UpdateControl
void UpdateControl(control id, bool enable, TranslatableString name)
Definition: Distortion.cpp:875
ShuttleGuiBase::AddSlider
wxSlider * AddSlider(const TranslatableString &Prompt, int pos, int Max, int Min=0)
Definition: ShuttleGui.cpp:582
EffectDistortion::InstanceProcess
size_t InstanceProcess(EffectDistortionState &data, float **inBlock, float **outBlock, size_t blockLen)
Definition: Distortion.cpp:552
EffectDistortionState::tablechoiceindx
int tablechoiceindx
Definition: Distortion.h:32
EffectDistortion::DCFilter
float DCFilter(EffectDistortionState &data, float sample)
Definition: Distortion.cpp:1318
EffectDistortionState::skipcount
sampleCount skipcount
Definition: Distortion.h:31
ShuttleGuiBase::StartStatic
wxStaticBox * StartStatic(const TranslatableString &Str, int iProp=0)
Definition: ShuttleGui.cpp:886
TABLESIZE
#define TABLESIZE
Definition: Distortion.h:25
id
int id
Definition: WaveTrackControls.cpp:589
min
int min(int a, int b)
Definition: CompareAudioCommand.cpp:106
ShuttleGui::Name
ShuttleGui & Name(const TranslatableString &name)
Definition: ShuttleGui.h:670
EffectDistortion::mRepeatsT
wxTextCtrl * mRepeatsT
Definition: Distortion.h:189
EffectDistortion::mOldmNoiseFloorTxt
wxString mOldmNoiseFloorTxt
Definition: Distortion.h:206
Effect::mSampleRate
double mSampleRate
Definition: Effect.h:459
EffectDistortion::SoftClip
void SoftClip()
Definition: Distortion.cpp:1045
EffectDistortionState::queuesamples
std::queue< float > queuesamples
Definition: Distortion.h:41
kHardLimiter
@ kHardLimiter
Definition: Distortion.cpp:60
Effect::mUIParent
wxWindow * mUIParent
Definition: Effect.h:477
names
static TranslatableStrings names
Definition: Tags.cpp:743
M_PI_2
#define M_PI_2
Definition: Distortion.cpp:32
EffectDistortion::UpdateControlText
void UpdateControlText(wxTextCtrl *textCtrl, wxString &string, bool enabled)
Definition: Distortion.cpp:968
EffectDistortion::mParam2Txt
wxStaticText * mParam2Txt
Definition: Distortion.h:202
ComponentInterfaceSymbol::Internal
const wxString & Internal() const
Definition: ComponentInterface.h:88
FactoryPresets
static const struct @0 FactoryPresets[]
EffectDistortionState::dcblock
bool dcblock
Definition: Distortion.h:33
EffectDistortion::ID_DCBlock
@ ID_DCBlock
Definition: Distortion.h:105
LINEAR_TO_DB
#define LINEAR_TO_DB(x)
Definition: MemoryX.h:721
kTableTypeStrings
static const EnumValueSymbol kTableTypeStrings[nTableTypes]
Definition: Distortion.cpp:64
EffectDistortion::Leveller
void Leveller()
Definition: Distortion.cpp:1189
M_PI
#define M_PI
Definition: Distortion.cpp:29
EffectDistortion::HardLimiter
void HardLimiter()
Definition: Distortion.cpp:1266
EffectDistortion::mTypeChoiceCtrl
wxChoice * mTypeChoiceCtrl
Definition: Distortion.h:184
EffectDistortion::ID_Param2
@ ID_Param2
Definition: Distortion.h:109
EffectDistortion::mOldParam1Txt
wxString mOldParam1Txt
Definition: Distortion.h:207
EffectDistortion::mNoiseFloorTxt
wxStaticText * mNoiseFloorTxt
Definition: Distortion.h:200
TranslatableString::Translation
wxString Translation() const
Definition: Types.h:337
ShuttleGuiBase::AddVariableText
wxStaticText * AddVariableText(const TranslatableString &Str, bool bCenter=false, int PositionFlags=0, int wrapWidth=0)
Definition: ShuttleGui.cpp:456
TranslatableString::Join
TranslatableString & Join(TranslatableString arg, const wxString &separator={}) &
Definition: Internat.cpp:390
EffectDistortionState::repeats
int repeats
Definition: Distortion.h:38
ShuttleGuiBase::EndStatic
void EndStatic()
Definition: ShuttleGui.cpp:915
kLogCurve
@ kLogCurve
Definition: Distortion.cpp:54
EffectDistortion::Params::mParam2
double mParam2
Definition: Distortion.h:60
EffectDistortion::mParam1S
wxSlider * mParam1S
Definition: Distortion.h:193
EffectDistortion::Symbol
static const ComponentInterfaceSymbol Symbol
Definition: Distortion.h:48
EffectDistortion::mParam1T
wxTextCtrl * mParam1T
Definition: Distortion.h:187
skipsamples
#define skipsamples
Definition: Distortion.cpp:92
EffectDistortion::mParam2T
wxTextCtrl * mParam2T
Definition: Distortion.h:188
ShuttleGuiBase::SetStretchyCol
void SetStretchyCol(int i)
Used to modify an already placed FlexGridSizer to make a column stretchy.
Definition: ShuttleGui.cpp:195
Effect::SetBlockSize
size_t SetBlockSize(size_t maxBlockSize) override
Definition: Effect.cpp:316
EffectDistortion::Params::mRepeats
int mRepeats
Definition: Distortion.h:61
EffectDistortion::WaveShaper
float WaveShaper(float sample)
Definition: Distortion.cpp:1288
EffectDistortionState::threshold
double threshold
Definition: Distortion.h:34
ReadAndVerifyBool
#define ReadAndVerifyBool(name)
Definition: Effect.h:634
EffectDistortion::ID_Param1
@ ID_Param1
Definition: Distortion.h:108
EffectDistortion::EvenHarmonicTable
void EvenHarmonicTable()
Definition: Distortion.cpp:1155