Audacity 3.2.0
Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | List of all members
EffectTwoPassSimpleMono Class Reference

An Effect base class that implements a two pass process. More...

#include <TwoPassSimpleMono.h>

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

Public Member Functions

 ~EffectTwoPassSimpleMono () override
 
bool Process (EffectInstance &instance, EffectSettings &settings) override
 
- Public Member Functions inherited from StatefulEffect
 ~StatefulEffect () override
 
std::shared_ptr< EffectInstanceMakeInstance () const override
 Make an object maintaining short-term state of an Effect. More...
 
- Public Member Functions inherited from StatefulEffectBase
virtual bool Init ()
 
virtual bool Process (EffectInstance &instance, EffectSettings &settings)=0
 
virtual bool RealtimeInitialize (EffectSettings &settings, double sampleRate)
 
virtual bool RealtimeAddProcessor (EffectSettings &settings, EffectOutputs *pOutputs, unsigned numChannels, float sampleRate)
 
virtual bool RealtimeSuspend ()
 
virtual bool RealtimeResume ()
 
virtual bool RealtimeProcessStart (MessagePackage &package)
 settings are possibly changed, since last call, by an asynchronous dialog More...
 
virtual size_t RealtimeProcess (size_t group, EffectSettings &settings, const float *const *inBuf, float *const *outBuf, size_t numSamples)
 
virtual bool RealtimeProcessEnd (EffectSettings &settings) noexcept
 settings can be updated to let a dialog change appearance at idle More...
 
virtual bool RealtimeFinalize (EffectSettings &settings) noexcept
 
virtual size_t SetBlockSize (size_t maxBlockSize)
 
virtual size_t GetBlockSize () const
 
virtual unsigned GetAudioInCount () const
 How many input buffers to allocate at once. More...
 
virtual unsigned GetAudioOutCount () const
 How many output buffers to allocate at once. More...
 
virtual sampleCount GetLatency () const
 
virtual bool NeedsDither () const
 
virtual bool ProcessInitialize (EffectSettings &settings, double sampleRate, ChannelNames chanMap=nullptr)
 
virtual bool ProcessFinalize () noexcept
 
- Public Member Functions inherited from Effect
 Effect ()
 
virtual ~Effect ()
 
PluginPath GetPath () const override
 
bool VisitSettings (SettingsVisitor &visitor, EffectSettings &settings) override
 
bool VisitSettings (ConstSettingsVisitor &visitor, const EffectSettings &settings) const override
 
ComponentInterfaceSymbol GetSymbol () const override
 
VendorSymbol GetVendor () const override
 
wxString GetVersion () const override
 
TranslatableString GetDescription () const override
 
EffectFamilySymbol GetFamily () const override
 Report identifier and user-visible name of the effect protocol. More...
 
bool IsInteractive () const override
 Whether the effect needs a dialog for entry of settings. More...
 
bool IsDefault () const override
 Whether the effect sorts "above the line" in the menus. More...
 
RealtimeSince RealtimeSupport () const override
 Since which version of Audacity has the effect supported realtime? More...
 
bool SupportsAutomation () const override
 Whether the effect has any automatable controls. More...
 
bool SaveSettings (const EffectSettings &settings, CommandParameters &parms) const override
 Store settings as keys and values. More...
 
bool LoadSettings (const CommandParameters &parms, EffectSettings &settings) const override
 Restore settings from keys and values. More...
 
OptionalMessage LoadUserPreset (const RegistryPath &name, EffectSettings &settings) const override
 
bool SaveUserPreset (const RegistryPath &name, const EffectSettings &settings) const override
 Save settings in the configuration file as a user-named preset. More...
 
RegistryPaths GetFactoryPresets () const override
 Report names of factory presets. More...
 
OptionalMessage LoadFactoryPreset (int id, EffectSettings &settings) const override
 
OptionalMessage LoadFactoryDefaults (EffectSettings &settings) const override
 
virtual const EffectParameterMethodsParameters () const
 
bool CanExportPresets () const override
 Whether the effect supports export of presets to files, and importing too. More...
 
bool HasOptions () const override
 
const EffectSettingsManagerGetDefinition () const override
 
