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
23class AudacityProject;
24class Track;
25
26class EFFECTS_API EffectBase /* not final */
27 : public EffectPlugin
28{
29public:
30 EffectBase();
31 ~EffectBase() override;
32
33 bool IsLinearEffect() const { return mIsLinearEffect; }
34 bool PreviewsFullSelection() const { return mPreviewFullSelection; }
35
36 void SetTracks(TrackList *pTracks);
37
39
43 virtual std::any BeginPreview(const EffectSettings &settings);
44
46 const InstanceFinder &finder,
47 double projectRate, TrackList *list,
49 unsigned flags,
50 const EffectSettingsAccessPtr &pAccess
51 ) override;
52
53 static std::optional<InstancePointer> FindInstance(EffectPlugin &plugin);
54 static InstanceFinder DefaultInstanceFinder(EffectPlugin &plugin);
55
56protected:
58 /*
59 Typically this is only useful in automation, for example
60 detecting that zero noise reduction is to be done,
61 or that normalisation is being done without Dc bias shift
62 or amplitude modification.
63 */
65 = 0;
66
67public:
68 // Determine duration of effect preview, given a suggested value
69 /*
70 Most effects just use the previewLength, but time-stretching/compressing
71 effects need to use a different input length, so override this method.
72
73 @return seconds
74 */
75 virtual double CalcPreviewInputLength(
76 const EffectSettings &settings, double previewLength) const = 0;
77
78protected:
79 // Previewing linear effect can be optimised by pre-mixing. However this
80 // should not be used for non-linear effects such as dynamic processors
81 // To allow pre-mixing before Preview, set linearEffectFlag to true.
82 void SetLinearEffectFlag(bool linearEffectFlag);
83
84 // Most effects only need to preview a short selection. However some
85 // (such as fade effects) need to know the full selection length.
86 void SetPreviewFullSelectionFlag(bool previewDurationFlag);
87
88 // Use this if the effect needs to know if it is previewing
89 bool IsPreviewing() const { return mIsPreview; }
90
91 const TrackList *inputTracks() const { return mTracks.get(); }
92 const AudacityProject *FindProject() const;
93
94 double mF0{};
95 double mF1{};
96
97 wxArrayString mPresetNames;
98 unsigned mUIFlags{ 0 };
99
100private:
101 friend class Effect;
102
103 double GetDefaultDuration();
104
105public:
106 // Public until we can move these fields out of here into EffectContext
107 std::shared_ptr<TrackList> mTracks{}; // the complete list of all tracks
108 int mNumTracks{}; // This is really mNumWaveTracks, per CountWaveTracks() and GetNumWaveTracks().
109 BasicUI::ProgressDialog *mProgress{}; // Temporary pointer, NOT deleted in destructor.
110 double mProjectRate{}; // Sample rate of the project - NEW tracks should
111 // be created with this rate...
113 double mT0{};
114 double mT1{};
115 bool mIsPreview{ false };
116
117 // Some public members that only change "context" fields
118
119 void CountWaveTracks();
120
121private:
122 bool mIsLinearEffect{ false };
124
126};
127
128/* i18n-hint: "Nyquist" is an embedded interpreted programming language in
129 Audacity, named in honor of the Swedish-American Harry Nyquist (or Nyqvist).
130 In the translations of this and other strings, you may transliterate the
131 name into another alphabet. */
132#define NYQUISTEFFECTS_FAMILY ( EffectFamilySymbol{ XO("Nyquist") } )
133
134#endif
static RegisteredToolbarFactory factory
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
Abstraction of a progress dialog with well defined time-to-completion estimate.
Definition: BasicUI.h:157
Base class for many of the effects in Audacity.
Definition: EffectBase.h:28
int mNumTracks
Definition: EffectBase.h:108
double mT1
Definition: EffectBase.h:114
WaveTrackFactory * mFactory
Definition: EffectBase.h:112
~EffectBase() override
void CountWaveTracks()
Definition: EffectBase.cpp:227
bool IsPreviewing() const
Definition: EffectBase.h:89
bool PreviewsFullSelection() const
Definition: EffectBase.h:34
const TrackList * inputTracks() const
Definition: EffectBase.h:91
virtual bool CheckWhetherSkipEffect(const EffectSettings &settings) const =0
After Init(), tell whether Process() should be skipped.
double mProjectRate
Definition: EffectBase.h:110
bool mIsPreview
Definition: EffectBase.h:115
bool IsLinearEffect() const
Definition: EffectBase.h:33
BasicUI::ProgressDialog * mProgress
Definition: EffectBase.h:109
int mNumGroups
Definition: EffectBase.h:125
std::shared_ptr< TrackList > mTracks
Definition: EffectBase.h:107
bool mPreviewFullSelection
Definition: EffectBase.h:123
virtual double CalcPreviewInputLength(const EffectSettings &settings, double previewLength) const =0
wxArrayString mPresetNames
Definition: EffectBase.h:97
double GetDefaultDuration()
Definition: EffectBase.cpp:48
double mT0
Definition: EffectBase.h:113
bool mIsLinearEffect
Definition: EffectBase.h:122
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:870
Externalized state of a plug-in.