Audacity 3.2.0
Classes | Public Member Functions | Protected Member Functions | Protected Attributes | Private Types | Private Member Functions | Static Private Member Functions | List of all members
PerTrackEffect Class Reference

Base class for many of the effects in Audacity. More...

#include <PerTrackEffect.h>

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

Classes

class  Instance
 

Public Member Functions

 ~PerTrackEffect () override
 
- 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
 
EffectType GetType () const override
 Type determines how it behaves. More...
 
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...
 
bool LoadUserPreset (const RegistryPath &name, EffectSettings &settings) const override
 Change settings to a user-named preset. More...
 
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...
 
bool LoadFactoryPreset (int id, EffectSettings &settings) const override
 Change settings to the preset whose name is GetFactoryPresets()[id] More...
 
bool LoadFactoryDefaults (EffectSettings &settings) const override
 Change settings back to "factory default". More...
 
virtual const EffectParameterMethodsParameters () const
 
int ShowClientInterface (wxWindow &parent, wxDialog &dialog, EffectUIValidator *pValidator, bool forceModal) override
 
EffectUIClientInterfaceGetEffectUIClientInterface () override
 Returns the EffectUIClientInterface instance for this effect. More...
 
std::unique_ptr< EffectUIValidatorPopulateUI (ShuttleGui &S, EffectInstance &instance, EffectSettingsAccess &access) override
 Adds controls to a panel that is given as the parent window of S More...
 
bool IsGraphicalUI () override
 
bool ValidateUI (EffectSettings &) override
 
bool CloseUI () override
 
bool CanExportPresets () override
 
void ExportPresets (const EffectSettings &settings) const override
 
void ImportPresets (EffectSettings &settings) override
 
bool HasOptions () override
 
void ShowOptions () override
 
const EffectSettingsManagerGetDefinition () const override
 
virtual NumericFormatSymbol GetSelectionFormat ()
 
int ShowHostInterface (wxWindow &parent, const EffectDialogFactory &factory, std::shared_ptr< EffectInstance > &pInstance, EffectSettingsAccess &access, bool forceModal=false) override
 Usually applies factory to self and given access. More...
 
bool SaveSettingsAsString (const EffectSettings &settings, wxString &parms) const override
 
bool LoadSettingsFromString (const wxString &parms, EffectSettings &settings) const override
 
bool IsBatchProcessing () const override
 
void SetBatchProcessing () override
 
void UnsetBatchProcessing () override
 
bool TransferDataToWindow (const EffectSettings &settings) override
 Update controls for the settings. More...
 
bool TransferDataFromWindow (EffectSettings &settings) override
 Update the given settings from controls. More...
 
unsigned TestUIFlags (unsigned mask)
 
bool Delegate (Effect &delegate, EffectSettings &settings)
 Re-invoke DoEffect on another Effect object that implements the work. More...
 
int MessageBox (const TranslatableString &message, long style=DefaultMessageBoxStyle, const TranslatableString &titleStr={}) const
 
bool EnableApply (bool enable=true)
 
wxWindow * GetUIParent ()
 
- Public Member Functions inherited from EffectBase
 EffectBase ()
 
 ~EffectBase () override
 
- Public Member Functions inherited from EffectUIClientInterface
virtual ~EffectUIClientInterface ()
 
virtual int ShowClientInterface (wxWindow &parent, wxDialog &dialog, EffectUIValidator *pValidator, bool forceModal=false)=0
 
virtual bool IsGraphicalUI ()=0
 
virtual std::unique_ptr< EffectUIValidatorPopulateUI (ShuttleGui &S, EffectInstance &instance, EffectSettingsAccess &access)=0
 Adds controls to a panel that is given as the parent window of S More...
 
virtual bool CanExportPresets ()=0
 
virtual void ExportPresets (const EffectSettings &settings) const =0
 
virtual void ImportPresets (EffectSettings &settings)=0
 
virtual bool HasOptions ()=0
 
virtual void ShowOptions ()=0
 
virtual bool ValidateUI (EffectSettings &settings)=0
 
virtual bool CloseUI ()=0
 
- Public Member Functions inherited from EffectPlugin
EffectPluginoperator= (EffectPlugin &)=delete
 
virtual ~EffectPlugin ()
 
virtual const EffectSettingsManagerGetDefinition () const =0
 
