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 EffectFamilySymbol GetFamily() const override;
60 bool IsInteractive() const override;
61 bool IsDefault() const override;
62 RealtimeSince RealtimeSupport() const override;
63 bool SupportsAutomation() const override;
64
65 bool SaveSettings(
66 const EffectSettings &settings, CommandParameters & parms) const override;
67 bool LoadSettings(
68 const CommandParameters & parms, EffectSettings &settings) const override;
69
71 const RegistryPath & name, EffectSettings &settings) const override;
72 bool SaveUserPreset(
73 const RegistryPath & name, const EffectSettings &settings) const override;
74
75 RegistryPaths GetFactoryPresets() const override;
77 const override;
79 const override;
80
81 // VisitSettings(), SaveSettings(), and LoadSettings()
82 // use the functions of EffectParameterMethods. By default, this function
83 // defines an empty list of parameters.
84 virtual const EffectParameterMethods &Parameters() const;
85
86 bool CanExportPresets() const override;
87 bool HasOptions() const override;
88
89 // EffectPlugin implementation
90
91 const EffectSettingsManager& GetDefinition() const override;
92 // time format in Selection toolbar
93 virtual NumericFormatID GetSelectionFormat() /* not override? */;
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 InstanceFinder finder = {});
110
111protected:
112
114 bool CheckWhetherSkipEffect(const EffectSettings &settings) const override;
115
118 const EffectSettings &settings, double previewLength) const override;
119
120 // No more virtuals!
121
122 // The Progress methods all return true if the user has cancelled;
123 // you should exit immediately if this happens (cleaning up memory
124 // is okay, but don't try to undo).
125
126 // Pass a fraction between 0.0 and 1.0
127 bool TotalProgress(double frac, const TranslatableString & = {}) const;
128
129 // Pass a fraction between 0.0 and 1.0, for the current track
130 // (when doing one track at a time)
131 bool TrackProgress(
132 int whichTrack, double frac, const TranslatableString & = {}) const;
133
134 // Pass a fraction between 0.0 and 1.0, for the current track group
135 // (when doing stereo groups at a time)
136 bool TrackGroupProgress(
137 int whichGroup, double frac, const TranslatableString & = {}) const;
138
139 int GetNumWaveTracks() const { return mNumTracks; }
140 int GetNumWaveGroups() const { return mNumGroups; }
141
142 // Calculates the start time and length in samples for one or two channels
146 void GetBounds(const WaveTrack &track, sampleCount *start, sampleCount *len);
147
148private:
149 wxString GetSavedStateGroup();
150
151 bool mIsBatch{ false };
152};
153
156template<typename Settings, typename Base>
157class EffectWithSettings : public Base {
158public:
160 {
161 return EffectSettings::Make<Settings>();
162 }
164 const EffectSettings &src, EffectSettings &dst) const override
165 {
166 return EffectSettings::Copy<Settings>(src, dst);
167 }
170 {
171 auto pSettings = settings.cast<Settings>();
172 assert(pSettings);
173 return *pSettings;
174 }
176 static inline const Settings &GetSettings(const EffectSettings &settings)
177 {
178 return GetSettings(const_cast<EffectSettings &>(settings));
179 }
180 static inline Settings *
182 return &GetSettings(s);
183 }
184};
185
186// FIXME:
187// FIXME: Remove this once all effects are using the NEW dialog
188// FIXME:
189
190#define ID_EFFECT_PREVIEW ePreviewID
191
192#endif
const TranslatableString name
Definition: Distortion.cpp:76
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:69
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:110
virtual bool CheckWhetherSkipEffect(const EffectSettings &settings) const =0
After Init(), tell whether Process() should be skipped.
int mNumGroups
Definition: EffectBase.h:127
virtual double CalcPreviewInputLength(const EffectSettings &settings, double previewLength) const =0
friend class Effect
Definition: EffectBase.h:103
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 Effect * FetchParameters(Effect &e, EffectSettings &)
Definition: Effect.h:34
int GetNumWaveTracks() const
Definition: Effect.h:139
int GetNumWaveGroups() const
Definition: Effect.h:140
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:176
static Settings & GetSettings(EffectSettings &settings)
Assume settings originated from MakeSettings() and copies thereof.
Definition: Effect.h:169
static Settings * FetchParameters(Base &, EffectSettings &s)
Definition: Effect.h:181
EffectSettings MakeSettings() const override
Definition: Effect.h:159
bool CopySettingsContents(const EffectSettings &src, EffectSettings &dst) const override
Definition: Effect.h:163
Visitor of effect or command parameters. This is a base class with lots of virtual functions that do ...
Holds a msgid for the translation catalog; may also bind format arguments.
A Track that contains audio waveform data.
Definition: WaveTrack.h:227
Positions or offsets within audio files need a wide type.
Definition: SampleCount.h:19
auto finder(TrackId id, int &distance)
Externalized state of a plug-in.