Audacity  3.2.0
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
 
ManualPageID ManualPage () override
 Name of a page in the Audacity alpha manual, default is empty. More...
 
EffectType GetType () override
 Type determines how it behaves. More...
 
bool GetAutomationParameters (CommandParameters &parms) override
 Save current settings into parms. More...
 
bool SetAutomationParameters (CommandParameters &parms) override
 Change settings to those stored in parms. More...
 
bool LoadFactoryDefaults () override
 Change settings back to "factory default". More...
 
unsigned GetAudioInCount () override
 
unsigned GetAudioOutCount () override
 
size_t ProcessBlock (float **inBlock, float **outBlock, size_t blockLen) override
 Called for destructive, non-realtime effect computation. More...
 
bool DefineParams (ShuttleParams &S) 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
 Type determines how it behaves. More...
 
EffectFamilySymbol GetFamily () override
 Report identifier and user-visible name of the effect protocol. More...
 
bool IsInteractive () override
 Whether the effect needs a dialog for entry of settings. More...
 
bool IsDefault () override
 Whether the effect sorts "above the line" in the menus. More...
 
bool IsLegacy () override
 
bool SupportsRealtime () override
 Whether the effect supports realtime previewing (while audio is playing). More...
 
bool SupportsAutomation () override
 Whether the effect can be used without the UI, in a macro. More...
 
bool GetAutomationParameters (CommandParameters &parms) override
 Save current settings into parms. More...
 
bool SetAutomationParameters (CommandParameters &parms) override
 Change settings to those stored in parms. More...
 
bool LoadUserPreset (const RegistryPath &name) override
 Change settings to a user-named preset. More...
 
bool SaveUserPreset (const RegistryPath &name) override
 Save current settings as a user-named preset. More...
 
RegistryPaths GetFactoryPresets () override
 Report names of factory presets. More...
 
bool LoadFactoryPreset (int id) override
 Change settings to the preset whose name is GetFactoryPresets()[id] More...
 
bool LoadFactoryDefaults () override
 Change settings back to "factory default". More...
 
bool SetHost (EffectHostInterface *host) override
 
unsigned GetAudioInCount () override
 
unsigned GetAudioOutCount () override
 
int GetMidiInCount () override
 
int GetMidiOutCount () override
 
sampleCount GetLatency () override
 Called for destructive, non-realtime effect computation. More...
 
size_t GetTailSize () override
 
void SetSampleRate (double rate) override
 
size_t SetBlockSize (size_t maxBlockSize) override
 
size_t GetBlockSize () const override
 
bool ProcessInitialize (sampleCount totalLen, ChannelNames chanMap=NULL) override
 Called for destructive, non-realtime effect computation. More...
 
bool ProcessFinalize () override
 Called for destructive, non-realtime effect computation. More...
 
size_t ProcessBlock (float **inBlock, float **outBlock, size_t blockLen) override
 Called for destructive, non-realtime effect computation. More...
 
bool RealtimeInitialize () override
 
bool RealtimeAddProcessor (unsigned numChannels, float sampleRate) override
 
bool RealtimeFinalize () override
 
bool RealtimeSuspend () override
 
bool RealtimeResume () noexcept override
 
bool RealtimeProcessStart () override
 
size_t RealtimeProcess (int group, float **inbuf, float **outbuf, size_t numSamples) override
 
bool RealtimeProcessEnd () noexcept override
 
int ShowClientInterface (wxWindow &parent, wxDialog &dialog, bool forceModal=false) override
 
bool PopulateUI (ShuttleGui &S) final
 Adds controls to a panel that is given as the parent window of S More...
 
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
 
EffectDefinitionInterfaceGetDefinition () 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 ()
 
int ShowHostInterface (wxWindow &parent, const EffectDialogFactory &factory, bool forceModal=false) override
 
unsigned TestUIFlags (unsigned mask)
 
void SetPresetParameters (const wxArrayString *Names, const wxArrayString *Values)
 