virtual int ShowHostInterface (wxWindow &parent, const EffectDialogFactory &factory, std::shared_ptr< EffectInstance > &pInstance, EffectSettingsAccess &access, bool forceModal=false)=0
 Usually applies factory to self and given access. More...
 
virtual EffectUIClientInterfaceGetEffectUIClientInterface ()=0
 Returns the EffectUIClientInterface instance for this effect. More...
 
virtual void Preview (EffectSettingsAccess &access, bool dryOnly)=0
 
virtual bool SaveSettingsAsString (const EffectSettings &settings, wxString &parms) const =0
 
virtual bool 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, double projectRate, TrackList *list, WaveTrackFactory *factory, NotifyingSelectedRegion &selectedRegion, unsigned flags, wxWindow *pParent=nullptr, const EffectDialogFactory &dialogFactory={}, const EffectSettingsAccessPtr &pAccess=nullptr)=0
 Unfortunately complicated dual-use function. More...
 
virtual bool TransferDataToWindow (const EffectSettings &settings)=0
 Update controls for the settings. More...
 
virtual bool TransferDataFromWindow (EffectSettings &settings)=0
 Update the given settings from controls. More...
 
- 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, SettingsCopyDirection copyDirection) const
 Update one settings object from another. 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
 

Protected Member Functions

bool DoPass1 () const
 
bool DoPass2 () const
 
bool Process (EffectInstance &instance, EffectSettings &settings) const
 
- Protected Member Functions inherited from Effect
bool EnablePreview (bool enable=true)
 
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...
 
virtual std::unique_ptr< EffectUIValidatorPopulateOrExchange (ShuttleGui &S, EffectInstance &instance, EffectSettingsAccess &access)
 Add controls to effect panel; always succeeds. 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, const WaveTrack *pRight, sampleCount *start, sampleCount *len)
 
void CopyInputTracks (bool allSyncLockSelected=false)
 
std::shared_ptr< AddedAnalysisTrackAddAnalysisTrack (const wxString &name=wxString())
 
ModifiedAnalysisTrack ModifyAnalysisTrack (const LabelTrack *pOrigTrack, const wxString &name=wxString())
 
TrackAddToOutputTracks (const std::shared_ptr< Track > &t)
 
- Protected Member Functions inherited from EffectBase
void Preview (EffectSettingsAccess &access, bool dryOnly) override
 
bool DoEffect (EffectSettings &settings, double projectRate, TrackList *list, WaveTrackFactory *factory, NotifyingSelectedRegion &selectedRegion, unsigned flags, wxWindow *pParent, const EffectDialogFactory &dialogFactory, const EffectSettingsAccessPtr &pAccess) override
 Unfortunately complicated dual-use function. More...
 
virtual bool CheckWhetherSkipEffect (const EffectSettings &settings) const =0
 After Init(), tell whether Process() should be skipped. More...
 
virtual double CalcPreviewInputLength (const EffectSettings &settings, double previewLength) const =0
 
void SetLinearEffectFlag (bool linearEffectFlag)
 
void SetPreviewFullSelectionFlag (bool previewDurationFlag)
 
bool IsPreviewing () const
 
void IncludeNotSelectedPreviewTracks (bool includeNotSelected)
 
void ReplaceProcessedTracks (const bool bGoodResult)
 
const TrackListinputTracks () const
 
const AudacityProjectFindProject () const
 

Protected Attributes

sampleCount mSampleCnt {}
 
- Protected Attributes inherited from Effect
wxWeakRef< wxDialog > mHostUIDialog
 This smart pointer tracks the lifetime of the dialog. More...
 
wxWindow * mUIParent {}
 
- Protected Attributes inherited from EffectBase
BasicUI::ProgressDialogmProgress {}
 
double mProjectRate {}
 
WaveTrackFactorymFactory {}
 
std::shared_ptr< TrackListmOutputTracks
 
double mT0 {}
 
double mT1 {}
 
wxArrayString mPresetNames
 
unsigned mUIFlags { 0 }
 

Private Types

using Buffers = AudioGraph::Buffers
 
using Factory = std::function< std::shared_ptr< EffectInstanceEx >()>
 

Private Member Functions

bool ProcessPass (Instance &instance, EffectSettings &settings)
 

Static Private Member Functions

static bool ProcessTrack (bool multi, const Factory &factory, EffectSettings &settings, AudioGraph::Source &source, AudioGraph::Sink &sink, std::optional< sampleCount > genLength, double sampleRate, const Track &track, Buffers &inBuffers, Buffers &outBuffers)
 

Additional Inherited Members

- Public Types inherited from Effect
enum  : long { DefaultMessageBoxStyle = wxOK | wxCENTRE }
 
- Public Types inherited from EffectPlugin
using EffectSettingsAccessPtr = std::shared_ptr< EffectSettingsAccess >
 
- Public Types inherited from EffectDefinitionInterface
enum class  RealtimeSince : unsigned { Never , Since_3_2 , Always }
 In which versions of Audacity was an effect realtime capable? More...
 
- Static Public Member Functions inherited from Effect
static EffectFetchParameters (Effect &e, EffectSettings &)
 
static void IncEffectCounter ()
 
- 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 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>")
 
- Static Protected Attributes inherited from EffectBase
static int nEffectsDone = 0
 

Detailed Description

Base class for many of the effects in Audacity.

Base class for Effects that treat each (mono or stereo) track independently of other tracks.

Its override of Effect::Process() uses ProcessInitialize(), ProcessBlock(), and ProcessFinalize() methods of its instance made by MakeInstance(), which must be a subclass of PerTrackEffect::Instance. Also uses GetLatency() to determine how many leading output samples to discard and how many extra samples to produce.

Definition at line 33 of file PerTrackEffect.h.

Member Typedef Documentation

◆ Buffers

Definition at line 68 of file PerTrackEffect.h.

◆ Factory

using PerTrackEffect::Factory = std::function<std::shared_ptr<EffectInstanceEx>()>
private

Definition at line 71 of file PerTrackEffect.h.

Constructor & Destructor Documentation

◆ ~PerTrackEffect()

PerTrackEffect::~PerTrackEffect ( )
overridedefault

Member Function Documentation

◆ DoPass1()

bool PerTrackEffect::DoPass1 ( ) const
protected

Definition at line 55 of file PerTrackEffect.cpp.

56{
57 return true;
58}

Referenced by Process().

Here is the caller graph for this function:

◆ DoPass2()

bool PerTrackEffect::DoPass2 ( ) const
protected

Definition at line 60 of file PerTrackEffect.cpp.

61{
62 return false;
63}

Referenced by Process().

Here is the caller graph for this function:

◆ Process()

bool PerTrackEffect::Process ( EffectInstance instance,
EffectSettings settings 
) const
protected

Definition at line 65 of file PerTrackEffect.cpp.

67{
68 auto pThis = const_cast<PerTrackEffect *>(this);
69 pThis->CopyInputTracks(true);
70 bool bGoodResult = true;
71 // mPass = 1;
72 if (DoPass1()) {
73 auto &myInstance = dynamic_cast<Instance&>(instance);
74 bGoodResult = pThis->ProcessPass(myInstance, settings);
75 // mPass = 2;
76 if (bGoodResult && DoPass2())
77 bGoodResult = pThis->ProcessPass(myInstance, settings);
78 }
79 pThis->ReplaceProcessedTracks(bGoodResult);
80 return bGoodResult;
81}
static Settings & settings()
Definition: TrackInfo.cpp:87
void CopyInputTracks(bool allSyncLockSelected=false)
Definition: Effect.cpp:724
Base class for many of the effects in Audacity.
bool DoPass2() const
bool DoPass1() const

References Effect::CopyInputTracks(), DoPass1(), DoPass2(), and settings().

Referenced by StatefulPerTrackEffect::Process(), and PerTrackEffect::Instance::Process().

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

◆ ProcessPass()

bool PerTrackEffect::ProcessPass ( Instance instance,
EffectSettings settings 
)
private

Definition at line 83 of file PerTrackEffect.cpp.

84{
85 const auto duration = settings.extra.GetDuration();
86 bool bGoodResult = true;
87 bool isGenerator = GetType() == EffectTypeGenerate;
88 bool isProcessor = GetType() == EffectTypeProcess;
89
90 Buffers inBuffers, outBuffers;
91 ChannelName map[3];
92 size_t prevBufferSize = 0;
93 int count = 0;
94 bool clear = false;
95
96 // It's possible that the number of channels the effect expects changed based on
97 // the parameters (the Audacity Reverb effect does when the stereo width is 0).
98 const auto numAudioIn = instance.GetAudioInCount();
99 const auto numAudioOut = instance.GetAudioOutCount();
100 if (numAudioOut < 1)
101 return false;
102
103 // Instances that can be reused in each loop pass
104 std::vector<std::shared_ptr<EffectInstanceEx>> recycledInstances{
105 // First one is the given one; any others pushed onto here are
106 // discarded when we exit
107 std::dynamic_pointer_cast<EffectInstanceEx>(instance.shared_from_this())
108 };
109
110 const bool multichannel = numAudioIn > 1;
111 auto range = multichannel
112 ? mOutputTracks->Leaders()
113 : mOutputTracks->Any();
114 range.VisitWhile( bGoodResult,
115 [&](WaveTrack *pLeft, const Track::Fallthrough &fallthrough) {
116 // Track range visitor functions receive a pointer that is never null
117 auto &left = *pLeft;
118 if (!left.GetSelected())
119 return fallthrough();
120
121 sampleCount len = 0;
122 sampleCount start = 0;
123 WaveTrack *pRight{};
124
125 const auto numChannels =
126 AudioGraph::MakeChannelMap(left, multichannel, map);
127 if (multichannel) {
128 assert(numAudioIn > 1);
129 if (numChannels == 2) {
130 // TODO: more-than-two-channels
131 pRight = *TrackList::Channels(&left).rbegin();
132 clear = false;
133 }
134 }
135
136 if (!isGenerator) {
137 GetBounds(left, pRight, &start, &len);
138 mSampleCnt = len;
139 if (len > 0 && numAudioIn < 1) {
140 bGoodResult = false;
141 return;
142 }
143 }
144 else
145 mSampleCnt = left.TimeToLongSamples(duration);
146
147 const auto sampleRate = left.GetRate();
148
149 // Get the block size the client wants to use
150 auto max = left.GetMaxBlockSize() * 2;
151 const auto blockSize = instance.SetBlockSize(max);
152 if (blockSize == 0) {
153 bGoodResult = false;
154 return;
155 }
156
157 // Calculate the buffer size to be at least the max rounded up to the clients
158 // selected block size.
159 const auto bufferSize =
160 ((max + (blockSize - 1)) / blockSize) * blockSize;
161 if (bufferSize == 0) {
162 bGoodResult = false;
163 return;
164 }
165
166 // Always create the number of input buffers the client expects even
167 // if we don't have
168 // the same number of channels.
169 // (These resizes may do nothing after the first track)
170
171 if (len > 0)
172 assert(numAudioIn > 0); // checked above
173 inBuffers.Reinit(
174 // TODO fix this hack for making Generator progress work without
175 // assertion violations. Make a dummy Source class that doesn't
176 // care about the buffers.
177 std::max(1u, numAudioIn),
178 blockSize,
179 std::max<size_t>(1, bufferSize / blockSize));
180 if (len > 0)
181 // post of Reinit later satisfies pre of Source::Acquire()
182 assert(inBuffers.Channels() > 0);
183
184 if (prevBufferSize != bufferSize) {
185 // Buffer size has changed
186 // We won't be using more than the first 2 buffers,
187 // so clear the rest (if any)
188 for (size_t i = 2; i < numAudioIn; i++)
189 inBuffers.ClearBuffer(i, bufferSize);
190 }
191 prevBufferSize = bufferSize;
192
193 // Always create the number of output buffers the client expects
194 // even if we don't have the same number of channels.
195 // (These resizes may do nothing after the first track)
196 // Output buffers get an extra blockSize worth to give extra room if
197 // the plugin adds latency -- PRL: actually not important to do
198 assert(numAudioOut > 0); // checked above
199 outBuffers.Reinit(numAudioOut, blockSize,
200 (bufferSize / blockSize) + 1);
201 // post of Reinit satisfies pre of ProcessTrack
202 assert(outBuffers.Channels() > 0);
203
204 // (Re)Set the input buffer positions
205 inBuffers.Rewind();
206
207 // Clear unused input buffers
208 if (!pRight && !clear && numAudioIn > 1) {
209 inBuffers.ClearBuffer(1, bufferSize);
210 clear = true;
211 }
212
213 const auto genLength = [this, &settings, &left, isGenerator](
214 ) -> std::optional<sampleCount> {
215 double genDur = 0;
216 if (isGenerator) {
217 const auto duration = settings.extra.GetDuration();
218 if (IsPreviewing()) {
219 gPrefs->Read(wxT("/AudioIO/EffectsPreviewLen"), &genDur, 6.0);
220 genDur = std::min(duration, CalcPreviewInputLength(settings, genDur));
221 }
222 else
223 genDur = duration;
224 // round to nearest sample
225 return sampleCount{ (left.GetRate() * genDur) + 0.5 };
226 }
227 else
228 return {};
229 }();
230
231 const auto pollUser = [this, numChannels, count, start,
232 length = (genLength ? *genLength : len).as_double()
233 ](sampleCount inPos){
234 if (numChannels > 1) {
236 count, (inPos - start).as_double() / length)
237 )
238 return false;
239 }
240 else {
241 if (TrackProgress(count, (inPos - start).as_double() / length))
242 return false;
243 }
244 return true;
245 };
246
247 // Assured above
248 assert(len == 0 || inBuffers.Channels() > 0);
249 // TODO fix this hack to make the time remaining of the generator
250 // progress dialog correct
251 if (len == 0 && genLength)
252 len = *genLength;
253 SampleTrackSource source{ left, pRight, start, len, pollUser };
254 // Assert source is safe to Acquire inBuffers
255 assert(source.AcceptsBuffers(inBuffers));
256 assert(source.AcceptsBlockSize(inBuffers.BlockSize()));
257
258 WaveTrackSink sink{ left, pRight, start, isGenerator, isProcessor };
259 assert(sink.AcceptsBuffers(outBuffers));
260
261 // Go process the track(s)
262 const auto factory =
263 [this, &recycledInstances, counter = 0]() mutable {
264 auto index = counter++;
265 if (index < recycledInstances.size())
266 return recycledInstances[index];
267 else
268 return recycledInstances.emplace_back(
269 std::dynamic_pointer_cast<EffectInstanceEx>(MakeInstance()));
270 };
271 bGoodResult = ProcessTrack(multichannel, factory, settings, source, sink,
272 genLength, sampleRate, left,
273 inBuffers, outBuffers);
274 if (bGoodResult)
275 sink.Flush(outBuffers,
276 mT0, ViewInfo::Get(*FindProject()).selectedRegion.t1());
277 if (!bGoodResult)
278 return;
279 ++count;
280 },
281 [&](Track *t) {
283 t->SyncLockAdjust(mT1, mT0 + duration);
284 }
285 );
286
287 if (bGoodResult && GetType() == EffectTypeGenerate)
288 mT1 = mT0 + duration;
289
290 return bGoodResult;
291}
wxT("CloseDown"))
int min(int a, int b)
@ EffectTypeGenerate
@ EffectTypeProcess
ChannelName
FileConfig * gPrefs
Definition: Prefs.cpp:71
double mT1
Definition: EffectBase.h:107
std::shared_ptr< TrackList > mOutputTracks
Definition: EffectBase.h:105
bool IsPreviewing() const
Definition: EffectBase.h:83
double mT0
Definition: EffectBase.h:106
const AudacityProject * FindProject() const
Definition: EffectBase.cpp:315
bool TrackGroupProgress(int whichGroup, double frac, const TranslatableString &={}) const
Definition: Effect.cpp:684
double CalcPreviewInputLength(const EffectSettings &settings, double previewLength) const override
Default implementation returns previewLength
Definition: Effect.cpp:848
bool TrackProgress(int whichTrack, double frac, const TranslatableString &={}) const
Definition: Effect.cpp:674
EffectType GetType() const override
Type determines how it behaves.
Definition: Effect.cpp:100
void GetBounds(const WaveTrack &track, const WaveTrack *pRight, sampleCount *start, sampleCount *len)
Definition: Effect.cpp:694
virtual std::shared_ptr< EffectInstance > MakeInstance() const =0
Make an object maintaining short-term state of an Effect.
AudioGraph::Buffers Buffers
static bool ProcessTrack(bool multi, const Factory &factory, EffectSettings &settings, AudioGraph::Source &source, AudioGraph::Sink &sink, std::optional< sampleCount > genLength, double sampleRate, const Track &track, Buffers &inBuffers, Buffers &outBuffers)
sampleCount mSampleCnt
Adapts SampleTrack to the interface AudioGraph::Source.
static bool IsSyncLockSelected(const Track *pTrack)
Definition: SyncLock.cpp:43
Abstract base class for an object holding data associated with points on a time axis.
Definition: Track.h:225
Continuation<> Fallthrough
Type of arguments passed as optional second parameter to TypeSwitch<void>() cases.
Definition: Track.h:541
static auto Channels(TrackType *pTrack) -> TrackIterRange< TrackType >
Definition: Track.h:1541
static ViewInfo & Get(AudacityProject &project)
Definition: ViewInfo.cpp:235
A Track that contains audio waveform data.
Definition: WaveTrack.h:57
Positions or offsets within audio files need a wide type.
Definition: SampleCount.h:19
AUDIO_GRAPH_API unsigned MakeChannelMap(const Track &track, bool multichannel, ChannelName map[3])
static RegisteredToolbarFactory factory

