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
 
EffectType GetType () const override
 Type determines how it behaves. More...
 
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 NumericFormatSymbol 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)
 Re-invoke DoEffect on another Effect object that implements the work. More...
 
- Public Member Functions inherited from EffectBase
 EffectBase ()
 
 ~EffectBase () override
 
void SetTracks (TrackList *pTracks)
 
bool DoEffect (EffectSettings &settings, const InstanceFinder &finder, double projectRate, TrackList *list, WaveTrackFactory *factory, NotifyingSelectedRegion &selectedRegion, unsigned flags, const EffectSettingsAccessPtr &pAccess) override
 
- 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 void Preview (EffectSettingsAccess &access, std::function< void()> updateUI, bool dryOnly)=0
 Calculate temporary tracks of limited length with effect applied and play. More...
 
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 void IncEffectCounter ()
 
- 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, const WaveTrack *pRight, sampleCount *start, sampleCount *len)
 
void CopyInputTracks (bool allSyncLockSelected=false)
 
TrackAddToOutputTracks (const std::shared_ptr< Track > &t)
 
- Protected Member Functions inherited from EffectBase
virtual std::any BeginPreview (const EffectSettings &settings)
 Called when Preview() starts, to allow temporary effect state changes. More...
 
void Preview (EffectSettingsAccess &access, std::function< void()> updateUI, bool dryOnly) final
 Calculate temporary tracks of limited length with effect applied and play. More...
 
virtual bool CheckWhetherSkipEffect (const EffectSettings &settings) const =0
 After Init(), tell whether Process() should be skipped. More...
 
virtual double CalcPreviewInputLength (const EffectSettings &settings, double previewLength) const =0
 
void SetLinearEffectFlag (bool linearEffectFlag)
 
void SetPreviewFullSelectionFlag (bool previewDurationFlag)
 
bool IsPreviewing () const
 
void IncludeNotSelectedPreviewTracks (bool includeNotSelected)
 
void ReplaceProcessedTracks (const bool bGoodResult)
 
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
TrackListmTracks {}
 
- 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
BasicUI::ProgressDialogmProgress {}
 
double mProjectRate {}
 
WaveTrackFactorymFactory {}
 
std::shared_ptr< TrackListmOutputTracks
 
double mT0 {}
 
double mT1 {}
 
wxArrayString mPresetNames
 
unsigned mUIFlags { 0 }
 
- Static Protected Attributes inherited from EffectBase
static int nEffectsDone = 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 35 of file Effect.cpp.

36{
37}

◆ ~Effect()

Effect::~Effect ( )
virtual

Definition at line 39 of file Effect.cpp.

40{
41}

Member Function Documentation

◆ AddToOutputTracks()

Track * Effect::AddToOutputTracks ( const std::shared_ptr< Track > &  t)
protected

Definition at line 421 of file Effect.cpp.

422{
423 mIMap.push_back(NULL);
424 mOMap.push_back(t.get());
425 return mOutputTracks->Add(t);
426}
std::shared_ptr< TrackList > mOutputTracks
Definition: EffectBase.h:111
std::vector< Track * > mOMap
Definition: EffectBase.h:140
std::vector< Track * > mIMap
Definition: EffectBase.h:139

References EffectBase::mIMap, EffectBase::mOMap, and EffectBase::mOutputTracks.

Referenced by NyquistEffect::ProcessOne().

Here is the caller graph for this function:

◆ CalcPreviewInputLength()

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

Default implementation returns previewLength

Implements EffectBase.

Definition at line 433 of file Effect.cpp.

435{
436 return previewLength;
437}

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.

Definition at line 178 of file Effect.cpp.

179{
180 return true;
181}

◆ CheckWhetherSkipEffect()

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

Default implementation returns false.

Implements EffectBase.

Definition at line 428 of file Effect.cpp.

429{
430 return false;
431}

◆ CopyInputTracks()

void Effect::CopyInputTracks ( bool  allSyncLockSelected = false)
protected

Definition at line 396 of file Effect.cpp.

