Audacity  2.2.2
Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | List of all members
EffectSimpleMono Class Referenceabstract

An abstract Effect class that simplifies the implementation of a basic monaural effect. Inherit from it if your effect just modifies a single track in place and doesn't care how many samples it gets at a time. More...

#include <SimpleMono.h>

Inheritance diagram for EffectSimpleMono:
Effect EffectClientInterface EffectUIClientInterface EffectHostInterface EffectDefinitionInterface ConfigClientInterface IdentInterface ParamsInterface

Public Member Functions

bool Process () override
 
- Public Member Functions inherited from Effect
 Effect ()
 
virtual ~Effect ()
 
wxString GetPath () override
 
IdentInterfaceSymbol GetSymbol () override
 
IdentInterfaceSymbol GetVendor () override
 
wxString GetVersion () override
 
wxString GetDescription () override
 
EffectType GetType () override
 
IdentInterfaceSymbol GetFamilyId () 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
 
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 ()
 
- 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 ()
 

Protected Member Functions

virtual bool NewTrackSimpleMono ()=0
 
virtual bool ProcessSimpleMono (float *buffer, size_t len)=0
 
- 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)
 
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

int mCurTrackNum
 
double mCurRate
 
double mCurT0
 
double mCurT1
 
int mCurChannel
 
- 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
 

Private Member Functions

bool ProcessOne (WaveTrack *t, sampleCount start, sampleCount end)
 

Additional Inherited Members

- Public Types inherited from Effect
enum  : long { DefaultMessageBoxStyle = wxOK | wxCENTRE }
 

Detailed Description

An abstract Effect class that simplifies the implementation of a basic monaural effect. Inherit from it if your effect just modifies a single track in place and doesn't care how many samples it gets at a time.

Your derived class only needs to implement GetSymbol, GetEffectAction, and ProcessSimpleMono.

Definition at line 24 of file SimpleMono.h.

Member Function Documentation

bool EffectSimpleMono::NewTrackSimpleMono ( )
protectedpure virtual

Definition at line 129 of file SimpleMono.cpp.

Referenced by Process().

130 {
131  return true;
132 }
bool EffectSimpleMono::Process ( )
overridevirtual

Reimplemented from Effect.

Definition at line 29 of file SimpleMono.cpp.

References Effect::CopyInputTracks(), mCurChannel, mCurRate, mCurT0, mCurT1, mCurTrackNum, Effect::mOutputTracks, Effect::mT0, Effect::mT1, NewTrackSimpleMono(), ProcessOne(), Effect::ReplaceProcessedTracks(), and Track::Wave.

30 {
31  //Iterate over each track
32  this->CopyInputTracks(); // Set up mOutputTracks.
33  bool bGoodResult = true;
34 
36  WaveTrack* pOutWaveTrack = (WaveTrack*)(iter.First());
37  mCurTrackNum = 0;
38  while (pOutWaveTrack != NULL)
39  {
40  //Get start and end times from track
41  double trackStart = pOutWaveTrack->GetStartTime();
42  double trackEnd = pOutWaveTrack->GetEndTime();
43 
44  //Set the current bounds to whichever left marker is
45  //greater and whichever right marker is less:
46  mCurT0 = mT0 < trackStart? trackStart: mT0;
47  mCurT1 = mT1 > trackEnd? trackEnd: mT1;
48 
49  // Process only if the right marker is to the right of the left marker
50  if (mCurT1 > mCurT0) {
51 
52  //Transform the marker timepoints to samples
53  auto start = pOutWaveTrack->TimeToLongSamples(mCurT0);
54  auto end = pOutWaveTrack->TimeToLongSamples(mCurT1);
55 
56  //Get the track rate and samples
57  mCurRate = pOutWaveTrack->GetRate();
58  mCurChannel = pOutWaveTrack->GetChannel();
59 
60  //NewTrackSimpleMono() will returns true by default
61  //ProcessOne() processes a single track
62  if (!NewTrackSimpleMono() || !ProcessOne(pOutWaveTrack, start, end))
63  {
64  bGoodResult = false;
65  break;
66  }
67  }
68 
69  //Iterate to the next track
70  pOutWaveTrack = (WaveTrack*)(iter.Next());
71  mCurTrackNum++;
72  }
73 
74  this->ReplaceProcessedTracks(bGoodResult);
75  return bGoodResult;
76 }
double mT1
Definition: Effect.h:461
void CopyInputTracks()
Definition: Effect.cpp:2036
void ReplaceProcessedTracks(const bool bGoodResult)
Definition: Effect.cpp:2162
A Track that contains audio waveform data.
Definition: WaveTrack.h:60
bool ProcessOne(WaveTrack *t, sampleCount start, sampleCount end)
Definition: SimpleMono.cpp:81
virtual bool NewTrackSimpleMono()=0
Definition: SimpleMono.cpp:129
std::shared_ptr< TrackList > mOutputTracks
Definition: Effect.h:459
double mT0
Definition: Effect.h:460
bool EffectSimpleMono::ProcessOne ( WaveTrack t,
sampleCount  start,
sampleCount  end 
)
private

Definition at line 81 of file SimpleMono.cpp.

References floatSample, WaveTrack::Get(), WaveTrack::GetBestBlockSize(), WaveTrack::GetMaxBlockSize(), limitSampleBufferSize(), mCurTrackNum, ProcessSimpleMono(), WaveTrack::Set(), and Effect::TrackProgress().

Referenced by Process().

83 {
84  //Get the length of the buffer (as double). len is
85  //used simple to calculate a progress meter, so it is easier
86  //to make it a double now than it is to do it later
87  auto len = (end - start).as_double();
88 
89  //Initiate a processing buffer. This buffer will (most likely)
90  //be shorter than the length of the track being processed.
91  Floats buffer{ track->GetMaxBlockSize() };
92 
93  //Go through the track one buffer at a time. s counts which
94  //sample the current buffer starts at.
95  auto s = start;
96  while (s < end) {
97  //Get a block of samples (smaller than the size of the buffer)
98  //Adjust the block size if it is the final block in the track
99  const auto block =
100  limitSampleBufferSize( track->GetBestBlockSize(s), end - s );
101 
102  //Get the samples from the track and put them in the buffer
103  track->Get((samplePtr) buffer.get(), floatSample, s, block);
104 
105  //Process the buffer. If it fails, clean up and exit.
106  if (!ProcessSimpleMono(buffer.get(), block))
107  //Return false because the effect failed.
108  return false;
109 
110  //Processing succeeded. copy the newly-changed samples back
111  //onto the track.
112  track->Set((samplePtr) buffer.get(), floatSample, s, block);
113 
114  //Increment s one blockfull of samples
115  s += block;
116 
117  //Update the Progress meter
119  (s - start).as_double() /
120  len))
121  return false;
122  }
123 
124  //Return true because the effect processing succeeded.
125  return true;
126 }
bool TrackProgress(int whichTrack, double frac, const wxString &=wxEmptyString)
Definition: Effect.cpp:1985
size_t limitSampleBufferSize(size_t bufferSize, sampleCount limit)
Definition: Types.h:178
char * samplePtr
Definition: Types.h:203
virtual bool ProcessSimpleMono(float *buffer, size_t len)=0
virtual bool EffectSimpleMono::ProcessSimpleMono ( float *  buffer,
size_t  len 
)
protectedpure virtual

Referenced by ProcessOne().

Member Data Documentation

int EffectSimpleMono::mCurChannel
protected

Definition at line 45 of file SimpleMono.h.

Referenced by Process().

double EffectSimpleMono::mCurRate
protected

Definition at line 42 of file SimpleMono.h.

Referenced by Process().

double EffectSimpleMono::mCurT0
protected

Definition at line 43 of file SimpleMono.h.

Referenced by Process().

double EffectSimpleMono::mCurT1
protected

Definition at line 44 of file SimpleMono.h.

Referenced by Process().

int EffectSimpleMono::mCurTrackNum
protected

Definition at line 41 of file SimpleMono.h.

Referenced by Process(), and ProcessOne().


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