Audacity  2.2.2
Public Member Functions | 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:
Effect EffectClientInterface EffectUIClientInterface EffectHostInterface EffectDefinitionInterface ConfigClientInterface IdentInterface ParamsInterface

Public Member Functions

 EffectRepair ()
 
virtual ~EffectRepair ()
 
IdentInterfaceSymbol GetSymbol () override
 
wxString GetDescription () override
 
EffectType GetType () override
 
bool IsInteractive () override
 
bool Process () override
 
- Public Member Functions inherited from Effect
 Effect ()
 
virtual ~Effect ()
 
wxString GetPath () override
 
IdentInterfaceSymbol GetVendor () override
 
wxString GetVersion () override
 
IdentInterfaceSymbol GetFamilyId () 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
 
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, bool forceModal=false) override
 
bool GetAutomationParameters (CommandParameters &parms) override
 
bool SetAutomationParameters (CommandParameters &parms) override
 
bool LoadUserPreset (const wxString &name) override
 
bool SaveUserPreset (const wxString &name) override
 
wxArrayString GetFactoryPresets () override
 
bool LoadFactoryPreset (int id) override
 
bool LoadFactoryDefaults () override
 
void SetHostUI (EffectUIHostInterface *host) override
 
bool PopulateUI (wxWindow *parent) override
 
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
 
NumericFormatId GetDurationFormat () override
 
virtual NumericFormatId GetSelectionFormat ()
 
void SetDuration (double duration) override
 
bool Apply () override
 
void Preview () override
 
wxDialog * CreateUI (wxWindow *parent, EffectUIClientInterface *client) override
 
wxString GetUserPresetsGroup (const wxString &name) override
 
wxString GetCurrentSettingsGroup () override
 
wxString GetFactoryDefaultsGroup () override
 
virtual wxString GetSavedStateGroup ()
 
bool HasSharedConfigGroup (const wxString &group) override
 
bool GetSharedConfigSubgroups (const wxString &group, wxArrayString &subgroups) override
 
bool GetSharedConfig (const wxString &group, const wxString &key, wxString &value, const wxString &defval=wxEmptyString) override
 
bool GetSharedConfig (const wxString &group, const wxString &key, int &value, int defval=0) override
 
bool GetSharedConfig (const wxString &group, const wxString &key, bool &value, bool defval=false) override
 
bool GetSharedConfig (const wxString &group, const wxString &key, float &value, float defval=0.0) override
 
bool GetSharedConfig (const wxString &group, const wxString &key, double &value, double defval=0.0) override
 
bool SetSharedConfig (const wxString &group, const wxString &key, const wxString &value) override
 
bool SetSharedConfig (const wxString &group, const wxString &key, const int &value) override
 
bool SetSharedConfig (const wxString &group, const wxString &key, const bool &value) override
 
bool SetSharedConfig (const wxString &group, const wxString &key, const float &value) override
 
bool SetSharedConfig (const wxString &group, const wxString &key, const double &value) override
 
bool RemoveSharedConfigSubgroup (const wxString &group) override
 
bool RemoveSharedConfig (const wxString &group, const wxString &key) override
 
bool HasPrivateConfigGroup (const wxString &group) override
 
bool GetPrivateConfigSubgroups (const wxString &group, wxArrayString &subgroups) override
 
bool GetPrivateConfig (const wxString &group, const wxString &key, wxString &value, const wxString &defval=wxEmptyString) override
 
bool GetPrivateConfig (const wxString &group, const wxString &key, int &value, int defval=0) override
 
bool GetPrivateConfig (const wxString &group, const wxString &key, bool &value, bool defval=false) override
 
bool GetPrivateConfig (const wxString &group, const wxString &key, float &value, float defval=0.0) override
 
bool GetPrivateConfig (const wxString &group, const wxString &key, double &value, double defval=0.0) override
 
bool SetPrivateConfig (const wxString &group, const wxString &key, const wxString &value) override
 
bool SetPrivateConfig (const wxString &group, const wxString &key, const int &value) override
 
bool SetPrivateConfig (const wxString &group, const wxString &key, const bool &value) override
 
bool SetPrivateConfig (const wxString &group, const wxString &key, const float &value) override
 
bool SetPrivateConfig (const wxString &group, const wxString &key, const double &value) override
 
bool RemovePrivateConfigSubgroup (const wxString &group) override
 
bool RemovePrivateConfig (const wxString &group, const wxString &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 wxArrayString GetUserPresets ()
 
virtual bool HasCurrentSettings ()
 
virtual bool HasFactoryDefaults ()
 
virtual wxString GetPreset (wxWindow *parent, const wxString &parms)
 
virtual wxString ManualPage ()
 
virtual wxString HelpPage ()
 
virtual bool IsBatchProcessing ()
 
virtual void SetBatchProcessing (bool start)
 
void SetPresetParameters (const wxArrayString *Names, const wxArrayString *Values)
 
bool DoEffect (wxWindow *parent, double projectRate, TrackList *list, TrackFactory *factory, SelectedRegion *selectedRegion, bool shouldPrompt=true)
 
bool Delegate (Effect &delegate, wxWindow *parent, bool shouldPrompt)
 
bool RealtimeAddProcessor (int group, unsigned chans, float rate)
 
size_t RealtimeProcess (int group, unsigned chans, float **inbuf, float **outbuf, size_t numSamples)
 
bool IsRealtimeActive ()
 
virtual bool IsHidden ()
 
int MessageBox (const wxString &message, long style=DefaultMessageBoxStyle, const wxString &titleStr=wxString{})
 
- Public Member Functions inherited from EffectClientInterface
virtual ~EffectClientInterface ()
 
- Public Member Functions inherited from EffectDefinitionInterface
virtual ~EffectDefinitionInterface ()
 
virtual EffectType GetClassification ()
 
- Public Member Functions inherited from IdentInterface
virtual ~IdentInterface ()
 
const wxString & GetTranslatedName ()
 
- Public Member Functions inherited from ParamsInterface
virtual ~ParamsInterface ()
 
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 ()
 

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 }
 
- Static Public Member Functions inherited from Effect
static void IncEffectCounter ()
 
- Protected Member Functions inherited from Effect
virtual bool Init ()
 
virtual bool PromptUser (wxWindow *parent)
 
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 wxString &=wxEmptyString)
 
bool TrackProgress (int whichTrack, double frac, const wxString &=wxEmptyString)
 
bool TrackGroupProgress (int whichGroup, double frac, const wxString &=wxEmptyString)
 
int GetNumWaveTracks ()
 
int GetNumWaveGroups ()
 
void GetSamples (const WaveTrack *track, sampleCount *start, sampleCount *len)
 
void SetLinearEffectFlag (bool linearEffectFlag)
 
void SetPreviewFullSelectionFlag (bool previewDurationFlag)
 
bool IsPreviewing ()
 
void IncludeNotSelectedPreviewTracks (bool includeNotSelected)
 
void CopyInputTracks ()
 
void CopyInputTracks (int trackType)
 
std::shared_ptr
< AddedAnalysisTrack
AddAnalysisTrack (const wxString &name=wxString())
 
ModifiedAnalysisTrack ModifyAnalysisTrack (const LabelTrack *pOrigTrack, const wxString &name=wxString())
 
void ReplaceProcessedTracks (const bool bGoodResult)
 
TrackAddToOutputTracks (std::unique_ptr< Track > &&t)
 
TrackListinputTracks () const
 
- Protected Attributes inherited from Effect
ProgressDialogmProgress
 
double mProjectRate
 
double mSampleRate
 
SelectedRegionmpSelectedRegion {}
 
TrackFactorymFactory
 
std::shared_ptr< TrackListmOutputTracks
 
double mT0
 
double mT1
 
double mF0
 
double mF1
 
wxArrayString mPresetNames
 
wxArrayString mPresetValues
 
int mPass
 
wxDialog * mUIDialog
 
wxWindow * mUIParent
 
int mUIResultID
 
sampleCount mSampleCnt
 
int mOutputTracksType
 
- 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 22 of file Repair.h.

Constructor & Destructor Documentation

EffectRepair::EffectRepair ( )

Definition at line 36 of file Repair.cpp.

37 {
38 }
EffectRepair::~EffectRepair ( )
virtual

Definition at line 40 of file Repair.cpp.

41 {
42 }

Member Function Documentation

wxString EffectRepair::GetDescription ( )
overridevirtual

Reimplemented from Effect.

Definition at line 51 of file Repair.cpp.

References _().

52 {
53  return _("Sets the peak amplitude of a one or more tracks");
54 }
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom")).Raw()), OnMoveTrack)#define SET_TRACK_NAME_PLUGIN_SYMBOLclass SetTrackNameCommand:public AudacityCommand
IdentInterfaceSymbol EffectRepair::GetSymbol ( )
overridevirtual

Reimplemented from Effect.

Definition at line 46 of file Repair.cpp.

References REPAIR_PLUGIN_SYMBOL.

47 {
48  return REPAIR_PLUGIN_SYMBOL;
49 }
#define REPAIR_PLUGIN_SYMBOL
Definition: Repair.h:18
EffectType EffectRepair::GetType ( )
overridevirtual

Reimplemented from Effect.

Definition at line 58 of file Repair.cpp.

References EffectTypeProcess.

59 {
60  return EffectTypeProcess;
61 }
bool EffectRepair::IsInteractive ( )
overridevirtual

Reimplemented from Effect.

Definition at line 63 of file Repair.cpp.

64 {
65  return false;
66 }
bool EffectRepair::Process ( )
overridevirtual

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

Reimplemented from Effect.

Definition at line 70 of file Repair.cpp.