397{
398 // Reset map
399 mIMap.clear();
400 mOMap.clear();
401
403 const_cast<AudacityProject*>( FindProject() ) // how to remove this const_cast?
404 );
405
406 auto trackRange = mTracks->Any() +
407 [&] (const Track *pTrack) {
408 return allSyncLockSelected
410 : track_cast<const WaveTrack*>( pTrack ) && pTrack->GetSelected();
411 };
412
413 for (auto aTrack : trackRange)
414 {
415 Track *o = mOutputTracks->Add(aTrack->Duplicate());
416 mIMap.push_back(aTrack);
417 mOMap.push_back(o);
418 }
419}
std::enable_if_t< std::is_pointer_v< T >, T > track_cast(Track *track)
Encapsulate the checked down-casting of track pointers.
Definition: Track.h:966
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:90
TrackList * mTracks
Definition: EffectBase.h:130
const AudacityProject * FindProject() const
Definition: EffectBase.cpp:311
static bool IsSelectedOrSyncLockSelected(const Track *pTrack)
Definition: SyncLock.cpp:112
Abstract base class for an object holding data associated with points on a time axis.
Definition: Track.h:226
static std::shared_ptr< TrackList > Create(AudacityProject *pOwner)
Definition: Track.cpp:503
auto Any() -> TrackIterRange< TrackType >
Definition: Track.h:1440
A Track that contains audio waveform data.
Definition: WaveTrack.h:51

References TrackList::Any(), TrackList::Create(), EffectBase::FindProject(), SyncLock::IsSelectedOrSyncLockSelected(), EffectBase::mIMap, EffectBase::mOMap, EffectBase::mOutputTracks, and EffectBase::mTracks.

Referenced by PerTrackEffect::Process(), EffectAutoDuck::Process(), EffectChangeSpeed::Process(), EffectClickRemoval::Process(), EffectEqualization::Process(), Generator::Process(), EffectLoudness::Process(), EffectNoiseReduction::Process(), EffectNoiseRemoval::Process(), EffectNormalize::Process(), NyquistEffect::Process(), EffectPaulstretch::Process(), EffectRepair::Process(), EffectRepeat::Process(), EffectReverse::Process(), EffectSBSMS::Process(), EffectSimpleMono::Process(), EffectStereoToMono::Process(), EffectTwoPassSimpleMono::Process(), EffectTruncSilence::ProcessAll(), and EffectTruncSilence::ProcessIndependently().

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

◆ Delegate()

bool Effect::Delegate ( Effect delegate,
EffectSettings settings 
)

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

Definition at line 329 of file Effect.cpp.

330{
332 region.setTimes( mT0, mT1 );
333
334 return delegate.DoEffect(settings, {}, mProjectRate, mTracks, mFactory,
335 region, mUIFlags, nullptr);
336}
static Settings & settings()
Definition: TrackInfo.cpp:87
double mT1
Definition: EffectBase.h:113
WaveTrackFactory * mFactory
Definition: EffectBase.h:107
double mProjectRate
Definition: EffectBase.h:105
bool DoEffect(EffectSettings &settings, const InstanceFinder &finder, double projectRate, TrackList *list, WaveTrackFactory *factory, NotifyingSelectedRegion &selectedRegion, unsigned flags, const EffectSettingsAccessPtr &pAccess) override
Definition: EffectBase.cpp:59
double mT0
Definition: EffectBase.h:112
unsigned mUIFlags
Definition: EffectBase.h:119
bool setTimes(double t0, double t1)
Definition: ViewInfo.cpp:51

References EffectBase::DoEffect(), 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,
const WaveTrack pRight,
sampleCount start,
sampleCount len 
)
protected

Definition at line 366 of file Effect.cpp.

369{
370 auto t0 = std::max( mT0, track.GetStartTime() );
371 auto t1 = std::min( mT1, track.GetEndTime() );
372
373 if ( pRight ) {
374 t0 = std::min( t0, std::max( mT0, pRight->GetStartTime() ) );
375 t1 = std::max( t1, std::min( mT1, pRight->GetEndTime() ) );
376 }
377
378 if (t1 > t0) {
379 *start = track.TimeToLongSamples(t0);
380 auto end = track.TimeToLongSamples(t1);
381 *len = end - *start;
382 }
383 else {
384 *start = 0;
385 *len = 0;
386 }
387}
int min(int a, int b)
sampleCount TimeToLongSamples(double t0) const
Convert correctly between an (absolute) time in seconds and a number of samples.
Definition: SampleTrack.cpp:43
double GetStartTime() const override
Get the time at which the first clip in the track starts.
Definition: WaveTrack.cpp:1802
double GetEndTime() const override
Get the time at which the last clip in the track ends, plus recorded stuff.
Definition: WaveTrack.cpp:1822
auto end(const Ptr< Type, BaseDeleter > &p)
Enables range-for.
Definition: PackedArray.h:159

References PackedArray::end(), WaveTrack::GetEndTime(), WaveTrack::GetStartTime(), min(), EffectBase::mT0, EffectBase::mT1, and SampleTrack::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 190 of file Effect.cpp.

191{
192 return *this;
193}

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

Here is the caller graph for this function:

◆ GetDescription()

TranslatableString Effect::GetDescription ( ) const
overridevirtual

Implements ComponentInterface.

Definition at line 65 of file Effect.cpp.

66{
67 return {};
68}

◆ GetFactoryPresets()

RegistryPaths Effect::GetFactoryPresets ( ) const
overridevirtual

Report names of factory presets.

Implements EffectSettingsManager.

Definition at line 163 of file Effect.cpp.

164{
165 return {};
166}

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.

Definition at line 77 of file Effect.cpp.

78{
79 // Unusually, the internal and visible strings differ for the built-in
80 // effect family.
81 return { wxT("Audacity"), XO("Built-in") };
82}
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 141 of file Effect.h.

141{ return mNumGroups; }
int mNumGroups
Definition: EffectBase.h:143

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 140 of file Effect.h.

140{ return mNumTracks; }
int mNumTracks
Definition: EffectBase.h:142

References EffectBase::mNumTracks.

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

Here is the caller graph for this function:

◆ GetPath()

PluginPath Effect::GetPath ( ) const
overridevirtual

Implements ComponentInterface.

Definition at line 45 of file Effect.cpp.

46{
48}
#define BUILTIN_EFFECT_PREFIX
Definition: Effect.h:17
const wxString & Internal() const
ComponentInterfaceSymbol GetSymbol() const override
Definition: Effect.cpp:50

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

Here is the call graph for this function:

◆ GetSavedStateGroup()

wxString Effect::GetSavedStateGroup ( )
private

Definition at line 202 of file Effect.cpp.

203{
204 return wxT("SavedState");
205}

References wxT().

Referenced by SetBatchProcessing(), and UnsetBatchProcessing().

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

◆ GetSelectionFormat()

NumericFormatSymbol Effect::GetSelectionFormat ( )
virtual

Definition at line 195 of file Effect.cpp.

196{
197 if( !IsBatchProcessing() && FindProject() )
200}
bool IsBatchProcessing() const override
Definition: Effect.cpp:302
static NumericFormatSymbol HoursMinsSecondsFormat()
const NumericFormatSymbol & GetSelectionFormat() const
static ProjectNumericFormats & Get(AudacityProject &project)

References EffectBase::FindProject(), ProjectNumericFormats::Get(), ProjectNumericFormats::GetSelectionFormat(), NumericConverter::HoursMinsSecondsFormat(), 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.

Definition at line 50 of file Effect.cpp.

51{
52 return {};
53}

Referenced by GetPath().

Here is the caller graph for this function:

◆ GetType()

EffectType Effect::GetType ( ) const
overridevirtual

Type determines how it behaves.

Implements EffectDefinitionInterface.

Definition at line 72 of file Effect.cpp.

73{
74 return EffectTypeNone;
75}
@ EffectTypeNone

References EffectTypeNone.

Referenced by PerTrackEffect::ProcessPass(), and VST3Editor::VST3Editor().

Here is the caller graph for this function:

◆ GetVendor()

VendorSymbol Effect::GetVendor ( ) const
overridevirtual

Implements ComponentInterface.

Definition at line 55 of file Effect.cpp.

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

References XO().

Here is the call graph for this function:

◆ GetVersion()

wxString Effect::GetVersion ( ) const
overridevirtual

Implements ComponentInterface.

Definition at line 60 of file Effect.cpp.

61{
62 return AUDACITY_VERSION_STRING;
63}

◆ 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.

Definition at line 183 of file Effect.cpp.

184{
185 return false;
186}

◆ IncEffectCounter()

static void Effect::IncEffectCounter ( )
inlinestatic

Definition at line 110 of file Effect.h.

110{ nEffectsDone++;}
static int nEffectsDone
Definition: EffectBase.h:97

Referenced by SelectTracksCommand::Apply().

Here is the caller graph for this function:

◆ IsBatchProcessing()

bool Effect::IsBatchProcessing ( ) const
overridevirtual

Implements EffectPlugin.

Definition at line 302 of file Effect.cpp.

303{
304 return mIsBatch;
305}
bool mIsBatch
Definition: Effect.h:159

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.

Definition at line 89 of file Effect.cpp.

90{
91 return true;
92}

◆ IsInteractive()

bool Effect::IsInteractive ( ) const
overridevirtual

Whether the effect needs a dialog for entry of settings.

Implements EffectDefinitionInterface.

Definition at line 84 of file Effect.cpp.

85{
86 return true;
87}

◆ LoadFactoryDefaults()

OptionalMessage Effect::LoadFactoryDefaults ( EffectSettings settings) const
overridevirtual

Change settings back to "factory default"

Returns
nullopt for failure

Implements EffectSettingsManager.

Definition at line 173 of file Effect.cpp.

174{
176}
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:138

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.

Definition at line 168 of file Effect.cpp.

169{
170 return { nullptr };
171}

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.

Definition at line 130 of file Effect.cpp.

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

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

Here is the caller graph for this function:

◆ LoadSettingsFromString()

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

Implements EffectPlugin.

Definition at line 227 of file Effect.cpp.

229{
230 // If the string starts with one of certain significant substrings,
231 // then the rest of the string is reinterpreted as part of a registry key,
232 // and a user or factory preset is then loaded.
233 // (Where did these prefixes come from? See EffectPresetsDialog; and
234 // ultimately the uses of it by EffectManager::GetPreset, which is used by
235 // the macro management dialog)
236 wxString preset = parms;
237 OptionalMessage result;
238 if (preset.StartsWith(kUserPresetIdent))
239 {
240 preset.Replace(kUserPresetIdent, wxEmptyString, false);
242 }
243 else if (preset.StartsWith(kFactoryPresetIdent))
244 {
245 preset.Replace(kFactoryPresetIdent, wxEmptyString, false);
246 auto presets = GetFactoryPresets();
247 result = LoadFactoryPreset(
248 make_iterator_range( presets ).index( preset ), settings );
249 }
250 else if (preset.StartsWith(kCurrentSettingsIdent))
251 {
252 preset.Replace(kCurrentSettingsIdent, wxEmptyString, false);
254 }
255 else if (preset.StartsWith(kFactoryDefaultsIdent))
256 {
257 preset.Replace(kFactoryDefaultsIdent, wxEmptyString, false);
259 }
260 else
261 {
262 // If the string did not start with any of the significant substrings,
263 // then use VisitSettings or LoadSettings to reinterpret it,
264 // or use LoadSettings.
265 // This interprets what was written by SaveSettings, above.
266 CommandParameters eap(parms);
268 S.SetForValidating( &eap );
269 // VisitSettings returns false if not defined for this effect.
270 // To do: fix const_cast in use of VisitSettings
271 if ( !const_cast<Effect*>(this)->VisitSettings(S, settings) ) {
272 // the old method...
273 if (LoadSettings(eap, settings))
274 return { nullptr };
275 }
276 else if( !S.bOK )
277 result = {};
278 else{
279 result = { nullptr };
280 S.SetForWriting( &eap );
281 const_cast<Effect*>(this)->VisitSettings(S, settings);
282 }
283 }
284
285 if (!result)
286 {
287 using namespace BasicUI;
289 XO("%s: Could not load settings below. Default settings will be used.\n\n%s")
290 .Format( GetName(), preset ),
292 // We are using default settings and we still wish to continue.
293 result = { nullptr };
294 }
295 return result;
296}
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: MemoryX.h:448
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:110
bool LoadSettings(const CommandParameters &parms, EffectSettings &settings) const override
Restore settings from keys and values.
Definition: Effect.cpp:130
OptionalMessage LoadFactoryPreset(int id, EffectSettings &settings) const override
Definition: Effect.cpp:168
RegistryPaths GetFactoryPresets() const override
Report names of factory presets.
Definition: Effect.cpp:163
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:274
MessageBoxOptions && Caption(TranslatableString caption_) &&
Definition: BasicUI.h:100

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 LoadUserPreset().

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.

Definition at line 138 of file Effect.cpp.

140{
141 // Find one string in the registry and then reinterpret it
142 // as complete settings
143 wxString parms;
145 name, wxT("Parameters"), parms))
146 return {};
147
148 return LoadSettingsFromString(parms, settings);
149}
const TranslatableString name
Definition: Distortion.cpp:76
const EffectSettingsManager & GetDefinition() const override
Definition: Effect.cpp:190
OptionalMessage LoadSettingsFromString(const wxString &parms, EffectSettings &settings) const override
Definition: Effect.cpp:227
bool GetConfig(const EffectDefinitionInterface &ident, ConfigurationType type, const RegistryPath &group, const RegistryPath &key, Value &var, const Value &defval)

References PluginSettings::GetConfig(), GetDefinition(), LoadSettingsFromString(), name, PluginSettings::Private, settings(), and wxT().

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

Here is the call graph for this function:
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 104 of file Effect.cpp.

105{
106 static const CapturedParameters<Effect> empty;
107 return empty;
108}
Generates EffectParameterMethods overrides from variadic template arguments.

Referenced by SaveSettings(), EffectNoiseReduction::TrackProgress(), 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.

Definition at line 94 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.

Definition at line 123 of file Effect.cpp.

125{
126 Parameters().Get( *this, settings, parms );
127 return true;
128}
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 209 of file Effect.cpp.

211{
214 S.mpEap = &eap;
215 if( VisitSettings( S, settings ) ){
216 ;// got eap value using VisitSettings.
217 }
218 // Won't be needed in future
219 else if (!SaveSettings(settings, eap))
220 {
221 return false;
222 }
223
224 return eap.GetParameters(parms);
225}
bool GetParameters(wxString &parms)
bool SaveSettings(const EffectSettings &settings, CommandParameters &parms) const override
Store settings as keys and values.
Definition: Effect.cpp:123
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.

Definition at line 151 of file Effect.cpp.

153{
154 // Save all settings as a single string value in the registry
155 wxString parms;
156 if (!SaveSettingsAsString(settings, parms))
157 return false;
158
160 name, wxT("Parameters"), parms);
161}
bool SaveSettingsAsString(const EffectSettings &settings, wxString &parms) const override
Definition: Effect.cpp:209
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 307 of file Effect.cpp.

308{
309 mIsBatch = true;
310 // Save effect's internal state in a special registry path
311 // just for this purpose
312 // If effect is not stateful, this step doesn't really matter, and the
313 // settings object is a dummy
314 auto dummySettings = MakeSettings();
315 SaveUserPreset(GetSavedStateGroup(), dummySettings);
316}
bool SaveUserPreset(const RegistryPath &name, const EffectSettings &settings) const override
Save settings in the configuration file as a user-named preset.
Definition: Effect.cpp:151
wxString GetSavedStateGroup()
Definition: Effect.cpp:202
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.

Definition at line 99 of file Effect.cpp.

100{
101 return true;
102}

◆ TestUIFlags()

unsigned Effect::TestUIFlags ( unsigned  mask)

Definition at line 298 of file Effect.cpp.

298 {
299 return mask & mUIFlags;
300}

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 338 of file Effect.cpp.

339{
340 auto updateResult = (mProgress ?
341 mProgress->Poll(frac * 1000, 1000, msg) :
343 return (updateResult != BasicUI::ProgressResult::Success);
344}
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:104

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

Referenced by EffectNormalize::AnalyseTrackData(), EffectTruncSilence::Analyze(), EffectAutoDuck::ApplyDuckFade(), EffectTruncSilence::DoRemoval(), NyquistEffect::GetCallback(), EffectAutoDuck::Process(), EffectStereoToMono::ProcessOne(), EffectNormalize::ProcessOne(), EffectTwoPassSimpleMono::ProcessOne(), NyquistEffect::PutCallback(), 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 356 of file Effect.cpp.

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

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 346 of file Effect.cpp.

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

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

Referenced by BlockGenerator::GenerateTrack(), EffectRepeat::Process(), EffectSBSMS::Process(), VampEffect::Process(), NyquistEffect::ProcessOne(), EffectEqualization::ProcessOne(), EffectClickRemoval::ProcessOne(), EffectNoiseRemoval::ProcessOne(), EffectRepair::ProcessOne(), EffectFindClipping::ProcessOne(), EffectChangeSpeed::ProcessOne(), EffectSimpleMono::ProcessOne(), EffectPaulstretch::ProcessOne(), EffectReverse::ProcessOneClip(), 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 318 of file Effect.cpp.

319{
320 mIsBatch = false;
321 // Restore effect's internal state from registry
322 // If effect is not stateful, this call doesn't really matter, and the
323 // settings object is a dummy
324 auto dummySettings = MakeSettings();
325 // Ignore failure
326 (void ) LoadUserPreset(GetSavedStateGroup(), dummySettings);
327}

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 116 of file Effect.cpp.

118{
119 Parameters().Visit(*this, visitor, settings);
120 return true;
121}
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 110 of file Effect.cpp.

111{
112 Parameters().Visit(*this, visitor, settings);
113 return true;
114}

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 159 of file Effect.h.

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


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