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#ifdef EXPERIMENTAL_SPECTRAL_EDITING
95 double mF0{};
96 double mF1{};
97#endif
98
99 wxArrayString mPresetNames;
100 unsigned mUIFlags{ 0 };
101
102private:
103 friend class Effect;
104
105 double GetDefaultDuration();
106
107public:
108 // Public until we can move these fields out of here into EffectContext
109 std::shared_ptr<TrackList> mTracks{}; // the complete list of all tracks
110 int mNumTracks{}; // This is really mNumWaveTracks, per CountWaveTracks() and GetNumWaveTracks().
111 BasicUI::ProgressDialog *mProgress{}; // Temporary pointer, NOT deleted in destructor.
112 double mProjectRate{}; // Sample rate of the project - NEW tracks should
113 // be created with this rate...
115 double mT0{};
116 double mT1{};
117 bool mIsPreview{ false };
118
119 // Some public members that only change "context" fields
120
121 void CountWaveTracks();
122
123private:
124 bool mIsLinearEffect{ false };
126
128};
129
130/* i18n-hint: "Nyquist" is an embedded interpreted programming language in
131 Audacity, named in honor of the Swedish-American Harry Nyquist (or Nyqvist).
132 In the translations of this and other strings, you may transliterate the
133 name into another alphabet. */
134#define NYQUISTEFFECTS_FAMILY ( EffectFamilySymbol{ XO("Nyquist") } )
135
136#endif
static Settings & settings()
Definition: TrackInfo.cpp:83
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:156
Base class for many of the effects in Audacity.
Definition: EffectBase.h:28
int mNumTracks
Definition: EffectBase.h:110
double mT1
Definition: EffectBase.h:116
WaveTrackFactory * mFactory
Definition: EffectBase.h:114
~EffectBase() override
void CountWaveTracks()
Definition: EffectBase.cpp:231
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:112
bool mIsPreview
Definition: EffectBase.h:117
bool IsLinearEffect() const
Definition: EffectBase.h:33
BasicUI::ProgressDialog * mProgress
Definition: EffectBase.h:111
int mNumGroups
Definition: EffectBase.h:127
std::shared_ptr< TrackList > mTracks
Definition: EffectBase.h:109
bool mPreviewFullSelection
Definition: EffectBase.h:125
virtual double CalcPreviewInputLength(const EffectSettings &settings, double previewLength) const =0
wxArrayString mPresetNames
Definition: EffectBase.h:99
double GetDefaultDuration()
Definition: EffectBase.cpp:48
double mT0
Definition: EffectBase.h:115
bool mIsLinearEffect
Definition: EffectBase.h:124
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:123
A flat linked list of tracks supporting Add, Remove, Clear, and Contains, serialization of the list o...
Definition: Track.h:987
Used to create or clone a WaveTrack, with appropriate context from the project that will own the trac...
Definition: WaveTrack.h:1074
static RegisteredToolbarFactory factory
Externalized state of a plug-in.