References AudioGraph::Buffers::BlockSize(), Effect::CalcPreviewInputLength(), AudioGraph::Buffers::Channels(), TrackList::Channels(), AudioGraph::Buffers::ClearBuffer(), EffectTypeGenerate, EffectTypeProcess, cloud::factory, EffectBase::FindProject(), ViewInfo::Get(), EffectInstance::GetAudioInCount(), EffectInstance::GetAudioOutCount(), Effect::GetBounds(), Effect::GetType(), gPrefs, EffectBase::IsPreviewing(), SyncLock::IsSyncLockSelected(), AudioGraph::MakeChannelMap(), EffectInstanceFactory::MakeInstance(), min(), EffectBase::mOutputTracks, mSampleCnt, EffectBase::mT0, EffectBase::mT1, ProcessTrack(), AudioGraph::Buffers::Reinit(), AudioGraph::Buffers::Rewind(), EffectInstance::SetBlockSize(), settings(), Effect::TrackGroupProgress(), Effect::TrackProgress(), and wxT().

Here is the call graph for this function:

◆ ProcessTrack()

bool PerTrackEffect::ProcessTrack ( bool  multi,
const Factory factory,
EffectSettings settings,
AudioGraph::Source source,
AudioGraph::Sink sink,
std::optional< sampleCount genLength,
double  sampleRate,
const Track track,
Buffers inBuffers,
Buffers outBuffers 
)
staticprivate

