Audacity 3.2.0
Classes | Public Member Functions | Protected Member Functions | Protected Attributes | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes | 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
 
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)
 
double GetDefaultDuration ()
 
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
 

Protected Member Functions

bool DoPass1 () const
 
bool DoPass2 () const
 
bool Process (EffectInstance &instance, EffectSettings &settings) const
 
std::shared_ptr< EffectOutputTracksMakeOutputTracks ()
 
void DestroyOutputTracks () const
 
- 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

sampleCount mSampleCnt {}
 
- Protected Attributes inherited from EffectBase
double mF0 {}
 
double mF1 {}
 
wxArrayString mPresetNames
 
unsigned mUIFlags { 0 }
 

Private Types

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

Private Member Functions

bool ProcessPass (TrackList &outputs, Instance &instance, EffectSettings &settings)
 

Static Private Member Functions

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

Private Attributes

std::shared_ptr< EffectOutputTracksmpOutputTracks
 

Additional Inherited Members

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

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 37 of file PerTrackEffect.h.

Member Typedef Documentation

◆ Buffers

Definition at line 78 of file PerTrackEffect.h.

◆ Factory

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

Definition at line 82 of file PerTrackEffect.h.

Constructor & Destructor Documentation

◆ ~PerTrackEffect()

PerTrackEffect::~PerTrackEffect ( )
overridedefault

Member Function Documentation

◆ DestroyOutputTracks()

void PerTrackEffect::DestroyOutputTracks ( ) const
protected

Definition at line 391 of file PerTrackEffect.cpp.

392{
393 mpOutputTracks.reset();
394}
std::shared_ptr< EffectOutputTracks > mpOutputTracks

References mpOutputTracks.

Referenced by Process(), and AmplifyBase::Instance::~Instance().

Here is the caller graph for this function:

◆ DoPass1()

bool PerTrackEffect::DoPass1 ( ) const
protected

Definition at line 54 of file PerTrackEffect.cpp.

55{
56 return true;
57}

Referenced by Process().

Here is the caller graph for this function:

◆ DoPass2()

bool PerTrackEffect::DoPass2 ( ) const
protected

Definition at line 59 of file PerTrackEffect.cpp.

60{
61 return false;
62}

Referenced by Process().

Here is the caller graph for this function:

◆ MakeOutputTracks()

std::shared_ptr< EffectOutputTracks > PerTrackEffect::MakeOutputTracks ( )
protected

Definition at line 384 of file PerTrackEffect.cpp.

385{
386 return mpOutputTracks =
387 std::make_shared<EffectOutputTracks>(*mTracks, GetType(),
389}
double mT1
Definition: EffectBase.h:123
std::shared_ptr< TrackList > mTracks
Definition: EffectBase.h:116
double mT0
Definition: EffectBase.h:122
virtual EffectType GetType() const =0
Type determines how it behaves.
std::pair< double, double > TimeInterval

References EffectDefinitionInterface::GetType(), mpOutputTracks, EffectBase::mT0, EffectBase::mT1, and EffectBase::mTracks.

Referenced by AmplifyBase::Init().

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

◆ Process()

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

Definition at line 64 of file PerTrackEffect.cpp.

66{
67 auto pThis = const_cast<PerTrackEffect *>(this);
68
69 // Destroy any pre-formed output tracks when done
70 auto pOutputs = mpOutputTracks.get();
71
72 std::optional<EffectOutputTracks> outputs;
73 if (!pOutputs)
74 pOutputs = &outputs.emplace(*mTracks, GetType(),
76
77 bool bGoodResult = true;
78 // mPass = 1;
79 if (DoPass1()) {
80 auto &myInstance = dynamic_cast<Instance&>(instance);
81 bGoodResult = pThis->ProcessPass(pOutputs->Get(), myInstance, settings);
82 // mPass = 2;
83 if (bGoodResult && DoPass2())
84 bGoodResult = pThis->ProcessPass(pOutputs->Get(), myInstance, settings);
85 }
86 if (bGoodResult)
87 pOutputs->Commit();
89 return bGoodResult;
90}
static Settings & settings()
Definition: TrackInfo.cpp:51
Base class for many of the effects in Audacity.
bool DoPass2() const
void DestroyOutputTracks() const
bool DoPass1() const

References DestroyOutputTracks(), DoPass1(), DoPass2(), EffectDefinitionInterface::GetType(), mpOutputTracks, EffectBase::mT0, EffectBase::mT1, EffectBase::mTracks, 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 ( TrackList outputs,
Instance instance,
EffectSettings settings 
)
private

Definition at line 92 of file PerTrackEffect.cpp.

94{
95 const auto duration = settings.extra.GetDuration();
96 bool bGoodResult = true;
97 bool isGenerator = GetType() == EffectTypeGenerate;
98 bool isProcessor = GetType() == EffectTypeProcess;
99
100 Buffers inBuffers, outBuffers;
101 ChannelName map[3];
102 size_t prevBufferSize = 0;
103 int count = 0;
104 bool clear = false;
105
106 // It's possible that the number of channels the effect expects changed based on
107 // the parameters (the Audacity Reverb effect does when the stereo width is 0).
108 const auto numAudioIn = instance.GetAudioInCount();
109 const auto numAudioOut = instance.GetAudioOutCount();
110 if (numAudioOut < 1)
111 return false;
112
113 // Instances that can be reused in each loop pass
114 std::vector<std::shared_ptr<EffectInstance>> recycledInstances{
115 // First one is the given one; any others pushed onto here are
116 // discarded when we exit
117 std::dynamic_pointer_cast<EffectInstanceEx>(instance.shared_from_this())
118 };
119
120 const bool multichannel = numAudioIn > 1;
121 int iChannel = 0;
122 TrackListHolder results;
123 const auto waveTrackVisitor =
124 [&](WaveTrack &wt, WaveChannel &chan, bool isFirst) {
125 if (isFirst)
126 iChannel = 0;
127
128 sampleCount len = 0;
129 sampleCount start = 0;
130 WaveChannel *pRight{};
131
132 const int channel = (multichannel ? -1 : iChannel++);
133 const auto numChannels = MakeChannelMap(wt.NChannels(), channel, map);
134 if (multichannel) {
135 assert(numAudioIn > 1);
136 if (numChannels == 2) {
137 // TODO: more-than-two-channels
138 pRight = (*wt.Channels().rbegin()).get();
139 clear = false;
140 }
141 }
142
143 if (!isGenerator) {
144 GetBounds(wt, &start, &len);
145 mSampleCnt = len;
146 if (len > 0 && numAudioIn < 1) {
147 bGoodResult = false;
148 return;
149 }
150 }
151 else
152 mSampleCnt = wt.TimeToLongSamples(duration);
153
154 const auto sampleRate = wt.GetRate();
155
156 // Get the block size the client wants to use
157 auto max = wt.GetMaxBlockSize() * 2;
158 const auto blockSize = instance.SetBlockSize(max);
159 if (blockSize == 0) {
160 bGoodResult = false;
161 return;
162 }
163
164 // Calculate the buffer size to be at least the max rounded up to the clients
165 // selected block size.
166 const auto bufferSize =
167 ((max + (blockSize - 1)) / blockSize) * blockSize;
168 if (bufferSize == 0) {
169 bGoodResult = false;
170 return;
171 }
172
173 // Always create the number of input buffers the client expects even
174 // if we don't have
175 // the same number of channels.
176 // (These resizes may do nothing after the first track)
177
178 if (len > 0)
179 assert(numAudioIn > 0); // checked above
180 inBuffers.Reinit(
181 // TODO fix this hack for making Generator progress work without
182 // assertion violations. Make a dummy Source class that doesn't
183 // care about the buffers.
184 std::max(1u, numAudioIn),
185 blockSize,
186 std::max<size_t>(1, bufferSize / blockSize));
187 if (len > 0)
188 // post of Reinit later satisfies pre of Source::Acquire()
189 assert(inBuffers.Channels() > 0);
190
191 if (prevBufferSize != bufferSize) {
192 // Buffer size has changed
193 // We won't be using more than the first 2 buffers,
194 // so clear the rest (if any)
195 for (size_t i = 2; i < numAudioIn; i++)
196 inBuffers.ClearBuffer(i, bufferSize);
197 }
198 prevBufferSize = bufferSize;
199
200 // Always create the number of output buffers the client expects
201 // even if we don't have the same number of channels.
202 // (These resizes may do nothing after the first track)
203 // Output buffers get an extra blockSize worth to give extra room if
204 // the plugin adds latency -- PRL: actually not important to do
205 assert(numAudioOut > 0); // checked above
206 outBuffers.Reinit(numAudioOut, blockSize,
207 (bufferSize / blockSize) + 1);
208 // post of Reinit satisfies pre of ProcessTrack
209 assert(outBuffers.Channels() > 0);
210
211 // (Re)Set the input buffer positions
212 inBuffers.Rewind();
213
214 // Clear unused input buffers
215 if (!pRight && !clear && numAudioIn > 1) {
216 inBuffers.ClearBuffer(1, bufferSize);
217 clear = true;
218 }
219
220 const auto genLength = [this, &settings, &wt, isGenerator](
221 ) -> std::optional<sampleCount> {
222 double genDur = 0;
223 if (isGenerator) {
224 const auto duration = settings.extra.GetDuration();
225 if (IsPreviewing()) {
226 gPrefs->Read(wxT("/AudioIO/EffectsPreviewLen"), &genDur, 6.0);
227 genDur = std::min(duration, CalcPreviewInputLength(settings, genDur));
228 }
229 else
230 genDur = duration;
231 // round to nearest sample
232 return sampleCount{ (wt.GetRate() * genDur) + 0.5 };
233 }
234 else
235 return {};
236 }();
237
238 const auto pollUser = [this, numChannels, count, start,
239 length = (genLength ? *genLength : len).as_double()
240 ](sampleCount inPos){
241 if (numChannels > 1) {
243 count, (inPos - start).as_double() / length)
244 )
245 return false;
246 }
247 else {
248 if (TrackProgress(count, (inPos - start).as_double() / length))
249 return false;
250 }
251 return true;
252 };
253
254 // Assured above
255 assert(len == 0 || inBuffers.Channels() > 0);
256 // TODO fix this hack to make the time remaining of the generator
257 // progress dialog correct
258 if (len == 0 && genLength)
259 len = *genLength;
260 WideSampleSequence *pSeq = &chan;
261 if (pRight)
262 pSeq = &wt;
263 WideSampleSource source{
264 *pSeq, size_t(pRight ? 2 : 1), start, len, pollUser };
265 // Assert source is safe to Acquire inBuffers
266 assert(source.AcceptsBuffers(inBuffers));
267 assert(source.AcceptsBlockSize(inBuffers.BlockSize()));
268
269 // Make "wide" or "narrow" copy of the track if generating
270 // Old generator code may still proceed "interval-major" and later
271 // join mono into stereo
272 auto wideTrack =
273 (pRight && isGenerator) ? wt.EmptyCopy() : nullptr;
274 auto narrowTrack =
275 (!pRight && isGenerator) ? wt.EmptyCopy(1) : nullptr;
276 const auto pGenerated = wideTrack
277 ? wideTrack
278 : narrowTrack;
279
280 WaveTrackSink sink{ chan, pRight, pGenerated.get(), start, isProcessor,
281 instance.NeedsDither() ? widestSampleFormat : narrowestSampleFormat
282 };
283 assert(sink.AcceptsBuffers(outBuffers));
284
285 // Go process the track(s)
286 const auto factory =
287 [this, &recycledInstances, counter = 0]() mutable {
288 auto index = counter++;
289 if (index < recycledInstances.size())
290 return recycledInstances[index];
291 else
292 return recycledInstances.emplace_back(MakeInstance());
293 };
294 bGoodResult = ProcessTrack(channel, factory, settings, source, sink,
295 genLength, sampleRate, wt, inBuffers, outBuffers);
296 if (bGoodResult) {
297 sink.Flush(outBuffers);
298 bGoodResult = sink.IsOk();
299 if (bGoodResult && pGenerated) {
300 if (!results)
301 results = TrackList::Temporary(nullptr, pGenerated);
302 else {
303 results->Add(pGenerated);
304 if (!multichannel && !isFirst && narrowTrack) {
305 // Generated a stereo track, in channel-major fashion.
306 // Get the last track but one -- generated in the previous
307 // pass
308 const auto pLast =
309 static_cast<WaveTrack*>(*std::next(results->rbegin()));
310 pLast->ZipClips();
311 }
312 }
313 }
314 }
315 if (!bGoodResult)
316 return;
317 ++count;
318 };
319 const auto defaultTrackVisitor =
320 [&](Track &t) {
322 t.SyncLockAdjust(mT1, mT0 + duration);
323 };
324
325 outputs.Any().VisitWhile(bGoodResult,
326 [&](auto &&fallthrough){ return [&](WaveTrack &wt) {
327 if (!wt.GetSelected())
328 return fallthrough();
329 const auto channels = wt.Channels();
330 if (multichannel)
331 waveTrackVisitor(wt, **channels.begin(), true);
332 else {
333 bool first = true;
334 for (const auto pChannel : channels) {
335 waveTrackVisitor(wt, *pChannel, first);
336 first = false;
337 }
338 }
339 if (results) {
340 const auto t1 = ViewInfo::Get(*FindProject()).selectedRegion.t1();
341 PasteTimeWarper warper { t1,
342 mT0 + (*results->begin())->GetEndTime() };
343 wt.ClearAndPaste(mT0, t1,
344 static_cast<WaveTrack&>(*results->DetachFirst()),
345 true, true, &warper);
346 results.reset();
347 }
348 }; },
349 defaultTrackVisitor
350 );
351
352 if (bGoodResult && GetType() == EffectTypeGenerate)
353 mT1 = mT0 + duration;
354
355 return bGoodResult;
356}
wxT("CloseDown"))
static RegisteredToolbarFactory factory
int min(int a, int b)
@ EffectTypeGenerate
@ EffectTypeProcess
ChannelName
unsigned MakeChannelMap(int nChannels, int channel, ChannelName map[3])
audacity::BasicSettings * gPrefs
Definition: Prefs.cpp:68
@ narrowestSampleFormat
Two synonyms for previous values that might change if more values were added.
std::shared_ptr< TrackList > TrackListHolder
Definition: Track.h:42
bool IsPreviewing() const
Definition: EffectBase.h:100
const AudacityProject * FindProject() const
Definition: EffectBase.cpp:220
bool TrackGroupProgress(int whichGroup, double frac, const TranslatableString &={}) const
Definition: Effect.cpp:353
void GetBounds(const WaveTrack &track, sampleCount *start, sampleCount *len)
Definition: Effect.cpp:363
double CalcPreviewInputLength(const EffectSettings &settings, double previewLength) const override
Default implementation returns previewLength
Definition: Effect.cpp:384
bool TrackProgress(int whichTrack, double frac, const TranslatableString &={}) const
Definition: Effect.cpp:343
virtual std::shared_ptr< EffectInstance > MakeInstance() const =0
Make an object maintaining short-term state of an Effect.
double t1() const
Definition: ViewInfo.h:36
Unit slope but with either a jump (pasting more) or a flat interval (pasting less)
Definition: TimeWarper.h:181
AudioGraph::Buffers Buffers
static bool ProcessTrack(int channel, const Factory &factory, EffectSettings &settings, AudioGraph::Source &source, AudioGraph::Sink &sink, std::optional< sampleCount > genLength, double sampleRate, const SampleTrack &wt, Buffers &inBuffers, Buffers &outBuffers)
sampleCount mSampleCnt
static bool IsSyncLockSelected(const Track &track)
Definition: SyncLock.cpp:80
Abstract base class for an object holding data associated with points on a time axis.
Definition: Track.h:110
auto Any() -> TrackIterRange< TrackType >
Definition: Track.h:950
static TrackListHolder Temporary(AudacityProject *pProject, const Track::Holder &pTrack={})
Definition: Track.cpp:858
NotifyingSelectedRegion selectedRegion
Definition: ViewInfo.h:216
static ViewInfo & Get(AudacityProject &project)
Definition: ViewInfo.cpp:235
A Track that contains audio waveform data.
Definition: WaveTrack.h:203
auto Channels()
Definition: WaveTrack.h:263
void ZipClips(bool mustAlign=true)
Definition: WaveTrack.cpp:3317
double GetRate() const override
Definition: WaveTrack.cpp:821
size_t NChannels() const override
A constant property.
Definition: WaveTrack.cpp:530
size_t GetMaxBlockSize() const
Definition: WaveTrack.cpp:2279
sampleCount TimeToLongSamples(double t0) const
Adapts WideSampleSequence to the interface AudioGraph::Source.
virtual bool Read(const wxString &key, bool *value) const =0
Positions or offsets within audio files need a wide type.
Definition: SampleCount.h:19