References _(), Effect::CopyInputTracks(), WaveTrack::GetStartTime(), Effect::MessageBox(), min(), Effect::mOutputTracks, Effect::mT0, Effect::mT1, ProcessOne(), Effect::ReplaceProcessedTracks(), and Track::Wave.

71 {
72  //v This may be too much copying for EffectRepair. To support Cancel, may be able to copy much less.
73  // But for now, Cancel isn't supported without this.
74  this->CopyInputTracks(); // Set up mOutputTracks. //v This may be too much copying for EffectRepair.
75  bool bGoodResult = true;
76 
78  WaveTrack *track = (WaveTrack *) iter.First();
79  int count = 0;
80  while (track) {
81  const
82  double trackStart = track->GetStartTime();
83  const double repair_t0 = std::max(mT0, trackStart);
84  const
85  double trackEnd = track->GetEndTime();
86  const double repair_t1 = std::min(mT1, trackEnd);
87  const
88  double repair_deltat = repair_t1 - repair_t0;
89  if (repair_deltat > 0) { // selection is within track audio
90  const auto repair0 = track->TimeToLongSamples(repair_t0);
91  const auto repair1 = track->TimeToLongSamples(repair_t1);
92  const auto repairLen = repair1 - repair0;
93  if (repairLen > 128) {
94  ::Effect::MessageBox(_("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."));
95  bGoodResult = false;
96  break;
97  }
98 
99  const double rate = track->GetRate();
100  const double spacing = std::max(repair_deltat * 2, 128. / rate);
101  const double t0 = std::max(repair_t0 - spacing, trackStart);
102  const double t1 = std::min(repair_t1 + spacing, trackEnd);
103 
104  const auto s0 = track->TimeToLongSamples(t0);
105  const auto s1 = track->TimeToLongSamples(t1);
106  // The difference is at most 2 * 128:
107  const auto repairStart = (repair0 - s0).as_size_t();
108  const auto len = s1 - s0;
109 
110  if (s0 == repair0 && s1 == repair1) {
111  ::Effect::MessageBox(_("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."));
113  bGoodResult = false;
114  break;
115  }
116 
117  if (!ProcessOne(count, track, s0,
118  // len is at most 5 * 128.
119  len.as_size_t(),
120  repairStart,
121  // repairLen is at most 128.
122  repairLen.as_size_t() )) {
123  bGoodResult = false;
124  break;
125  }
126  }
127 
128  track = (WaveTrack *) iter.Next();
129  count++;
130  }
131 
132  this->ReplaceProcessedTracks(bGoodResult);
133  return bGoodResult;
134 }
double mT1
Definition: Effect.h:465
int MessageBox(const wxString &message, long style=DefaultMessageBoxStyle, const wxString &titleStr=wxString{})
Definition: Effect.cpp:2651
void CopyInputTracks()
Definition: Effect.cpp:2040
void ReplaceProcessedTracks(const bool bGoodResult)
Definition: Effect.cpp:2166
double GetStartTime() const override
Get the time at which the first clip in the track starts.
Definition: WaveTrack.cpp:1853
A Track that contains audio waveform data.
Definition: WaveTrack.h:60
int min(int a, int b)
bool ProcessOne(int count, WaveTrack *track, sampleCount start, size_t len, size_t repairStart, size_t repairLen)
Definition: Repair.cpp:136
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom")).Raw()), OnMoveTrack)#define SET_TRACK_NAME_PLUGIN_SYMBOLclass SetTrackNameCommand:public AudacityCommand
std::shared_ptr< TrackList > mOutputTracks
Definition: Effect.h:463
double mT0
Definition: Effect.h:464
bool EffectRepair::ProcessOne ( int  count,
WaveTrack track,
sampleCount  start,
size_t  len,
size_t  repairStart,
size_t  repairLen 
)
private

Definition at line 136 of file Repair.cpp.

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

Referenced by Process().

140 {
141  Floats buffer{ len };
142  track->Get((samplePtr) buffer.get(), floatSample, start, len);
143  InterpolateAudio(buffer.get(), len, repairStart, repairLen);
144  track->Set((samplePtr)&buffer[repairStart], floatSample,
145  start + repairStart, repairLen);
146  return !TrackProgress(count, 1.0); // TrackProgress returns true on Cancel.
147 }
bool TrackProgress(int whichTrack, double frac, const wxString &=wxEmptyString)
Definition: Effect.cpp:1989
void InterpolateAudio(float *buffer, const size_t len, size_t firstBad, size_t numBad)
void Set(samplePtr buffer, sampleFormat format, sampleCount start, size_t len)
Definition: WaveTrack.cpp:2052
char * samplePtr
Definition: Types.h:203
bool Get(samplePtr buffer, sampleFormat format, sampleCount start, size_t len, fillFormat fill=fillZero, bool mayThrow=true, sampleCount *pNumCopied=nullptr) const
Definition: WaveTrack.cpp:1971

The documentation for this class was generated from the following files: