Audacity  3.0.3
Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes | List of all members
EffectAmplify Class Referencefinal

An Effect that makes a sound louder or softer. More...

#include <Amplify.h>

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

Public Member Functions

 EffectAmplify ()
 
virtual ~EffectAmplify ()
 
ComponentInterfaceSymbol GetSymbol () override
 
TranslatableString GetDescription () override
 
wxString ManualPage () override
 
EffectType GetType () override
 
unsigned GetAudioInCount () override
 
unsigned GetAudioOutCount () override
 
size_t ProcessBlock (float **inBlock, float **outBlock, size_t blockLen) override
 
bool DefineParams (ShuttleParams &S) override
 
bool GetAutomationParameters (CommandParameters &parms) override
 
bool SetAutomationParameters (CommandParameters &parms) override
 
bool LoadFactoryDefaults () override
 
bool Init () override
 
void Preview (bool dryOnly) 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("Amplify") }
 
- 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 Member Functions

void OnAmpText (wxCommandEvent &evt)
 
void OnPeakText (wxCommandEvent &evt)
 
void OnAmpSlider (wxCommandEvent &evt)
 
void OnClipCheckBox (wxCommandEvent &evt)
 
void CheckClip ()
 

Private Attributes

double mPeak
 
double mRatio
 
double mRatioClip
 
double mAmp
 
double mNewPeak
 
bool mCanClip
 
wxSlider * mAmpS
 
wxTextCtrl * mAmpT
 
wxTextCtrl * mNewPeakT
 
wxCheckBox * mClip
 

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 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 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

An Effect that makes a sound louder or softer.

This rewritten class supports a smart Amplify effect - it calculates the maximum amount of gain that can be applied to all tracks without causing clipping and selects this as the default parameter.

Definition at line 26 of file Amplify.h.

Constructor & Destructor Documentation

◆ EffectAmplify()

EffectAmplify::EffectAmplify ( )

Definition at line 74 of file Amplify.cpp.

75 {
76  mAmp = DEF_Amp;
78  mRatioClip = 0.0;
79  mCanClip = false;
80  mPeak = 0.0;
81 
82  SetLinearEffectFlag(true);
83 }

References DB_TO_LINEAR().

Here is the call graph for this function:

◆ ~EffectAmplify()

EffectAmplify::~EffectAmplify ( )
virtual

Definition at line 85 of file Amplify.cpp.

86 {
87 }

Member Function Documentation

◆ CheckClip()

void EffectAmplify::CheckClip ( )
private

Definition at line 337 of file Amplify.cpp.

338 {
339  EnableApply(mClip->GetValue() || (mPeak > 0.0 && mRatio <= mRatioClip));
340 }

References Effect::EnableApply(), mClip, mPeak, mRatio, and mRatioClip.

Referenced by OnAmpSlider(), OnAmpText(), OnClipCheckBox(), OnPeakText(), and TransferDataToWindow().

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

◆ DefineParams()

bool EffectAmplify::DefineParams ( ShuttleParams S)
override

Definition at line 135 of file Amplify.cpp.

135  {
136  S.SHUTTLE_PARAM( mRatio, Ratio );
137  if (!IsBatchProcessing())
138  S.SHUTTLE_PARAM( mCanClip, Clipping );
139  return true;
140 }

References Effect::IsBatchProcessing(), mCanClip, and mRatio.

Here is the call graph for this function:

◆ GetAudioInCount()

unsigned EffectAmplify::GetAudioInCount ( )
overridevirtual

Implements EffectClientInterface.

Definition at line 116 of file Amplify.cpp.

117 {
118  return 1;
119 }

◆ GetAudioOutCount()

unsigned EffectAmplify::GetAudioOutCount ( )
overridevirtual

Implements EffectClientInterface.

Definition at line 121 of file Amplify.cpp.

122 {
123  return 1;
124 }

◆ GetAutomationParameters()

bool EffectAmplify::GetAutomationParameters ( CommandParameters parms)
overridevirtual

Implements EffectClientInterface.

Definition at line 142 of file Amplify.cpp.

143 {
144  parms.WriteFloat(KEY_Ratio, mRatio);
145  if (!IsBatchProcessing())
146  parms.WriteFloat(KEY_Clipping, mCanClip);
147 
148  return true;
149 }

References Effect::IsBatchProcessing(), mCanClip, mRatio, and CommandParameters::WriteFloat().

Here is the call graph for this function:

◆ GetDescription()

TranslatableString EffectAmplify::GetDescription ( )
overridevirtual

Implements ComponentInterface.

Definition at line 96 of file Amplify.cpp.

97 {
98  // Note: This is useful only after ratio has been set.
99  return XO("Increases or decreases the volume of the audio you have selected");
100 }

References XO.

◆ GetSymbol()

ComponentInterfaceSymbol EffectAmplify::GetSymbol ( )
overridevirtual

Implements ComponentInterface.

Definition at line 91 of file Amplify.cpp.

92 {
93  return Symbol;
94 }

References Symbol.

◆ GetType()

EffectType EffectAmplify::GetType ( )
overridevirtual

Implements EffectDefinitionInterface.

Definition at line 109 of file Amplify.cpp.

110 {
111  return EffectTypeProcess;
112 }

References EffectTypeProcess.

◆ Init()

bool EffectAmplify::Init ( )
overridevirtual

Reimplemented from Effect.

Definition at line 187 of file Amplify.cpp.

188 {
189  mPeak = 0.0;
190 
191  for (auto t : inputTracks()->Selected< const WaveTrack >())
192  {
193  auto pair = t->GetMinMax(mT0, mT1); // may throw
194  const float min = pair.first, max = pair.second;
195  float newpeak = (fabs(min) > fabs(max) ? fabs(min) : fabs(max));
196 
197  if (newpeak > mPeak)
198  {
199  mPeak = newpeak;
200  }
201  }
202 
203  return true;
204 }

References Effect::inputTracks(), min(), mPeak, Effect::mT0, and Effect::mT1.

Referenced by LoadFactoryDefaults().

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

◆ LoadFactoryDefaults()

bool EffectAmplify::LoadFactoryDefaults ( )
overridevirtual

Implements EffectClientInterface.

Definition at line 166 of file Amplify.cpp.

167 {
168  Init();
169 
170  mRatioClip = 0.0;
171  if (mPeak > 0.0)
172  {
173  mRatio = 1.0 / mPeak;
174  mRatioClip = mRatio;
175  }
176  else
177  {
178  mRatio = 1.0;
179  }
180  mCanClip = false;
181 
182  return TransferDataToWindow();
183 }

References Init(), mCanClip, mPeak, mRatio, mRatioClip, and TransferDataToWindow().

Here is the call graph for this function:

◆ ManualPage()

wxString EffectAmplify::ManualPage ( )
overridevirtual

Reimplemented from Effect.

Definition at line 102 of file Amplify.cpp.

103 {
104  return wxT("Amplify");
105 }

◆ OnAmpSlider()

void EffectAmplify::OnAmpSlider ( wxCommandEvent &  evt)
private

Definition at line 385 of file Amplify.cpp.

386 {
387  double dB = evt.GetInt() / SCL_Amp;
388  mRatio = DB_TO_LINEAR(TrapDouble(dB, MIN_Amp, MAX_Amp));
389 
390  double dB2 = (evt.GetInt() - 1) / SCL_Amp;
391  double ratio2 = DB_TO_LINEAR(TrapDouble(dB2, MIN_Amp, MAX_Amp));
392 
393  if (!mClip->GetValue() && mRatio * mPeak > 1.0 && ratio2 * mPeak < 1.0)
394  {
395  mRatio = 1.0 / mPeak;
396  }
397 
399  mAmpT->GetValidator()->TransferToWindow();
400 
402  mNewPeakT->GetValidator()->TransferToWindow();
403 
404  CheckClip();
405 }

References CheckClip(), DB_TO_LINEAR(), LINEAR_TO_DB, mAmp, mAmpT, mClip, mNewPeak, mNewPeakT, mPeak, mRatio, and TrapDouble().

Here is the call graph for this function:

◆ OnAmpText()

void EffectAmplify::OnAmpText ( wxCommandEvent &  evt)
private

Definition at line 342 of file Amplify.cpp.

343 {
344  if (!mAmpT->GetValidator()->TransferFromWindow())
345  {
346  EnableApply(false);
347  return;
348  }
349 
350  mRatio = DB_TO_LINEAR(TrapDouble(mAmp * SCL_Amp, MIN_Amp * SCL_Amp, MAX_Amp * SCL_Amp) / SCL_Amp);
351 
352  mAmpS->SetValue((int) (LINEAR_TO_DB(mRatio) * SCL_Amp + 0.5));
353 
355  mNewPeakT->GetValidator()->TransferToWindow();
356 
357  CheckClip();
358 }

References CheckClip(), DB_TO_LINEAR(), Effect::EnableApply(), LINEAR_TO_DB, mAmp, mAmpS, mAmpT, mNewPeak, mNewPeakT, mPeak, mRatio, and TrapDouble().

Here is the call graph for this function:

◆ OnClipCheckBox()

void EffectAmplify::OnClipCheckBox ( wxCommandEvent &  evt)
private

Definition at line 407 of file Amplify.cpp.

408 {
409  CheckClip();
410 }

References CheckClip().

Here is the call graph for this function:

◆ OnPeakText()

void EffectAmplify::OnPeakText ( wxCommandEvent &  evt)
private

Definition at line 360 of file Amplify.cpp.

361 {
362  if (!mNewPeakT->GetValidator()->TransferFromWindow())
363  {
364  EnableApply(false);
365  return;
366  }
367 
368  if (mNewPeak == 0.0)
369  mRatio = mRatioClip;
370  else
372 
373  double ampInit = LINEAR_TO_DB(mRatio);
374  mAmp = TrapDouble(ampInit, MIN_Amp, MAX_Amp);
375  if (mAmp != ampInit)
377 
378  mAmpT->GetValidator()->TransferToWindow();
379 
380  mAmpS->SetValue((int) (mAmp * SCL_Amp + 0.5f));
381 
382  CheckClip();
383 }

References CheckClip(), DB_TO_LINEAR(), Effect::EnableApply(), LINEAR_TO_DB, mAmp, mAmpS, mAmpT, mNewPeak, mNewPeakT, mPeak, mRatio, mRatioClip, and TrapDouble().

Here is the call graph for this function:

◆ PopulateOrExchange()

void EffectAmplify::PopulateOrExchange ( ShuttleGui S)
overridevirtual

Reimplemented from Effect.

Definition at line 214 of file Amplify.cpp.

