Audacity  3.0.3
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
 
wxString ManualPage () override
 
EffectType GetType () override
 
bool DefineParams (ShuttleParams &S) override
 
bool GetAutomationParameters (CommandParameters &parms) override
 
bool SetAutomationParameters (CommandParameters &parms) 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
 
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 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("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 }
 
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 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

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, and mThresholdLevel.

◆ GetAutomationParameters()

bool EffectClickRemoval::GetAutomationParameters ( CommandParameters parms)
overridevirtual

Implements EffectClientInterface.

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

Implements EffectDefinitionInterface.

Definition at line 103 of file ClickRemoval.cpp.

104 {
105  return EffectTypeProcess;
106 }

References EffectTypeProcess.

◆ ManualPage()

wxString EffectClickRemoval::ManualPage ( )
overridevirtual

Reimplemented from Effect.

Definition at line 96 of file ClickRemoval.cpp.

97 {
98  return wxT("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 ShuttleGui::AddSpace(), ShuttleGuiBase::EndMultiColumn(), ShuttleGui::Id(), ID_Thresh, ID_Width, mClickWidth, mThresholdLevel, mThreshS, mThreshT, mWidthS, mWidthT, ShuttleGui::Name(), ShuttleGuiBase::SetBorder(), ShuttleGuiBase::SetStretchyCol(), ShuttleGuiBase::StartMultiColumn(), ShuttleGui::Validator(), XO, and XXO.

Here is the call graph for this function:

◆ Process()

bool EffectClickRemoval::Process ( )
overridevirtual

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->Get((samplePtr) buffer.get(), floatSample, 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, WaveTrack::Get(), 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

Implements EffectClientInterface.

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:68
EffectTypeProcess
@ EffectTypeProcess
Definition: EffectInterface.h:59
Effect::SetLinearEffectFlag
void SetLinearEffectFlag(bool linearEffectFlag)
Definition: Effect.cpp:2000
ID_Width
@ ID_Width
Definition: ClickRemoval.cpp:48
gPrefs
FileConfig * gPrefs
Definition: Prefs.cpp:67
Effect::MessageBox
int MessageBox(const TranslatableString &message, long style=DefaultMessageBoxStyle, const TranslatableString &titleStr={})
Definition: Effect.cpp:2478
Effect::CopyInputTracks
void CopyInputTracks(bool allSyncLockSelected=false)
Definition: Effect.cpp:2070
Format
Abstract base class used in importing a file.
Effect::mT1
double mT1
Definition: Effect.h:466
EffectClickRemoval::mThresholdLevel
int mThresholdLevel
Definition: ClickRemoval.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
ID_Thresh
@ ID_Thresh
Definition: ClickRemoval.cpp:47
ShuttleGuiBase::EndMultiColumn
void EndMultiColumn()
Definition: ShuttleGui.cpp:1212
floatSample
@ floatSample
Definition: Types.h:714
EffectClickRemoval::sep
int sep
Definition: ClickRemoval.h:77
Effect::SaveUserPreset
bool SaveUserPreset(const RegistryPath &name) override
Definition: Effect.cpp:569
EffectClickRemoval::mThreshT
wxTextCtrl * mThreshT
Definition: ClickRemoval.h:82
ShuttleGui::Id
ShuttleGui & Id(int id)
Definition: ShuttleGui.cpp:2248
WaveTrack::Get
bool Get(samplePtr buffer, sampleFormat format, sampleCount start, size_t len, fillFormat fill=fillZero, bool mayThrow=true, sampleCount *pNumWithinClips=nullptr) const
Definition: WaveTrack.cpp:1895
limitSampleBufferSize
size_t limitSampleBufferSize(size_t bufferSize, sampleCount limit)
Definition: Types.h:698
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:1978
ReadAndVerifyInt
#define ReadAndVerifyInt(name)
Definition: Effect.h:631
samplePtr
char * samplePtr
Definition: Types.h:729
XXO
#define XXO(s)
Definition: Internat.h:45
Effect::mT0
double mT0
Definition: Effect.h:465
sampleCount::as_double
double as_double() const
Definition: Types.h:608
ShuttleGuiBase::StartMultiColumn
void StartMultiColumn(int nCols, int PositionFlags=wxALIGN_LEFT)
Definition: ShuttleGui.cpp:1203
EffectClickRemoval::Symbol
static const ComponentInterfaceSymbol Symbol
Definition: ClickRemoval.h:29
EffectClickRemoval::mClickWidth
int mClickWidth
Definition: ClickRemoval.h:76
EffectClickRemoval::mbDidSomething
bool mbDidSomething
Definition: ClickRemoval.h:73
Effect::ReplaceProcessedTracks
void ReplaceProcessedTracks(const bool bGoodResult)
Definition: Effect.cpp:2192
ShuttleGui::Validator
ShuttleGui & Validator(const Factory &f)
Definition: ShuttleGui.h:685
Effect::mOutputTracks
std::shared_ptr< TrackList > mOutputTracks
Definition: Effect.h:464
Effect::GetCurrentSettingsGroup
RegistryPath GetCurrentSettingsGroup() override
Definition: Effect.cpp:865
min
int min(int a, int b)
Definition: CompareAudioCommand.cpp:106
WaveTrack::GetMaxBlockSize
size_t GetMaxBlockSize() const
Definition: WaveTrack.cpp:1578
ShuttleGui::Name
ShuttleGui & Name(const TranslatableString &name)
Definition: ShuttleGui.h:670
EffectClickRemoval::mThreshS
wxSlider * mThreshS
Definition: ClickRemoval.h:80
FileConfig::Flush
virtual bool Flush(bool bCurrentOnly=false) wxOVERRIDE
Definition: FileConfig.cpp:151
EffectClickRemoval::RemoveClicks
bool RemoveClicks(size_t len, float *buffer)
Definition: ClickRemoval.cpp:268
Effect::mUIParent
wxWindow * mUIParent
Definition: Effect.h:477
EffectClickRemoval::ProcessOne
bool ProcessOne(int count, WaveTrack *track, sampleCount start, sampleCount len)
Definition: ClickRemoval.cpp:213
EffectClickRemoval::mWidthS
wxSlider * mWidthS
Definition: ClickRemoval.h:79
ShuttleGuiBase::SetBorder
void SetBorder(int Border)
Definition: ShuttleGui.h:497
ShuttleGuiBase::SetStretchyCol
void SetStretchyCol(int i)
Used to modify an already placed FlexGridSizer to make a column stretchy.
Definition: ShuttleGui.cpp:195
Effect::TrackProgress
bool TrackProgress(int whichTrack, double frac, const TranslatableString &={})
Definition: Effect.cpp:2024
ArrayOf< float >
EffectClickRemoval::mWidthT
wxTextCtrl * mWidthT
Definition: ClickRemoval.h:81