Audacity 3.2.0
Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
Effect Class Reference

Base class for many of the effects in Audacity. More...

#include <Effect.h>

Inheritance diagram for Effect:
[legend]
Collaboration diagram for Effect:
[legend]

Public Member Functions

 Effect ()
 
virtual ~Effect ()
 
PluginPath GetPath () const override
 
bool VisitSettings (SettingsVisitor &visitor, EffectSettings &settings) override
 
bool VisitSettings (ConstSettingsVisitor &visitor, const EffectSettings &settings) const override
 
ComponentInterfaceSymbol GetSymbol () const override
 
VendorSymbol GetVendor () const override
 
wxString GetVersion () const override
 
TranslatableString GetDescription () const override
 
EffectFamilySymbol GetFamily () const override
 Report identifier and user-visible name of the effect protocol. More...
 
bool IsInteractive () const override
 Whether the effect needs a dialog for entry of settings. More...
 
bool IsDefault () const override
 Whether the effect sorts "above the line" in the menus. More...
 
RealtimeSince RealtimeSupport () const override
 Since which version of Audacity has the effect supported realtime? More...
 
bool SupportsAutomation () const override
 Whether the effect has any automatable controls. More...
 
bool SaveSettings (const EffectSettings &settings, CommandParameters &parms) const override
 Store settings as keys and values. More...
 
bool LoadSettings (const CommandParameters &parms, EffectSettings &settings) const override
 Restore settings from keys and values. More...
 
OptionalMessage LoadUserPreset (const RegistryPath &name, EffectSettings &settings) const override
 
bool SaveUserPreset (const RegistryPath &name, const EffectSettings &settings) const override
 Save settings in the configuration file as a user-named preset. More...
 
RegistryPaths GetFactoryPresets () const override
 Report names of factory presets. More...
 
OptionalMessage LoadFactoryPreset (int id, EffectSettings &settings) const override
 
OptionalMessage LoadFactoryDefaults (EffectSettings &settings) const override
 
virtual const EffectParameterMethodsParameters () const
 
bool CanExportPresets () const override
 Whether the effect supports export of presets to files, and importing too. More...
 
bool HasOptions () const override
 
const EffectSettingsManagerGetDefinition () const override
 
virtual NumericFormatID GetSelectionFormat ()
 
bool SaveSettingsAsString (const EffectSettings &settings, wxString &parms) const override
 
OptionalMessage LoadSettingsFromString (const wxString &parms, EffectSettings &settings) const override
 
bool IsBatchProcessing () const override
 
void SetBatchProcessing () override
 
void UnsetBatchProcessing () override
 
unsigned TestUIFlags (unsigned mask)
 
bool Delegate (Effect &delegate, EffectSettings &settings, InstanceFinder finder={})
 Re-invoke DoEffect on another Effect object that implements the work. More...
 
- Public Member Functions inherited from EffectBase
 EffectBase ()
 
 ~EffectBase () override
 
bool IsLinearEffect () const
 
bool PreviewsFullSelection () const
 
void SetTracks (TrackList *pTracks)
 
virtual std::any BeginPreview (const EffectSettings &settings)
 Called when Preview() starts, to allow temporary effect state changes. More...
 
bool DoEffect (EffectSettings &settings, const InstanceFinder &finder, double projectRate, TrackList *list, WaveTrackFactory *factory, NotifyingSelectedRegion &selectedRegion, unsigned flags, const EffectSettingsAccessPtr &pAccess) override
 
virtual double CalcPreviewInputLength (const EffectSettings &settings, double previewLength) const =0
 
void CountWaveTracks ()
 
- Public Member Functions inherited from EffectPlugin
EffectPluginoperator= (EffectPlugin &)=delete
 
virtual ~EffectPlugin ()
 
virtual bool HasOptions () const =0
 
virtual bool CanExportPresets () const =0
 Whether the effect supports export of presets to files, and importing too. More...
 
virtual const EffectSettingsManagerGetDefinition () const =0
 
virtual bool SaveSettingsAsString (const EffectSettings &settings, wxString &parms) const =0
 
virtual OptionalMessage LoadSettingsFromString (const wxString &parms, EffectSettings &settings) const =0
 
virtual bool IsBatchProcessing () const =0
 
virtual void SetBatchProcessing ()=0
 
virtual void UnsetBatchProcessing ()=0
 
virtual bool DoEffect (EffectSettings &settings, const InstanceFinder &finder, double projectRate, TrackList *list, WaveTrackFactory *factory, NotifyingSelectedRegion &selectedRegion, unsigned flags, const EffectSettingsAccessPtr &pAccess=nullptr)=0
 
- Public Member Functions inherited from EffectInstanceFactory
virtual ~EffectInstanceFactory ()
 
virtual std::shared_ptr< EffectInstanceMakeInstance () const =0
 Make an object maintaining short-term state of an Effect. More...
 
- Public Member Functions inherited from EffectSettingsManager
virtual ~EffectSettingsManager ()
 
virtual bool VisitSettings (SettingsVisitor &visitor, EffectSettings &settings)
 
virtual bool VisitSettings (ConstSettingsVisitor &visitor, const EffectSettings &settings) const
 
virtual EffectSettings MakeSettings () const
 
virtual bool CopySettingsContents (const EffectSettings &src, EffectSettings &dst) const
 Update one settings object from another. More...
 
virtual std::unique_ptr< EffectOutputsMakeOutputs () const
 Produce an object to hold values to send to effect output meters. More...
 
- Public Member Functions inherited from EffectDefinitionInterface
virtual ~EffectDefinitionInterface ()
 
virtual EffectType GetType () const =0
 Type determines how it behaves. More...
 
virtual EffectType GetClassification () const
 Determines which menu it appears in; default same as GetType(). More...
 
virtual EffectFamilySymbol GetFamily () const =0
 Report identifier and user-visible name of the effect protocol. More...
 
virtual bool IsInteractive () const =0
 Whether the effect needs a dialog for entry of settings. More...
 
virtual bool IsDefault () const =0
 Whether the effect sorts "above the line" in the menus. More...
 
virtual RealtimeSince RealtimeSupport () const =0
 Since which version of Audacity has the effect supported realtime? More...
 
bool SupportsRealtime () const
 
virtual bool SupportsAutomation () const =0
 Whether the effect has any automatable controls. More...
 
virtual bool EnablesDebug () const
 Whether the effect dialog should have a Debug button; default, always false. More...
 
virtual ManualPageID ManualPage () const
 Name of a page in the Audacity alpha manual, default is empty. More...
 
virtual FilePath HelpPage () const
 Fully qualified local help file name, default is empty. More...
 
virtual bool IsHiddenFromMenus () const
 Default is false. More...
 
- Public Member Functions inherited from ComponentInterface
virtual ~ComponentInterface ()
 
virtual PluginPath GetPath () const =0
 
virtual ComponentInterfaceSymbol GetSymbol () const =0
 
virtual VendorSymbol GetVendor () const =0
 
virtual wxString GetVersion () const =0
 
virtual TranslatableString GetDescription () const =0
 
TranslatableString GetName () const
 

Static Public Member Functions

static EffectFetchParameters (Effect &e, EffectSettings &)
 
- Static Public Member Functions inherited from EffectBase
static std::optional< InstancePointerFindInstance (EffectPlugin &plugin)
 
static InstanceFinder DefaultInstanceFinder (EffectPlugin &plugin)
 
- Static Public Member Functions inherited from EffectDefinitionInterface
static Identifier GetSquashedName (const Identifier &ident)
 A utility that strips spaces and CamelCases a name. More...
 

Protected Member Functions

bool CheckWhetherSkipEffect (const EffectSettings &settings) const override
 Default implementation returns false. More...
 
double CalcPreviewInputLength (const EffectSettings &settings, double previewLength) const override
 Default implementation returns previewLength More...
 
bool TotalProgress (double frac, const TranslatableString &={}) const
 
bool TrackProgress (int whichTrack, double frac, const TranslatableString &={}) const
 
bool TrackGroupProgress (int whichGroup, double frac, const TranslatableString &={}) const
 
int GetNumWaveTracks () const
 
int GetNumWaveGroups () const
 
void GetBounds (const WaveTrack &track, sampleCount *start, sampleCount *len)
 
- Protected Member Functions inherited from EffectBase
virtual bool CheckWhetherSkipEffect (const EffectSettings &settings) const =0
 After Init(), tell whether Process() should be skipped. More...
 
void SetLinearEffectFlag (bool linearEffectFlag)
 
void SetPreviewFullSelectionFlag (bool previewDurationFlag)
 
bool IsPreviewing () const
 
const TrackListinputTracks () const
 
const AudacityProjectFindProject () const
 

Private Member Functions

wxString GetSavedStateGroup ()
 

Private Attributes

bool mIsBatch { false }
 

Additional Inherited Members

- Public Types inherited from EffectPlugin
using EffectSettingsAccessPtr = std::shared_ptr< EffectSettingsAccess >
 
using InstancePointer = std::shared_ptr< EffectInstanceEx >
 
using InstanceFinder = std::function< std::optional< InstancePointer >(EffectSettings &settings) >
 
- Public Types inherited from EffectDefinitionInterface
enum class  RealtimeSince : unsigned { Never , After_3_1 , Always }
 In which versions of Audacity was an effect realtime capable? More...
 
- Public Attributes inherited from EffectBase
std::shared_ptr< TrackListmTracks {}
 
int mNumTracks {}
 
BasicUI::ProgressDialogmProgress {}
 
double mProjectRate {}
 
WaveTrackFactorymFactory {}
 
double mT0 {}
 
double mT1 {}
 
bool mIsPreview { false }
 
- Static Public Attributes inherited from EffectPlugin
static const wxString kUserPresetIdent = wxT("User Preset:")
 
static const wxString kFactoryPresetIdent = wxT("Factory Preset:")
 
static const wxString kCurrentSettingsIdent = wxT("<Current Settings>")
 
static const wxString kFactoryDefaultsIdent = wxT("<Factory Defaults>")
 
- Protected Attributes inherited from EffectBase
wxArrayString mPresetNames
 
unsigned mUIFlags { 0 }
 

Detailed Description

Base class for many of the effects in Audacity.

Definition at line 24 of file Effect.h.

Constructor & Destructor Documentation

◆ Effect()

Effect::Effect ( )

Definition at line 34 of file Effect.cpp.

35{
36}

◆ ~Effect()

Effect::~Effect ( )
virtual

Definition at line 38 of file Effect.cpp.

39{
40}

