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 764 of file EffectManager.cpp.

765{
766 if (auto effect = GetEffect(ID))
767 effect->UnsetBatchProcessing();
768 else if (auto command = GetAudacityCommand(ID))
769 command->SetBatchProcessing(false);
770}
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 756 of file EffectManager.cpp.

757{
758 if (auto effect = GetEffect(ID))
759 effect->SetBatchProcessing();
760 else if (auto command = GetAudacityCommand(ID))
761 command->SetBatchProcessing(true);
762}

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 CommandDispatch::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 835 of file EffectManager.cpp.

836{
837 static EffectAndDefaultSettings empty;
838
839 // Must have a "valid" ID
840 if (ID.empty())
841 return empty;
842
843 // If it is actually a command then refuse it (as an effect).
844 if( mCommands.find( ID ) != mCommands.end() )
845 return empty;
846
847 if (auto iter = mEffects.find(ID); iter != mEffects.end())
848 return iter->second;
849 else {
850 // This will instantiate the effect client if it hasn't already been done
851 auto [component, settings] = LoadComponent(ID);
852 if (!component)
853 return empty;
854
855 if (auto effect = dynamic_cast<EffectPlugin *>(component))
856 return (mEffects[ID] = { effect, std::move(settings) });
857 else if (auto client = dynamic_cast<EffectUIClientInterface *>(component)) {
858 // Nothing inherits EffectUIClientInterface now that does not also
859 // inherit EffectPlugin
860 wxASSERT(false);
861 return empty;
862 }
863 else {
864 if ( !dynamic_cast<AudacityCommand *>(component) )
866 XO(
867"Attempting to initialize the following effect failed:\n\n%s\n\nMore information may be available in 'Help > Diagnostics > Show Log'")
868 .Format( GetCommandName(ID) ),
869 XO("Effect failed to initialize"));
870
871 return empty;
872 }
873 }
874}
int AudacityMessageBox(const TranslatableString &message, const TranslatableString &caption, long style, wxWindow *parent, int x, int y)
XO("Cut/Copy/Paste")
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:55
EffectUIClientInterface is an abstract base class to populate a UI and validate UI values....
Definition: EffectPlugin.h:170
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(), CommandDispatch::DoAudacityCommand(), EffectUI::DoEffect(), anonymous_namespace{PluginMenus.cpp}::EffectMenu(), anonymous_namespace{PluginMenus.cpp}::GenerateMenu(), MacroCommands::GetCurrentParamsFor(), GetInstanceFactory(), CommandDispatch::HandleTextualCommand(), anonymous_namespace{PluginMenus.cpp}::IsEnabledPlugin(), MacroCommandsCatalog::MacroCommandsCatalog(), anonymous_namespace{BatchProcessDialog.cpp}::OnApplyMacroDirectlyByName(), CommandDispatch::OnAudacityCommand(), EffectNoiseReduction::Dialog::OnGetProfile(), NyqBench::OnGo(), MacroCommandDialog::OnItemSelected(), anonymous_namespace{RealtimeEffectPanel.cpp}::RealtimeEffectControl::OnOptionsClicked(), anonymous_namespace{TrackMenus.cpp}::OnStereoToMono(), PluginMenuItems(), NyquistEffect::Process(), MacroCommands::PromptForParamsFor(), MacroCommands::PromptForPresetFor(), GetInfoCommand::SendCommands(), MacroCommandDialog::SetCommandAndParams(), RealtimeEffectStateUI::Show(), anonymous_namespace{TrackMenus.cpp}::TracksMenu(), and RealtimeEffectStateUI::UpdateTitle().

Here is the caller graph for this function:

◆ GetAudacityCommand()

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

Definition at line 876 of file EffectManager.cpp.

877{
878 // Must have a "valid" ID
879 if (ID.empty())
880 {
881 return NULL;
882 }
883
884 if (mCommands.find(ID) == mCommands.end()) {
885 // This will instantiate the command if it hasn't already been done
886 auto command =
887 dynamic_cast<AudacityCommand *>(PluginManager::Get().Load(ID));
888 if (command)
889 {
890 command->Init();
891 mCommands[ID] = command;
892 return command;
893 }
894
896 XO(
897"Attempting to initialize the following command failed:\n\n%s\n\nMore information may be available in 'Help > Diagnostics > Show Log'")
898 .Format( GetCommandName(ID) ),
899 XO("Command failed to initialize"));
900
901 return NULL;
902 }
903
904 return mCommands[ID];
905}
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:74
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(), CommandDispatch::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 anonymous_namespace{BatchProcessDialog.cpp}::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 726 of file EffectManager.cpp.

727{
728 auto effect = GetEffect(ID);
729
730 if (!effect)
731 {
732 return wxEmptyString;
733 }
734
735 wxString preset;
736 if (HasCurrentSettings(*effect))
737 {
739 }
740 else if (HasFactoryDefaults(*effect))
741 {
743 }
744
745 if (!preset.empty())
746 {
748
749 eap.Write(wxT("Use Preset"), preset);
751 }
752
753 return preset;
754}
wxT("CloseDown"))
static bool HasFactoryDefaults(EffectPlugin &host)
static bool HasCurrentSettings(EffectPlugin &host)
EffectReverbSettings preset
Definition: Reverb.cpp:45
CommandParameters, derived from wxFileConfig, is essentially doing the same things as the SettingsVis...
bool GetParameters(wxString &parms)
static const wxString kCurrentSettingsIdent
Definition: EffectPlugin.h:61
static const wxString kFactoryDefaultsIdent
Definition: EffectPlugin.h:62

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

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 777 of file EffectManager.cpp.

778{
779 return GetEffectAndDefaultSettings(ID).second;
780}

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 772 of file EffectManager.cpp.

773{
774 return DoGetEffect(ID).effect;
775}
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(), PromptUser(), RealtimeEffectStateUI::Show(), and RealtimeEffectStateUI::UpdateTitle().

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 783 of file EffectManager.cpp.

784{
785 auto &results = DoGetEffect(ID);
786 if (results.effect)
787 return {results.effect, &results.settings};
788 else
789 return {nullptr, nullptr};
790}

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 908 of file EffectManager.cpp.

909{
910 static PluginID empty;
911 if (strTarget.empty()) // set GetCommandIdentifier to wxT("") to not show an effect in Batch mode
912 {
913 return empty;
914 }
915
917 // Effects OR Generic commands...
918 for (auto &plug
920 auto &ID = plug.GetID();
921 if (GetCommandIdentifier(ID) == strTarget)
922 return ID;
923 }
924 return empty;
925}
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:42
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 928 of file EffectManager.cpp.

929{
930 return Get().GetEffect(ID);
931}
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 680 of file EffectManager.cpp.

681{
682 auto effect = GetEffect(ID);
683
684 if (!effect)
685 {
686 return wxEmptyString;
687 }
688
690
691 wxString preset;
692 if (eap.HasEntry(wxT("Use Preset")))
693 {
694 preset = eap.Read(wxT("Use Preset"));
695 }
696
697 {
698 EffectPresetsDialog dlg(parent, effect);
699 dlg.Layout();
700 dlg.Fit();
701 dlg.SetSize(dlg.GetMinSize());
702 dlg.CenterOnParent();
703 dlg.SetSelected(preset);
704
705 if (dlg.ShowModal())
706 preset = dlg.GetSelected();
707 else
708 preset = wxEmptyString;
709 }
710
711 if (preset.empty())
712 {
713 return preset;
714 }
715
716 // This cleans a config "file" backed by a string in memory.
717 eap.DeleteAll();
718
719 eap.Write(wxT("Use Preset"), preset);
720 eap.GetParameters(preset);
721
722 return preset;
723}
EffectDistortionSettings params
Definition: Distortion.cpp:75

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

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 392 of file EffectManager.cpp.

393{
394 auto effect = GetEffect(ID);
395
396 if (!effect)
397 {
398 return false;
399 }
400
401 return GetUserPresets(*effect).size() > 0 ||
402 effect->GetDefinition().GetFactoryPresets().size() > 0 ||
403 HasCurrentSettings(*effect) ||
404 HasFactoryDefaults(*effect);
405}
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
337 auto empty = TrackList::Create(nullptr);
338 auto pEffectBase = dynamic_cast<EffectBase*>(effect);
339 if (pEffectBase)
340 // This allows effects to call Init() safely
341 pEffectBase->SetTracks(empty.get());
342 Finally Do([&]{
343 // reverse the side-effect
344 if (pEffectBase)
345 pEffectBase->SetTracks(nullptr);
346 });
347
348 std::shared_ptr<EffectInstance> pInstance;
351 if (const auto pSettings = GetDefaultSettings(ID))
352 result = effect->ShowHostInterface(
353 parent, factory,
354 pInstance,
355 *std::make_shared<SimpleEffectSettingsAccess>(*pSettings),
356 effect->IsBatchProcessing() ) != 0;
357 return result;
358 }
359
360 AudacityCommand *command = GetAudacityCommand(ID);
361
362 if (command)
363 {
364 result = command->PromptUser(&parent);
365 return result;
366 }
367
368 return result;
369}
virtual bool PromptUser(wxWindow *parent)
Base class for many of the effects in Audacity.
Definition: EffectBase.h:33
void SetTracks(TrackList *pTracks)
Definition: EffectBase.h:38
EffectSettings * GetDefaultSettings(const PluginID &ID)
static std::shared_ptr< TrackList > Create(AudacityProject *pOwner)
Definition: Track.cpp:502
static RegisteredToolbarFactory factory
"finally" as in The C++ Programming Language, 4th ed., p. 358 Useful for defining ad-hoc RAII actions...
Definition: MemoryX.h:173

References TrackList::Create(), cloud::factory, GetAudacityCommand(), GetDefaultSettings(), GetEffect(), AudacityCommand::PromptUser(), and EffectBase::SetTracks().

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(), 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).has_value();
303 }
304
305 return effect->LoadSettingsFromString(params, settings).has_value();
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, settings(), and wxT().

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: