Audacity  3.2.0
Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes | List of all members
EffectClickRemoval Class Referencefinal

An Effect for removing clicks. More...

#include <ClickRemoval.h>

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

Public Member Functions

 EffectClickRemoval ()
 
virtual ~EffectClickRemoval ()
 
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 DefineParams (ShuttleParams &S) override
 
bool CheckWhetherSkipEffect () override
 
bool Startup () override
 
bool Process () 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={})
 
- 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("Click Removal") }
 
- 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

bool ProcessOne (int count, WaveTrack *track, sampleCount start, sampleCount len)
 
bool RemoveClicks (size_t len, float *buffer)
 
void OnWidthText (wxCommandEvent &evt)
 
void OnThreshText (wxCommandEvent &evt)
 
void OnWidthSlider (wxCommandEvent &evt)
 
void OnThreshSlider (wxCommandEvent &evt)
 

Private Attributes

EnvelopemEnvelope
 
bool mbDidSomething
 
size_t windowSize
 
int mThresholdLevel
 
int mClickWidth
 
int sep
 
wxSlider * mWidthS
 
wxSlider * mThreshS
 
wxTextCtrl * mWidthT
 
wxTextCtrl * mThreshT
 

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 Init ()
 
virtual bool ProcessPass ()
 
virtual bool InitPass1 ()
 
virtual bool InitPass2 ()
 
virtual void End ()
 
virtual double CalcPreviewInputLength (double previewLength)
 
virtual void Preview (bool dryOnly)
 
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 for removing clicks.

Clicks are identified as small regions of high amplitude compared to the surrounding chunk of sound. Anything sufficiently tall compared to a large (2048 sample) window around it, and sufficiently narrow, is considered to be a click.

The structure was largely stolen from Domonic Mazzoni's NoiseRemoval module, and reworked for the NEW effect.

This file is intended to become part of Audacity. You may modify and/or distribute it under the same terms as Audacity itself.

Definition at line 26 of file ClickRemoval.h.

Constructor & Destructor Documentation

◆ EffectClickRemoval()

EffectClickRemoval::EffectClickRemoval ( )

Definition at line 69 of file ClickRemoval.cpp.

70 {
71  mThresholdLevel = DEF_Threshold;
72  mClickWidth = DEF_Width;
73 
74  SetLinearEffectFlag(false);
75 
76  windowSize = 8192;
77  sep = 2049;
78 }

◆ ~EffectClickRemoval()

EffectClickRemoval::~EffectClickRemoval ( )
virtual

Definition at line 80 of file ClickRemoval.cpp.

81 {
82 }

Member Function Documentation

◆ CheckWhetherSkipEffect()

bool EffectClickRemoval::CheckWhetherSkipEffect ( )
overridevirtual

Reimplemented from Effect.

Definition at line 136 of file ClickRemoval.cpp.

137 {
138  return ((mClickWidth == 0) || (mThresholdLevel == 0));
139 }

References mClickWidth, and mThresholdLevel.

◆ DefineParams()

bool EffectClickRemoval::DefineParams ( ShuttleParams S)
override

Definition at line 109 of file ClickRemoval.cpp.

109  {
110  S.SHUTTLE_PARAM( mThresholdLevel, Threshold );
111  S.SHUTTLE_PARAM( mClickWidth, Width );
112  return true;
113 }

References mClickWidth, mThresholdLevel, and S.

◆ GetAutomationParameters()

bool EffectClickRemoval::GetAutomationParameters ( CommandParameters parms)
overridevirtual

Save current settings into parms.

Implements EffectDefinitionInterface.

Definition at line 115 of file ClickRemoval.cpp.

116 {
117  parms.Write(KEY_Threshold, mThresholdLevel);
118  parms.Write(KEY_Width, mClickWidth);
119 
120  return true;
121 }

References mClickWidth, and mThresholdLevel.

◆ GetDescription()

TranslatableString EffectClickRemoval::GetDescription ( )
overridevirtual

Implements ComponentInterface.

Definition at line 91 of file ClickRemoval.cpp.

92 {
93  return XO("Click Removal is designed to remove clicks on audio tracks");
94 }

References XO.

◆ GetSymbol()

ComponentInterfaceSymbol EffectClickRemoval::GetSymbol ( )
overridevirtual

Implements ComponentInterface.

Definition at line 86 of file ClickRemoval.cpp.

87 {
88  return Symbol;
89 }

References Symbol.

◆ GetType()

EffectType EffectClickRemoval::GetType ( )
overridevirtual

Type determines how it behaves.

Implements EffectDefinitionInterface.

Definition at line 103 of file ClickRemoval.cpp.

104 {
105  return EffectTypeProcess;
106 }

References EffectTypeProcess.

◆ ManualPage()

ManualPageID EffectClickRemoval::ManualPage ( )
overridevirtual

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

Reimplemented from EffectDefinitionInterface.

Definition at line 96 of file ClickRemoval.cpp.

97 {
98  return L"Click_Removal";
99 }

◆ OnThreshSlider()

void EffectClickRemoval::OnThreshSlider ( wxCommandEvent &  evt)
private

Definition at line 421 of file ClickRemoval.cpp.

422 {
423  mThreshS->GetValidator()->TransferFromWindow();
424  mThreshT->GetValidator()->TransferToWindow();
425 }

References mThreshS, and mThreshT.

◆ OnThreshText()

void EffectClickRemoval::OnThreshText ( wxCommandEvent &  evt)
private

Definition at line 409 of file ClickRemoval.cpp.

410 {
411  mThreshT->GetValidator()->TransferFromWindow();
412  mThreshS->GetValidator()->TransferToWindow();
413 }

References mThreshS, and mThreshT.

◆ OnWidthSlider()

void EffectClickRemoval::OnWidthSlider ( wxCommandEvent &  evt)
private

Definition at line 415 of file ClickRemoval.cpp.

416 {
417  mWidthS->GetValidator()->TransferFromWindow();
418  mWidthT->GetValidator()->TransferToWindow();
419 }

References mWidthS, and mWidthT.

◆ OnWidthText()

void EffectClickRemoval::OnWidthText ( wxCommandEvent &  evt)
private

Definition at line 403 of file ClickRemoval.cpp.

404 {
405  mWidthT->GetValidator()->TransferFromWindow();
406  mWidthS->GetValidator()->TransferToWindow();
407 }

References mWidthS, and mWidthT.

◆ PopulateOrExchange()

void EffectClickRemoval::PopulateOrExchange ( ShuttleGui S)
overridevirtual

Reimplemented from Effect.

Definition at line 338 of file ClickRemoval.cpp.

339 {
340  S.AddSpace(0, 5);
341  S.SetBorder(10);
342 
343  S.StartMultiColumn(3, wxEXPAND);
344  S.SetStretchyCol(2);
345  {
346  // Threshold
347  mThreshT = S.Id(ID_Thresh)
348  .Validator<IntegerValidator<int>>(
349  &mThresholdLevel, NumValidatorStyle::DEFAULT,
350  MIN_Threshold, MAX_Threshold
351  )
352  .AddTextBox(XXO("&Threshold (lower is more sensitive):"),
353  wxT(""),
354  10);
355 
356  mThreshS = S.Id(ID_Thresh)
357  .Name(XO("Threshold"))
358  .Style(wxSL_HORIZONTAL)
359  .Validator<wxGenericValidator>(&mThresholdLevel)
360  .MinSize( { 150, -1 } )
361  .AddSlider( {}, mThresholdLevel, MAX_Threshold, MIN_Threshold);
362 
363  // Click width
364  mWidthT = S.Id(ID_Width)
365  .Validator<IntegerValidator<int>>(
366  &mClickWidth, NumValidatorStyle::DEFAULT, MIN_Width, MAX_Width)
367  .AddTextBox(XXO("Max &Spike Width (higher is more sensitive):"),
368  wxT(""),
369  10);
370 
371  mWidthS = S.Id(ID_Width)
372  .Name(XO("Max Spike Width"))
373  .Style(wxSL_HORIZONTAL)
374  .Validator<wxGenericValidator>(&mClickWidth)
375  .MinSize( { 150, -1 } )
376  .AddSlider( {}, mClickWidth, MAX_Width, MIN_Width);
377  }
378  S.EndMultiColumn();
379 
380  return;
381 }

References ID_Thresh, ID_Width, mClickWidth, mThresholdLevel, mThreshS, mThreshT, mWidthS, mWidthT, S, XO, and XXO.

◆ Process()

bool EffectClickRemoval::Process ( )
overridevirtual

If Process() is not overridden, it uses ProcessInitialize(), ProcessBlock(), and ProcessFinalize() methods of EffectProcessor, and also GetLatency() to determine how many leading output samples to discard and how many extra samples to produce.

Reimplemented from Effect.

Definition at line 177 of file ClickRemoval.cpp.

178 {
179  this->CopyInputTracks(); // Set up mOutputTracks.
180  bool bGoodResult = true;
181  mbDidSomething = false;
182 
183  int count = 0;
184  for( auto track : mOutputTracks->Selected< WaveTrack >() ) {
185  double trackStart = track->GetStartTime();
186  double trackEnd = track->GetEndTime();
187  double t0 = mT0 < trackStart? trackStart: mT0;
188  double t1 = mT1 > trackEnd? trackEnd: mT1;
189 
190  if (t1 > t0) {
191  auto start = track->TimeToLongSamples(t0);
192  auto end = track->TimeToLongSamples(t1);
193  auto len = end - start;
194 
195  if (!ProcessOne(count, track, start, len))
196  {
197  bGoodResult = false;
198  break;
199  }
200  }
201 
202  count++;
203  }
204  if (bGoodResult && !mbDidSomething) // Processing successful, but ineffective.
206  XO("Algorithm not effective on this audio. Nothing changed."),
207  wxOK | wxICON_ERROR );
208 
209  this->ReplaceProcessedTracks(bGoodResult && mbDidSomething);
210  return bGoodResult && mbDidSomething;
211 }

References Effect::CopyInputTracks(), mbDidSomething, Effect::MessageBox(), Effect::mOutputTracks, Effect::mT0, Effect::mT1, ProcessOne(), Effect::ReplaceProcessedTracks(), and XO.

Here is the call graph for this function:

◆ ProcessOne()

bool EffectClickRemoval::ProcessOne ( int  count,
WaveTrack track,
sampleCount  start,
sampleCount  len 
)
private

Definition at line 213 of file ClickRemoval.cpp.

214 {
215  if (len <= windowSize / 2)
216  {
218  XO("Selection must be larger than %d samples.")
219  .Format(windowSize / 2),
220  wxOK | wxICON_ERROR );
221  return false;
222  }
223 
224  auto idealBlockLen = track->GetMaxBlockSize() * 4;
225  if (idealBlockLen % windowSize != 0)
226  idealBlockLen += (windowSize - (idealBlockLen % windowSize));
227 
228  bool bResult = true;
229  decltype(len) s = 0;
230  Floats buffer{ idealBlockLen };
231  Floats datawindow{ windowSize };
232  while ((len - s) > windowSize / 2)
233  {
234  auto block = limitSampleBufferSize( idealBlockLen, len - s );
235 
236  track->GetFloats(buffer.get(), start + s, block);
237 
238  for (decltype(block) i = 0; i + windowSize / 2 < block; i += windowSize / 2)
239  {
240  auto wcopy = std::min( windowSize, block - i );
241 
242  for(decltype(wcopy) j = 0; j < wcopy; j++)
243  datawindow[j] = buffer[i+j];
244  for(auto j = wcopy; j < windowSize; j++)
245  datawindow[j] = 0;
246 
247  mbDidSomething |= RemoveClicks(windowSize, datawindow.get());
248 
249  for(decltype(wcopy) j = 0; j < wcopy; j++)
250  buffer[i+j] = datawindow[j];
251  }
252 
253  if (mbDidSomething) // RemoveClicks() actually did something.
254  track->Set((samplePtr) buffer.get(), floatSample, start + s, block);
255 
256  s += block;
257 
258  if (TrackProgress(count, s.as_double() /
259  len.as_double())) {
260  bResult = false;
261  break;
262  }
263  }
264 
265  return bResult;
266 }

References sampleCount::as_double(), floatSample, SampleTrack::GetFloats(), WaveTrack::GetMaxBlockSize(), limitSampleBufferSize(), mbDidSomething, Effect::MessageBox(), min(), RemoveClicks(), WaveTrack::Set(), Effect::TrackProgress(), windowSize, and XO.

Referenced by Process().

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

◆ RemoveClicks()

bool EffectClickRemoval::RemoveClicks ( size_t  len,
float *  buffer 
)
private

Definition at line 268 of file ClickRemoval.cpp.

269 {
270  bool bResult = false; // This effect usually does nothing.
271  size_t i;
272  size_t j;
273  int left = 0;
274 
275  float msw;
276  int ww;
277  int s2 = sep/2;
278  Floats ms_seq{ len };
279  Floats b2{ len };
280 
281  for( i=0; i<len; i++)
282  b2[i] = buffer[i]*buffer[i];
283 
284  /* Shortcut for rms - multiple passes through b2, accumulating
285  * as we go.
286  */
287  for(i=0;i<len;i++)
288  ms_seq[i]=b2[i];
289 
290  for(i=1; (int)i < sep; i *= 2) {
291  for(j=0;j<len-i; j++)
292  ms_seq[j] += ms_seq[j+i];
293  }
294 
295  /* Cheat by truncating sep to next-lower power of two... */
296  sep = i;
297 
298  for( i=0; i<len-sep; i++ ) {
299  ms_seq[i] /= sep;
300  }
301  /* ww runs from about 4 to mClickWidth. wrc is the reciprocal;
302  * chosen so that integer roundoff doesn't clobber us.
303  */
304  int wrc;
305  for(wrc=mClickWidth/4; wrc>=1; wrc /= 2) {
306  ww = mClickWidth/wrc;
307 
308  for( i=0; i<len-sep; i++ ){
309  msw = 0;
310  for( j=0; (int)j<ww; j++) {
311  msw += b2[i+s2+j];
312  }
313  msw /= ww;
314 
315  if(msw >= mThresholdLevel * ms_seq[i]/10) {
316  if( left == 0 ) {
317  left = i+s2;
318  }
319  } else {
320  if(left != 0 && ((int)i-left+s2) <= ww*2) {
321  float lv = buffer[left];
322  float rv = buffer[i+ww+s2];
323  for(j=left; j<i+ww+s2; j++) {
324  bResult = true;
325  buffer[j]= (rv*(j-left) + lv*(i+ww+s2-j))/(float)(i+ww+s2-left);
326  b2[j] = buffer[j]*buffer[j];
327  }
328  left=0;
329  } else if(left != 0) {
330  left = 0;
331  }
332  }
333  }
334  }
335  return bResult;
336 }

References mClickWidth, mThresholdLevel, and sep.

Referenced by ProcessOne().

Here is the caller graph for this function:

◆ SetAutomationParameters()

bool EffectClickRemoval::SetAutomationParameters ( CommandParameters parms)
overridevirtual

Change settings to those stored in parms.

Implements EffectDefinitionInterface.

Definition at line 123 of file ClickRemoval.cpp.

124 {
125  ReadAndVerifyInt(Threshold);
126  ReadAndVerifyInt(Width);
127 
128  mThresholdLevel = Threshold;
129  mClickWidth = Width;
130 
131  return true;
132 }

References mClickWidth, mThresholdLevel, and ReadAndVerifyInt.

◆ Startup()

bool EffectClickRemoval::Startup ( )
overridevirtual

Reimplemented from Effect.

Definition at line 141 of file ClickRemoval.cpp.

142 {
143  wxString base = wxT("/Effects/ClickRemoval/");
144 
145  // Migrate settings from 2.1.0 or before
146 
147  // Already migrated, so bail
148  if (gPrefs->Exists(base + wxT("Migrated")))
149  {
150  return true;
151  }
152 
153  // Load the old "current" settings
154  if (gPrefs->Exists(base))
155  {
156  mThresholdLevel = gPrefs->Read(base + wxT("ClickThresholdLevel"), 200);
157  if ((mThresholdLevel < MIN_Threshold) || (mThresholdLevel > MAX_Threshold))
158  { // corrupted Prefs?
159  mThresholdLevel = 0; //Off-skip
160  }
161  mClickWidth = gPrefs->Read(base + wxT("ClickWidth"), 20);
162  if ((mClickWidth < MIN_Width) || (mClickWidth > MAX_Width))
163  { // corrupted Prefs?
164  mClickWidth = 0; //Off-skip
165  }
166 
168 
169  // Do not migrate again
170  gPrefs->Write(base + wxT("Migrated"), true);
171  gPrefs->Flush();
172  }
173 
174  return true;
175 }

References FileConfig::Flush(), Effect::GetCurrentSettingsGroup(), gPrefs, mClickWidth, mThresholdLevel, and Effect::SaveUserPreset().

Here is the call graph for this function:

◆ TransferDataFromWindow()

bool EffectClickRemoval::TransferDataFromWindow ( )
overridevirtual

Reimplemented from Effect.

Definition at line 393 of file ClickRemoval.cpp.

394 {
395  if (!mUIParent->Validate() || !mUIParent->TransferDataFromWindow())
396  {
397  return false;
398  }
399 
400  return true;
401 }

References Effect::mUIParent.

◆ TransferDataToWindow()

bool EffectClickRemoval::TransferDataToWindow ( )
overridevirtual

Reimplemented from Effect.

Definition at line 383 of file ClickRemoval.cpp.

384 {
385  if (!mUIParent->TransferDataToWindow())
386  {
387  return false;
388  }
389 
390  return true;
391 }

References Effect::mUIParent.

Member Data Documentation

◆ mbDidSomething

bool EffectClickRemoval::mbDidSomething
private

Definition at line 73 of file ClickRemoval.h.

Referenced by Process(), and ProcessOne().

◆ mClickWidth

int EffectClickRemoval::mClickWidth
private

◆ mEnvelope

Envelope* EffectClickRemoval::mEnvelope
private

Definition at line 71 of file ClickRemoval.h.

◆ mThresholdLevel

int EffectClickRemoval::mThresholdLevel
private

◆ mThreshS

wxSlider* EffectClickRemoval::mThreshS
private

Definition at line 80 of file ClickRemoval.h.

Referenced by OnThreshSlider(), OnThreshText(), and PopulateOrExchange().

◆ mThreshT

wxTextCtrl* EffectClickRemoval::mThreshT
private

Definition at line 82 of file ClickRemoval.h.

Referenced by OnThreshSlider(), OnThreshText(), and PopulateOrExchange().

◆ mWidthS

wxSlider* EffectClickRemoval::mWidthS
private

Definition at line 79 of file ClickRemoval.h.

Referenced by OnWidthSlider(), OnWidthText(), and PopulateOrExchange().

◆ mWidthT

wxTextCtrl* EffectClickRemoval::mWidthT
private

Definition at line 81 of file ClickRemoval.h.

Referenced by OnWidthSlider(), OnWidthText(), and PopulateOrExchange().

◆ sep

int EffectClickRemoval::sep
private

Definition at line 77 of file ClickRemoval.h.

Referenced by RemoveClicks().

◆ Symbol

const ComponentInterfaceSymbol EffectClickRemoval::Symbol { XO("Click Removal") }
static

Definition at line 29 of file ClickRemoval.h.

Referenced by GetSymbol().

◆ windowSize

size_t EffectClickRemoval::windowSize
private

Definition at line 74 of file ClickRemoval.h.

Referenced by ProcessOne().


The documentation for this class was generated from the following files:
WaveTrack
A Track that contains audio waveform data.
Definition: WaveTrack.h:75
EffectTypeProcess
@ EffectTypeProcess
Definition: EffectInterface.h:56
Effect::SetLinearEffectFlag
void SetLinearEffectFlag(bool linearEffectFlag)
Definition: Effect.cpp:1764
S
#define S(N)
Definition: ToChars.cpp:64
gPrefs
FileConfig * gPrefs
Definition: Prefs.cpp:71
Effect::MessageBox
int MessageBox(const TranslatableString &message, long style=DefaultMessageBoxStyle, const TranslatableString &titleStr={})
Definition: Effect.cpp:2238
Effect::CopyInputTracks
void CopyInputTracks(bool allSyncLockSelected=false)
Definition: Effect.cpp:1834
Format
Abstract base class used in importing a file.
Effect::mT1
double mT1
Definition: Effect.h:424
EffectClickRemoval::mThresholdLevel
int mThresholdLevel
Definition: ClickRemoval.h:75
XO
#define XO(s)
Definition: Internat.h:31
ID_Width
@ ID_Width
Definition: ClickRemoval.cpp:48
EffectClickRemoval::sep
int sep
Definition: ClickRemoval.h:77
Effect::SaveUserPreset
bool SaveUserPreset(const RegistryPath &name) override
Save current settings as a user-named preset.
Definition: Effect.cpp:547
EffectClickRemoval::mThreshT
wxTextCtrl * mThreshT
Definition: ClickRemoval.h:82
EffectClickRemoval::windowSize
size_t windowSize
Definition: ClickRemoval.h:74
WaveTrack::Set
void Set(constSamplePtr buffer, sampleFormat format, sampleCount start, size_t len)
Definition: WaveTrack.cpp:2194
floatSample
@ floatSample
Definition: SampleFormat.h:34
ReadAndVerifyInt
#define ReadAndVerifyInt(name)
Definition: Effect.h:591
XXO
#define XXO(s)
Definition: Internat.h:44
Effect::mT0
double mT0
Definition: Effect.h:423
sampleCount::as_double
double as_double() const
Definition: SampleCount.h:45
EffectClickRemoval::Symbol
static const ComponentInterfaceSymbol Symbol
Definition: ClickRemoval.h:29
SampleTrack::GetFloats
bool GetFloats(float *buffer, sampleCount start, size_t len, fillFormat fill=fillZero, bool mayThrow=true, sampleCount *pNumWithinClips=nullptr) const
Retrieve samples from a track in floating-point format, regardless of the storage format.
Definition: SampleTrack.h:64
EffectClickRemoval::mClickWidth
int mClickWidth
Definition: ClickRemoval.h:76
EffectClickRemoval::mbDidSomething
bool mbDidSomething
Definition: ClickRemoval.h:73
ID_Thresh
@ ID_Thresh
Definition: ClickRemoval.cpp:47
Effect::ReplaceProcessedTracks
void ReplaceProcessedTracks(const bool bGoodResult)
Definition: Effect.cpp:1956
WaveTrack::GetMaxBlockSize
size_t GetMaxBlockSize() const override
This returns a nonnegative number of samples meant to size a memory buffer.
Definition: WaveTrack.cpp:1811
Effect::mOutputTracks
std::shared_ptr< TrackList > mOutputTracks
Definition: Effect.h:422
Effect::GetCurrentSettingsGroup
RegistryPath GetCurrentSettingsGroup() override
Definition: Effect.cpp:820
samplePtr
char * samplePtr
Definition: SampleFormat.h:49
min
int min(int a, int b)
Definition: CompareAudioCommand.cpp:106
EffectClickRemoval::mThreshS
wxSlider * mThreshS
Definition: ClickRemoval.h:80
FileConfig::Flush
virtual bool Flush(bool bCurrentOnly=false) wxOVERRIDE
Definition: FileConfig.cpp:143
EffectClickRemoval::RemoveClicks
bool RemoveClicks(size_t len, float *buffer)
Definition: ClickRemoval.cpp:268
Effect::mUIParent
wxWindow * mUIParent
Definition: Effect.h:438
EffectClickRemoval::ProcessOne
bool ProcessOne(int count, WaveTrack *track, sampleCount start, sampleCount len)
Definition: ClickRemoval.cpp:213
EffectClickRemoval::mWidthS
wxSlider * mWidthS
Definition: ClickRemoval.h:79
limitSampleBufferSize
size_t limitSampleBufferSize(size_t bufferSize, sampleCount limit)
Definition: SampleCount.cpp:23
Effect::TrackProgress
bool TrackProgress(int whichTrack, double frac, const TranslatableString &={})
Definition: Effect.cpp:1788
ArrayOf< float >
EffectClickRemoval::mWidthT
wxTextCtrl * mWidthT
Definition: ClickRemoval.h:81