Previous contents of inBuffers and outBuffers are ignored

Precondition
source.AcceptsBuffers(inBuffers)
source.AcceptsBlockSize(inBuffers.BlockSize())
sink.AcceptsBuffers(outBuffers)
inBuffers.BlockSize() == outBuffers.BlockSize()

Definition at line 293 of file PerTrackEffect.cpp.

299{
300 assert(upstream.AcceptsBuffers(inBuffers));
301 assert(sink.AcceptsBuffers(outBuffers));
302
303 const auto blockSize = inBuffers.BlockSize();
304 assert(upstream.AcceptsBlockSize(blockSize));
305 assert(blockSize == outBuffers.BlockSize());
306
307 auto pSource = AudioGraph::EffectStage::Create( multi, upstream, inBuffers,
308 factory, settings, sampleRate, genLength, track );
309 if (!pSource)
310 return false;
311 assert(pSource->AcceptsBlockSize(blockSize)); // post of ctor
312 assert(pSource->AcceptsBuffers(outBuffers));
313
314 AudioGraph::Task task{ *pSource, outBuffers, sink };
315 return task.RunLoop();
316}
static std::unique_ptr< EffectStage > Create(bool multi, Source &upstream, Buffers &inBuffers, const Factory &factory, EffectSettings &settings, double sampleRate, std::optional< sampleCount > genLength, const Track &track)
Satisfies postcondition of constructor or returns null.
Definition: EffectStage.cpp:87
virtual bool AcceptsBuffers(const Buffers &buffers) const =0
Copies from a Source to a Sink, mediated by Buffers.

References AudioGraph::Source::AcceptsBlockSize(), AudioGraph::Sink::AcceptsBuffers(), AudioGraph::Source::AcceptsBuffers(), AudioGraph::Buffers::BlockSize(), AudioGraph::EffectStage::Create(), cloud::factory, and settings().

Referenced by ProcessPass().

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

Member Data Documentation

◆ mSampleCnt

sampleCount PerTrackEffect::mSampleCnt {}
protected

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