virtual NumericFormatID GetSelectionFormat ()
 
bool SaveSettingsAsString (const EffectSettings &settings, wxString &parms) const override
 
OptionalMessage LoadSettingsFromString (const wxString &parms, EffectSettings &settings) const override
 
bool IsBatchProcessing () const override
 
void SetBatchProcessing () override
 
void UnsetBatchProcessing () override
 
unsigned TestUIFlags (unsigned mask)
 
bool Delegate (Effect &delegate, EffectSettings &settings, InstanceFinder finder={})
 Re-invoke DoEffect on another Effect object that implements the work. More...
 
- Public Member Functions inherited from EffectBase
 EffectBase ()
 
 ~EffectBase () override
 
bool IsLinearEffect () const
 
bool PreviewsFullSelection () const
 
void SetTracks (TrackList *pTracks)
 
virtual std::any BeginPreview (const EffectSettings &settings)
 Called when Preview() starts, to allow temporary effect state changes. More...
 
bool DoEffect (EffectSettings &settings, const InstanceFinder &finder, double projectRate, TrackList *list, WaveTrackFactory *factory, NotifyingSelectedRegion &selectedRegion, unsigned flags, const EffectSettingsAccessPtr &pAccess) override
 
virtual double CalcPreviewInputLength (const EffectSettings &settings, double previewLength) const =0
 
void CountWaveTracks ()
 
- Public Member Functions inherited from EffectPlugin
EffectPluginoperator= (EffectPlugin &)=delete
 
virtual ~EffectPlugin ()
 
virtual bool HasOptions () const =0
 
virtual bool CanExportPresets () const =0
 Whether the effect supports export of presets to files, and importing too. More...
 
virtual const EffectSettingsManagerGetDefinition () const =0
 
virtual bool SaveSettingsAsString (const EffectSettings &settings, wxString &parms) const =0
 
virtual OptionalMessage LoadSettingsFromString (const wxString &parms, EffectSettings &settings) const =0
 
virtual bool IsBatchProcessing () const =0
 
virtual void SetBatchProcessing ()=0
 
virtual void UnsetBatchProcessing ()=0
 
virtual bool DoEffect (EffectSettings &settings, const InstanceFinder &finder, double projectRate, TrackList *list, WaveTrackFactory *factory, NotifyingSelectedRegion &selectedRegion, unsigned flags, const EffectSettingsAccessPtr &pAccess=nullptr)=0
 
- Public Member Functions inherited from EffectInstanceFactory
virtual ~EffectInstanceFactory ()
 
virtual std::shared_ptr< EffectInstanceMakeInstance () const =0
 Make an object maintaining short-term state of an Effect. More...
 
- Public Member Functions inherited from EffectSettingsManager
virtual ~EffectSettingsManager ()
 
virtual bool VisitSettings (SettingsVisitor &visitor, EffectSettings &settings)
 
virtual bool VisitSettings (ConstSettingsVisitor &visitor, const EffectSettings &settings) const
 
virtual EffectSettings MakeSettings () const
 
virtual bool CopySettingsContents (const EffectSettings &src, EffectSettings &dst) const
 Update one settings object from another. More...
 
virtual std::unique_ptr< EffectOutputsMakeOutputs () const
 Produce an object to hold values to send to effect output meters. More...
 
- Public Member Functions inherited from EffectDefinitionInterface
virtual ~EffectDefinitionInterface ()
 
virtual EffectType GetType () const =0
 Type determines how it behaves. More...
 
virtual EffectType GetClassification () const
 Determines which menu it appears in; default same as GetType(). More...
 
virtual EffectFamilySymbol GetFamily () const =0
 Report identifier and user-visible name of the effect protocol. More...
 
virtual bool IsInteractive () const =0
 Whether the effect needs a dialog for entry of settings. More...
 
virtual bool IsDefault () const =0
 Whether the effect sorts "above the line" in the menus. More...
 
virtual RealtimeSince RealtimeSupport () const =0
 Since which version of Audacity has the effect supported realtime? More...
 
bool SupportsRealtime () const
 
virtual bool SupportsAutomation () const =0
 Whether the effect has any automatable controls. More...
 
virtual bool EnablesDebug () const
 Whether the effect dialog should have a Debug button; default, always false. More...
 
virtual ManualPageID ManualPage () const
 Name of a page in the Audacity alpha manual, default is empty. More...
 
virtual FilePath HelpPage () const
 Fully qualified local help file name, default is empty. More...
 
virtual bool IsHiddenFromMenus () const
 Default is false. More...
 
- Public Member Functions inherited from ComponentInterface
virtual ~ComponentInterface ()
 
virtual PluginPath GetPath () const =0
 
virtual ComponentInterfaceSymbol GetSymbol () const =0
 
virtual VendorSymbol GetVendor () const =0
 
virtual wxString GetVersion () const =0
 
virtual TranslatableString GetDescription () const =0
 
TranslatableString GetName () const
 
- Public Member Functions inherited from StatefulEffectUIServices
 ~StatefulEffectUIServices () override
 
std::unique_ptr< EffectEditorPopulateUI (const EffectPlugin &plugin, ShuttleGui &S, EffectInstance &instance, EffectSettingsAccess &access, const EffectOutputs *pOutputs) const override
 Allows PopulateOrExchange to return null. More...
 
virtual std::unique_ptr< EffectEditorPopulateOrExchange (ShuttleGui &S, EffectInstance &instance, EffectSettingsAccess &access, const EffectOutputs *pOutputs)
 Add controls to effect panel; always succeeds. More...
 
virtual bool TransferDataToWindow (const EffectSettings &settings)
 
virtual bool TransferDataFromWindow (EffectSettings &settings)
 
- Public Member Functions inherited from BasicEffectUIServices
int ShowClientInterface (const EffectPlugin &plugin, wxWindow &parent, wxDialog &dialog, EffectEditor *pEditor, bool forceModal) const override
 
void ExportPresets (const EffectPlugin &plugin, const EffectSettings &settings) const override
 
OptionalMessage ImportPresets (const EffectPlugin &plugin, EffectSettings &settings) const override
 
void ShowOptions (const EffectPlugin &plugin) const override
 
bool ValidateUI (const EffectPlugin &context, EffectSettings &) const override
 
bool CloseUI () const override
 
- Public Member Functions inherited from EffectUIServices
virtual ~EffectUIServices ()
 
virtual int ShowHostInterface (EffectBase &plugin, wxWindow &parent, const EffectDialogFactory &factory, std::shared_ptr< EffectInstance > &pInstance, EffectSettingsAccess &access, bool forceModal=false)
 
virtual int ShowClientInterface (const EffectPlugin &plugin, wxWindow &parent, wxDialog &dialog, EffectEditor *pEditor, bool forceModal=false) const =0
 
virtual std::unique_ptr< EffectEditorPopulateUI (const EffectPlugin &plugin, ShuttleGui &S, EffectInstance &instance, EffectSettingsAccess &access, const EffectOutputs *pOutputs) const =0
 Adds controls to a panel that is given as the parent window of S More...
 
virtual void ExportPresets (const EffectPlugin &plugin, const EffectSettings &settings) const =0
 
virtual OptionalMessage ImportPresets (const EffectPlugin &plugin, EffectSettings &settings) const =0
 
virtual void ShowOptions (const EffectPlugin &plugin) const =0
 
virtual bool ValidateUI (const EffectPlugin &context, EffectSettings &settings) const =0
 
virtual bool CloseUI () const =0
 

Protected Member Functions

virtual bool InitPass1 ()
 
virtual bool InitPass2 ()
 
virtual bool NewTrackPass1 ()
 
virtual bool NewTrackPass2 ()
 
virtual bool ProcessPass1 (float *WXUNUSED(buffer), size_t WXUNUSED(len))
 Override this method to actually process audio. More...
 
virtual bool ProcessPass2 (float *WXUNUSED(buffer), size_t WXUNUSED(len))
 
virtual bool TwoBufferProcessPass1 (float *buffer1, size_t len1, float *buffer2, size_t len2)
 
virtual bool TwoBufferProcessPass2 (float *buffer1, size_t len1, float *buffer2, size_t len2)
 
void DisableSecondPass ()
 Call this if you know in advance that no second pass will be needed. More...
 
- Protected Member Functions inherited from Effect
bool CheckWhetherSkipEffect (const EffectSettings &settings) const override
 Default implementation returns false. More...
 
double CalcPreviewInputLength (const EffectSettings &settings, double previewLength) const override
 Default implementation returns previewLength More...
 
bool TotalProgress (double frac, const TranslatableString &={}) const
 
bool TrackProgress (int whichTrack, double frac, const TranslatableString &={}) const
 
bool TrackGroupProgress (int whichGroup, double frac, const TranslatableString &={}) const
 
int GetNumWaveTracks () const
 
int GetNumWaveGroups () const
 
void GetBounds (const WaveTrack &track, sampleCount *start, sampleCount *len)
 
- Protected Member Functions inherited from EffectBase
virtual bool CheckWhetherSkipEffect (const EffectSettings &settings) const =0
 After Init(), tell whether Process() should be skipped. More...
 
void SetLinearEffectFlag (bool linearEffectFlag)
 
void SetPreviewFullSelectionFlag (bool previewDurationFlag)
 
bool IsPreviewing () const
 
const TrackListinputTracks () const
 
const AudacityProjectFindProject () const
 

Protected Attributes

int mCurTrackNum
 
double mCurRate
 
double mCurT0
 
double mCurT1
 
int mPass
 
bool mSecondPassDisabled
 
std::shared_ptr< TrackListmWorkTracks
 
TrackListmTrackLists [2]
 
- Protected Attributes inherited from EffectBase
wxArrayString mPresetNames
 
unsigned mUIFlags { 0 }
 

Private Member Functions

bool ProcessOne (WaveChannel &t, WaveChannel &outTrack, sampleCount start, sampleCount end)
 
bool ProcessPass (EffectSettings &settings)
 

Additional Inherited Members

- Public Types inherited from StatefulEffectBase
using MessagePackage = EffectInstance::MessagePackage
 
- Public Types inherited from EffectPlugin
using EffectSettingsAccessPtr = std::shared_ptr< EffectSettingsAccess >
 
using InstancePointer = std::shared_ptr< EffectInstanceEx >
 
using InstanceFinder = std::function< std::optional< InstancePointer >(EffectSettings &settings) >
 
- Public Types inherited from EffectDefinitionInterface
enum class  RealtimeSince : unsigned { Never , After_3_1 , Always }
 In which versions of Audacity was an effect realtime capable? More...
 
- Public Types inherited from EffectUIServices
enum  : long { DefaultMessageBoxStyle = wxOK | wxCENTRE }
 
- Static Public Member Functions inherited from Effect
static EffectFetchParameters (Effect &e, EffectSettings &)
 
- Static Public Member Functions inherited from EffectBase
static std::optional< InstancePointerFindInstance (EffectPlugin &plugin)
 
static InstanceFinder DefaultInstanceFinder (EffectPlugin &plugin)
 
- Static Public Member Functions inherited from EffectDefinitionInterface
static Identifier GetSquashedName (const Identifier &ident)
 A utility that strips spaces and CamelCases a name. More...
 
- Static Public Member Functions inherited from EffectUIServices
static int DoMessageBox (const EffectPlugin &plugin, const TranslatableString &message, long style=DefaultMessageBoxStyle, const TranslatableString &titleStr={})
 
- Public Attributes inherited from EffectBase
std::shared_ptr< TrackListmTracks {}
 
int mNumTracks {}
 
BasicUI::ProgressDialogmProgress {}
 
double mProjectRate {}
 
WaveTrackFactorymFactory {}
 
double mT0 {}
 
double mT1 {}
 
bool mIsPreview { false }
 
- Static Public Attributes inherited from EffectPlugin
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>")
 

Detailed Description

An Effect base class that implements a two pass process.

Inherit from it if your effect needs to pass twice over the data. It does the first pass on all selected tracks before going back and doing the second pass over all selected tracks.

Definition at line 19 of file TwoPassSimpleMono.h.

Constructor & Destructor Documentation

◆ ~EffectTwoPassSimpleMono()

EffectTwoPassSimpleMono::~EffectTwoPassSimpleMono ( )
overridedefault

Member Function Documentation

◆ DisableSecondPass()

void EffectTwoPassSimpleMono::DisableSecondPass ( )
inlineprotected

Call this if you know in advance that no second pass will be needed.

This is used as a hint for the progress bar

Definition at line 83 of file TwoPassSimpleMono.h.

Referenced by EffectCompressor::InitPass1().

Here is the caller graph for this function:

◆ InitPass1()

bool EffectTwoPassSimpleMono::InitPass1 ( )
protectedvirtual

Override these methods if you need to initialize something before each pass. Return false if processing should stop.

Reimplemented in EffectCompressor.

Definition at line 242 of file TwoPassSimpleMono.cpp.

243{
244 return true;
245}

Referenced by Process().

Here is the caller graph for this function:

◆ InitPass2()

bool EffectTwoPassSimpleMono::InitPass2 ( )
protectedvirtual

Reimplemented in EffectCompressor.

Definition at line 249 of file TwoPassSimpleMono.cpp.

250{
251 return true;
252}

Referenced by Process().

Here is the caller graph for this function:

◆ NewTrackPass1()

bool EffectTwoPassSimpleMono::NewTrackPass1 ( )
protectedvirtual

Override these methods if you need to do things before every track (including the first one)

Reimplemented in EffectCompressor.

Definition at line 231 of file TwoPassSimpleMono.cpp.

232{
233 return true;
234}

Referenced by ProcessPass().

Here is the caller graph for this function:

◆ NewTrackPass2()

bool EffectTwoPassSimpleMono::NewTrackPass2 ( )
protectedvirtual

Definition at line 236 of file TwoPassSimpleMono.cpp.

237{
238 return true;
239}

Referenced by ProcessPass().

Here is the caller graph for this function:

◆ Process()

bool EffectTwoPassSimpleMono::Process ( EffectInstance instance,
EffectSettings settings 
)
overridevirtual

Implements StatefulEffectBase.

Definition at line 24 of file TwoPassSimpleMono.cpp.

26{
27 mPass = 0;
28 mSecondPassDisabled = false;
29
30 InitPass1();
31 EffectOutputTracks outputs { *mTracks, GetType(), { { mT0, mT1 } } };
32
34 for (auto track : outputs.Get().Selected<WaveTrack>()) {
35 auto pNewTracks = track->WideEmptyCopy();
36 mWorkTracks->Append(std::move(*pNewTracks));
37 }
38 for (const auto pNewTrack : mWorkTracks->Any<WaveTrack>()) {
39 pNewTrack->ConvertToSampleFormat(floatSample);
40 }
41
42 mTrackLists[0] = &outputs.Get();
44
45 bool bGoodResult = ProcessPass(settings);
46 if (bGoodResult && !mSecondPassDisabled) {
47 mPass = 1;
48 if (InitPass2())
49 bGoodResult = ProcessPass(settings);
50 }
51
52 mWorkTracks->Clear();
53 mWorkTracks.reset();
54
55 if (bGoodResult)
56 outputs.Commit();
57
58 return bGoodResult;
59}
static Settings & settings()
Definition: TrackInfo.cpp:69
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:90
double mT1
Definition: EffectBase.h:116
std::shared_ptr< TrackList > mTracks
Definition: EffectBase.h:109
double mT0
Definition: EffectBase.h:115
const AudacityProject * FindProject() const
Definition: EffectBase.cpp:225
virtual EffectType GetType() const =0
Type determines how it behaves.
Use this object to copy the input tracks to tentative outputTracks.
bool ProcessPass(EffectSettings &settings)
std::shared_ptr< TrackList > mWorkTracks
static TrackListHolder Create(AudacityProject *pOwner)
Definition: Track.cpp:365
static TrackList & Get(AudacityProject &project)
Definition: Track.cpp:347
A Track that contains audio waveform data.
Definition: WaveTrack.h:227

References TrackList::Create(), EffectBase::FindProject(), floatSample, TrackList::Get(), EffectDefinitionInterface::GetType(), InitPass1(), InitPass2(), mPass, mSecondPassDisabled, EffectBase::mT0, EffectBase::mT1, mTrackLists, EffectBase::mTracks, mWorkTracks, ProcessPass(), and settings().