References TrackList::Any(), AudioGraph::Buffers::BlockSize(), Effect::CalcPreviewInputLength(), WaveTrack::Channels(), AudioGraph::Buffers::Channels(), WaveTrack::ClearAndPaste(), AudioGraph::Buffers::ClearBuffer(), EffectTypeGenerate, EffectTypeProcess, factory, EffectBase::FindProject(), ViewInfo::Get(), EffectInstance::GetAudioInCount(), EffectInstance::GetAudioOutCount(), Effect::GetBounds(), WaveTrack::GetMaxBlockSize(), WaveTrack::GetRate(), Track::GetSelected(), EffectDefinitionInterface::GetType(), gPrefs, anonymous_namespace{StretchingSequenceIntegrationTest.cpp}::iChannel, EffectBase::IsPreviewing(), SyncLock::IsSyncLockSelected(), MakeChannelMap(), EffectInstanceFactory::MakeInstance(), min(), mSampleCnt, EffectBase::mT0, EffectBase::mT1, narrowestSampleFormat, WaveTrack::NChannels(), EffectInstance::NeedsDither(), ProcessTrack(), audacity::BasicSettings::Read(), AudioGraph::Buffers::Reinit(), AudioGraph::Buffers::Rewind(), anonymous_namespace{ClipSegmentTest.cpp}::sampleRate, ViewInfo::selectedRegion, EffectInstance::SetBlockSize(), settings(), NotifyingSelectedRegion::t1(), TrackList::Temporary(), WideSampleSequence::TimeToLongSamples(), Effect::TrackGroupProgress(), Effect::TrackProgress(), widestSampleFormat, wxT(), and WaveTrack::ZipClips().