Member Function Documentation

◆ CalcPreviewInputLength()

double Effect::CalcPreviewInputLength ( const EffectSettings settings,
double  previewLength 
) const
overrideprotectedvirtual

Default implementation returns previewLength

Implements EffectBase.

Definition at line 385 of file Effect.cpp.

387{
388 return previewLength;
389}

Referenced by PerTrackEffect::ProcessPass().

Here is the caller graph for this function:

◆ CanExportPresets()

bool Effect::CanExportPresets ( ) const
overridevirtual

Whether the effect supports export of presets to files, and importing too.

Implements EffectPlugin.

Reimplemented in LadspaEffectBase, LV2EffectBase, VSTEffectBase, and VST3EffectBase.

Definition at line 170 of file Effect.cpp.

171{
172 return true;
173}

◆ CheckWhetherSkipEffect()

bool Effect::CheckWhetherSkipEffect ( const EffectSettings settings) const
overrideprotectedvirtual

Default implementation returns false.

Implements EffectBase.

Definition at line 380 of file Effect.cpp.

381{
382 return false;
383}

◆ Delegate()

bool Effect::Delegate ( Effect delegate,
EffectSettings settings,
InstanceFinder  finder = {} 
)

Re-invoke DoEffect on another Effect object that implements the work.

Definition at line 322 of file Effect.cpp.

324{
325 if (!finder)
326 finder = DefaultInstanceFinder(delegate);
327
329 region.setTimes( mT0, mT1 );
330
331 return delegate.DoEffect(settings, finder, mProjectRate, mTracks.get(),
332 mFactory, region, mUIFlags, nullptr);
333}
static Settings & settings()
Definition: TrackInfo.cpp:69
double mT1
Definition: EffectBase.h:116
WaveTrackFactory * mFactory
Definition: EffectBase.h:114
double mProjectRate
Definition: EffectBase.h:112
bool DoEffect(EffectSettings &settings, const InstanceFinder &finder, double projectRate, TrackList *list, WaveTrackFactory *factory, NotifyingSelectedRegion &selectedRegion, unsigned flags, const EffectSettingsAccessPtr &pAccess) override
Definition: EffectBase.cpp:57
std::shared_ptr< TrackList > mTracks
Definition: EffectBase.h:109
static InstanceFinder DefaultInstanceFinder(EffectPlugin &plugin)
Definition: EffectBase.cpp:254
double mT0
Definition: EffectBase.h:115
unsigned mUIFlags
Definition: EffectBase.h:100
bool setTimes(double t0, double t1)
Definition: ViewInfo.cpp:51
auto finder(TrackId id, int &distance)

References EffectBase::DefaultInstanceFinder(), EffectBase::DoEffect(), anonymous_namespace{PendingTracks.cpp}::finder(), EffectBase::mFactory, EffectBase::mProjectRate, EffectBase::mT0, EffectBase::mT1, EffectBase::mTracks, EffectBase::mUIFlags, NotifyingSelectedRegion::setTimes(), and settings().

Referenced by NyquistEffect::Process().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FetchParameters()

static Effect * Effect::FetchParameters ( Effect e,
EffectSettings  
)
inlinestatic

Definition at line 34 of file Effect.h.

35 { return &e; }

◆ GetBounds()

void Effect::GetBounds ( const WaveTrack track,
sampleCount start,
sampleCount len 
)
protected
Precondition
track.IsLeader()

Definition at line 363 of file Effect.cpp.

365{
366 assert(track.IsLeader());
367 const auto t0 = std::max(mT0, track.GetStartTime());
368 const auto t1 = std::min(mT1, track.GetEndTime());
369 if (t1 > t0) {
370 *start = track.TimeToLongSamples(t0);
371 auto end = track.TimeToLongSamples(t1);
372 *len = end - *start;
373 }
374 else {
375 *start = 0;
376 *len = 0;
377 }
378}
int min(int a, int b)
double GetStartTime() const override
Implement WideSampleSequence.
Definition: WaveTrack.cpp:3087
bool IsLeader() const override
Definition: WaveTrack.cpp:2820
double GetEndTime() const override
Implement WideSampleSequence.
Definition: WaveTrack.cpp:3092
sampleCount TimeToLongSamples(double t0) const
auto end(const Ptr< Type, BaseDeleter > &p)
Enables range-for.
Definition: PackedArray.h:159

References PackedArray::end(), WaveTrack::GetEndTime(), WaveTrack::GetStartTime(), WaveTrack::IsLeader(), min(), EffectBase::mT0, EffectBase::mT1, and WideSampleSequence::TimeToLongSamples().

Referenced by VampEffect::Process(), and PerTrackEffect::ProcessPass().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetDefinition()

const EffectSettingsManager & Effect::GetDefinition ( ) const
overridevirtual

Implements EffectPlugin.

Definition at line 182 of file Effect.cpp.

183{
184 return *this;
185}

Referenced by EffectChangeSpeed::OnChoice_Vinyl(), EffectChangeSpeed::PopulateOrExchange(), SaveUserPreset(), EffectNoiseReduction::TrackProgress(), EffectChangeSpeed::TransferDataFromWindow(), and EffectChangeSpeed::Update_Vinyl().

Here is the caller graph for this function:

◆ GetDescription()

TranslatableString Effect::GetDescription ( ) const
overridevirtual

