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

Use the interpolation code to fill in damaged audio. Damage can include pops, clicks, or clipping. As long as the damaged section is short and surrounded by lots of good audio, it is usually quite successful. More...

#include <Repair.h>

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

Public Member Functions

 EffectRepair ()
 
virtual ~EffectRepair ()
 
ComponentInterfaceSymbol GetSymbol () override
 
TranslatableString GetDescription () override
 
EffectType GetType () override
 
bool IsInteractive () override
 
bool Process () override
 
- Public Member Functions inherited from Effect
 Effect ()
 
virtual ~Effect ()
 
PluginPath GetPath () override
 
VendorSymbol GetVendor () override
 
wxString GetVersion () override
 
EffectFamilySymbol GetFamily () 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 ManualPageID ManualPage ()
 
virtual FilePath 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("Repair") }
 
- 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, size_t len, size_t repairStart, size_t repairLen)
 

Additional Inherited Members

- Public Types inherited from Effect
enum  : long { DefaultMessageBoxStyle = wxOK | wxCENTRE }
 
using VetoDialogHook = bool(*)(wxDialog *)
 
- Public Types inherited from EffectClientInterface
using EffectDialogFactory = std::function< wxDialog *(wxWindow &parent, EffectHostInterface *, EffectUIClientInterface *) >
 
- Static Public Member Functions inherited from Effect
static VetoDialogHook SetVetoDialogHook (VetoDialogHook hook)
 
static CommandID GetSquashedName (wxString name)
 
static void IncEffectCounter ()
 
- Protected Member Functions inherited from Effect
virtual bool Init ()
 
virtual bool CheckWhetherSkipEffect ()
 
virtual bool ProcessPass ()
 
virtual bool InitPass1 ()
 
virtual bool InitPass2 ()
 
virtual int GetPass ()
 
virtual void End ()
 
virtual double CalcPreviewInputLength (double previewLength)
 
virtual void Preview (bool dryOnly)
 
virtual void PopulateOrExchange (ShuttleGui &S)
 
virtual bool TransferDataToWindow ()
 
virtual bool TransferDataFromWindow ()
 
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

Use the interpolation code to fill in damaged audio. Damage can include pops, clicks, or clipping. As long as the damaged section is short and surrounded by lots of good audio, it is usually quite successful.

This was formerly the PopClickRemoval effect, but it was renamed and focused on the smaller subproblem of repairing the audio, rather than actually finding the clicks.

Definition at line 18 of file Repair.h.

Constructor & Destructor Documentation

◆ EffectRepair()

EffectRepair::EffectRepair ( )

Definition at line 42 of file Repair.cpp.

43 {
44 }

◆ ~EffectRepair()

EffectRepair::~EffectRepair ( )
virtual

Definition at line 46 of file Repair.cpp.

47 {
48 }

Member Function Documentation

◆ GetDescription()

TranslatableString EffectRepair::GetDescription ( )
overridevirtual

Reimplemented from Effect.

Definition at line 57 of file Repair.cpp.

58 {
59  return XO("Sets the peak amplitude of a one or more tracks");
60 }

References XO.

◆ GetSymbol()

ComponentInterfaceSymbol EffectRepair::GetSymbol ( )
overridevirtual

Reimplemented from Effect.

Definition at line 52 of file Repair.cpp.

53 {
54  return Symbol;
55 }

References Symbol.

◆ GetType()

EffectType EffectRepair::GetType ( )
overridevirtual

Reimplemented from Effect.

Definition at line 64 of file Repair.cpp.

65 {
66  return EffectTypeProcess;
67 }

References EffectTypeProcess.

◆ IsInteractive()

bool EffectRepair::IsInteractive ( )
overridevirtual

Reimplemented from Effect.

Definition at line 69 of file Repair.cpp.

70 {
71  return false;
72 }

◆ Process()

bool EffectRepair::Process ( )
overridevirtual

The Repair effect needs some data to go on.
\nPlease select an area to repair with some audio on at least one side (the more the better).") );

Reimplemented from Effect.

Definition at line 76 of file Repair.cpp.

77 {
78  //v This may be too much copying for EffectRepair. To support Cancel, may be able to copy much less.
79  // But for now, Cancel isn't supported without this.
80  this->CopyInputTracks(); // Set up mOutputTracks. //v This may be too much copying for EffectRepair.
81  bool bGoodResult = true;
82 
83  int count = 0;
84  for( auto track : mOutputTracks->Selected< WaveTrack >() ) {
85  const
86  double trackStart = track->GetStartTime();
87  const double repair_t0 = std::max(mT0, trackStart);
88  const
89  double trackEnd = track->GetEndTime();
90  const double repair_t1 = std::min(mT1, trackEnd);
91  const
92  double repair_deltat = repair_t1 - repair_t0;
93  if (repair_deltat > 0) { // selection is within track audio
94  const auto repair0 = track->TimeToLongSamples(repair_t0);
95  const auto repair1 = track->TimeToLongSamples(repair_t1);
96  const auto repairLen = repair1 - repair0;
97  if (repairLen > 128) {
99  XO(
100 "The Repair effect is intended to be used on very short sections of damaged audio (up to 128 samples).\n\nZoom in and select a tiny fraction of a second to repair.") );
101  bGoodResult = false;
102  break;
103  }
104 
105  const double rate = track->GetRate();
106  const double spacing = std::max(repair_deltat * 2, 128. / rate);
107  const double t0 = std::max(repair_t0 - spacing, trackStart);
108  const double t1 = std::min(repair_t1 + spacing, trackEnd);
109 
110  const auto s0 = track->TimeToLongSamples(t0);
111  const auto s1 = track->TimeToLongSamples(t1);
112  // The difference is at most 2 * 128:
113  const auto repairStart = (repair0 - s0).as_size_t();
114  const auto len = s1 - s0;
115 
116  if (s0 == repair0 && s1 == repair1) {
118  XO(
119 "Repair works by using audio data outside the selection region.\n\nPlease select a region that has audio touching at least one side of it.\n\nThe more surrounding audio, the better it performs.") );
121  bGoodResult = false;
122  break;
123  }
124 
125  if (!ProcessOne(count, track, s0,
126  // len is at most 5 * 128.
127  len.as_size_t(),
128  repairStart,
129  // repairLen is at most 128.
130  repairLen.as_size_t() )) {
131  bGoodResult = false;
132  break;
133  }
134  }
135 
136  count++;
137  }
138 
139  this->ReplaceProcessedTracks(bGoodResult);
140  return bGoodResult;
141 }

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

Here is the call graph for this function:

◆ ProcessOne()

bool EffectRepair::ProcessOne ( int  count,
WaveTrack track,
sampleCount  start,
size_t  len,
size_t  repairStart,
size_t  repairLen 
)
private

Definition at line 143 of file Repair.cpp.

147 {
148  Floats buffer{ len };
149  track->GetFloats(buffer.get(), start, len);
150  InterpolateAudio(buffer.get(), len, repairStart, repairLen);
151  track->Set((samplePtr)&buffer[repairStart], floatSample,
152  start + repairStart, repairLen);
153  return !TrackProgress(count, 1.0); // TrackProgress returns true on Cancel.
154 }

References floatSample, WaveTrack::GetFloats(), InterpolateAudio(), WaveTrack::Set(), and Effect::TrackProgress().

Referenced by Process().

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

Member Data Documentation

◆ Symbol

const ComponentInterfaceSymbol EffectRepair::Symbol { XO("Repair") }
static

Definition at line 21 of file Repair.h.

Referenced by GetSymbol().


The documentation for this class was generated from the following files:
WaveTrack
A Track that contains audio waveform data.
Definition: WaveTrack.h:69
EffectTypeProcess
@ EffectTypeProcess
Definition: EffectInterface.h:59
Effect::MessageBox
int MessageBox(const TranslatableString &message, long style=DefaultMessageBoxStyle, const TranslatableString &titleStr={})
Definition: Effect.cpp:2482
Effect::CopyInputTracks
void CopyInputTracks(bool allSyncLockSelected=false)
Definition: Effect.cpp:2071
EffectRepair::Symbol
static const ComponentInterfaceSymbol Symbol
Definition: Repair.h:21
InterpolateAudio
void InterpolateAudio(float *buffer, const size_t len, size_t firstBad, size_t numBad)
Definition: InterpolateAudio.cpp:82
Effect::mT1
double mT1
Definition: Effect.h:467
XO
#define XO(s)
Definition: Internat.h:31
WaveTrack::Set
void Set(constSamplePtr buffer, sampleFormat format, sampleCount start, size_t len)
Definition: WaveTrack.cpp:2076
floatSample
@ floatSample
Definition: SampleFormat.h:34
Effect::mT0
double mT0
Definition: Effect.h:466
Effect::ReplaceProcessedTracks
void ReplaceProcessedTracks(const bool bGoodResult)
Definition: Effect.cpp:2193
Effect::mOutputTracks
std::shared_ptr< TrackList > mOutputTracks
Definition: Effect.h:465
samplePtr
char * samplePtr
Definition: SampleFormat.h:49
min
int min(int a, int b)
Definition: CompareAudioCommand.cpp:106
EffectRepair::ProcessOne
bool ProcessOne(int count, WaveTrack *track, sampleCount start, size_t len, size_t repairStart, size_t repairLen)
Definition: Repair.cpp:143
WaveTrack::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: WaveTrack.h:265
Effect::TrackProgress
bool TrackProgress(int whichTrack, double frac, const TranslatableString &={})
Definition: Effect.cpp:2025
ArrayOf< float >