Here is the call graph for this function:

◆ ProcessTrack()

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

Previous contents of inBuffers and outBuffers are ignored

Parameters
channelselects one channel if non-negative; else all channels
Precondition
source.AcceptsBuffers(inBuffers)
source.AcceptsBlockSize(inBuffers.BlockSize())
sink.AcceptsBuffers(outBuffers)
inBuffers.BlockSize() == outBuffers.BlockSize()
channel < track.NChannels()

Definition at line 358 of file PerTrackEffect.cpp.

364{
365 assert(upstream.AcceptsBuffers(inBuffers));
366 assert(sink.AcceptsBuffers(outBuffers));
367
368 const auto blockSize = inBuffers.BlockSize();
369 assert(upstream.AcceptsBlockSize(blockSize));
370 assert(blockSize == outBuffers.BlockSize());
371
372 auto pSource = EffectStage::Create(
373 channel, static_cast<const WideSampleSequence&>(wt).NChannels(), upstream,
374 inBuffers, factory, settings, sampleRate, genLength);
375 if (!pSource)
376 return false;
377 assert(pSource->AcceptsBlockSize(blockSize)); // post of ctor
378 assert(pSource->AcceptsBuffers(outBuffers));
379
380 AudioGraph::Task task{ *pSource, outBuffers, sink };
381 return task.RunLoop();
382}
virtual bool AcceptsBuffers(const Buffers &buffers) const =0
static std::unique_ptr< EffectStage > Create(int channel, int nInputChannels, Source &upstream, Buffers &inBuffers, const Factory &factory, EffectSettings &settings, double sampleRate, std::optional< sampleCount > genLength)
Satisfies postcondition of constructor or returns null.
Definition: EffectStage.cpp:79
Copies from a Source to a Sink, mediated by Buffers.

References AudioGraph::Source::AcceptsBlockSize(), AudioGraph::Sink::AcceptsBuffers(), AudioGraph::Source::AcceptsBuffers(), AudioGraph::Buffers::BlockSize(), EffectStage::Create(), factory, anonymous_namespace{ClipSegmentTest.cpp}::sampleRate, and settings().

Referenced by ProcessPass().

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

Member Data Documentation

◆ mpOutputTracks

std::shared_ptr<EffectOutputTracks> PerTrackEffect::mpOutputTracks
mutableprivate

Definition at line 102 of file PerTrackEffect.h.

Referenced by DestroyOutputTracks(), MakeOutputTracks(), and Process().

◆ mSampleCnt

sampleCount PerTrackEffect::mSampleCnt {}
protected

Definition at line 69 of file PerTrackEffect.h.

Referenced by Fade::ProcessBlock(), ToneGenBase::ProcessBlock(), and ProcessPass().


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