Audacity 3.2.0
EffectBase.h
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 EffectBase.h
6
7 Dominic Mazzoni
8 Vaughan Johnson
9
10 Paul Licameli split from Effect.h
11
12**********************************************************************/
13
14#ifndef __AUDACITY_EFFECT_BASE__
15#define __AUDACITY_EFFECT_BASE__
16
17#include "EffectPlugin.h" // to inherit
18
19#include <any>
20
21namespace BasicUI { class ProgressDialog; }
22
23namespace au::effects {
24class EffectsProvider;
25class EffectExecutionScenario;
26}
27
28class AudacityProject;
29class Track;
30
31class EFFECTS_API EffectBase /* not final */
32 : public EffectPlugin
33{
34public:
35 EffectBase();
36 ~EffectBase() override;
37
38 bool IsLinearEffect() const { return mIsLinearEffect; }
39 bool PreviewsFullSelection() const { return mPreviewFullSelection; }
40
41 void SetTracks(TrackList *pTracks);
42
43 double GetDefaultDuration();
44
46
50 virtual std::any BeginPreview(const EffectSettings &settings);
51
53 const InstanceFinder &finder,
54 double projectRate, TrackList *list,
56 unsigned flags,
57 const EffectSettingsAccessPtr &pAccess
58 ) override;
59
60 static std::optional<InstancePointer> FindInstance(EffectPlugin &plugin);
61 static InstanceFinder DefaultInstanceFinder(EffectPlugin &plugin);
62
63protected:
65 friend class au::effects::EffectsProvider;
66 friend class au::effects::EffectExecutionScenario;
67
69 /*
70 Typically this is only useful in automation, for example
71 detecting that zero noise reduction is to be done,
72 or that normalisation is being done without Dc bias shift
73 or amplitude modification.
74 */
76 = 0;
77
78public:
79 // Determine duration of effect preview, given a suggested value
80 /*
81 Most effects just use the previewLength, but time-stretching/compressing
82 effects need to use a different input length, so override this method.
83
84 @return seconds
85 */
86 virtual double CalcPreviewInputLength(
87 const EffectSettings &settings, double previewLength) const = 0;
88
89protected:
90 // Previewing linear effect can be optimised by pre-mixing. However this
91 // should not be used for non-linear effects such as dynamic processors
92 // To allow pre-mixing before Preview, set linearEffectFlag to true.
93 void SetLinearEffectFlag(bool linearEffectFlag);
94
95 // Most effects only need to preview a short selection. However some
96 // (such as fade effects) need to know the full selection length.
97 void SetPreviewFullSelectionFlag(bool previewDurationFlag);
98
99 // Use this if the effect needs to know if it is previewing
100 bool IsPreviewing() const { return mIsPreview; }
101
102 const TrackList *inputTracks() const { return mTracks.get(); }
103 const AudacityProject *FindProject() const;
104
105 double mF0{};
106 double mF1{};
107
108 wxArrayString mPresetNames;
109 unsigned mUIFlags{ 0 };
110
111private:
112 friend class Effect;
113
114public:
115 // Public until we can move these fields out of here into EffectContext
116 std::shared_ptr<TrackList> mTracks{}; // the complete list of all tracks
117 int mNumTracks{}; // This is really mNumWaveTracks, per CountWaveTracks() and GetNumWaveTracks().
118 BasicUI::ProgressDialog *mProgress{}; // Temporary pointer, NOT deleted in destructor.
119 double mProjectRate{}; // Sample rate of the project - NEW tracks should
120 // be created with this rate...
122 double mT0{};
123 double mT1{};
124 bool mIsPreview{ false };
125
126 // Some public members that only change "context" fields
127
128 void CountWaveTracks();
129
130private:
131 bool mIsLinearEffect{ false };
133
135};
136
137/* i18n-hint: "Nyquist" is an embedded interpreted programming language in
138 Audacity, named in honor of the Swedish-American Harry Nyquist (or Nyqvist).
139 In the translations of this and other strings, you may transliterate the
140 name into another alphabet. */
141#define NYQUISTEFFECTS_FAMILY ( EffectFamilySymbol{ XO("Nyquist") } )
142
143#endif
static RegisteredToolbarFactory factory
static Settings & settings()
Definition: TrackInfo.cpp:51
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:90
Abstraction of a progress dialog with well defined time-to-completion estimate.
Definition: BasicUI.h:164
Base class for many of the effects in Audacity.
Definition: EffectBase.h:33
int mNumTracks
Definition: EffectBase.h:117
double mT1
Definition: EffectBase.h:123
WaveTrackFactory * mFactory
Definition: EffectBase.h:121
~EffectBase() override
void CountWaveTracks()
Definition: EffectBase.cpp:227
bool IsPreviewing() const
Definition: EffectBase.h:100
bool PreviewsFullSelection() const
Definition: EffectBase.h:39
const TrackList * inputTracks() const
Definition: EffectBase.h:102
virtual bool CheckWhetherSkipEffect(const EffectSettings &settings) const =0
After Init(), tell whether Process() should be skipped.
double mProjectRate
Definition: EffectBase.h:119
bool mIsPreview
Definition: EffectBase.h:124
bool IsLinearEffect() const
Definition: EffectBase.h:38
BasicUI::ProgressDialog * mProgress
Definition: EffectBase.h:118
int mNumGroups
Definition: EffectBase.h:134
std::shared_ptr< TrackList > mTracks
Definition: EffectBase.h:116
bool mPreviewFullSelection
Definition: EffectBase.h:132
virtual double CalcPreviewInputLength(const EffectSettings &settings, double previewLength) const =0
wxArrayString mPresetNames
Definition: EffectBase.h:108
double mT0
Definition: EffectBase.h:122
bool mIsLinearEffect
Definition: EffectBase.h:131
Base class for many of the effects in Audacity.
Definition: Effect.h:26
Factory of instances of an effect.
Definition: EffectPlugin.h:36
virtual bool DoEffect(EffectSettings &settings, const InstanceFinder &finder, double projectRate, TrackList *list, WaveTrackFactory *factory, NotifyingSelectedRegion &selectedRegion, unsigned flags, const EffectSettingsAccessPtr &pAccess=nullptr)=0
ProgressDialog Class.
Abstract base class for an object holding data associated with points on a time axis.
Definition: Track.h:110
A flat linked list of tracks supporting Add, Remove, Clear, and Contains, serialization of the list o...
Definition: Track.h:850
Used to create or clone a WaveTrack, with appropriate context from the project that will own the trac...
Definition: WaveTrack.h:871
Externalized state of a plug-in.