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// Wanted to include just wx/weakref.h, but it fails to compile on Windows
18// when you have wxWeakRef to an incomplete type
19#include <wx/dialog.h>
20
21#include "EffectPlugin.h" // to inherit
22#include "EffectInterface.h" // to inherit
23
24
25namespace BasicUI { class ProgressDialog; }
26
27class AudacityProject;
28class Track;
29
30class AUDACITY_DLL_API EffectBase /* not final */
32 , public EffectPlugin
33{
34public:
35 EffectBase();
36 ~EffectBase() override;
37
38 void SetTracks(TrackList *pTracks) { mTracks = pTracks; }
39
40protected:
41 // The EffectBase class fully implements the Preview method for you.
42 // Only override it if you need to do preprocessing or cleanup.
43 void Preview(EffectSettingsAccess &access, bool dryOnly) override;
44
46 double projectRate, TrackList *list,
48 unsigned flags,
49 // Prompt the user for input only if the next arguments are not all null.
50 wxWindow *pParent,
51 const EffectDialogFactory &dialogFactory,
52 const EffectSettingsAccessPtr &pAccess
53 ) override;
54
56 /*
57 Typically this is only useful in automation, for example
58 detecting that zero noise reduction is to be done,
59 or that normalisation is being done without Dc bias shift
60 or amplitude modification.
61 */
63 = 0;
64
65 // Determine duration of effect preview, given a suggested value
66 /*
67 Most effects just use the previewLength, but time-stretching/compressing
68 effects need to use a different input length, so override this method.
69
70 @return seconds
71 */
72 virtual double CalcPreviewInputLength(
73 const EffectSettings &settings, double previewLength) const = 0;
74
75 // Previewing linear effect can be optimised by pre-mixing. However this
76 // should not be used for non-linear effects such as dynamic processors
77 // To allow pre-mixing before Preview, set linearEffectFlag to true.
78 void SetLinearEffectFlag(bool linearEffectFlag);
79
80 // Most effects only need to preview a short selection. However some
81 // (such as fade effects) need to know the full selection length.
82 void SetPreviewFullSelectionFlag(bool previewDurationFlag);
83
84 // Use this if the effect needs to know if it is previewing
85 bool IsPreviewing() const { return mIsPreview; }
86
87 // Most effects only require selected tracks to be copied for Preview.
88 // If IncludeNotSelectedPreviewTracks(true), then non-linear effects have
89 // preview copies of all wave tracks.
90 void IncludeNotSelectedPreviewTracks(bool includeNotSelected);
91
92 // A global counter of all the successful Effect invocations.
93 static int nEffectsDone;
94
95 // If bGoodResult, replace mWaveTracks tracks in mTracks with successfully processed
96 // mOutputTracks copies, get rid of old mWaveTracks, and set mWaveTracks to mOutputTracks.
97 // Else clear and DELETE mOutputTracks copies.
98 void ReplaceProcessedTracks(const bool bGoodResult);
99
100 BasicUI::ProgressDialog *mProgress{}; // Temporary pointer, NOT deleted in destructor.
101 double mProjectRate{}; // Sample rate of the project - NEW tracks should
102 // be created with this rate...
103 WaveTrackFactory *mFactory{};
104 const TrackList *inputTracks() const { return mTracks; }
105 const AudacityProject *FindProject() const;
106 // used only if CopyInputTracks() is called.
107 std::shared_ptr<TrackList> mOutputTracks;
108 double mT0{};
109 double mT1{};
110#ifdef EXPERIMENTAL_SPECTRAL_EDITING
111 double mF0{};
112 double mF1{};
113#endif
114 wxArrayString mPresetNames;
115 unsigned mUIFlags{ 0 };
116
117private:
118 friend class Effect;
119
121 wxWeakRef<wxDialog> mUIDialog;
122
123 double GetDefaultDuration();
124
125 void CountWaveTracks();
126
127 TrackList *mTracks{}; // the complete list of all tracks
129 bool mIsLinearEffect{ false };
132
133 bool mIsPreview{ false };
134
135 std::vector<Track*> mIMap;
136 std::vector<Track*> mOMap;
137
138 int mNumTracks{}; //v This is really mNumWaveTracks, per CountWaveTracks() and GetNumWaveTracks().
140};
141
142/* i18n-hint: "Nyquist" is an embedded interpreted programming language in
143 Audacity, named in honor of the Swedish-American Harry Nyquist (or Nyqvist).
144 In the translations of this and other strings, you may transliterate the
145 name into another alphabet. */
146#define NYQUISTEFFECTS_FAMILY ( EffectFamilySymbol{ XO("Nyquist") } )
147
148#endif
std::function< DialogFactoryResults(wxWindow &parent, EffectPlugin &, EffectUIClientInterface &, EffectSettingsAccess &) > EffectDialogFactory
Type of function that creates a dialog for an effect.
Definition: EffectPlugin.h:42
static Settings & settings()
Definition: TrackInfo.cpp:87
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:154
Base class for many of the effects in Audacity.
Definition: EffectBase.h:33
int mNumTracks
Definition: EffectBase.h:138
std::shared_ptr< TrackList > mOutputTracks
Definition: EffectBase.h:107
~EffectBase() override
TrackList * mTracks
Definition: EffectBase.h:127
void CountWaveTracks()
Definition: EffectBase.cpp:327
std::vector< Track * > mOMap
Definition: EffectBase.h:136
bool IsPreviewing() const
Definition: EffectBase.h:85
const TrackList * inputTracks() const
Definition: EffectBase.h:104
virtual bool CheckWhetherSkipEffect(const EffectSettings &settings) const =0
After Init(), tell whether Process() should be skipped.
bool mIsPreview
Definition: EffectBase.h:133
bool mPreviewWithNotSelected
Definition: EffectBase.h:130
int mNumGroups
Definition: EffectBase.h:139
bool mPreviewFullSelection
Definition: EffectBase.h:131
virtual double CalcPreviewInputLength(const EffectSettings &settings, double previewLength) const =0
std::vector< Track * > mIMap
Definition: EffectBase.h:135
wxArrayString mPresetNames
Definition: EffectBase.h:114
double GetDefaultDuration()
Definition: EffectBase.cpp:51
wxWeakRef< wxDialog > mUIDialog
This weak pointer may be the same as mUIParent, or null.
Definition: EffectBase.h:121
void SetTracks(TrackList *pTracks)
Definition: EffectBase.h:38
bool mIsLinearEffect
This weak pointer may be the same as mHostUIDialog, or null.
Definition: EffectBase.h:129
static int nEffectsDone
Definition: EffectBase.h:93
Base class for many of the effects in Audacity.
Definition: Effect.h:63
Factory of instances of an effect and of dialogs to control them.
Definition: EffectPlugin.h:55
virtual void Preview(EffectSettingsAccess &access, bool dryOnly)=0
EffectUIClientInterface is an abstract base class to populate a UI and validate UI values....
Definition: EffectPlugin.h:170
ProgressDialog Class.
Abstract base class for an object holding data associated with points on a time axis.
Definition: Track.h:225
A flat linked list of tracks supporting Add, Remove, Clear, and Contains, serialization of the list o...
Definition: Track.h:1338
Used to create or clone a WaveTrack, with appropriate context from the project that will own the trac...
Definition: WaveTrack.h:620
AUDACITY_DLL_API bool DoEffect(const PluginID &ID, const CommandContext &context, unsigned flags)
'Repeat Last Effect'.
Definition: EffectUI.cpp:1241
static RegisteredToolbarFactory factory
Externalized state of a plug-in.