Audacity 3.2.0
Classes | Public Types | Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
EffectManager Class Reference

EffectManager is the class that handles effects and effect categories. More...

#include <EffectManager.h>

Collaboration diagram for EffectManager:
[legend]

Classes

struct  UnsetBatchProcessing
 A custom deleter for std::unique_ptr. More...
 

Public Types

enum  : unsigned {
  kNone = 0x00 , kConfigured = 0x01 , kSkipState = 0x02 , kDontRepeatLast = 0x04 ,
  kRepeatGen = 0x08 , kRepeatNyquistPrompt = 0x10
}
 

Public Member Functions

 EffectManager ()
 
virtual ~EffectManager ()
 
const PluginIDRegisterEffect (std::unique_ptr< EffectPlugin > uEffect)
 Here solely for the purpose of Nyquist Workbench until a better solution is devised. More...
 
void UnregisterEffect (const PluginID &ID)
 Used only by Nyquist Workbench module. More...
 
TranslatableString GetEffectFamilyName (const PluginID &ID)
 
TranslatableString GetVendorName (const PluginID &ID)
 
bool DoAudacityCommand (const PluginID &ID, const CommandContext &, wxWindow *parent, bool shouldPrompt=true)
 
ComponentInterfaceSymbol GetCommandSymbol (const PluginID &ID)
 
TranslatableString GetCommandName (const PluginID &ID)
 
CommandID GetCommandIdentifier (const PluginID &ID)
 
TranslatableString GetCommandDescription (const PluginID &ID)
 
ManualPageID GetCommandUrl (const PluginID &ID)
 
TranslatableString GetCommandTip (const PluginID &ID)
 
void GetCommandDefinition (const PluginID &ID, const CommandContext &context, int flags)
 
bool IsHidden (const PluginID &ID)
 
bool SupportsAutomation (const PluginID &ID)
 
wxString GetEffectParameters (const PluginID &ID)
 
bool SetEffectParameters (const PluginID &ID, const wxString &params)
 
bool PromptUser (const PluginID &ID, const EffectDialogFactory &factory, wxWindow &parent)
 Shows an effect or command dialog so the user can specify settings for later. More...
 
bool HasPresets (const PluginID &ID)
 
wxString GetPreset (const PluginID &ID, const wxString &params, wxWindow *parent)
 
wxString GetDefaultPreset (const PluginID &ID)
 
BatchProcessingScope SetBatchProcessing (const PluginID &ID)
 Begin a scope that ends when the returned object is destroyed. More...
 
void SetSkipStateFlag (bool flag)
 
bool GetSkipStateFlag ()
 
const PluginIDGetEffectByIdentifier (const CommandID &strTarget)
 
EffectPluginGetEffect (const PluginID &ID)
 
EffectSettingsGetDefaultSettings (const PluginID &ID)
 
std::pair< EffectPlugin *, EffectSettings * > GetEffectAndDefaultSettings (const PluginID &ID)
 

Static Public Member Functions

static const EffectInstanceFactoryGetInstanceFactory (const PluginID &ID)
 
static EffectManagerGet ()
 

Private Types

using BatchProcessingScope = std::unique_ptr< EffectManager, UnsetBatchProcessing >
 

Private Member Functions

void BatchProcessingOn (const PluginID &ID)
 
void BatchProcessingOff (const PluginID &ID)
 
EffectAndDefaultSettingsDoGetEffect (const PluginID &ID)
 
AudacityCommandGetAudacityCommand (const PluginID &ID)
 

Private Attributes

EffectMap mEffects
 
AudacityCommandMap mCommands
 
EffectOwnerMap mHostEffects
 
int mNumEffects
 
bool mSkipStateFlag
 

Detailed Description

EffectManager is the class that handles effects and effect categories.

It maintains a graph of effect categories and subcategories, registers and unregisters effects and can return filtered lists of effects.

Definition at line 47 of file EffectManager.h.

Member Typedef Documentation

◆ BatchProcessingScope

Definition at line 131 of file EffectManager.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum : unsigned
Enumerator
kNone 
kConfigured 
kSkipState 
kDontRepeatLast 
kRepeatGen 
kRepeatNyquistPrompt 

Definition at line 51 of file EffectManager.h.

51 : unsigned {
52 // No flags specified
53 kNone = 0x00,
54 // Flag used to disable prompting for configuration parameteres.
55 kConfigured = 0x01,
56 // Flag used to disable saving the state after processing.
57 kSkipState = 0x02,
58 // Flag used to disable "Repeat Last Effect"
59 kDontRepeatLast = 0x04,
60 // Flag used to disable "Select All during Repeat Generator Effect"
61 kRepeatGen = 0x08,
62 // Flag used for repeating Nyquist Prompt
64 };

Constructor & Destructor Documentation

◆ EffectManager()

EffectManager::EffectManager ( )

Definition at line 49 of file EffectManager.cpp.

50{
51 mSkipStateFlag = false;
52}

References mSkipStateFlag.

◆ ~EffectManager()

EffectManager::~EffectManager ( )
virtual

Definition at line 54 of file EffectManager.cpp.

55{
56}

Member Function Documentation

◆ BatchProcessingOff()

void EffectManager::BatchProcessingOff ( const PluginID ID)
private

Definition at line 752 of file EffectManager.cpp.

753{
754 if (auto effect = GetEffect(ID))
755 effect->UnsetBatchProcessing();
756 else if (auto command = GetAudacityCommand(ID))
757 command->SetBatchProcessing(false);
758}
AudacityCommand * GetAudacityCommand(const PluginID &ID)
EffectPlugin * GetEffect(const PluginID &ID)

References GetAudacityCommand(), and GetEffect().

Referenced by EffectManager::UnsetBatchProcessing::operator()().

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

◆ BatchProcessingOn()

void EffectManager::BatchProcessingOn ( const PluginID ID)
private

Definition at line 744 of file EffectManager.cpp.

745{
746 if (auto effect = GetEffect(ID))
747 effect->SetBatchProcessing();
748 else if (auto command = GetAudacityCommand(ID))
749 command->SetBatchProcessing(true);
750}

References GetAudacityCommand(), and GetEffect().

Here is the call graph for this function:

◆ DoAudacityCommand()

bool EffectManager::DoAudacityCommand ( const PluginID ID,
const CommandContext context,
wxWindow *  parent,
bool  shouldPrompt = true 
)

Run a command given the plugin ID

Definition at line 79 of file EffectManager.cpp.

84{
85 this->SetSkipStateFlag(false);
87
88 if (!command)
89 {
90 return false;
91 }
92
93 bool res = command->DoAudacityCommand(parent, context, shouldPrompt);
94
95 return res;
96}
Base class for command in Audacity.
bool DoAudacityCommand(wxWindow *parent, const CommandContext &context, bool shouldPrompt=true)
void SetSkipStateFlag(bool flag)

References AudacityCommand::DoAudacityCommand(), GetAudacityCommand(), and SetSkipStateFlag().

Referenced by MacroCommands::DoAudacityCommand().

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

◆ DoGetEffect()

EffectAndDefaultSettings & EffectManager::DoGetEffect ( const PluginID ID)
private

Definition at line 814 of file EffectManager.cpp.

815{
816 static EffectAndDefaultSettings empty;
817
818 // Must have a "valid" ID
819 if (ID.empty())
820 return empty;
821
822 // If it is actually a command then refuse it (as an effect).
823 if( mCommands.find( ID ) != mCommands.end() )
824 return empty;
825
826 if (auto iter = mEffects.find(ID); iter != mEffects.end())
827 return iter->second;
828 else {
829 // This will instantiate the effect client if it hasn't already been done
830 auto [component, settings] = LoadComponent(ID);
831 if (!component)
832 return empty;
833
834 if (auto effect = dynamic_cast<EffectPlugin *>(component))
835 return (mEffects[ID] = { effect, std::move(settings) });
836 else if (auto client = dynamic_cast<EffectUIClientInterface *>(component)) {
837 // Nothing inherits EffectUIClientInterface now that does not also
838 // inherit EffectPlugin
839 wxASSERT(false);
840 return empty;
841 }
842 else {
843 if ( !dynamic_cast<AudacityCommand *>(component) )
845 XO(
846"Attempting to initialize the following effect failed:\n\n%s\n\nMore information may be available in 'Help > Diagnostics > Show Log'")
847 .Format( GetCommandName(ID) ),
848 XO("Effect failed to initialize"));
849
850 return empty;
851 }
852 }
853}
int AudacityMessageBox(const TranslatableString &message, const TranslatableString &caption, long style, wxWindow *parent, int x, int y)
#define XO(s)
Definition: Internat.h:31
static Settings & settings()
Definition: TrackInfo.cpp:87
EffectMap mEffects
TranslatableString GetCommandName(const PluginID &ID)
AudacityCommandMap mCommands
Factory of instances of an effect and of dialogs to control them.
Definition: EffectPlugin.h:52
EffectUIClientInterface is an abstract base class to populate a UI and validate UI values....
Abstract base class used in importing a file.
std::pair< ComponentInterface *, EffectSettings > LoadComponent(const PluginID &ID)

References AudacityMessageBox(), GetCommandName(), anonymous_namespace{EffectManager.cpp}::LoadComponent(), mCommands, mEffects, settings(), and XO.

Referenced by GetEffect(), and GetEffectAndDefaultSettings().

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

◆ Get()

EffectManager & EffectManager::Get ( )
static

Get the singleton instance of the EffectManager. Probably not safe for multi-thread use.

Definition at line 43 of file EffectManager.cpp.

44{
45 static EffectManager em;
46 return em;
47}
EffectManager is the class that handles effects and effect categories.
Definition: EffectManager.h:48

Referenced by anonymous_namespace{PluginMenus.cpp}::AddGroupedEffectMenuItems(), anonymous_namespace{PluginMenus.cpp}::AddSortedEffectMenuItems(), anonymous_namespace{PluginMenus.cpp}::AnalyzeMenu(), MacroCommands::ApplyCommand(), MacroCommands::ApplyEffectCommand(), HelpCommand::ApplyInner(), anonymous_namespace{PluginMenus.cpp}::CompareEffectsByPublisher(), anonymous_namespace{PluginMenus.cpp}::CompareEffectsByPublisherAndName(), anonymous_namespace{PluginMenus.cpp}::CompareEffectsByType(), anonymous_namespace{PluginMenus.cpp}::CompareEffectsByTypeAndName(), MacroCommands::DoAudacityCommand(), EffectUI::DoEffect(), anonymous_namespace{PluginMenus.cpp}::EffectMenu(), anonymous_namespace{PluginMenus.cpp}::GenerateMenu(), MacroCommands::GetCurrentParamsFor(), GetInstanceFactory(), HandleTextualCommand(), anonymous_namespace{PluginMenus.cpp}::IsEnabledPlugin(), MacroCommandsCatalog::MacroCommandsCatalog(), PluginActions::Handler::OnApplyMacroDirectlyByName(), PluginActions::Handler::OnAudacityCommand(), EffectNoiseReduction::Dialog::OnGetProfile(), NyqBench::OnGo(), MacroCommandDialog::OnItemSelected(), anonymous_namespace{RealtimeEffectPanel.cpp}::RealtimeEffectControl::OnOptionsClicked(), TrackActions::Handler::OnStereoToMono(), NyquistEffect::Process(), MacroCommands::PromptForParamsFor(), MacroCommands::PromptForPresetFor(), GetInfoCommand::SendCommands(), MacroCommandDialog::SetCommandAndParams(), anonymous_namespace{PluginMenus.cpp}::ToolsMenu(), and anonymous_namespace{TrackMenus.cpp}::TracksMenu().

Here is the caller graph for this function:

◆ GetAudacityCommand()

AudacityCommand * EffectManager::GetAudacityCommand ( const PluginID ID)
private

Definition at line 855 of file EffectManager.cpp.

856{
857 // Must have a "valid" ID
858 if (ID.empty())
859 {
860 return NULL;
861 }
862
863 if (mCommands.find(ID) == mCommands.end()) {
864 // This will instantiate the command if it hasn't already been done
865 auto command =
866 dynamic_cast<AudacityCommand *>(PluginManager::Get().Load(ID));
867 if (command)
868 {
869 command->Init();
870 mCommands[ID] = command;
871 return command;
872 }
873
875 XO(
876"Attempting to initialize the following command failed:\n\n%s\n\nMore information may be available in 'Help > Diagnostics > Show Log'")
877 .Format( GetCommandName(ID) ),
878 XO("Command failed to initialize"));
879
880 return NULL;
881 }
882
883 return mCommands[ID];
884}
virtual bool Init()
ComponentInterface * Load(const PluginID &ID)
static PluginManager & Get()

References AudacityMessageBox(), PluginManager::Get(), GetCommandName(), AudacityCommand::Init(), PluginManager::Load(), mCommands, and XO.

Referenced by BatchProcessingOff(), BatchProcessingOn(), DoAudacityCommand(), GetCommandDefinition(), GetCommandDescription(), GetCommandTip(), GetCommandUrl(), GetEffectParameters(), PromptUser(), and SetEffectParameters().

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

◆ GetCommandDefinition()

void EffectManager::GetCommandDefinition ( const PluginID ID,
const CommandContext context,
int  flags 
)

Definition at line 169 of file EffectManager.cpp.

170{
171 const EffectSettingsManager *effect = nullptr;
173 AudacityCommand *command = nullptr;
174
175 if (auto [edi, pSettings] = GetEffectAndDefaultSettings(ID); edi) {
176 effect = &edi->GetDefinition();
177 assert(pSettings); // postcondition
178 settings = pSettings;
179 }
180 else
181 command = GetAudacityCommand( ID );
182 if ( !effect && !command )
183 return;
184
185 ConstSettingsVisitor NullShuttle;
186
187 // Test if it defines any parameters at all.
188 bool bHasParams = command
189 ? command->VisitSettings( NullShuttle )
190 : effect->VisitSettings( NullShuttle, *settings );
191 if ( (flags == 0) && !bHasParams )
192 return;
193
194 // This is capturing the output context into the shuttle.
195 ShuttleGetDefinition S( *context.pOutput.get()->mStatusTarget.get() );
196 S.StartStruct();
197 // using GET to expose a CommandID to the user!
198 // Macro command details are one place that we do expose Identifier
199 // to (more sophisticated) users
200 S.AddItem( GetCommandIdentifier( ID ).GET(), "id" );
201 S.AddItem( GetCommandName( ID ).Translation(), "name" );
202 if ( bHasParams ) {
203 S.StartField( "params" );
204 S.StartArray();
205 command
206 ? command->VisitSettings( S )
207 : effect->VisitSettings( S, *settings );
208 S.EndArray();
209 S.EndField();
210 }
211 // use GET() to expose some details to macro programming users
212 S.AddItem( GetCommandUrl( ID ).GET(), "url" );
213 // The tip is a translated string!
214 S.AddItem( GetCommandTip( ID ).Translation(), "tip" );
215 S.EndStruct();
216}
#define S(N)
Definition: ToChars.cpp:64
virtual bool VisitSettings(SettingsVisitor &)
std::unique_ptr< CommandOutputTargets > pOutput
ManualPageID GetCommandUrl(const PluginID &ID)
CommandID GetCommandIdentifier(const PluginID &ID)
std::pair< EffectPlugin *, EffectSettings * > GetEffectAndDefaultSettings(const PluginID &ID)
TranslatableString GetCommandTip(const PluginID &ID)
EffectSettingsManager is an EffectDefinitionInterface that adds a factory function for EffectSettings...
virtual bool VisitSettings(SettingsVisitor &visitor, EffectSettings &settings)
Visitor of effect or command parameters. This is a base class with lots of virtual functions that do ...
Definition: Shuttle.h:115
SettingsVisitor that retrieves a JSON format definition of a command's parameters.
Externalized state of a plug-in.

References GetAudacityCommand(), GetCommandIdentifier(), GetCommandName(), GetCommandTip(), GetCommandUrl(), GetEffectAndDefaultSettings(), CommandContext::pOutput, S, settings(), AudacityCommand::VisitSettings(), and EffectSettingsManager::VisitSettings().

Referenced by HelpCommand::ApplyInner(), and GetInfoCommand::SendCommands().

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

◆ GetCommandDescription()

TranslatableString EffectManager::GetCommandDescription ( const PluginID ID)

Definition at line 136 of file EffectManager.cpp.

137{
138 if (GetEffect(ID))
139 return XO("Applied effect: %s").Format( GetCommandName(ID) );
140 if (GetAudacityCommand(ID))
141 return XO("Applied command: %s").Format( GetCommandName(ID) );
142
143 return {};
144}

References GetAudacityCommand(), GetCommandName(), GetEffect(), and XO.

Referenced by EffectUI::DoEffect().

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

◆ GetCommandIdentifier()

CommandID EffectManager::GetCommandIdentifier ( const PluginID ID)

Definition at line 130 of file EffectManager.cpp.

131{
134}
const TranslatableString name
Definition: Distortion.cpp:82
const wxString & Internal() const
static Identifier GetSquashedName(const Identifier &ident)
A utility that strips spaces and CamelCases a name.
const ComponentInterfaceSymbol & GetSymbol(const PluginID &ID)

References PluginManager::Get(), EffectDefinitionInterface::GetSquashedName(), PluginManager::GetSymbol(), ComponentInterfaceSymbol::Internal(), and name.

Referenced by GetCommandDefinition(), GetEffectByIdentifier(), HandleTextualCommand(), MacroCommandsCatalog::MacroCommandsCatalog(), and GetInfoCommand::SendCommands().

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

◆ GetCommandName()

TranslatableString EffectManager::GetCommandName ( const PluginID ID)

Definition at line 103 of file EffectManager.cpp.

104{
105 return GetCommandSymbol(ID).Msgid();
106}
const TranslatableString & Msgid() const
ComponentInterfaceSymbol GetCommandSymbol(const PluginID &ID)

References GetCommandSymbol(), and ComponentInterfaceSymbol::Msgid().

Referenced by EffectUI::DoEffect(), DoGetEffect(), GetAudacityCommand(), GetCommandDefinition(), GetCommandDescription(), and PluginActions::Handler::OnApplyMacroDirectlyByName().

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

◆ GetCommandSymbol()

ComponentInterfaceSymbol EffectManager::GetCommandSymbol ( const PluginID ID)

Definition at line 98 of file EffectManager.cpp.

99{
100 return PluginManager::Get().GetSymbol(ID);
101}

References PluginManager::Get(), and PluginManager::GetSymbol().

Referenced by GetCommandName().

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

◆ GetCommandTip()

TranslatableString EffectManager::GetCommandTip ( const PluginID ID)

Definition at line 157 of file EffectManager.cpp.

158{
159 if (auto pEff = GetEffect(ID))
160 return pEff->GetDefinition().GetDescription();
162 if( pCom )
163 return pCom->GetDescription();
164
165 return {};
166}
virtual TranslatableString GetDescription() const override

References GetAudacityCommand(), AudacityCommand::GetDescription(), and GetEffect().

Referenced by GetCommandDefinition().

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

◆ GetCommandUrl()

ManualPageID EffectManager::GetCommandUrl ( const PluginID ID)

Definition at line 146 of file EffectManager.cpp.

147{
148 if (auto pEff = GetEffect(ID))
149 return pEff->GetDefinition().ManualPage();
151 if( pCom )
152 return pCom->ManualPage();
153
154 return wxEmptyString;
155}
virtual ManualPageID ManualPage()

References GetAudacityCommand(), GetEffect(), and AudacityCommand::ManualPage().

Referenced by GetCommandDefinition().

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

◆ GetDefaultPreset()

wxString EffectManager::GetDefaultPreset ( const PluginID ID)

Definition at line 714 of file EffectManager.cpp.

715{
716 auto effect = GetEffect(ID);
717
718 if (!effect)
719 {
720 return wxEmptyString;
721 }
722
723 wxString preset;
724 if (HasCurrentSettings(*effect))
725 {
727 }
728 else if (HasFactoryDefaults(*effect))
729 {
731 }
732
733 if (!preset.empty())
734 {
736
737 eap.Write(wxT("Use Preset"), preset);
739 }
740
741 return preset;
742}
static bool HasFactoryDefaults(EffectPlugin &host)
static bool HasCurrentSettings(EffectPlugin &host)
EffectReverbSettings preset
Definition: Reverb.cpp:46
CommandParameters, derived from wxFileConfig, is essentially doing the same things as the SettingsVis...
bool GetParameters(wxString &parms)
static const wxString kCurrentSettingsIdent
Definition: EffectPlugin.h:58
static const wxString kFactoryDefaultsIdent
Definition: EffectPlugin.h:59

References GetEffect(), CommandParameters::GetParameters(), HasCurrentSettings(), HasFactoryDefaults(), EffectPlugin::kCurrentSettingsIdent, EffectPlugin::kFactoryDefaultsIdent, and preset.

Referenced by GetEffectParameters(), and MacroCommandDialog::OnItemSelected().

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

◆ GetDefaultSettings()

EffectSettings * EffectManager::GetDefaultSettings ( const PluginID ID)

Get default settings by effect ID. May return nullptr

Definition at line 765 of file EffectManager.cpp.

766{
767 return GetEffectAndDefaultSettings(ID).second;
768}

References GetEffectAndDefaultSettings().

Referenced by EffectUI::DoEffect(), and PromptUser().

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

◆ GetEffect()

EffectPlugin * EffectManager::GetEffect ( const PluginID ID)

Return an effect by its ID.

Definition at line 760 of file EffectManager.cpp.

761{
762 return DoGetEffect(ID).effect;
763}
EffectAndDefaultSettings & DoGetEffect(const PluginID &ID)

References DoGetEffect(), and EffectAndDefaultSettings::effect.

Referenced by BatchProcessingOff(), BatchProcessingOn(), EffectUI::DoEffect(), GetCommandDescription(), GetCommandTip(), GetCommandUrl(), GetDefaultPreset(), GetEffectFamilyName(), GetInstanceFactory(), GetPreset(), GetVendorName(), HasPresets(), IsHidden(), anonymous_namespace{RealtimeEffectPanel.cpp}::RealtimeEffectControl::OnOptionsClicked(), and PromptUser().

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

◆ GetEffectAndDefaultSettings()

std::pair< EffectPlugin *, EffectSettings * > EffectManager::GetEffectAndDefaultSettings ( const PluginID ID)

Get effect and default settings by effect ID.

Postcondition
result: !result.first || result.second (if first member is not null, then the second is not null)

Definition at line 771 of file EffectManager.cpp.

772{
773 auto &results = DoGetEffect(ID);
774 if (results.effect)
775 return {results.effect, &results.settings};
776 else
777 return {nullptr, nullptr};
778}

References DoGetEffect().

Referenced by GetCommandDefinition(), GetDefaultSettings(), GetEffectParameters(), and SetEffectParameters().

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

◆ GetEffectByIdentifier()

const PluginID & EffectManager::GetEffectByIdentifier ( const CommandID strTarget)

Definition at line 887 of file EffectManager.cpp.

888{
889 static PluginID empty;
890 if (strTarget.empty()) // set GetCommandIdentifier to wxT("") to not show an effect in Batch mode
891 {
892 return empty;
893 }
894
896 // Effects OR Generic commands...
897 for (auto &plug
899 auto &ID = plug.GetID();
900 if (GetCommandIdentifier(ID) == strTarget)
901 return ID;
902 }
903 return empty;
904}
wxString PluginID
Definition: EffectManager.h:30
@ PluginTypeAudacityCommand
@ PluginTypeEffect
bool empty() const
Definition: Identifier.h:61
PluginManager maintains a list of all plug ins. That covers modules, effects, generators,...
Definition: PluginManager.h:41
Range PluginsOfType(int type)

References Identifier::empty(), PluginManager::Get(), GetCommandIdentifier(), PluginManager::PluginsOfType(), PluginTypeAudacityCommand, and PluginTypeEffect.

Referenced by MacroCommands::ApplyCommand(), HelpCommand::ApplyInner(), MacroCommands::GetCurrentParamsFor(), MacroCommandDialog::OnItemSelected(), MacroCommands::PromptForParamsFor(), MacroCommands::PromptForPresetFor(), MacroCommandDialog::SetCommandAndParams(), and anonymous_namespace{TrackMenus.cpp}::TracksMenu().

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

◆ GetEffectFamilyName()

TranslatableString EffectManager::GetEffectFamilyName ( const PluginID ID)

Definition at line 108 of file EffectManager.cpp.

109{
110 if(auto description = PluginManager::Get().GetPlugin(ID))
111 return TranslatableString { description->GetEffectFamily(), {} };
112
113 auto effect = GetEffect(ID);
114 if (effect)
115 return effect->GetDefinition().GetFamily().Msgid();
116 return {};
117}
Holds a msgid for the translation catalog; may also bind format arguments.

References PluginManager::Get(), and GetEffect().

Referenced by anonymous_namespace{PluginMenus.cpp}::AddGroupedEffectMenuItems(), and anonymous_namespace{PluginMenus.cpp}::AddSortedEffectMenuItems().

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

◆ GetEffectParameters()

wxString EffectManager::GetEffectParameters ( const PluginID ID)

Definition at line 249 of file EffectManager.cpp.

250{
251 auto pair = GetEffectAndDefaultSettings(ID);
252 if (auto effect = pair.first) {
253 assert(pair.second); // postcondition
254 wxString parms;
255
256 effect->SaveSettingsAsString(*pair.second, parms);
257
258 // Some effects don't have automatable parameters and will not return
259 // anything, so try to get the active preset (current or factory).
260 if (parms.empty())
261 {
262 parms = GetDefaultPreset(ID);
263 }
264
265 return parms;
266 }
267
268 AudacityCommand *command = GetAudacityCommand(ID);
269
270 if (command)
271 {
272 wxString parms;
273
274 command->SaveSettingsAsString(parms);
275
276 // Some effects don't have automatable parameters and will not return
277 // anything, so try to get the active preset (current or factory).
278 if (parms.empty())
279 {
280 parms = GetDefaultPreset(ID);
281 }
282
283 return parms;
284 }
285 return wxEmptyString;
286}
bool SaveSettingsAsString(wxString &parms)
wxString GetDefaultPreset(const PluginID &ID)

References GetAudacityCommand(), GetDefaultPreset(), GetEffectAndDefaultSettings(), and AudacityCommand::SaveSettingsAsString().

Referenced by MacroCommands::GetCurrentParamsFor(), and MacroCommands::PromptForParamsFor().

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

◆ GetInstanceFactory()

const EffectInstanceFactory * EffectManager::GetInstanceFactory ( const PluginID ID)
static

Find the singleton EffectInstanceFactory for ID.

Definition at line 907 of file EffectManager.cpp.

908{
909 return Get().GetEffect(ID);
910}
static EffectManager & Get()

References Get(), and GetEffect().

Here is the call graph for this function:

◆ GetPreset()

wxString EffectManager::GetPreset ( const PluginID ID,
const wxString &  params,
wxWindow *  parent 
)

Definition at line 668 of file EffectManager.cpp.

669{
670 auto effect = GetEffect(ID);
671
672 if (!effect)
673 {
674 return wxEmptyString;
675 }
676
678
679 wxString preset;
680 if (eap.HasEntry(wxT("Use Preset")))
681 {
682 preset = eap.Read(wxT("Use Preset"));
683 }
684
685 {
686 EffectPresetsDialog dlg(parent, effect);
687 dlg.Layout();
688 dlg.Fit();
689 dlg.SetSize(dlg.GetMinSize());
690 dlg.CenterOnParent();
691 dlg.SetSelected(preset);
692
693 if (dlg.ShowModal())
694 preset = dlg.GetSelected();
695 else
696 preset = wxEmptyString;
697 }
698
699 if (preset.empty())
700 {
701 return preset;
702 }
703
704 // This cleans a config "file" backed by a string in memory.
705 eap.DeleteAll();
706
707 eap.Write(wxT("Use Preset"), preset);
708 eap.GetParameters(preset);
709
710 return preset;
711}
EffectDistortion::Params params
Definition: Distortion.cpp:83

References GetEffect(), CommandParameters::GetParameters(), CommandParameters::HasEntry(), params, and preset.

Referenced by MacroCommands::PromptForPresetFor().

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

◆ GetSkipStateFlag()

bool EffectManager::GetSkipStateFlag ( )

Definition at line 232 of file EffectManager.cpp.

233{
234 return mSkipStateFlag;
235}

References mSkipStateFlag.

Referenced by EffectUI::DoEffect().

Here is the caller graph for this function:

◆ GetVendorName()

TranslatableString EffectManager::GetVendorName ( const PluginID ID)

Definition at line 119 of file EffectManager.cpp.

120{
121 if(auto description = PluginManager::Get().GetPlugin(ID))
122 return TranslatableString { description->GetVendor(), {} };
123
124 auto effect = GetEffect(ID);
125 if (effect)
126 return effect->GetDefinition().GetVendor().Msgid();
127 return {};
128}

References PluginManager::Get(), and GetEffect().

Referenced by anonymous_namespace{PluginMenus.cpp}::AddGroupedEffectMenuItems(), and anonymous_namespace{PluginMenus.cpp}::AddSortedEffectMenuItems().

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

◆ HasPresets()

bool EffectManager::HasPresets ( const PluginID ID)

Definition at line 380 of file EffectManager.cpp.

381{
382 auto effect = GetEffect(ID);
383
384 if (!effect)
385 {
386 return false;
387 }
388
389 return GetUserPresets(*effect).size() > 0 ||
390 effect->GetDefinition().GetFactoryPresets().size() > 0 ||
391 HasCurrentSettings(*effect) ||
392 HasFactoryDefaults(*effect);
393}
static RegistryPaths GetUserPresets(EffectPlugin &host)

References GetEffect(), GetUserPresets(), HasCurrentSettings(), and HasFactoryDefaults().

Referenced by MacroCommandDialog::OnItemSelected(), and MacroCommandDialog::SetCommandAndParams().

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

◆ IsHidden()

bool EffectManager::IsHidden ( const PluginID ID)

Definition at line 220 of file EffectManager.cpp.

221{
222 if(auto effect = GetEffect(ID))
223 return effect->GetDefinition().IsHiddenFromMenus();
224 return false;
225}

References GetEffect().

Referenced by anonymous_namespace{PluginMenus.cpp}::IsEnabledPlugin().

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

◆ PromptUser()

bool EffectManager::PromptUser ( const PluginID ID,
const EffectDialogFactory factory,
wxWindow &  parent 
)

Shows an effect or command dialog so the user can specify settings for later.

It is used when defining a macro. It does not invoke the effect or command.

Show the effect dialog, only so that the user can choose settings, for instance to define a macro.

Definition at line 331 of file EffectManager.cpp.

333{
334 bool result = false;
335 if (auto effect = GetEffect(ID)) {
336 std::shared_ptr<EffectInstance> pInstance;
339 if (const auto pSettings = GetDefaultSettings(ID))
340 result = effect->ShowHostInterface(
341 parent, factory,
342 pInstance,
343 *std::make_shared<SimpleEffectSettingsAccess>(*pSettings),
344 effect->IsBatchProcessing() ) != 0;
345 return result;
346 }
347
348 AudacityCommand *command = GetAudacityCommand(ID);
349
350 if (command)
351 {
352 result = command->PromptUser(&parent);
353 return result;
354 }
355
356 return result;
357}
static RegisteredToolbarFactory factory
virtual bool PromptUser(wxWindow *parent)
EffectSettings * GetDefaultSettings(const PluginID &ID)

References factory, GetAudacityCommand(), GetDefaultSettings(), GetEffect(), and AudacityCommand::PromptUser().

Here is the call graph for this function:

◆ RegisterEffect()

const PluginID & EffectManager::RegisterEffect ( std::unique_ptr< EffectPlugin uEffect)

Here solely for the purpose of Nyquist Workbench until a better solution is devised.

Register an effect so it can be executed. uEffect is expected to be a self-hosting Nyquist effect

Definition at line 60 of file EffectManager.cpp.

62{
63 auto pEffect = uEffect.get();
64 const PluginID & ID =
66 mEffects[ID] = { pEffect, {} };
67 return ID;
68}
void RegisterPlugin(PluginDescriptor &&desc)

References PluginManager::Get(), mEffects, PluginTypeEffect, and PluginManager::RegisterPlugin().

Referenced by NyqBench::OnGo().

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

◆ SetBatchProcessing()

BatchProcessingScope EffectManager::SetBatchProcessing ( const PluginID ID)
inline

Begin a scope that ends when the returned object is destroyed.

Within this scope, "batch" (i.e. macro) processing happens, and Effects that are not yet stateless may change their state temporarily, but it is restored afterward

Definition at line 140 of file EffectManager.h.

141 {
142 BatchProcessingOn(ID); return BatchProcessingScope{ this, {ID} };
143 }
void BatchProcessingOn(const PluginID &ID)
std::unique_ptr< EffectManager, UnsetBatchProcessing > BatchProcessingScope

Referenced by MacroCommands::ApplyEffectCommand(), anonymous_namespace{RealtimeEffectPanel.cpp}::RealtimeEffectControl::OnOptionsClicked(), and MacroCommands::PromptForParamsFor().

Here is the caller graph for this function:

◆ SetEffectParameters()

bool EffectManager::SetEffectParameters ( const PluginID ID,
const wxString &  params 
)

Definition at line 289 of file EffectManager.cpp.

291{
292 auto pair = GetEffectAndDefaultSettings(ID);
293 if (auto effect = pair.first) {
294 assert(pair.second); // postcondition
295 auto &settings = *pair.second;
297
298 // Check first for what GetDefaultPreset() might have written
299 if (eap.HasEntry(wxT("Use Preset")))
300 {
301 return effect->LoadSettingsFromString(
302 eap.Read(wxT("Use Preset")), settings);
303 }
304
305 return effect->LoadSettingsFromString(params, settings);
306 }
307 AudacityCommand *command = GetAudacityCommand(ID);
308
309 if (command)
310 {
311 // Set defaults (if not initialised) before setting values.
312 command->Init();
314
315 // Check first for what GetDefaultPreset() might have written
316 if (eap.HasEntry(wxT("Use Preset")))
317 {
318 return command
319 ->LoadSettingsFromString(eap.Read(wxT("Use Preset")));
320 }
321
322 return command->LoadSettingsFromString(params);
323 }
324 return false;
325}
bool LoadSettingsFromString(const wxString &parms)

References GetAudacityCommand(), GetEffectAndDefaultSettings(), CommandParameters::HasEntry(), AudacityCommand::Init(), AudacityCommand::LoadSettingsFromString(), params, and settings().

Here is the call graph for this function:

◆ SetSkipStateFlag()

void EffectManager::SetSkipStateFlag ( bool  flag)

Allow effects to disable saving the state at run time

Definition at line 227 of file EffectManager.cpp.

228{
230}
static std::once_flag flag

References flag, and mSkipStateFlag.

Referenced by DoAudacityCommand(), EffectUI::DoEffect(), EffectNoiseReduction::Dialog::OnGetProfile(), and NyquistEffect::Process().

Here is the caller graph for this function:

◆ SupportsAutomation()

bool EffectManager::SupportsAutomation ( const PluginID ID)

Support for batch commands

Definition at line 237 of file EffectManager.cpp.

238{
240 if (plug)
241 {
242 return plug->IsEffectAutomatable();
243 }
244
245 return false;
246}
bool IsEffectAutomatable() const
const PluginDescriptor * GetPlugin(const PluginID &ID) const

References PluginManager::Get(), PluginManager::GetPlugin(), and PluginDescriptor::IsEffectAutomatable().

Here is the call graph for this function:

◆ UnregisterEffect()

void EffectManager::UnregisterEffect ( const PluginID ID)

Used only by Nyquist Workbench module.

Definition at line 72 of file EffectManager.cpp.

73{
74 PluginID id = ID;
76 mEffects.erase(id);
77}
void UnregisterPlugin(const PluginID &ID)

References PluginManager::Get(), mEffects, and PluginManager::UnregisterPlugin().

Referenced by NyqBench::OnGo().

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

Member Data Documentation

◆ mCommands

AudacityCommandMap EffectManager::mCommands
private

Definition at line 171 of file EffectManager.h.

Referenced by DoGetEffect(), and GetAudacityCommand().

◆ mEffects

EffectMap EffectManager::mEffects
private

Definition at line 170 of file EffectManager.h.

Referenced by DoGetEffect(), RegisterEffect(), and UnregisterEffect().

◆ mHostEffects

EffectOwnerMap EffectManager::mHostEffects
private

Definition at line 172 of file EffectManager.h.

◆ mNumEffects

int EffectManager::mNumEffects
private

Definition at line 174 of file EffectManager.h.

◆ mSkipStateFlag

bool EffectManager::mSkipStateFlag
private

Definition at line 178 of file EffectManager.h.

Referenced by EffectManager(), GetSkipStateFlag(), and SetSkipStateFlag().


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