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

49{
50 mSkipStateFlag = false;
51}

References mSkipStateFlag.

◆ ~EffectManager()

EffectManager::~EffectManager ( )
virtual

Definition at line 53 of file EffectManager.cpp.

54{
55}

Member Function Documentation

◆ BatchProcessingOff()

void EffectManager::BatchProcessingOff ( const PluginID ID)
private

Definition at line 765 of file EffectManager.cpp.

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

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

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

83{
84 this->SetSkipStateFlag(false);
86
87 if (!command)
88 {
89 return false;
90 }
91
92 bool res = command->DoAudacityCommand(parent, context, shouldPrompt);
93
94 return res;
95}
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 836 of file EffectManager.cpp.

837{
838 static EffectAndDefaultSettings empty;
839
840 // Must have a "valid" ID
841 if (ID.empty())
842 return empty;
843
844 // If it is actually a command then refuse it (as an effect).
845 if( mCommands.find( ID ) != mCommands.end() )
846 return empty;
847
848 if (auto iter = mEffects.find(ID); iter != mEffects.end())
849 return iter->second;
850 else {
851 // This will instantiate the effect client if it hasn't already been done
852 auto [component, settings] = LoadComponent(ID);
853 if (!component)
854 return empty;
855
856 if (auto effect = dynamic_cast<EffectPlugin *>(component))
857 return (mEffects[ID] = { effect, std::move(settings) });
858 else {
859 if ( !dynamic_cast<AudacityCommand *>(component) )
861 XO(
862"Attempting to initialize the following effect failed:\n\n%s\n\nMore information may be available in 'Help > Diagnostics > Show Log'")
863 .Format( GetCommandName(ID) ),
864 XO("Effect failed to initialize"));
865
866 return empty;
867 }
868 }
869}
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:47
EffectMap mEffects
TranslatableString GetCommandName(const PluginID &ID)
AudacityCommandMap mCommands
Factory of instances of an effect.
Definition: EffectPlugin.h:36
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 42 of file EffectManager.cpp.

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

Referenced by anonymous_namespace{MenuHelper.cpp}::AddGroupedEffectMenuItems(), anonymous_namespace{MenuHelper.cpp}::AddSortedEffectMenuItems(), anonymous_namespace{PluginMenus.cpp}::AnalyzeMenu(), MacroCommands::ApplyCommand(), MacroCommands::ApplyEffectCommand(), HelpCommand::ApplyInner(), anonymous_namespace{MenuHelper.cpp}::ComapareEffectsByTypeAndPublisher(), anonymous_namespace{MenuHelper.cpp}::CompareEffectsByPublisher(), anonymous_namespace{MenuHelper.cpp}::CompareEffectsByPublisherAndName(), anonymous_namespace{MenuHelper.cpp}::CompareEffectsByType(), anonymous_namespace{MenuHelper.cpp}::CompareEffectsByTypeAndName(), CommandDispatch::DoAudacityCommand(), EffectUI::DoEffect(), anonymous_namespace{PluginMenus.cpp}::EffectMenu(), anonymous_namespace{PluginMenus.cpp}::GenerateMenu(), MacroCommands::GetCurrentParamsFor(), GetInstanceFactory(), CommandDispatch::HandleTextualCommand(), anonymous_namespace{MenuHelper.cpp}::IsEnabledPlugin(), MacroCommandsCatalog::MacroCommandsCatalog(), anonymous_namespace{BatchProcessDialog.cpp}::OnApplyMacroDirectlyByName(), CommandDispatch::OnAudacityCommand(), EffectNoiseReduction::Dialog::OnGetProfile(), NyqBench::OnGo(), MacroCommandDialog::OnItemSelected(), MacrosWindow::OnListSelected(), 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 871 of file EffectManager.cpp.

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

169{
170 const EffectSettingsManager *effect = nullptr;
172 AudacityCommand *command = nullptr;
173
174 if (auto [edi, pSettings] = GetEffectAndDefaultSettings(ID); edi) {
175 effect = &edi->GetDefinition();
176 assert(pSettings); // postcondition
177 settings = pSettings;
178 }
179 else
180 command = GetAudacityCommand( ID );
181 if ( !effect && !command )
182 return;
183
184 ConstSettingsVisitor NullShuttle;
185
186 // Test if it defines any parameters at all.
187 bool bHasParams = command
188 ? command->VisitSettings( NullShuttle )
189 : effect->VisitSettings( NullShuttle, *settings );
190 if ( (flags == 0) && !bHasParams )
191 return;
192
193 // This is capturing the output context into the shuttle.
194 ShuttleGetDefinition S( *context.pOutput.get()->mStatusTarget.get() );
195 S.StartStruct();
196 // using GET to expose a CommandID to the user!
197 // Macro command details are one place that we do expose Identifier
198 // to (more sophisticated) users
199 S.AddItem( GetCommandIdentifier( ID ).GET(), "id" );
200 S.AddItem( GetCommandName( ID ).Translation(), "name" );
201 if ( bHasParams ) {
202 S.StartField( "params" );
203 S.StartArray();
204 command
205 ? command->VisitSettings( S )
206 : effect->VisitSettings( S, *settings );
207 S.EndArray();
208 S.EndField();
209 }
210 // use GET() to expose some details to macro programming users
211 S.AddItem( GetCommandUrl( ID ).GET(), "url" );
212 // The tip is a translated string!
213 S.AddItem( GetCommandTip( ID ).Translation(), "tip" );
214 S.EndStruct();
215}
#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 ...
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 135 of file EffectManager.cpp.

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

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

130{
133}
const TranslatableString name
Definition: Distortion.cpp:76
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 102 of file EffectManager.cpp.

103{
104 return GetCommandSymbol(ID).Msgid();
105}
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 97 of file EffectManager.cpp.

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

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

157{
158 if (auto pEff = GetEffect(ID))
159 return pEff->GetDefinition().GetDescription();
161 if( pCom )
162 return pCom->GetDescription();
163
164 return {};
165}
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 145 of file EffectManager.cpp.

146{
147 if (auto pEff = GetEffect(ID))
148 return pEff->GetDefinition().ManualPage();
150 if( pCom )
151 return pCom->ManualPage();
152
153 return wxEmptyString;
154}
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 727 of file EffectManager.cpp.

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

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

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

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

774{
775 return DoGetEffect(ID).effect;
776}
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 784 of file EffectManager.cpp.

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

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

904{
905 static PluginID empty;
906 if (strTarget.empty()) // set GetCommandIdentifier to wxT("") to not show an effect in Batch mode
907 {
908 return empty;
909 }
910
912 // Effects OR Generic commands...
913 for (auto &plug
915 auto &ID = plug.GetID();
916 if (GetCommandIdentifier(ID) == strTarget)
917 return ID;
918 }
919 return empty;
920}
wxString PluginID
@ 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:51
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(), MacrosWindow::OnListSelected(), 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 107 of file EffectManager.cpp.

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

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