215 {
216  enum{ precision = 3 }; // allow (a generous) 3 decimal places for Amplification (dB)
217 
218  bool batch = IsBatchProcessing();
219  if ( batch )
220  {
221  mCanClip = true;
222  mPeak = 1.0;
223  }
224  else
225  {
226  if (mPeak > 0.0)
227  {
228  mRatio = 1.0 / mPeak;
229  mRatioClip = mRatio;
230  }
231  else
232  {
233  mRatio = 1.0;
234  }
235  }
236 
237  S.AddSpace(0, 5);
238 
239  S.StartVerticalLay(0);
240  {
241  // Amplitude
242  S.StartMultiColumn(2, wxCENTER);
243  {
244  mAmpT = S.Id(ID_Amp)
245  .Validator<FloatingPointValidator<double>>(
246  precision, &mAmp, NumValidatorStyle::ONE_TRAILING_ZERO, MIN_Amp, MAX_Amp
247  )
248  .AddTextBox(XXO("&Amplification (dB):"), wxT(""), 12);
249  }
250  S.EndMultiColumn();
251 
252  // Amplitude
253  S.StartHorizontalLay(wxEXPAND);
254  {
255  mAmpS = S.Id(ID_Amp)
256  .Style(wxSL_HORIZONTAL)
257  .Name(XO("Amplification dB"))
258  .AddSlider( {}, 0, MAX_Amp * SCL_Amp, MIN_Amp * SCL_Amp);
259  }
260  S.EndHorizontalLay();
261 
262  // Peak
263  S.StartMultiColumn(2, wxCENTER);
264  {
265  mNewPeakT = S.Id(ID_Peak)
266  .Validator<FloatingPointValidator<double>>(
267  // One extra decimal place so that rounding is visible to user
268  // (see: bug 958)
269  precision + 1,
270  &mNewPeak, NumValidatorStyle::ONE_TRAILING_ZERO,
271  // min and max need same precision as what we're validating (bug 963)
272  RoundValue( precision + 1, MIN_Amp + LINEAR_TO_DB(mPeak) ),
273  RoundValue( precision + 1, MAX_Amp + LINEAR_TO_DB(mPeak) )
274  )
275  .AddTextBox(XXO("&New Peak Amplitude (dB):"), wxT(""), 12);
276  }
277  S.EndMultiColumn();
278 
279  // Clipping
280  S.StartHorizontalLay(wxCENTER);
281  {
282 
283  mClip = S.Id(ID_Clip).Disable( batch )
284  .AddCheckBox(XXO("Allo&w clipping"), false);
285  }
286  S.EndHorizontalLay();
287  }
288  S.EndVerticalLay();
289 
290  return;
291 }

References ShuttleGuiBase::AddCheckBox(), ShuttleGui::AddSpace(), ShuttleGui::Disable(), ShuttleGuiBase::EndHorizontalLay(), ShuttleGuiBase::EndMultiColumn(), ShuttleGuiBase::EndVerticalLay(), ShuttleGui::Id(), ID_Amp, ID_Clip, ID_Peak, Effect::IsBatchProcessing(), LINEAR_TO_DB, mAmp, mAmpS, mAmpT, mCanClip, mClip, mNewPeak, mNewPeakT, mPeak, mRatio, mRatioClip, ShuttleGui::Name(), ShuttleGuiBase::StartHorizontalLay(), ShuttleGuiBase::StartMultiColumn(), ShuttleGuiBase::StartVerticalLay(), ShuttleGui::Style(), ShuttleGui::Validator(), XO, and XXO.

Here is the call graph for this function:

◆ Preview()

void EffectAmplify::Preview ( bool  dryOnly)
overridevirtual

Reimplemented from Effect.

Definition at line 206 of file Amplify.cpp.

207 {
208  auto cleanup1 = valueRestorer( mRatio );
209  auto cleanup2 = valueRestorer( mPeak );
210 
211  Effect::Preview(dryOnly);
212 }

References mPeak, mRatio, Effect::Preview(), and valueRestorer().

Here is the call graph for this function:

◆ ProcessBlock()

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

Implements EffectClientInterface.

Definition at line 126 of file Amplify.cpp.

127 {
128  for (decltype(blockLen) i = 0; i < blockLen; i++)
129  {
130  outBlock[0][i] = inBlock[0][i] * mRatio;
131  }
132 
133  return blockLen;
134 }

References mRatio.

◆ SetAutomationParameters()

bool EffectAmplify::SetAutomationParameters ( CommandParameters parms)
overridevirtual

Implements EffectClientInterface.

Definition at line 151 of file Amplify.cpp.

152 {
153  ReadAndVerifyFloat(Ratio);
154  mRatio = Ratio;
155 
156  if (!IsBatchProcessing()){
157  ReadAndVerifyBool(Clipping);
158  mCanClip = Clipping;
159  } else {
160  mCanClip = true;
161  }
162 
163  return true;
164 }

References Effect::IsBatchProcessing(), mCanClip, mRatio, ReadAndVerifyBool, and ReadAndVerifyFloat.

Here is the call graph for this function:

◆ TransferDataFromWindow()

bool EffectAmplify::TransferDataFromWindow ( )
overridevirtual

Reimplemented from Effect.

Definition at line 316 of file Amplify.cpp.

317 {
318  if (!mUIParent->Validate() || !mUIParent->TransferDataFromWindow())
319  {
320  return false;
321  }
322 
323  mRatio = DB_TO_LINEAR(TrapDouble(mAmp * SCL_Amp, MIN_Amp * SCL_Amp, MAX_Amp * SCL_Amp) / SCL_Amp);
324 
325  mCanClip = mClip->GetValue();
326 
327  if (!mCanClip && mRatio * mPeak > 1.0)
328  {
329  mRatio = 1.0 / mPeak;
330  }
331 
332  return true;
333 }

References DB_TO_LINEAR(), mAmp, mCanClip, mClip, mPeak, mRatio, Effect::mUIParent, and TrapDouble().

Here is the call graph for this function:

◆ TransferDataToWindow()

bool EffectAmplify::TransferDataToWindow ( )
overridevirtual

Reimplemented from Effect.

Definition at line 293 of file Amplify.cpp.

294 {
295  // limit range of gain
296  double dBInit = LINEAR_TO_DB(mRatio);
297  double dB = TrapDouble(dBInit, MIN_Amp, MAX_Amp);
298  if (dB != dBInit)
299  mRatio = DB_TO_LINEAR(dB);
300 
302  mAmpT->GetValidator()->TransferToWindow();
303 
304  mAmpS->SetValue((int) (mAmp * SCL_Amp + 0.5f));
305 
307  mNewPeakT->GetValidator()->TransferToWindow();
308 
309  mClip->SetValue(mCanClip);
310 
311  CheckClip();
312 
313  return true;
314 }

References CheckClip(), DB_TO_LINEAR(), LINEAR_TO_DB, mAmp, mAmpS, mAmpT, mCanClip, mClip, mNewPeak, mNewPeakT, mPeak, mRatio, and TrapDouble().

Referenced by LoadFactoryDefaults().

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

Member Data Documentation

◆ mAmp

double EffectAmplify::mAmp
private

◆ mAmpS

wxSlider* EffectAmplify::mAmpS
private

Definition at line 80 of file Amplify.h.

Referenced by OnAmpText(), OnPeakText(), PopulateOrExchange(), and TransferDataToWindow().

◆ mAmpT

wxTextCtrl* EffectAmplify::mAmpT
private

◆ mCanClip

bool EffectAmplify::mCanClip
private

◆ mClip

wxCheckBox* EffectAmplify::mClip
private

◆ mNewPeak

double EffectAmplify::mNewPeak
private

◆ mNewPeakT

wxTextCtrl* EffectAmplify::mNewPeakT
private

◆ mPeak

double EffectAmplify::mPeak
private

◆ mRatio

double EffectAmplify::mRatio
private

◆ mRatioClip

double EffectAmplify::mRatioClip
private

Definition at line 75 of file Amplify.h.

Referenced by CheckClip(), LoadFactoryDefaults(), OnPeakText(), and PopulateOrExchange().

◆ Symbol

const ComponentInterfaceSymbol EffectAmplify::Symbol { XO("Amplify") }
static

Definition at line 29 of file Amplify.h.

Referenced by GetSymbol().


The documentation for this class was generated from the following files:
EffectAmplify::mRatio
double mRatio
Definition: Amplify.h:74
valueRestorer
ValueRestorer< T > valueRestorer(T &var)
inline functions provide convenient parameter type deduction
Definition: MemoryX.h:430
ShuttleGuiBase::StartVerticalLay
void StartVerticalLay(int iProp=1)
Definition: ShuttleGui.cpp:1177
EffectTypeProcess
@ EffectTypeProcess
Definition: EffectInterface.h:59
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::SetLinearEffectFlag
void SetLinearEffectFlag(bool linearEffectFlag)
Definition: Effect.cpp:2000
Effect::EnableApply
virtual bool EnableApply(bool enable=true)
Definition: Effect.cpp:1925
ID_Clip
@ ID_Clip
Definition: Amplify.cpp:48
EffectAmplify::CheckClip
void CheckClip()
Definition: Amplify.cpp:337
Effect::mT1
double mT1
Definition: Effect.h:466
EffectAmplify::mRatioClip
double mRatioClip
Definition: Amplify.h:75
ShuttleGui::AddSpace
wxSizerItem * AddSpace(int width, int height, int prop=0)
Definition: ShuttleGui.cpp:2421
XO
#define XO(s)
Definition: Internat.h:32
EffectAmplify::mAmp
double mAmp
Definition: Amplify.h:76
ShuttleGuiBase::EndMultiColumn
void EndMultiColumn()
Definition: ShuttleGui.cpp:1212
Effect::IsBatchProcessing
virtual bool IsBatchProcessing()
Definition: Effect.cpp:1189
EffectAmplify::Symbol
static const ComponentInterfaceSymbol Symbol
Definition: Amplify.h:29
CommandParameters::WriteFloat
bool WriteFloat(const wxString &key, float f)
Definition: EffectAutomationParameters.h:156
EffectAmplify::mNewPeakT
wxTextCtrl * mNewPeakT
Definition: Amplify.h:82
EffectAmplify::mCanClip
bool mCanClip
Definition: Amplify.h:78
ShuttleGui::Id
ShuttleGui & Id(int id)
Definition: ShuttleGui.cpp:2248
ShuttleGui::Style
ShuttleGui & Style(long iStyle)
Definition: ShuttleGui.h:734
XXO
#define XXO(s)
Definition: Internat.h:45
Effect::inputTracks
const TrackList * inputTracks() const
Definition: Effect.h:462
ShuttleGuiBase::EndHorizontalLay
void EndHorizontalLay()
Definition: ShuttleGui.cpp:1170
Effect::mT0
double mT0
Definition: Effect.h:465
ShuttleGuiBase::StartHorizontalLay
void StartHorizontalLay(int PositionFlags=wxALIGN_CENTRE, int iProp=1)
Definition: ShuttleGui.cpp:1160
EffectAmplify::mAmpT
wxTextCtrl * mAmpT
Definition: Amplify.h:81
ShuttleGui::Disable
ShuttleGui & Disable(bool disabled=true)
Definition: ShuttleGui.h:657
ShuttleGuiBase::StartMultiColumn
void StartMultiColumn(int nCols, int PositionFlags=wxALIGN_LEFT)
Definition: ShuttleGui.cpp:1203
ShuttleGuiBase::EndVerticalLay
void EndVerticalLay()
Definition: ShuttleGui.cpp:1196
ID_Peak
@ ID_Peak
Definition: Amplify.cpp:47
EffectAmplify::mNewPeak
double mNewPeak
Definition: Amplify.h:77
ShuttleGui::Validator
ShuttleGui & Validator(const Factory &f)
Definition: ShuttleGui.h:685
EffectAmplify::mPeak
double mPeak
Definition: Amplify.h:72
EffectAmplify::TransferDataToWindow
bool TransferDataToWindow() override
Definition: Amplify.cpp:293
Effect::Preview
virtual void Preview(bool dryOnly)
Definition: Effect.cpp:2294
min
int min(int a, int b)
Definition: CompareAudioCommand.cpp:106
ShuttleGui::Name
ShuttleGui & Name(const TranslatableString &name)
Definition: ShuttleGui.h:670
EffectAmplify::Init
bool Init() override
Definition: Amplify.cpp:187
EffectAmplify::mClip
wxCheckBox * mClip
Definition: Amplify.h:83
Effect::mUIParent
wxWindow * mUIParent
Definition: Effect.h:477
EffectAmplify::mAmpS
wxSlider * mAmpS
Definition: Amplify.h:80
LINEAR_TO_DB
#define LINEAR_TO_DB(x)
Definition: MemoryX.h:721
TrapDouble
double TrapDouble(double x, double min, double max)
Definition: Effect.h:563
ReadAndVerifyBool
#define ReadAndVerifyBool(name)
Definition: Effect.h:634
ID_Amp
@ ID_Amp
Definition: Amplify.cpp:46
ReadAndVerifyFloat
#define ReadAndVerifyFloat(name)
Definition: Effect.h:633