Audacity 3.2.0
PerTrackEffect.h
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 PerTrackEffect.h
6
7 Dominic Mazzoni
8 Vaughan Johnson
9
10 Paul Licameli split from Effect.h
11
12**********************************************************************/
13
14#ifndef __AUDACITY_PER_TRACK_EFFECT__
15#define __AUDACITY_PER_TRACK_EFFECT__
16
17#include "AudioGraphSink.h" // to inherit
18#include "AudioGraphSource.h" // to inherit
19#include "Effect.h" // to inherit
20#include "MemoryX.h"
21#include "SampleCount.h"
22#include <functional>
23#include <memory>
24
26class SampleTrack;
27
30
37class EFFECTS_API PerTrackEffect
38 : public Effect
39{
40public:
41 ~PerTrackEffect() override;
42
43 class EFFECTS_API Instance : public virtual EffectInstanceEx {
44 public:
45 explicit Instance(const PerTrackEffect &processor)
46 : mProcessor{ processor }
47 {}
48 ~Instance() override;
49
51 bool Process(EffectSettings &settings) final;
52
53 bool ProcessInitialize(EffectSettings &settings,
54 double sampleRate, ChannelNames chanMap) override;
55
56 bool ProcessFinalize() noexcept override;
57 protected:
58 const PerTrackEffect &mProcessor;
59 };
60
61protected:
62 // These were overridables but the generality wasn't used yet
63 /* virtual */ bool DoPass1() const;
64 /* virtual */ bool DoPass2() const;
65
66 // non-virtual
67 bool Process(EffectInstance &instance, EffectSettings &settings) const;
68
69 sampleCount mSampleCnt{};
70
71 // Pre-compute the output track list
72 std::shared_ptr<EffectOutputTracks> MakeOutputTracks();
73
74 // Clean up unnecessary output track list
75 void DestroyOutputTracks() const;
76
77private:
79
80 bool ProcessPass(TrackList &outputs,
81 Instance &instance, EffectSettings &settings);
82 using Factory = std::function<std::shared_ptr<EffectInstance>()>;
94 static bool ProcessTrack(int channel,
97 std::optional<sampleCount> genLength,
98 double sampleRate, const SampleTrack &wt,
99 Buffers &inBuffers, Buffers &outBuffers);
100
101 // TODO: put this in struct EffectContext? (Which doesn't exist yet)
102 mutable std::shared_ptr<EffectOutputTracks> mpOutputTracks;
103};
104#endif
static RegisteredToolbarFactory factory
ChannelName
static Settings & settings()
Definition: TrackInfo.cpp:51
Accumulates (non-interleaved) data during effect processing.
Downstream receiver of sample streams, taking Buffers as external context.
Upstream producer of sample streams, taking Buffers as external context.
Base class for many of the effects in Audacity.
Definition: Effect.h:26
Performs effect computation.
Definition: EffectPlugin.h:96
Performs effect computation.
Use this object to copy the input tracks to tentative outputTracks.
Instance(const PerTrackEffect &processor)
Base class for many of the effects in Audacity.
std::shared_ptr< EffectOutputTracks > mpOutputTracks
~PerTrackEffect() override
std::function< std::shared_ptr< EffectInstance >()> Factory
A flat linked list of tracks supporting Add, Remove, Clear, and Contains, serialization of the list o...
Definition: Track.h:850
Positions or offsets within audio files need a wide type.
Definition: SampleCount.h:19
Externalized state of a plug-in.