Implements ComponentInterface.

Reimplemented in LadspaEffectBase, LV2EffectBase, VSTEffectBase, and VST3EffectBase.

Definition at line 64 of file Effect.cpp.

65{
66 return {};
67}

◆ GetFactoryPresets()

RegistryPaths Effect::GetFactoryPresets ( ) const
overridevirtual

Report names of factory presets.

Implements EffectSettingsManager.

Reimplemented in LadspaEffectBase, LV2EffectBase, VSTEffectBase, and VST3EffectBase.

Definition at line 155 of file Effect.cpp.

156{
157 return {};
158}

Referenced by LoadSettingsFromString().

Here is the caller graph for this function:

◆ GetFamily()

EffectFamilySymbol Effect::GetFamily ( ) const
overridevirtual

Report identifier and user-visible name of the effect protocol.

Implements EffectDefinitionInterface.

Reimplemented in LadspaEffectBase, LV2EffectBase, VSTEffectBase, and VST3EffectBase.

Definition at line 69 of file Effect.cpp.

70{
71 // Unusually, the internal and visible strings differ for the built-in
72 // effect family.
73 return { wxT("Audacity"), XO("Built-in") };
74}
wxT("CloseDown"))
XO("Cut/Copy/Paste")

References wxT(), and XO().

Here is the call graph for this function:

◆ GetNumWaveGroups()

int Effect::GetNumWaveGroups ( ) const
inlineprotected

Definition at line 140 of file Effect.h.

140{ return mNumGroups; }
int mNumGroups
Definition: EffectBase.h:127

References EffectBase::mNumGroups.

Referenced by NyquistEffect::Process(), and VampEffect::Process().

Here is the caller graph for this function:

◆ GetNumWaveTracks()

int Effect::GetNumWaveTracks ( ) const
inlineprotected

Definition at line 139 of file Effect.h.

139{ return mNumTracks; }
int mNumTracks
Definition: EffectBase.h:110

References EffectBase::mNumTracks.

Referenced by EffectTruncSilence::Analyze(), EffectAutoDuck::ApplyDuckFade(), EffectAutoDuck::Process(), EffectNormalize::Process(), EffectTwoPassSimpleMono::ProcessOne(), EffectNormalize::ProcessOne(), EffectNoiseRemoval::ShowHostInterface(), and EffectLoudness::UpdateProgress().

Here is the caller graph for this function:

◆ GetPath()

PluginPath Effect::GetPath ( ) const
overridevirtual

Implements ComponentInterface.

Reimplemented in LadspaEffectBase, LV2EffectBase, VSTEffectBase, and VST3EffectBase.

Definition at line 44 of file Effect.cpp.

45{
47}
#define BUILTIN_EFFECT_PREFIX
Definition: Effect.h:17
const wxString & Internal() const
ComponentInterfaceSymbol GetSymbol() const override
Definition: Effect.cpp:49

References BUILTIN_EFFECT_PREFIX, GetSymbol(), and ComponentInterfaceSymbol::Internal().

Here is the call graph for this function:

◆ GetSavedStateGroup()

wxString Effect::GetSavedStateGroup ( )
private

Definition at line 195 of file Effect.cpp.

196{
197 return wxT("SavedState");
198}

References wxT().

Referenced by SetBatchProcessing(), and UnsetBatchProcessing().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetSelectionFormat()

NumericFormatID Effect::GetSelectionFormat ( )
virtual

Definition at line 187 of file Effect.cpp.

188{
189 if( !IsBatchProcessing() && FindProject() )
193}
const AudacityProject * FindProject() const
Definition: EffectBase.cpp:225
bool IsBatchProcessing() const override
Definition: Effect.cpp:295
NumericFormatID GetSelectionFormat() const
static ProjectNumericFormats & Get(AudacityProject &project)
NUMERIC_FORMATS_API NumericFormatSymbol HoursMinsSecondsFormat()

References EffectBase::FindProject(), ProjectNumericFormats::Get(), ProjectNumericFormats::GetSelectionFormat(), NumericConverterFormats::HoursMinsSecondsFormat(), ComponentInterfaceSymbol::Internal(), and IsBatchProcessing().

Referenced by NyquistEffect::BuildEffectWindow(), and EffectRepeat::DisplayNewTime().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetSymbol()

ComponentInterfaceSymbol Effect::GetSymbol ( ) const
overridevirtual

Implements ComponentInterface.

Reimplemented in LadspaEffectBase, LV2EffectBase, VSTEffectBase, and VST3EffectBase.

Definition at line 49 of file Effect.cpp.

50{
51 return {};
52}

Referenced by GetPath().

Here is the caller graph for this function:

◆ GetVendor()

VendorSymbol Effect::GetVendor ( ) const
overridevirtual

Implements ComponentInterface.

Reimplemented in LadspaEffectBase, LV2EffectBase, VSTEffectBase, and VST3EffectBase.

Definition at line 54 of file Effect.cpp.

55{
56 return XO("Audacity");
57}

References XO().

Here is the call graph for this function:

◆ GetVersion()

wxString Effect::GetVersion ( ) const
overridevirtual

Implements ComponentInterface.

Reimplemented in LadspaEffectBase, LV2EffectBase, VSTEffectBase, and VST3EffectBase.

Definition at line 59 of file Effect.cpp.

60{
61 return AUDACITY_VERSION_STRING;
62}

◆ HasOptions()

bool Effect::HasOptions ( ) const
overridevirtual

Whether there are preferences applying to the effect's family, for which a UI may be needed to change them

Implements EffectPlugin.

Reimplemented in LadspaEffectBase, LV2EffectBase, VSTEffectBase, and VST3EffectBase.

Definition at line 175 of file Effect.cpp.

176{
177 return false;
178}

◆ IsBatchProcessing()

bool Effect::IsBatchProcessing ( ) const
overridevirtual

Implements EffectPlugin.

Definition at line 295 of file Effect.cpp.

296{
297 return mIsBatch;
298}
bool mIsBatch
Definition: Effect.h:151

References mIsBatch.

Referenced by NyquistEffect::DoLoadSettings(), GetSelectionFormat(), EffectAmplify::Parameters(), EffectAmplify::PopulateOrExchange(), NyquistEffect::Process(), EffectNoiseReduction::ShowHostInterface(), and NyquistEffect::ShowHostInterface().

Here is the caller graph for this function:

◆ IsDefault()

bool Effect::IsDefault ( ) const
overridevirtual

Whether the effect sorts "above the line" in the menus.

Implements EffectDefinitionInterface.

Reimplemented in LadspaEffectBase, LV2EffectBase, VSTEffectBase, and VST3EffectBase.

Definition at line 81 of file Effect.cpp.

82{
83 return true;
84}

◆ IsInteractive()

bool Effect::IsInteractive ( ) const
overridevirtual

Whether the effect needs a dialog for entry of settings.

Implements EffectDefinitionInterface.

Reimplemented in LadspaEffectBase, LV2EffectBase, VSTEffectBase, and VST3EffectBase.

Definition at line 76 of file Effect.cpp.

77{
78 return true;
79}

◆ LoadFactoryDefaults()

OptionalMessage Effect::LoadFactoryDefaults ( EffectSettings settings) const
overridevirtual

Change settings back to "factory default"

Returns
nullopt for failure

Implements EffectSettingsManager.

Definition at line 165 of file Effect.cpp.

166{
168}
const RegistryPath & FactoryDefaultsGroup()
Component of a configuration key path, for default state of MakeSettings()
OptionalMessage LoadUserPreset(const RegistryPath &name, EffectSettings &settings) const override
Definition: Effect.cpp:130

References FactoryDefaultsGroup(), LoadUserPreset(), and settings().

Referenced by EffectChangeSpeed::DoLoadFactoryDefaults(), and EffectEqualization::DoLoadFactoryDefaults().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ LoadFactoryPreset()

OptionalMessage Effect::LoadFactoryPreset ( int  id,
EffectSettings settings 
) const
overridevirtual

Change settings to the preset whose name is GetFactoryPresets()[id]

Returns
nullopt for failure

Implements EffectSettingsManager.

Reimplemented in LadspaEffectBase, LV2EffectBase, VSTEffectBase, and VST3EffectBase.

Definition at line 160 of file Effect.cpp.

161{
162 return { nullptr };
163}

Referenced by LoadSettingsFromString().

Here is the caller graph for this function:

◆ LoadSettings()

bool Effect::LoadSettings ( const CommandParameters parms,
EffectSettings settings 
) const
overridevirtual

Restore settings from keys and values.

Returns
true on success

Implements EffectSettingsManager.

Reimplemented in LadspaEffectBase, LV2EffectBase, VSTEffectBase, and VST3EffectBase.

Definition at line 122 of file Effect.cpp.

124{
125 // The first argument, and with it the const_cast, will disappear when
126 // all built-in effects are stateless.
127 return Parameters().Set( *const_cast<Effect*>(this), parms, settings );
128}
Base class for many of the effects in Audacity.
Definition: Effect.h:26
virtual const EffectParameterMethods & Parameters() const
Definition: Effect.cpp:96
virtual bool Set(Effect &effect, const CommandParameters &parms, EffectSettings &settings) const =0

References Parameters(), EffectParameterMethods::Set(), and settings().

Referenced by EffectTruncSilence::LoadSettings(), and LoadSettingsFromString().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ LoadSettingsFromString()

OptionalMessage Effect::LoadSettingsFromString ( const wxString &  parms,
EffectSettings settings 
) const
overridevirtual

Implements EffectPlugin.

Definition at line 220 of file Effect.cpp.

222{
223 // If the string starts with one of certain significant substrings,
224 // then the rest of the string is reinterpreted as part of a registry key,
225 // and a user or factory preset is then loaded.
226 // (Where did these prefixes come from? See EffectPresetsDialog; and
227 // ultimately the uses of it by EffectManager::GetPreset, which is used by
228 // the macro management dialog)
229 wxString preset = parms;
230 OptionalMessage result;
231 if (preset.StartsWith(kUserPresetIdent))
232 {
233 preset.Replace(kUserPresetIdent, wxEmptyString, false);
235 }
236 else if (preset.StartsWith(kFactoryPresetIdent))
237 {
238 preset.Replace(kFactoryPresetIdent, wxEmptyString, false);
239 auto presets = GetFactoryPresets();
240 result = LoadFactoryPreset(
241 make_iterator_range( presets ).index( preset ), settings );
242 }
243 else if (preset.StartsWith(kCurrentSettingsIdent))
244 {
245 preset.Replace(kCurrentSettingsIdent, wxEmptyString, false);
247 }
248 else if (preset.StartsWith(kFactoryDefaultsIdent))
249 {
250 preset.Replace(kFactoryDefaultsIdent, wxEmptyString, false);
252 }
253 else
254 {
255 // If the string did not start with any of the significant substrings,
256 // then use VisitSettings or LoadSettings to reinterpret it,
257 // or use LoadSettings.
258 // This interprets what was written by SaveSettings, above.
259 CommandParameters eap(parms);
261 S.SetForValidating( &eap );
262 // VisitSettings returns false if not defined for this effect.
263 // To do: fix const_cast in use of VisitSettings
264 if ( !const_cast<Effect*>(this)->VisitSettings(S, settings) ) {
265 // the old method...
266 if (LoadSettings(eap, settings))
267 return { nullptr };
268 }
269 else if( !S.bOK )
270 result = {};
271 else{
272 result = { nullptr };
273 S.SetForWriting( &eap );
274 const_cast<Effect*>(this)->VisitSettings(S, settings);
275 }
276 }
277
278 if (!result)
279 {
280 using namespace BasicUI;
282 XO("%s: Could not load settings below. Default settings will be used.\n\n%s")
283 .Format( GetName(), preset ),
285 // We are using default settings and we still wish to continue.
286 result = { nullptr };
287 }
288 return result;
289}
RegistryPath UserPresetsGroup(const RegistryPath &name)
Compute part of a registry path, given a name which may be empty.
const RegistryPath & CurrentSettingsGroup()
Component of a configuration key path, for last-used destructive settings.
std::optional< std::unique_ptr< EffectSettingsAccess::Message > > OptionalMessage
IteratorRange< Iterator > make_iterator_range(const Iterator &i1, const Iterator &i2)
Definition: IteratorX.h:210
EffectReverbSettings preset
Definition: Reverb.cpp:44
#define S(N)
Definition: ToChars.cpp:64
CommandParameters, derived from wxFileConfig, is essentially doing the same things as the SettingsVis...
TranslatableString GetName() const
bool VisitSettings(SettingsVisitor &visitor, EffectSettings &settings) override
Definition: Effect.cpp:102
bool LoadSettings(const CommandParameters &parms, EffectSettings &settings) const override
Restore settings from keys and values.
Definition: Effect.cpp:122
OptionalMessage LoadFactoryPreset(int id, EffectSettings &settings) const override
Definition: Effect.cpp:160
RegistryPaths GetFactoryPresets() const override
Report names of factory presets.
Definition: Effect.cpp:155
static const wxString kUserPresetIdent
Definition: EffectPlugin.h:40
static const wxString kFactoryPresetIdent
Definition: EffectPlugin.h:41
static const wxString kCurrentSettingsIdent
Definition: EffectPlugin.h:42
static const wxString kFactoryDefaultsIdent
Definition: EffectPlugin.h:43
Abstract base class used in importing a file.
SettingsVisitor that sets parameters to a value (from a string)
MessageBoxResult ShowMessageBox(const TranslatableString &message, MessageBoxOptions options={})
Show a modal message box with either Ok or Yes and No, and optionally Cancel.
Definition: BasicUI.h:277
MessageBoxOptions && Caption(TranslatableString caption_) &&
Definition: BasicUI.h:101

References BasicUI::MessageBoxOptions::Caption(), CurrentSettingsGroup(), FactoryDefaultsGroup(), GetFactoryPresets(), ComponentInterface::GetName(), EffectPlugin::kCurrentSettingsIdent, EffectPlugin::kFactoryDefaultsIdent, EffectPlugin::kFactoryPresetIdent, EffectPlugin::kUserPresetIdent, LoadFactoryPreset(), LoadSettings(), LoadUserPreset(), make_iterator_range(), preset, S, settings(), BasicUI::ShowMessageBox(), UserPresetsGroup(), VisitSettings(), and XO().

Referenced by EffectNoiseReduction::TrackProgress().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ LoadUserPreset()

OptionalMessage Effect::LoadUserPreset ( const RegistryPath name,
EffectSettings settings 
) const
overridevirtual

Change settings to a user-named preset

Returns
nullopt for failure

Implements EffectSettingsManager.

Reimplemented in LadspaEffectBase, LV2EffectBase, VSTEffectBase, and VST3EffectBase.

Definition at line 130 of file Effect.cpp.

132{
133 // Find one string in the registry and then reinterpret it
134 // as complete settings
135 wxString parms;
137 name, wxT("Parameters"), parms))
138 return {};
139
140 return LoadSettingsFromString(parms, settings);
141}
const TranslatableString name
Definition: Distortion.cpp:76
const EffectSettingsManager & GetDefinition() const override
Definition: Effect.cpp:182
OptionalMessage LoadSettingsFromString(const wxString &parms, EffectSettings &settings) const override
Definition: Effect.cpp:220
bool GetConfig(const EffectDefinitionInterface &ident, ConfigurationType type, const RegistryPath &group, const RegistryPath &key, Value &var, const Value &defval)

Referenced by LoadFactoryDefaults(), LoadSettingsFromString(), and UnsetBatchProcessing().

Here is the caller graph for this function:

◆ Parameters()

const EffectParameterMethods & Effect::Parameters ( ) const
virtual

Reimplemented in EffectAmplify, EffectAutoDuck, EffectBassTreble, EffectChangeSpeed, EffectClickRemoval, EffectCompressor, EffectDistortion, EffectDtmf, EffectEcho, EffectEqualization, EffectFindClipping, EffectLoudness, EffectNoise, EffectNormalize, EffectPaulstretch, EffectPhaser, EffectRepeat, EffectReverb, EffectScienFilter, EffectTimeScale, EffectToneGen, EffectTruncSilence, and EffectWahwah.

Definition at line 96 of file Effect.cpp.

97{
98 static const CapturedParameters<Effect> empty;
99 return empty;
100}
Generates EffectParameterMethods overrides from variadic template arguments.

Referenced by LoadSettings(), SaveSettings(), and VisitSettings().

Here is the caller graph for this function:

◆ RealtimeSupport()

auto Effect::RealtimeSupport ( ) const
overridevirtual

Since which version of Audacity has the effect supported realtime?

Implements EffectDefinitionInterface.

Reimplemented in LadspaEffectBase, LV2EffectBase, VSTEffectBase, and VST3EffectBase.

Definition at line 86 of file Effect.cpp.

References EffectDefinitionInterface::Never.

◆ SaveSettings()

bool Effect::SaveSettings ( const EffectSettings settings,
CommandParameters parms 
) const
overridevirtual

Store settings as keys and values.

The override may assume parms is initially empty

Returns
true on success

Implements EffectSettingsManager.

Reimplemented in LadspaEffectBase, LV2EffectBase, VSTEffectBase, and VST3EffectBase.

Definition at line 115 of file Effect.cpp.

117{
118 Parameters().Get( *this, settings, parms );
119 return true;
120}
virtual void Get(const Effect &effect, const EffectSettings &settings, CommandParameters &parms) const =0

References EffectParameterMethods::Get(), Parameters(), and settings().

Referenced by SaveSettingsAsString().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SaveSettingsAsString()

bool Effect::SaveSettingsAsString ( const EffectSettings settings,
wxString &  parms 
) const
overridevirtual

Implements EffectPlugin.

Definition at line 202 of file Effect.cpp.

204{
207 S.mpEap = &eap;
208 if( VisitSettings( S, settings ) ){
209 ;// got eap value using VisitSettings.
210 }
211 // Won't be needed in future
212 else if (!SaveSettings(settings, eap))
213 {
214 return false;
215 }
216
217 return eap.GetParameters(parms);
218}
bool GetParameters(wxString &parms)
bool SaveSettings(const EffectSettings &settings, CommandParameters &parms) const override
Store settings as keys and values.
Definition: Effect.cpp:115
SettingsVisitor that gets parameter values into a string.

References CommandParameters::GetParameters(), S, SaveSettings(), settings(), and VisitSettings().

Referenced by SaveUserPreset().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SaveUserPreset()

bool Effect::SaveUserPreset ( const RegistryPath name,
const EffectSettings settings 
) const
overridevirtual

Save settings in the configuration file as a user-named preset.

Implements EffectSettingsManager.

Reimplemented in LadspaEffectBase, LV2EffectBase, VSTEffectBase, and VST3EffectBase.

Definition at line 143 of file Effect.cpp.

145{
146 // Save all settings as a single string value in the registry
147 wxString parms;
148 if (!SaveSettingsAsString(settings, parms))
149 return false;
150
152 name, wxT("Parameters"), parms);
153}
bool SaveSettingsAsString(const EffectSettings &settings, wxString &parms) const override
Definition: Effect.cpp:202
bool SetConfig(const EffectDefinitionInterface &ident, ConfigurationType type, const RegistryPath &group, const RegistryPath &key, const Value &value)

References GetDefinition(), name, PluginSettings::Private, SaveSettingsAsString(), PluginSettings::SetConfig(), settings(), and wxT().

Referenced by SetBatchProcessing().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetBatchProcessing()

void Effect::SetBatchProcessing ( )
overridevirtual

Implements EffectPlugin.

Definition at line 300 of file Effect.cpp.

301{
302 mIsBatch = true;
303 // Save effect's internal state in a special registry path
304 // just for this purpose
305 // If effect is not stateful, this step doesn't really matter, and the
306 // settings object is a dummy
307 auto dummySettings = MakeSettings();
308 SaveUserPreset(GetSavedStateGroup(), dummySettings);
309}
bool SaveUserPreset(const RegistryPath &name, const EffectSettings &settings) const override
Save settings in the configuration file as a user-named preset.
Definition: Effect.cpp:143
wxString GetSavedStateGroup()
Definition: Effect.cpp:195
virtual EffectSettings MakeSettings() const

References GetSavedStateGroup(), EffectSettingsManager::MakeSettings(), mIsBatch, and SaveUserPreset().

Referenced by NyquistEffect::ShowHostInterface().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SupportsAutomation()

bool Effect::SupportsAutomation ( ) const
overridevirtual

Whether the effect has any automatable controls.

Implements EffectDefinitionInterface.

Reimplemented in LadspaEffectBase, LV2EffectBase, VSTEffectBase, and VST3EffectBase.

Definition at line 91 of file Effect.cpp.

92{
93 return true;
94}

◆ TestUIFlags()

unsigned Effect::TestUIFlags ( unsigned  mask)

Definition at line 291 of file Effect.cpp.

291 {
292 return mask & mUIFlags;
293}

References EffectBase::mUIFlags.

Referenced by NyquistEffect::ShowHostInterface().

Here is the caller graph for this function:

◆ TotalProgress()

bool Effect::TotalProgress ( double  frac,
const TranslatableString msg = {} 
) const
protected

Definition at line 335 of file Effect.cpp.

336{
337 auto updateResult = (mProgress ?
338 mProgress->Poll(frac * 1000, 1000, msg) :
340 return (updateResult != BasicUI::ProgressResult::Success);
341}
virtual ProgressResult Poll(unsigned long long numerator, unsigned long long denominator, const TranslatableString &message={})=0
Update the bar and poll for clicks. Call only on the main thread.
BasicUI::ProgressDialog * mProgress
Definition: EffectBase.h:111

References EffectBase::mProgress, BasicUI::ProgressDialog::Poll(), and BasicUI::Success.

Referenced by EffectTruncSilence::Analyze(), EffectAutoDuck::ApplyDuckFade(), EffectTruncSilence::DoRemoval(), EffectAutoDuck::Process(), EffectNormalize::Process(), NyquistEffect::Process(), EffectStereoToMono::ProcessOne(), EffectTwoPassSimpleMono::ProcessOne(), EffectNormalize::ProcessOne(), and EffectLoudness::UpdateProgress().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TrackGroupProgress()

bool Effect::TrackGroupProgress ( int  whichGroup,
double  frac,
const TranslatableString msg = {} 
) const
protected

Definition at line 353 of file Effect.cpp.

355{
356 auto updateResult = (mProgress ?
357 mProgress->Poll((whichGroup + frac) * 1000,
358 (double) mNumGroups * 1000, msg) :
360 return (updateResult != BasicUI::ProgressResult::Success);
361}

References EffectBase::mNumGroups, EffectBase::mProgress, BasicUI::ProgressDialog::Poll(), and BasicUI::Success.

Referenced by VampEffect::Process(), NyquistEffect::ProcessOne(), and PerTrackEffect::ProcessPass().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TrackProgress()

bool Effect::TrackProgress ( int  whichTrack,
double  frac,
const TranslatableString msg = {} 
) const
protected

Definition at line 343 of file Effect.cpp.

345{
346 auto updateResult = (mProgress ?
347 mProgress->Poll((whichTrack + frac) * 1000,
348 (double) mNumTracks * 1000, msg) :
350 return (updateResult != BasicUI::ProgressResult::Success);
351}

References EffectBase::mNumTracks, EffectBase::mProgress, BasicUI::ProgressDialog::Poll(), and BasicUI::Success.

Referenced by EffectRepeat::Process(), EffectReverse::Process(), EffectSBSMS::Process(), VampEffect::Process(), EffectPaulstretch::ProcessOne(), EffectChangeSpeed::ProcessOne(), EffectClickRemoval::ProcessOne(), EffectRepair::ProcessOne(), EffectNoiseRemoval::ProcessOne(), EffectFindClipping::ProcessOne(), NyquistEffect::ProcessOne(), EffectEqualization::ProcessOne(), and PerTrackEffect::ProcessPass().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ UnsetBatchProcessing()

void Effect::UnsetBatchProcessing ( )
overridevirtual

Implements EffectPlugin.

Definition at line 311 of file Effect.cpp.

312{
313 mIsBatch = false;
314 // Restore effect's internal state from registry
315 // If effect is not stateful, this call doesn't really matter, and the
316 // settings object is a dummy
317 auto dummySettings = MakeSettings();
318 // Ignore failure
319 (void ) LoadUserPreset(GetSavedStateGroup(), dummySettings);
320}

References GetSavedStateGroup(), LoadUserPreset(), EffectSettingsManager::MakeSettings(), and mIsBatch.

Here is the call graph for this function:

◆ VisitSettings() [1/2]

bool Effect::VisitSettings ( ConstSettingsVisitor visitor,
const EffectSettings settings 
) const
overridevirtual

Visit settings (read-only), if defined. false means no defined settings. Default implementation returns false

Reimplemented from EffectSettingsManager.

Definition at line 108 of file Effect.cpp.

110{
111 Parameters().Visit(*this, visitor, settings);
112 return true;
113}
virtual void Visit(Effect &effect, SettingsVisitor &visitor, EffectSettings &settings) const =0

References Parameters(), settings(), and EffectParameterMethods::Visit().

Here is the call graph for this function:

◆ VisitSettings() [2/2]

bool Effect::VisitSettings ( SettingsVisitor visitor,
EffectSettings settings 
)
overridevirtual

Visit settings (and maybe change them), if defined. false means no defined settings. Default implementation returns false

Reimplemented from EffectSettingsManager.

Definition at line 102 of file Effect.cpp.

103{
104 Parameters().Visit(*this, visitor, settings);
105 return true;
106}

References Parameters(), settings(), and EffectParameterMethods::Visit().

Referenced by LoadSettingsFromString(), SaveSettingsAsString(), and EffectEqualization::VisitSettings().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ mIsBatch

bool Effect::mIsBatch { false }
private

Definition at line 151 of file Effect.h.

Referenced by IsBatchProcessing(), SetBatchProcessing(), and UnsetBatchProcessing().


The documentation for this class was generated from the following files: