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