Audacity 3.2.0
VST3EffectBase.cpp
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 @file VST3EffectBase.cpp
6
7 @author Vitaly Sverchinsky
8
9 Paul Licameli split from VST3Effect.cpp
10
11 @brief Part of Audacity VST3 module
12
13**********************************************************************/
14
15#include "VST3EffectBase.h"
16#include "VST3Utils.h"
17#include "VST3Wrapper.h"
18#include "VST3Instance.h"
19
21{
22 return XO("VST3");
23}
24
26
28 std::shared_ptr<VST3::Hosting::Module> module,
29 VST3::Hosting::ClassInfo effectClassInfo)
30 : mModule(std::move(module)), mEffectClassInfo(std::move(effectClassInfo))
31{
32}
33
35{
36 return VST3Utils::MakePluginPathString( { mModule->getPath() }, mEffectClassInfo.ID().toString());
37}
38
41 return wxString { mEffectClassInfo.name() };
42}
43
45{
46 return wxString { mEffectClassInfo.vendor() };
47}
48
50{
51 return mEffectClassInfo.version();
52}
53
55{
56 //i18n-hint VST3 effect description string
57 return XO("SubCategories: %s").Format( mEffectClassInfo.subCategoriesString() );
58}
59
61{
62 using namespace Steinberg::Vst::PlugType;
63 if(mEffectClassInfo.subCategoriesString() == kFxGenerator)
64 return EffectTypeGenerate;
65 const auto& cats = mEffectClassInfo.subCategories();
66
67 if(std::find(cats.begin(), cats.end(), kFx) != cats.end())
68 return EffectTypeProcess;
69
70 return EffectTypeNone;
71}
72
74{
76}
77
79{
80 return true;
81}
82
84{
85 return false;
86}
87
89{
90 return GetType() == EffectTypeProcess
93}
94
96{
97 return true;
98}
99
101 const EffectSettings& settings, CommandParameters& parms) const
102{
104 return true;
105}
106
108 const CommandParameters& parms, EffectSettings& settings) const
109{
111 return true;
112}
113
116{
118}
119
121 const RegistryPath& name, const EffectSettings& settings) const
122{
124 return true;
125}
126
128{
130 return mFactoryPresetNames;
131
133 for(auto& desc : wrapper.FindFactoryPresets())
134 {
135 mFactoryPresetNames.push_back(desc.displayName);
136 mFactoryPresetIDs.push_back(desc.id);
137 }
138 mRescanFactoryPresets = false;
139
140 return mFactoryPresetNames;
141}
142
144{
145 if(index >= 0 && index < mFactoryPresetIDs.size())
146 {
148 wrapper.InitializeComponents();
149 wrapper.LoadPreset(mFactoryPresetIDs[index]);
150 wrapper.FlushParameters(settings);
151 wrapper.StoreSettings(settings);
152 return { nullptr };
153 }
154 return { };
155}
156
157std::shared_ptr<EffectInstance> VST3EffectBase::MakeInstance() const
158{
159 return std::make_shared<VST3Instance>(*this, *mModule, mEffectClassInfo);
160}
161
163{
164 return true;
165}
166
168{
169 return true;
170}
171
172void VST3EffectBase::LoadPreset(const wxString& id, EffectSettings& settings) const
173{
174 auto wrapper = std::make_unique<VST3Wrapper>(*mModule, mEffectClassInfo);
175 wrapper->InitializeComponents();
176 wrapper->LoadPreset(id);
177 wrapper->StoreSettings(settings);
178}
179
181{
183}
184
186{
188 return true;
189}
const TranslatableString name
Definition: Distortion.cpp:76
EffectType
@ EffectTypeGenerate
@ EffectTypeNone
@ EffectTypeProcess
std::optional< std::unique_ptr< EffectSettingsAccess::Message > > OptionalMessage
XO("Cut/Copy/Paste")
wxString RegistryPath
Definition: Identifier.h:218
wxString PluginPath
type alias for identifying a Plugin supplied by a module, each module defining its own interpretation...
Definition: Identifier.h:214
std::vector< RegistryPath > RegistryPaths
Definition: Identifier.h:219
static Settings & settings()
Definition: TrackInfo.cpp:69
CommandParameters, derived from wxFileConfig, is essentially doing the same things as the SettingsVis...
ComponentInterfaceSymbol pairs a persistent string identifier used internally with an optional,...
RealtimeSince
In which versions of Audacity was an effect realtime capable?
Holds a msgid for the translation catalog; may also bind format arguments.
bool SupportsAutomation() const override
Whether the effect has any automatable controls.
bool CopySettingsContents(const EffectSettings &src, EffectSettings &dst) const override
Update one settings object from another.
OptionalMessage LoadUserPreset(const RegistryPath &name, EffectSettings &settings) const override
TranslatableString GetDescription() const override
void LoadPreset(const wxString &id, EffectSettings &settings) const
const VST3::Hosting::ClassInfo mEffectClassInfo
bool CanExportPresets() const override
Whether the effect supports export of presets to files, and importing too.
std::shared_ptr< VST3::Hosting::Module > mModule
ComponentInterfaceSymbol GetSymbol() const override
std::shared_ptr< EffectInstance > MakeInstance() const override
Make an object maintaining short-term state of an Effect.
bool HasOptions() const override
EffectType GetType() const override
Type determines how it behaves.
VST3EffectBase(std::shared_ptr< VST3::Hosting::Module > module, VST3::Hosting::ClassInfo effectClassInfo)
bool SaveUserPreset(const RegistryPath &name, const EffectSettings &settings) const override
Save settings in the configuration file as a user-named preset.
EffectFamilySymbol GetFamily() const override
Report identifier and user-visible name of the effect protocol.
RealtimeSince RealtimeSupport() const override
Since which version of Audacity has the effect supported realtime?
wxString GetVersion() const override
RegistryPaths GetFactoryPresets() const override
Report names of factory presets.
VendorSymbol GetVendor() const override
~VST3EffectBase() override
bool IsInteractive() const override
Whether the effect needs a dialog for entry of settings.
std::vector< wxString > mFactoryPresetIDs
bool LoadSettings(const CommandParameters &parms, EffectSettings &settings) const override
Restore settings from keys and values.
OptionalMessage LoadFactoryPreset(int id, EffectSettings &settings) const override
static EffectFamilySymbol GetFamilySymbol()
EffectSettings MakeSettings() const override
bool mRescanFactoryPresets
PluginPath GetPath() const override
bool IsDefault() const override
Whether the effect sorts "above the line" in the menus.
RegistryPaths mFactoryPresetNames
bool SaveSettings(const EffectSettings &settings, CommandParameters &parms) const override
Store settings as keys and values.
static wxString MakePluginPathString(const wxString &modulePath, const std::string &effectUIDString)
Definition: VST3Utils.cpp:69
static EffectSettings MakeSettings()
void LoadPreset(const wxString &presetId)
static void SaveUserPreset(const EffectDefinitionInterface &effect, const RegistryPath &name, const EffectSettings &settings)
static void SaveSettings(const EffectSettings &settings, CommandParameters &parms)
std::vector< FactoryPresetDesc > FindFactoryPresets() const
static void CopySettingsContents(const EffectSettings &src, EffectSettings &dst)
void InitializeComponents()
Should be called once before almost any other method call.
void StoreSettings(EffectSettings &) const
Saves current state inside settings object, clears all runtime data.
static void LoadSettings(const CommandParameters &parms, EffectSettings &settings)
void FlushParameters(EffectSettings &settings, bool *hasChanges=nullptr)
static OptionalMessage LoadUserPreset(const EffectDefinitionInterface &effect, const RegistryPath &name, EffectSettings &settings)
const TranslatableString desc
Definition: ExportPCM.cpp:51
STL namespace.
Externalized state of a plug-in.