Referenced by anonymous_namespace{MenuHelper.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 248 of file EffectManager.cpp.

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

924{
925 return Get().GetEffect(ID);
926}
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 681 of file EffectManager.cpp.

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

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

232{
233 return mSkipStateFlag;
234}

References mSkipStateFlag.

Referenced by EffectUI::DoEffect().

Here is the caller graph for this function:

◆ GetVendorName()

TranslatableString EffectManager::GetVendorName ( const PluginID ID)

Definition at line 118 of file EffectManager.cpp.

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

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

Referenced by anonymous_namespace{MenuHelper.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 393 of file EffectManager.cpp.

394{
395 auto effect = GetEffect(ID);
396
397 if (!effect)
398 {
399 return false;
400 }
401
402 return GetUserPresets(*effect).size() > 0 ||
403 effect->GetDefinition().GetFactoryPresets().size() > 0 ||
404 HasCurrentSettings(*effect) ||
405 HasFactoryDefaults(*effect);
406}
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 219 of file EffectManager.cpp.

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

References GetEffect().

Referenced by anonymous_namespace{MenuHelper.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 330 of file EffectManager.cpp.

332{
333 bool result = false;
334 if (auto effect = dynamic_cast<Effect*>(GetEffect(ID))) {
335
336 auto empty = TrackList::Create(nullptr);
337 auto pEffectBase = dynamic_cast<EffectBase*>(effect);
338 if (pEffectBase)
339 // This allows effects to call Init() safely
340 pEffectBase->SetTracks(empty.get());
341 Finally Do([&]{
342 // reverse the side-effect
343 if (pEffectBase)
344 pEffectBase->SetTracks(nullptr);
345 });
346
347 std::shared_ptr<EffectInstance> pInstance;
350 if (const auto pSettings = GetDefaultSettings(ID)) {
351 const auto pServices = dynamic_cast<EffectUIServices *>(effect);
352 result = pServices && pServices->ShowHostInterface(*effect,
353 parent, factory,
354 pInstance,
355 *std::make_shared<SimpleEffectSettingsAccess>(*pSettings),
356 effect->IsBatchProcessing() ) != 0;
357 }
358 return result;
359 }
360
361 AudacityCommand *command = GetAudacityCommand(ID);
362
363 if (command)
364 {
365 result = command->PromptUser(&parent);
366 return result;
367 }
368
369 return result;
370}
static RegisteredToolbarFactory factory
virtual bool PromptUser(wxWindow *parent)
Base class for many of the effects in Audacity.
Definition: EffectBase.h:28
void SetTracks(TrackList *pTracks)
Definition: EffectBase.cpp:43
Base class for many of the effects in Audacity.
Definition: Effect.h:26
EffectSettings * GetDefaultSettings(const PluginID &ID)
virtual int ShowHostInterface(EffectBase &plugin, wxWindow &parent, const EffectDialogFactory &factory, std::shared_ptr< EffectInstance > &pInstance, EffectSettingsAccess &access, bool forceModal=false)
static TrackListHolder Create(AudacityProject *pOwner)
Definition: Track.cpp:330
"finally" as in The C++ Programming Language, 4th ed., p. 358 Useful for defining ad-hoc RAII actions...
Definition: MemoryX.h:175

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

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

61{
62 auto pEffect = uEffect.get();
63 const PluginID & ID =
65 mEffects[ID] = { pEffect, {} };
66 return ID;
67}
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 288 of file EffectManager.cpp.

290{
291 auto pair = GetEffectAndDefaultSettings(ID);
292 if (auto effect = pair.first) {
293 assert(pair.second); // postcondition
294 auto &settings = *pair.second;
296
297 // Check first for what GetDefaultPreset() might have written
298 if (eap.HasEntry(wxT("Use Preset")))
299 {
300 return effect->LoadSettingsFromString(
301 eap.Read(wxT("Use Preset")), settings).has_value();
302 }
303
304 return effect->LoadSettingsFromString(params, settings).has_value();
305 }
306 AudacityCommand *command = GetAudacityCommand(ID);
307
308 if (command)
309 {
310 // Set defaults (if not initialised) before setting values.
311 command->Init();
313
314 // Check first for what GetDefaultPreset() might have written
315 if (eap.HasEntry(wxT("Use Preset")))
316 {
317 return command
318 ->LoadSettingsFromString(eap.Read(wxT("Use Preset")));
319 }
320
321 return command->LoadSettingsFromString(params);
322 }
323 return false;
324}
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 226 of file EffectManager.cpp.

227{
229}
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 236 of file EffectManager.cpp.

237{
239 if (plug)
240 {
241 return plug->IsEffectAutomatable();
242 }
243
244 return false;
245}
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 71 of file EffectManager.cpp.

72{
73 PluginID id = ID;
75 mEffects.erase(id);
76}
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: