Audacity 3.2.0
Public Types | Public Member Functions | Static Public Member Functions | 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]

Public Types

enum  : unsigned {
  kNone = 0x00 , kConfigured = 0x01 , kSkipState = 0x02 , kDontRepeatLast = 0x04 ,
  kRepeatGen = 0x08 , kRepeatNyquistPrompt = 0x10
}
 
using EffectPresetDialog = std::function< std::optional< wxString >(EffectPlugin &, const wxString &preset)>
 

Public Member Functions

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 IsHidden (const PluginID &ID)
 
bool HasPresets (const PluginID &ID)
 
wxString GetPreset (const PluginID &ID, const wxString &params, EffectPresetDialog)
 
wxString GetDefaultPreset (const PluginID &ID)
 
void SetSkipStateFlag (bool flag)
 
bool GetSkipStateFlag ()
 
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 Member Functions

EffectAndDefaultSettingsDoGetEffect (const PluginID &ID)
 

Private Attributes

EffectMap mEffects
 
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 51 of file EffectManager.h.

Member Typedef Documentation

◆ EffectPresetDialog

using EffectManager::EffectPresetDialog = std::function<std::optional<wxString>( EffectPlugin&, const wxString& preset)>

Definition at line 85 of file EffectManager.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum : unsigned
Enumerator
kNone 
kConfigured 
kSkipState 
kDontRepeatLast 
kRepeatGen 
kRepeatNyquistPrompt 

Definition at line 55 of file EffectManager.h.

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

Member Function Documentation

◆ DoGetEffect()

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

Definition at line 268 of file EffectManager.cpp.

269{
270 static EffectAndDefaultSettings empty;
271
272 // Must have a "valid" ID
273 if (ID.empty())
274 return empty;
275
276 if (auto iter = mEffects.find(ID); iter != mEffects.end())
277 return iter->second;
278 else {
279 // This will instantiate the effect client if it hasn't already been done
280 auto [component, settings] = LoadComponent(ID);
281 if (!component)
282 return empty;
283
284 if (auto effect = dynamic_cast<EffectPlugin*>(component))
285 return (mEffects[ID] = { effect, std::move(settings) });
286 else
287 return empty;
288 }
289}
static Settings & settings()
Definition: TrackInfo.cpp:51
EffectMap mEffects
Factory of instances of an effect.
Definition: EffectPlugin.h:36
std::pair< ComponentInterface *, EffectSettings > LoadComponent(const PluginID &ID)

References anonymous_namespace{EffectManager.cpp}::LoadComponent(), mEffects, and settings().

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

34{
35 static EffectManager em;
36 return em;
37}
EffectManager is the class that handles effects and effect categories.
Definition: EffectManager.h:52

Referenced by anonymous_namespace{MenuHelper.cpp}::AddGroupedEffectMenuItems(), anonymous_namespace{MenuHelper.cpp}::AddSortedEffectMenuItems(), EffectAndCommandPluginManager::BatchProcessingOff(), EffectAndCommandPluginManager::BatchProcessingOn(), 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(), EffectAndCommandPluginManager::DoAudacityCommand(), AudacityApplicationLogic::DoEffect(), EffectAndCommandPluginManager::GetCommandDefinition(), EffectAndCommandPluginManager::GetCommandTip(), EffectAndCommandPluginManager::GetCommandUrl(), EffectAndCommandPluginManager::GetEffectParameters(), GetInstanceFactory(), anonymous_namespace{MenuHelper.cpp}::IsEnabledPlugin(), MacroCommandsCatalog::MacroCommandsCatalog(), EffectNoiseReduction::Dialog::OnGetProfile(), NyqBench::OnGo(), MacroCommandDialog::OnItemSelected(), anonymous_namespace{RealtimeEffectPanel.cpp}::RealtimeEffectControl::OnOptionsClicked(), NyquistBase::Process(), MacroCommands::PromptForPresetFor(), EffectAndCommandPluginManager::PromptUser(), MacroCommandDialog::SetCommandAndParams(), EffectAndCommandPluginManager::SetEffectParameters(), RealtimeEffectStateUI::Show(), and RealtimeEffectStateUI::UpdateTitle().

Here is the caller graph for this function:

◆ GetDefaultPreset()

wxString EffectManager::GetDefaultPreset ( const PluginID ID)

Definition at line 175 of file EffectManager.cpp.

176{
177 auto effect = GetEffect(ID);
178
179 if (!effect)
180 {
181 return wxEmptyString;
182 }
183
184 wxString preset;
185 if (HasCurrentSettings(*effect))
186 {
188 }
189 else if (HasFactoryDefaults(*effect))
190 {
192 }
193
194 if (!preset.empty())
195 {
197
198 eap.Write(wxT("Use Preset"), preset);
200 }
201
202 return preset;
203}
wxT("CloseDown"))
bool HasCurrentSettings(EffectPlugin &host)
bool HasFactoryDefaults(EffectPlugin &host)
ReverbSettings preset
Definition: ReverbBase.cpp:25
CommandParameters, derived from wxFileConfig, is essentially doing the same things as the SettingsVis...
bool GetParameters(wxString &parms)
EffectPlugin * GetEffect(const PluginID &ID)
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 EffectAndCommandPluginManager::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 210 of file EffectManager.cpp.

211{
212 return GetEffectAndDefaultSettings(ID).second;
213}
std::pair< EffectPlugin *, EffectSettings * > GetEffectAndDefaultSettings(const PluginID &ID)

References GetEffectAndDefaultSettings().

Referenced by AudacityApplicationLogic::DoEffect().

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

206{
207 return DoGetEffect(ID).effect;
208}
EffectAndDefaultSettings & DoGetEffect(const PluginID &ID)

References DoGetEffect(), and EffectAndDefaultSettings::effect.

Referenced by AudacityApplicationLogic::DoEffect(), GetDefaultPreset(), GetEffectFamilyName(), GetInstanceFactory(), GetPreset(), GetVendorName(), HasPresets(), IsHidden(), anonymous_namespace{RealtimeEffectPanel.cpp}::RealtimeEffectControl::OnOptionsClicked(), 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 216 of file EffectManager.cpp.

217{
218 auto &results = DoGetEffect(ID);
219 if (results.effect)
220 return {results.effect, &results.settings};
221 else
222 return {nullptr, nullptr};
223}

References DoGetEffect().

Referenced by GetDefaultSettings(), EffectAndCommandPluginManager::GetEffectParameters(), and EffectAndCommandPluginManager::SetEffectParameters().

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

61{
62 if(auto description = PluginManager::Get().GetPlugin(ID))
63 return TranslatableString { description->GetEffectFamily(), {} };
64
65 auto effect = GetEffect(ID);
66 if (effect)
67 return effect->GetDefinition().GetFamily().Msgid();
68 return {};
69}
static PluginManager & Get()
Holds a msgid for the translation catalog; may also bind format arguments.
const PluginDescriptor * GetPlugin(const PluginID &ID)

References PluginManager::Get(), GetEffect(), and anonymous_namespace{RealtimeEffectPanel.cpp}::GetPlugin().

Referenced by anonymous_namespace{MenuHelper.cpp}::AddSortedEffectMenuItems().

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

293{
294 return Get().GetEffect(ID);
295}
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,
EffectPresetDialog  dialog 
)

Definition at line 137 of file EffectManager.cpp.

139{
140 auto effect = GetEffect(ID);
141
142 if (!effect)
143 {
144 return wxEmptyString;
145 }
146
148
149 wxString preset;
150 if (eap.HasEntry(wxT("Use Preset")))
151 {
152 preset = eap.Read(wxT("Use Preset"));
153 }
154
155 if (const auto answer = dialog(*effect, preset))
156 preset = *answer;
157 else
158 preset = wxEmptyString;
159
160 if (preset.empty())
161 {
162 return preset;
163 }
164
165 // This cleans a config "file" backed by a string in memory.
166 eap.DeleteAll();
167
168 eap.Write(wxT("Use Preset"), preset);
169 eap.GetParameters(preset);
170
171 return preset;
172}
EffectDistortionSettings params

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

96{
97 return mSkipStateFlag;
98}

References mSkipStateFlag.

Referenced by AudacityApplicationLogic::DoEffect().

Here is the caller graph for this function:

◆ GetVendorName()

TranslatableString EffectManager::GetVendorName ( const PluginID ID)

Definition at line 71 of file EffectManager.cpp.

72{
73 if(auto description = PluginManager::Get().GetPlugin(ID))
74 return TranslatableString { description->GetVendor(), {} };
75
76 auto effect = GetEffect(ID);
77 if (effect)
78 return effect->GetDefinition().GetVendor().Msgid();
79 return {};
80}

References PluginManager::Get(), GetEffect(), and anonymous_namespace{RealtimeEffectPanel.cpp}::GetPlugin().

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

122{
123 auto effect = GetEffect(ID);
124
125 if (!effect)
126 {
127 return false;
128 }
129
130 return GetUserPresets(*effect).size() > 0 ||
131 effect->GetDefinition().GetFactoryPresets().size() > 0 ||
132 HasCurrentSettings(*effect) ||
133 HasFactoryDefaults(*effect);
134}
RegistryPaths GetUserPresets(EffectPlugin &host)

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

Referenced by MacroCommandDialog::OnItemSelected().

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

84{
85 if(auto effect = GetEffect(ID))
86 return effect->GetDefinition().IsHiddenFromMenus();
87 return false;
88}

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:

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

43{
44 auto pEffect = uEffect.get();
45 const PluginID & ID =
47 mEffects[ID] = { pEffect, {} };
48 return ID;
49}
wxString PluginID
@ PluginTypeEffect
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:

◆ SetSkipStateFlag()

void EffectManager::SetSkipStateFlag ( bool  flag)

Allow effects to disable saving the state at run time

Definition at line 90 of file EffectManager.cpp.

91{
93}
static std::once_flag flag

References flag, and mSkipStateFlag.

Referenced by EffectAndCommandPluginManager::DoAudacityCommand(), AudacityApplicationLogic::DoEffect(), EffectNoiseReduction::Dialog::OnGetProfile(), and NyquistBase::Process().

Here is the caller graph for this function:

◆ UnregisterEffect()

void EffectManager::UnregisterEffect ( const PluginID ID)

Used only by Nyquist Workbench module.

Definition at line 53 of file EffectManager.cpp.

54{
55 PluginID id = ID;
57 mEffects.erase(id);
58}
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

◆ mEffects

EffectMap EffectManager::mEffects
private

Definition at line 126 of file EffectManager.h.

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

◆ mHostEffects

EffectOwnerMap EffectManager::mHostEffects
private

Definition at line 127 of file EffectManager.h.

◆ mNumEffects

int EffectManager::mNumEffects
private

Definition at line 129 of file EffectManager.h.

◆ mSkipStateFlag

bool EffectManager::mSkipStateFlag
private

Definition at line 133 of file EffectManager.h.

Referenced by GetSkipStateFlag(), and SetSkipStateFlag().


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