virtual bool Startup (EffectUIClientInterface *client)
 
virtual bool GetAutomationParametersAsString (wxString &parms)
 
virtual bool SetAutomationParametersFromString (const wxString &parms)
 
virtual bool IsBatchProcessing ()
 
virtual void SetBatchProcessing (bool start)
 
bool DoEffect (double projectRate, TrackList *list, WaveTrackFactory *factory, NotifyingSelectedRegion &selectedRegion, unsigned flags, wxWindow *pParent=nullptr, const EffectDialogFactory &dialogFactory={})
 
bool Delegate (Effect &delegate, wxWindow &parent, const EffectDialogFactory &factory)
 
int MessageBox (const TranslatableString &message, long style=DefaultMessageBoxStyle, const TranslatableString &titleStr={})
 
virtual bool Startup ()
 
- Public Member Functions inherited from EffectUIClientInterface
virtual ~EffectUIClientInterface ()
 
- Public Member Functions inherited from EffectProcessor
virtual ~EffectProcessor ()
 
- Public Member Functions inherited from EffectDefinitionInterface
virtual ~EffectDefinitionInterface ()
 
virtual EffectType GetClassification ()
 Determines which menu it appears in; default same as GetType(). More...
 
virtual bool EnablesDebug ()
 Whether the effect dialog should have a Debug button; default, always false. More...
 
virtual FilePath HelpPage ()
 Fully qualified local help file name, default is empty. More...
 
virtual bool IsHiddenFromMenus ()
 Default is false. More...
 
- Public Member Functions inherited from ComponentInterface
virtual ~ComponentInterface ()
 
TranslatableString GetName ()
 
virtual bool DefineParams (ShuttleParams &WXUNUSED(S))
 
- Public Member Functions inherited from EffectUIHostInterface
virtual ~EffectUIHostInterface ()
 
- Public Member Functions inherited from EffectHostInterface
virtual ~EffectHostInterface ()
 

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 }
 
- Static Public Member Functions inherited from Effect
static void IncEffectCounter ()
 
- Static Public Member Functions inherited from EffectDefinitionInterface
static Identifier GetSquashedName (const Identifier &ident)
 A utility that strips spaces and CamelCases a name. More...
 
- Protected Member Functions inherited from Effect
bool EnableApply (bool enable=true)
 
bool EnablePreview (bool enable=true)
 
virtual bool CheckWhetherSkipEffect ()
 
virtual bool Process ()
 
virtual bool ProcessPass ()
 
virtual bool InitPass1 ()
 
virtual bool InitPass2 ()
 
virtual void End ()
 
virtual double CalcPreviewInputLength (double previewLength)
 
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
BasicUI::ProgressDialogmProgress = nullptr
 
double mProjectRate
 
double mSampleRate
 
WaveTrackFactorymFactory
 
std::shared_ptr< TrackListmOutputTracks
 
double mT0
 
double mT1
 
wxArrayString mPresetNames
 
wxArrayString mPresetValues
 
int mPass
 
wxWeakRef< wxDialog > mHostUIDialog
 This smart pointer tracks the lifetime of the dialog. More...
 
wxWeakRef< wxDialog > mUIDialog
 This weak pointer may be the same as the above, or null. More...
 
wxWindow * mUIParent
 
unsigned mUIFlags { 0 }
 
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, mRatio, and S.

Here is the call graph for this function:

◆ GetAudioInCount()

unsigned EffectAmplify::GetAudioInCount ( )
overridevirtual

Implements EffectProcessor.

Definition at line 116 of file Amplify.cpp.

117 {
118  return 1;
119 }

◆ GetAudioOutCount()

unsigned EffectAmplify::GetAudioOutCount ( )
overridevirtual

Implements EffectProcessor.

Definition at line 121 of file Amplify.cpp.

122 {
123  return 1;
124 }

◆ GetAutomationParameters()

bool EffectAmplify::GetAutomationParameters ( CommandParameters parms)
overridevirtual

Save current settings into parms.

Implements EffectDefinitionInterface.

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

Type determines how it behaves.

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

Change settings back to "factory default".

Implements EffectDefinitionInterface.

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

ManualPageID EffectAmplify::ManualPage ( )
overridevirtual

Name of a page in the Audacity alpha manual, default is empty.

Reimplemented from EffectDefinitionInterface.

Definition at line 102 of file Amplify.cpp.

103 {
104  return L"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 ID_Amp, ID_Clip, ID_Peak, Effect::IsBatchProcessing(), LINEAR_TO_DB, mAmp, mAmpS, mAmpT, mCanClip, mClip, mNewPeak, mNewPeakT, mPeak, mRatio, mRatioClip, S, 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

Called for destructive, non-realtime effect computation.

Implements EffectProcessor.

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

Change settings to those stored in parms.

Implements EffectDefinitionInterface.

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:226
EffectTypeProcess
@ EffectTypeProcess
Definition: EffectInterface.h:56
DB_TO_LINEAR
const double MIN_Threshold_Linear DB_TO_LINEAR(MIN_Threshold_dB)
Effect::SetLinearEffectFlag
void SetLinearEffectFlag(bool linearEffectFlag)
Definition: Effect.cpp:1764
ID_Amp
@ ID_Amp
Definition: Amplify.cpp:46
Effect::EnableApply
bool EnableApply(bool enable=true)
Definition: Effect.cpp:1694
S
#define S(N)
Definition: ToChars.cpp:64
EffectAmplify::CheckClip
void CheckClip()
Definition: Amplify.cpp:337
Effect::mT1
double mT1
Definition: Effect.h:424
EffectAmplify::mRatioClip
double mRatioClip
Definition: Amplify.h:75
XO
#define XO(s)
Definition: Internat.h:31
EffectAmplify::mAmp
double mAmp
Definition: Amplify.h:76
Effect::IsBatchProcessing
virtual bool IsBatchProcessing()
Definition: Effect.cpp:960
EffectAmplify::Symbol
static const ComponentInterfaceSymbol Symbol
Definition: Amplify.h:29
CommandParameters::WriteFloat
bool WriteFloat(const wxString &key, float f)
Definition: EffectAutomationParameters.h:155
EffectAmplify::mNewPeakT
wxTextCtrl * mNewPeakT
Definition: Amplify.h:82
EffectAmplify::mCanClip
bool mCanClip
Definition: Amplify.h:78
XXO
#define XXO(s)
Definition: Internat.h:44
Effect::inputTracks
const TrackList * inputTracks() const
Definition: Effect.h:420
Effect::mT0
double mT0
Definition: Effect.h:423
EffectAmplify::mAmpT
wxTextCtrl * mAmpT
Definition: Amplify.h:81
EffectAmplify::mNewPeak
double mNewPeak
Definition: Amplify.h:77
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:2053
min
int min(int a, int b)
Definition: CompareAudioCommand.cpp:106
EffectAmplify::Init
bool Init() override
Definition: Amplify.cpp:187
ID_Clip
@ ID_Clip
Definition: Amplify.cpp:48
EffectAmplify::mClip
wxCheckBox * mClip
Definition: Amplify.h:83
Effect::mUIParent
wxWindow * mUIParent
Definition: Effect.h:438
EffectAmplify::mAmpS
wxSlider * mAmpS
Definition: Amplify.h:80
LINEAR_TO_DB
#define LINEAR_TO_DB(x)
Definition: MemoryX.h:503
TrapDouble
double TrapDouble(double x, double min, double max)
Definition: Effect.h:523
ID_Peak
@ ID_Peak
Definition: Amplify.cpp:47
ReadAndVerifyBool
#define ReadAndVerifyBool(name)
Definition: Effect.h:594
ReadAndVerifyFloat
#define ReadAndVerifyFloat(name)
Definition: Effect.h:593