Here is the call graph for this function:

◆ ProcessOne()

bool EffectTwoPassSimpleMono::ProcessOne ( WaveChannel t,
WaveChannel outTrack,
sampleCount  start,
sampleCount  end 
)
private

Definition at line 122 of file TwoPassSimpleMono.cpp.

124{
125 bool ret;
126
127 // Get the length of the buffer (as double). len is
128 // used simple to calculate a progress meter, so it is easier
129 // to make it a double now than it is to do it later
130 auto len = (end - start).as_double();
131 auto maxblock = track.GetMaxBlockSize();
132
133 // Initiate a processing buffer. This buffer will (most likely)
134 // be shorter than the length of the track being processed.
135 Floats buffer1{ maxblock };
136 Floats buffer2{ maxblock };
137 auto samples1 = limitSampleBufferSize(
138 std::min(maxblock, track.GetBestBlockSize(start)), end - start);
139
140 // Get the samples from the track and put them in the buffer
141 track.GetFloats(buffer1.get(), start, samples1);
142
143 // Process the first buffer with a null previous buffer
144 if (mPass == 0)
145 ret = TwoBufferProcessPass1(nullptr, 0, buffer1.get(), samples1);
146 else
147 ret = TwoBufferProcessPass2(nullptr, 0, buffer1.get(), samples1);
148 if (!ret)
149 // Return false because the effect failed.
150 return false;
151
152 // Go through the track one buffer at a time. s counts which
153 // sample the current buffer starts at.
154 auto s = start + samples1;
155 while (s < end) {
156 // Get a block of samples (smaller than the size of the buffer)
157 // Adjust the block size if it is the final block in the track
158 auto samples2 = limitSampleBufferSize(
159 std::min(track.GetBestBlockSize(s), maxblock), end - s);
160
161 // Get the samples from the track and put them in the buffer
162 track.GetFloats(buffer2.get(), s, samples2);
163
164 // Process the buffer. If it fails, clean up and exit.
165 if (mPass == 0)
166 ret = TwoBufferProcessPass1(buffer1.get(), samples1, buffer2.get(),
167 samples2);
168 else
169 ret = TwoBufferProcessPass2(buffer1.get(), samples1, buffer2.get(),
170 samples2);
171 if (!ret)
172 // Return false because the effect failed.
173 return false;
174
175 // Processing succeeded. copy the newly-changed samples back
176 // onto the track.
177 if (mSecondPassDisabled || mPass != 0) {
178 if (!outTrack.Set((samplePtr)buffer1.get(), floatSample, s - samples1,
179 samples1))
180 return false;
181 }
182 else
183 outTrack.Append((samplePtr)buffer1.get(), floatSample, samples1);
184
185 // Increment s one blockfull of samples
186 s += samples2;
187
188 // Update the Progress meter
190 ret = TotalProgress(
191 (mCurTrackNum + (s - start).as_double() / len) /
193 else
194 ret = TotalProgress(
195 (mCurTrackNum + (s-start).as_double() / len +
197 (GetNumWaveTracks() * 2));
198 if (ret)
199 // Return false because the effect failed.
200 return false;
201
202 // Rotate the buffers
203 buffer1.swap(buffer2);
204 std::swap(samples1, samples2);
205 }
206
207 // Send the last buffer with a null pointer for the current buffer
208 if (mPass == 0)
209 ret = TwoBufferProcessPass1(buffer1.get(), samples1, nullptr, 0);
210 else
211 ret = TwoBufferProcessPass2(buffer1.get(), samples1, nullptr, 0);
212
213 if (!ret)
214 //Return false because the effect failed.
215 return false;
216
217 // Processing succeeded. copy the newly-changed samples back
218 // onto the track.
219 if (mSecondPassDisabled || mPass != 0) {
220 if (!outTrack.Set((samplePtr)buffer1.get(), floatSample, s - samples1,
221 samples1))
222 return false;
223 }
224 else
225 outTrack.Append((samplePtr)buffer1.get(), floatSample, samples1);
226
227 // Return true because the effect processing succeeded.
228 return true;
229}
int min(int a, int b)
size_t limitSampleBufferSize(size_t bufferSize, sampleCount limit)
Definition: SampleCount.cpp:22
char * samplePtr
Definition: SampleFormat.h:57
bool TotalProgress(double frac, const TranslatableString &={}) const
Definition: Effect.cpp:335
int GetNumWaveTracks() const
Definition: Effect.h:139
virtual bool TwoBufferProcessPass2(float *buffer1, size_t len1, float *buffer2, size_t len2)
virtual bool TwoBufferProcessPass1(float *buffer1, size_t len1, float *buffer2, size_t len2)
bool Set(constSamplePtr buffer, sampleFormat format, sampleCount start, size_t len, sampleFormat effectiveFormat=widestSampleFormat)
Random-access assignment of a range of samples.
Definition: WaveTrack.cpp:3560
bool Append(constSamplePtr buffer, sampleFormat format, size_t len)
Definition: WaveTrack.cpp:2711
auto end(const Ptr< Type, BaseDeleter > &p)
Enables range-for.
Definition: PackedArray.h:159
void swap(std::unique_ptr< Alg_seq > &a, std::unique_ptr< Alg_seq > &b)
Definition: NoteTrack.cpp:645

References WaveChannel::Append(), PackedArray::end(), floatSample, WaveChannel::GetBestBlockSize(), WaveChannel::GetFloats(), WaveChannel::GetMaxBlockSize(), Effect::GetNumWaveTracks(), limitSampleBufferSize(), mCurTrackNum, min(), mPass, mSecondPassDisabled, WaveChannel::Set(), anonymous_namespace{NoteTrack.cpp}::swap(), Effect::TotalProgress(), TwoBufferProcessPass1(), and TwoBufferProcessPass2().

Referenced by ProcessPass().

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

◆ ProcessPass()

bool EffectTwoPassSimpleMono::ProcessPass ( EffectSettings settings)
private

Definition at line 61 of file TwoPassSimpleMono.cpp.

62{
63 // Iterate over each track
64 mCurTrackNum = 0;
65
66 auto outTracks =
67 (*mTrackLists[1 - mPass]).Selected<WaveTrack>().begin();
68 for (auto track : (*mTrackLists[mPass]).Selected<WaveTrack>()) {
69 auto outTrack = *outTracks;
70
71 // Get start and end times from the orignal track
72 double trackStart = mPass == 0 ? track->GetStartTime() : (*outTracks)->GetStartTime();
73 double trackEnd = mPass == 0 ? track->GetEndTime() : (*outTracks)->GetEndTime();
74
75 // Set the current bounds to whichever left marker is
76 // greater and whichever right marker is less:
77 mCurT0 = std::max(trackStart, mT0);
78 mCurT1 = std::min(trackEnd, mT1);
79
80 // So that in ProcessOne(), when mPass == 0, samples are
81 // appended starting at mCurT0
82 if (!mSecondPassDisabled && mPass == 0 && mCurT0 > 0)
83 (*outTracks)->InsertSilence(0, mCurT0);
84
85 // Process only if the right marker is to the right of the left marker
86 if (mCurT1 > mCurT0) {
87 // Transform the marker timepoints to samples
88 auto start = track->TimeToLongSamples(mCurT0);
89 auto end = track->TimeToLongSamples(mCurT1);
90
91 // Get the track rate and samples
92 mCurRate = track->GetRate();
93
94 // NewTrackPass1/2() returns true by default
95 bool ret;
96 if (mPass == 0)
97 ret = NewTrackPass1();
98 else
99 ret = NewTrackPass2();
100 if (!ret)
101 return false;
102
103 // ProcessOne() (implemented below) processes a single track
104 auto outIter = outTrack->Channels().begin();
105 for (const auto pChannel : track->Channels())
106 if (!ProcessOne(*pChannel, **outIter++, start, end))
107 return false;
108 if (!mSecondPassDisabled && mPass == 0)
109 outTrack->Flush();
110 }
111
112 ++mCurTrackNum;
113 ++outTracks;
114 }
115
116 return true;
117}
bool ProcessOne(WaveChannel &t, WaveChannel &outTrack, sampleCount start, sampleCount end)

References PackedArray::end(), mCurRate, mCurT0, mCurT1, mCurTrackNum, min(), mPass, mSecondPassDisabled, EffectBase::mT0, EffectBase::mT1, mTrackLists, NewTrackPass1(), NewTrackPass2(), and ProcessOne().

Referenced by Process().

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

◆ ProcessPass1()

virtual bool EffectTwoPassSimpleMono::ProcessPass1 ( float *  WXUNUSEDbuffer,
size_t   WXUNUSEDlen 
)
inlineprotectedvirtual

Override this method to actually process audio.

Definition at line 45 of file TwoPassSimpleMono.h.

47 { return false; }

◆ ProcessPass2()

virtual bool EffectTwoPassSimpleMono::ProcessPass2 ( float *  WXUNUSEDbuffer,
size_t   WXUNUSEDlen 
)
inlineprotectedvirtual

Definition at line 49 of file TwoPassSimpleMono.h.

51 { return false; }

◆ TwoBufferProcessPass1()

virtual bool EffectTwoPassSimpleMono::TwoBufferProcessPass1 ( float *  buffer1,
size_t  len1,
float *  buffer2,
size_t  len2 
)
inlineprotectedvirtual

Override this method to actually process audio with access to 2 sequential buffers at a time

Either buffer1 or buffer2 may be modified as needed This allows implementation of processing with delays The default just calls the one-buffer-at-a-time method

Reimplemented in EffectCompressor.

Definition at line 60 of file TwoPassSimpleMono.h.

63 {
64 if (buffer1)
65 return ProcessPass1(buffer1, len1);
66 else return true;
67 }
virtual bool ProcessPass1(float *WXUNUSED(buffer), size_t WXUNUSED(len))
Override this method to actually process audio.

Referenced by ProcessOne().

Here is the caller graph for this function:

◆ TwoBufferProcessPass2()

virtual bool EffectTwoPassSimpleMono::TwoBufferProcessPass2 ( float *  buffer1,
size_t  len1,
float *  buffer2,
size_t  len2 
)
inlineprotectedvirtual

Definition at line 68 of file TwoPassSimpleMono.h.

71 {
72 if(buffer1)
73 return ProcessPass2(buffer1, len1);
74 else return true;
75 }
virtual bool ProcessPass2(float *WXUNUSED(buffer), size_t WXUNUSED(len))

Referenced by ProcessOne().

Here is the caller graph for this function:

Member Data Documentation

◆ mCurRate

double EffectTwoPassSimpleMono::mCurRate
protected

Definition at line 87 of file TwoPassSimpleMono.h.

Referenced by EffectCompressor::NewTrackPass1(), and ProcessPass().

◆ mCurT0

double EffectTwoPassSimpleMono::mCurT0
protected

Definition at line 88 of file TwoPassSimpleMono.h.

Referenced by ProcessPass().

◆ mCurT1

double EffectTwoPassSimpleMono::mCurT1
protected

Definition at line 89 of file TwoPassSimpleMono.h.

Referenced by ProcessPass().

◆ mCurTrackNum

int EffectTwoPassSimpleMono::mCurTrackNum
protected

Definition at line 86 of file TwoPassSimpleMono.h.

Referenced by ProcessOne(), and ProcessPass().

◆ mPass

int EffectTwoPassSimpleMono::mPass
protected

Definition at line 90 of file TwoPassSimpleMono.h.

Referenced by Process(), ProcessOne(), and ProcessPass().

◆ mSecondPassDisabled

bool EffectTwoPassSimpleMono::mSecondPassDisabled
protected

Definition at line 91 of file TwoPassSimpleMono.h.

Referenced by Process(), ProcessOne(), and ProcessPass().

◆ mTrackLists

TrackList* EffectTwoPassSimpleMono::mTrackLists[2]
protected

Definition at line 94 of file TwoPassSimpleMono.h.

Referenced by Process(), and ProcessPass().

◆ mWorkTracks

std::shared_ptr<TrackList> EffectTwoPassSimpleMono::mWorkTracks
protected

Definition at line 93 of file TwoPassSimpleMono.h.

Referenced by Process().


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