Audacity  3.0.3
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:
[legend]
Collaboration diagram for EffectSimpleMono:
[legend]

Public Member Functions

bool Process () 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 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 ()
 

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 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

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

Private Member Functions

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

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 ()
 
- 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>")
 
- Static Protected Attributes inherited from Effect
static int nEffectsDone =0
 

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

◆ NewTrackSimpleMono()

bool EffectSimpleMono::NewTrackSimpleMono ( )
protectedpure virtual

Definition at line 125 of file SimpleMono.cpp.

126 {
127  return true;
128 }

Referenced by Process().

Here is the caller graph for this function:

◆ Process()

bool EffectSimpleMono::Process ( )
overridevirtual

Reimplemented from Effect.

Definition at line 29 of file SimpleMono.cpp.

30 {
31  //Iterate over each track
32  this->CopyInputTracks(); // Set up mOutputTracks.
33  bool bGoodResult = true;
34 
35  mCurTrackNum = 0;
36  for( auto pOutWaveTrack : mOutputTracks->Selected< WaveTrack >() )
37  {
38  //Get start and end times from track
39  double trackStart = pOutWaveTrack->GetStartTime();
40  double trackEnd = pOutWaveTrack->GetEndTime();
41 
42  //Set the current bounds to whichever left marker is
43  //greater and whichever right marker is less:
44  mCurT0 = mT0 < trackStart? trackStart: mT0;
45  mCurT1 = mT1 > trackEnd? trackEnd: mT1;
46 
47  // Process only if the right marker is to the right of the left marker
48  if (mCurT1 > mCurT0) {
49 
50  //Transform the marker timepoints to samples
51  auto start = pOutWaveTrack->TimeToLongSamples(mCurT0);
52  auto end = pOutWaveTrack->TimeToLongSamples(mCurT1);
53 
54  //Get the track rate and samples
55  mCurRate = pOutWaveTrack->GetRate();
56  mCurChannel = pOutWaveTrack->GetChannel();
57 
58  //NewTrackSimpleMono() will returns true by default
59  //ProcessOne() processes a single track
60  if (!NewTrackSimpleMono() || !ProcessOne(pOutWaveTrack, start, end))
61  {
62  bGoodResult = false;
63  break;
64  }
65  }
66 
67  mCurTrackNum++;
68  }
69 
70  this->ReplaceProcessedTracks(bGoodResult);
71  return bGoodResult;
72 }

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

Here is the call graph for this function:

◆ ProcessOne()

bool EffectSimpleMono::ProcessOne ( WaveTrack t,
sampleCount  start,
sampleCount  end 
)
private

Definition at line 77 of file SimpleMono.cpp.

79 {
80  //Get the length of the buffer (as double). len is
81  //used simple to calculate a progress meter, so it is easier
82  //to make it a double now than it is to do it later
83  auto len = (end - start).as_double();
84 
85  //Initiate a processing buffer. This buffer will (most likely)
86  //be shorter than the length of the track being processed.
87  Floats buffer{ track->GetMaxBlockSize() };
88 
89  //Go through the track one buffer at a time. s counts which
90  //sample the current buffer starts at.
91  auto s = start;
92  while (s < end) {
93  //Get a block of samples (smaller than the size of the buffer)
94  //Adjust the block size if it is the final block in the track
95  const auto block =
96  limitSampleBufferSize( track->GetBestBlockSize(s), end - s );
97 
98  //Get the samples from the track and put them in the buffer
99  track->GetFloats(buffer.get(), s, block);
100 
101  //Process the buffer. If it fails, clean up and exit.
102  if (!ProcessSimpleMono(buffer.get(), block))
103  //Return false because the effect failed.
104  return false;
105 
106  //Processing succeeded. copy the newly-changed samples back
107  //onto the track.
108  track->Set((samplePtr) buffer.get(), floatSample, s, block);
109 
110  //Increment s one blockfull of samples
111  s += block;
112 
113  //Update the Progress meter
115  (s - start).as_double() /
116  len))
117  return false;
118  }
119 
120  //Return true because the effect processing succeeded.
121  return true;
122 }

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

Referenced by Process().

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

◆ ProcessSimpleMono()

virtual bool EffectSimpleMono::ProcessSimpleMono ( float *  buffer,
size_t  len 
)
protectedpure virtual

Referenced by ProcessOne().

Here is the caller graph for this function:

Member Data Documentation

◆ mCurChannel

int EffectSimpleMono::mCurChannel
protected

Definition at line 45 of file SimpleMono.h.

Referenced by Process().

◆ mCurRate

double EffectSimpleMono::mCurRate
protected

Definition at line 42 of file SimpleMono.h.

Referenced by Process().

◆ mCurT0

double EffectSimpleMono::mCurT0
protected

Definition at line 43 of file SimpleMono.h.

Referenced by Process().

◆ mCurT1

double EffectSimpleMono::mCurT1
protected

Definition at line 44 of file SimpleMono.h.

Referenced by Process().

◆ mCurTrackNum

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:
WaveTrack
A Track that contains audio waveform data.
Definition: WaveTrack.h:69
EffectSimpleMono::mCurChannel
int mCurChannel
Definition: SimpleMono.h:45
Effect::CopyInputTracks
void CopyInputTracks(bool allSyncLockSelected=false)
Definition: Effect.cpp:2071
Effect::mT1
double mT1
Definition: Effect.h:467
floatSample
@ floatSample
Definition: SampleFormat.h:34
Effect::mT0
double mT0
Definition: Effect.h:466
EffectSimpleMono::ProcessSimpleMono
virtual bool ProcessSimpleMono(float *buffer, size_t len)=0
Effect::ReplaceProcessedTracks
void ReplaceProcessedTracks(const bool bGoodResult)
Definition: Effect.cpp:2193
EffectSimpleMono::ProcessOne
bool ProcessOne(WaveTrack *t, sampleCount start, sampleCount end)
Definition: SimpleMono.cpp:77
Effect::mOutputTracks
std::shared_ptr< TrackList > mOutputTracks
Definition: Effect.h:465
samplePtr
char * samplePtr
Definition: SampleFormat.h:49
EffectSimpleMono::NewTrackSimpleMono
virtual bool NewTrackSimpleMono()=0
Definition: SimpleMono.cpp:125
EffectSimpleMono::mCurT0
double mCurT0
Definition: SimpleMono.h:43
EffectSimpleMono::mCurRate
double mCurRate
Definition: SimpleMono.h:42
EffectSimpleMono::mCurTrackNum
int mCurTrackNum
Definition: SimpleMono.h:41
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:2025
ArrayOf< float >
EffectSimpleMono::mCurT1
double mCurT1
Definition: SimpleMono.h:44