Audacity 3.2.0
Effect.h
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 Effect.h
6
7 Dominic Mazzoni
8 Vaughan Johnson
9
10**********************************************************************/
11
12#ifndef __AUDACITY_EFFECT__
13#define __AUDACITY_EFFECT__
14
15#include "EffectBase.h"
16
17#define BUILTIN_EFFECT_PREFIX wxT("Built-in Effect: ")
18
20class WaveTrack;
21
22class sampleCount;
23
24class EFFECTS_API Effect /* not final */
25 : public EffectBase
26{
27 //
28 // public methods
29 //
30 // Used by the outside program to determine properties of an effect and
31 // apply the effect to one or more tracks.
32 //
33 public:
35 { return &e; }
36
37 // The constructor is called once by each subclass at the beginning of the program.
38 // Avoid allocating memory or doing time-consuming processing here.
39 Effect();
40 virtual ~Effect();
41
42 // ComponentInterface implementation
43
44 PluginPath GetPath() const override;
45 bool VisitSettings(
46 SettingsVisitor &visitor, EffectSettings &settings) override;
47 bool VisitSettings(
49 const override;
50
51 ComponentInterfaceSymbol GetSymbol() const override;
52
53 VendorSymbol GetVendor() const override;
54 wxString GetVersion() const override;
55 TranslatableString GetDescription() const override;
56
57 // EffectDefinitionInterface implementation
58
59 EffectType GetType() const override;
60 EffectFamilySymbol GetFamily() const override;
61 bool IsInteractive() const override;
62 bool IsDefault() const override;
63 RealtimeSince RealtimeSupport() const override;
64 bool SupportsAutomation() const override;
65
66 bool SaveSettings(
67 const EffectSettings &settings, CommandParameters & parms) const override;
68 bool LoadSettings(
69 const CommandParameters & parms, EffectSettings &settings) const override;
70
72 const RegistryPath & name, EffectSettings &settings) const override;
73 bool SaveUserPreset(
74 const RegistryPath & name, const EffectSettings &settings) const override;
75
76 RegistryPaths GetFactoryPresets() const override;
78 const override;
80 const override;
81
82 // VisitSettings(), SaveSettings(), and LoadSettings()
83 // use the functions of EffectParameterMethods. By default, this function
84 // defines an empty list of parameters.
85 virtual const EffectParameterMethods &Parameters() const;
86
87 bool CanExportPresets() const override;
88 bool HasOptions() const override;
89
90 // EffectPlugin implementation
91
92 const EffectSettingsManager& GetDefinition() const override;
93 virtual NumericFormatSymbol GetSelectionFormat() /* not override? */; // time format in Selection toolbar
94
96 const EffectSettings &settings, wxString & parms) const override;
98 const wxString & parms, EffectSettings &settings) const override;
99 bool IsBatchProcessing() const override;
100 void SetBatchProcessing() override;
101 void UnsetBatchProcessing() override;
102
103 // Effect implementation
104
105 unsigned TestUIFlags(unsigned mask);
106
108 bool Delegate(Effect &delegate, EffectSettings &settings);
109
110 static void IncEffectCounter(){ nEffectsDone++;}
111
112protected:
113
115 bool CheckWhetherSkipEffect(const EffectSettings &settings) const override;
116
119 const EffectSettings &settings, double previewLength) const override;
120
121 // No more virtuals!
122
123 // The Progress methods all return true if the user has cancelled;
124 // you should exit immediately if this happens (cleaning up memory
125 // is okay, but don't try to undo).
126
127 // Pass a fraction between 0.0 and 1.0
128 bool TotalProgress(double frac, const TranslatableString & = {}) const;
129
130 // Pass a fraction between 0.0 and 1.0, for the current track
131 // (when doing one track at a time)
132 bool TrackProgress(
133 int whichTrack, double frac, const TranslatableString & = {}) const;
134
135 // Pass a fraction between 0.0 and 1.0, for the current track group
136 // (when doing stereo groups at a time)
137 bool TrackGroupProgress(
138 int whichGroup, double frac, const TranslatableString & = {}) const;
139
140 int GetNumWaveTracks() const { return mNumTracks; }
141 int GetNumWaveGroups() const { return mNumGroups; }
142
143 // Calculates the start time and length in samples for one or two channels
144 void GetBounds(
145 const WaveTrack &track, const WaveTrack *pRight,
146 sampleCount *start, sampleCount *len);
147
148 // Use this method to copy the input tracks to mOutputTracks, if
149 // doing the processing on them, and replacing the originals only on success (and not cancel).
150 // If not all sync-locked selected, then only selected wave tracks.
151 void CopyInputTracks(bool allSyncLockSelected = false);
152
153 // Use this to append a NEW output track.
154 Track *AddToOutputTracks(const std::shared_ptr<Track> &t);
155
156private:
157 wxString GetSavedStateGroup();
158
159 bool mIsBatch{ false };
160};
161
164template<typename Settings, typename Base>
165class EffectWithSettings : public Base {
166public:
168 {
169 return EffectSettings::Make<Settings>();
170 }
172 const EffectSettings &src, EffectSettings &dst) const override
173 {
174 return EffectSettings::Copy<Settings>(src, dst);
175 }
178 {
179 auto pSettings = settings.cast<Settings>();
180 assert(pSettings);
181 return *pSettings;
182 }
184 static inline const Settings &GetSettings(const EffectSettings &settings)
185 {
186 return GetSettings(const_cast<EffectSettings &>(settings));
187 }
188 static inline Settings *
190 return &GetSettings(s);
191 }
192};
193
194// FIXME:
195// FIXME: Remove this once all effects are using the NEW dialog
196// FIXME:
197
198#define ID_EFFECT_PREVIEW ePreviewID
199
200#endif
const TranslatableString name
Definition: Distortion.cpp:76
EffectType
std::optional< std::unique_ptr< EffectSettingsAccess::Message > > OptionalMessage
wxString RegistryPath
Definition: Identifier.h:218
wxString PluginPath
type alias for identifying a Plugin supplied by a module, each module defining its own interpretation...
Definition: Identifier.h:214
std::vector< RegistryPath > RegistryPaths
Definition: Identifier.h:219
static Settings & settings()
Definition: TrackInfo.cpp:87
CommandParameters, derived from wxFileConfig, is essentially doing the same things as the SettingsVis...
virtual wxString GetVersion() const =0
virtual PluginPath GetPath() const =0
virtual VendorSymbol GetVendor() const =0
virtual ComponentInterfaceSymbol GetSymbol() const =0
virtual TranslatableString GetDescription() const =0
ComponentInterfaceSymbol pairs a persistent string identifier used internally with an optional,...
Base class for many of the effects in Audacity.
Definition: EffectBase.h:28
int mNumTracks
Definition: EffectBase.h:142
virtual bool CheckWhetherSkipEffect(const EffectSettings &settings) const =0
After Init(), tell whether Process() should be skipped.
int mNumGroups
Definition: EffectBase.h:143
virtual double CalcPreviewInputLength(const EffectSettings &settings, double previewLength) const =0
friend class Effect
Definition: EffectBase.h:122
virtual EffectType GetType() const =0
Type determines how it behaves.
virtual bool IsDefault() const =0
Whether the effect sorts "above the line" in the menus.
virtual bool IsInteractive() const =0
Whether the effect needs a dialog for entry of settings.
virtual bool SupportsAutomation() const =0
Whether the effect has any automatable controls.
virtual RealtimeSince RealtimeSupport() const =0
Since which version of Audacity has the effect supported realtime?
virtual EffectFamilySymbol GetFamily() const =0
Report identifier and user-visible name of the effect protocol.
Base class for many of the effects in Audacity.
Definition: Effect.h:26
static void IncEffectCounter()
Definition: Effect.h:110
static Effect * FetchParameters(Effect &e, EffectSettings &)
Definition: Effect.h:34
int GetNumWaveTracks() const
Definition: Effect.h:140
int GetNumWaveGroups() const
Definition: Effect.h:141
Interface for manipulations of an Effect's settings.
virtual bool HasOptions() const =0
virtual void SetBatchProcessing()=0
virtual bool CanExportPresets() const =0
Whether the effect supports export of presets to files, and importing too.
virtual void UnsetBatchProcessing()=0
virtual bool SaveSettingsAsString(const EffectSettings &settings, wxString &parms) const =0
virtual const EffectSettingsManager & GetDefinition() const =0
virtual bool IsBatchProcessing() const =0
virtual OptionalMessage LoadSettingsFromString(const wxString &parms, EffectSettings &settings) const =0
EffectSettingsManager is an EffectDefinitionInterface that adds a factory function for EffectSettings...
virtual bool VisitSettings(SettingsVisitor &visitor, EffectSettings &settings)
virtual OptionalMessage LoadFactoryDefaults(EffectSettings &settings) const =0
virtual RegistryPaths GetFactoryPresets() const =0
Report names of factory presets.
virtual OptionalMessage LoadUserPreset(const RegistryPath &name, EffectSettings &settings) const =0
virtual bool SaveUserPreset(const RegistryPath &name, const EffectSettings &settings) const =0
Save settings in the configuration file as a user-named preset.
virtual OptionalMessage LoadFactoryPreset(int id, EffectSettings &settings) const =0
virtual bool LoadSettings(const CommandParameters &parms, EffectSettings &settings) const =0
Restore settings from keys and values.
virtual bool SaveSettings(const EffectSettings &settings, CommandParameters &parms) const =0
Store settings as keys and values.
static const Settings & GetSettings(const EffectSettings &settings)
Assume settings originated from MakeSettings() and copies thereof.
Definition: Effect.h:184
static Settings & GetSettings(EffectSettings &settings)
Assume settings originated from MakeSettings() and copies thereof.
Definition: Effect.h:177
static Settings * FetchParameters(Base &, EffectSettings &s)
Definition: Effect.h:189
EffectSettings MakeSettings() const override
Definition: Effect.h:167
bool CopySettingsContents(const EffectSettings &src, EffectSettings &dst) const override
Definition: Effect.h:171
Visitor of effect or command parameters. This is a base class with lots of virtual functions that do ...
Abstract base class for an object holding data associated with points on a time axis.
Definition: Track.h:226
Holds a msgid for the translation catalog; may also bind format arguments.
A Track that contains audio waveform data.
Definition: WaveTrack.h:51
Positions or offsets within audio files need a wide type.
Definition: SampleCount.h:19
Externalized state of a plug-in.