22#include <wx/stdpaths.h>
25#include <public.sdk/source/vst/hosting/hostclasses.h>
55 PWSTR commonFolderPath {
nullptr };
56 auto cleanup =
finally([&](){ CoTaskMemFree(commonFolderPath); });
57 if(SHGetKnownFolderPath(FOLDERID_ProgramData, KF_FLAG_DEFAULT , NULL, &commonFolderPath) == S_OK)
58 return wxString(commonFolderPath) +
"\\VST3 Presets\\";
61 return wxString(
"Library/Audio/Presets/");
63 return wxString(
"/usr/local/share/vst3/presets/");
67wxString
GetPresetsPath(
const wxString& basePath,
const VST3::Hosting::ClassInfo& effectClassInfo)
69 wxRegEx fixName(R
"([\\*?/:<>|])");
70 wxString companyName = wxString (effectClassInfo.vendor()).Trim();
71 wxString pluginName = wxString (effectClassInfo.name()).Trim();
73 fixName.ReplaceAll( &companyName, { "_" });
74 fixName.ReplaceAll( &pluginName, {
"_" });
77 result.SetPath(basePath);
78 result.AppendDir(companyName);
79 result.AppendDir(pluginName);
80 auto path = result.GetPath();
108 std::shared_ptr<VST3::Hosting::Module> module,
109 VST3::Hosting::ClassInfo effectClassInfo)
110 : mModule(
std::move(module)), mEffectClassInfo(
std::move(effectClassInfo))
142 using namespace Steinberg::Vst::PlugType;
147 if(std::find(cats.begin(), cats.end(), kFx) != cats.end())
216 for(
auto& path : paths)
218 wxFileName filename(path);
219 result.push_back(filename.GetName());
247 dialog.SetWindowStyle(dialog.GetWindowStyle() & ~(wxRESIZE_BORDER | wxMAXIMIZE_BOX));
251 return dialog.ShowModal();
266 bool useGUI {
true };
272 const auto vst3instance =
dynamic_cast<VST3Instance*
>(&instance);
275 return std::make_unique<VST3UIValidator>(
mParent, vst3instance->GetWrapper(), *
this, access, useGUI);
293 auto path =
SelectFile(FileNames::Operation::Presets,
294 XO(
"Save VST3 Preset As:"),
299 {
XO(
"VST3 preset file"), {
wxT(
"vstpreset") },
true }
301 wxFD_SAVE | wxFD_OVERWRITE_PROMPT | wxRESIZE_BORDER,
309 auto fileStream = owned(Vst::FileStream::open(path.c_str(),
"wb"));
314 XO(
"Cannot open file"),
316 .Caption(
XO(
"Error"))
317 .Parent(&dialogPlacement)
324 wrapper->FetchSettings(dummy);
326 if (!wrapper->SavePreset(fileStream))
329 XO(
"Failed to save VST3 preset to file"),
331 .Caption(
XO(
"Error"))
332 .Parent(&dialogPlacement)
341 auto path =
SelectFile(FileNames::Operation::Presets,
342 XO(
"Load VST3 preset:"),
347 {
XO(
"VST3 preset file"), {
wxT(
"vstpreset") },
true }
349 wxFD_OPEN | wxRESIZE_BORDER,
378 auto fileStream = owned(Vst::FileStream::open(path.c_str(),
"rb"));
382 XO(
"Cannot open VST3 preset file %s").
Format(path),
384 .Caption(
XO(
"Error"))
385 .Parent(&dialogPlacement)
392 if (!wrapper->LoadPreset(fileStream))
395 XO(
"Unable to apply VST3 preset file %s").
Format(path),
397 .Caption(
XO(
"Error"))
398 .Parent(&dialogPlacement)
Declare abstract class AudacityException, some often-used subclasses, and GuardedCall.
Toolkit-neutral facade for basic user interface services.
const TranslatableString name
std::optional< std::unique_ptr< EffectSettingsAccess::Message > > OptionalMessage
wxString PluginPath
type alias for identifying a Plugin supplied by a module, each module defining its own interpretation...
std::vector< RegistryPath > RegistryPaths
FilePath SelectFile(FileNames::Operation op, const TranslatableString &message, const FilePath &default_path, const FilePath &default_filename, const FileExtension &default_extension, const FileTypes &fileTypes, int flags, wxWindow *parent)
static Settings & settings()
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?
Performs effect computation.
Hold values to send to effect output meters.
Interface for transferring values from a panel of effect controls.
virtual bool IsGraphicalUI()
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Holds a msgid for the translation catalog; may also bind format arguments.
bool SaveUserPreset(const RegistryPath &name, const EffectSettings &settings) const override
Save settings in the configuration file as a user-named preset.
const VST3::Hosting::ClassInfo mEffectClassInfo
VST3Effect(std::shared_ptr< VST3::Hosting::Module > module, VST3::Hosting::ClassInfo effectClassInfo)
ComponentInterfaceSymbol GetSymbol() const override
bool IsInteractive() const override
Whether the effect needs a dialog for entry of settings.
OptionalMessage LoadUserPreset(const RegistryPath &name, EffectSettings &settings) const override
bool IsDefault() const override
Whether the effect sorts "above the line" in the menus.
EffectType GetType() const override
Type determines how it behaves.
std::unique_ptr< EffectUIValidator > PopulateUI(ShuttleGui &S, EffectInstance &instance, EffectSettingsAccess &access, const EffectOutputs *pOutputs) override
Adds controls to a panel that is given as the parent window of S
std::shared_ptr< VST3::Hosting::Module > mModule
bool mRescanFactoryPresets
PluginPath GetPath() const override
static EffectFamilySymbol GetFamilySymbol()
int ShowClientInterface(wxWindow &parent, wxDialog &dialog, EffectUIValidator *pValidator, bool forceModal) override
void ExportPresets(const EffectSettings &settings) const override
OptionalMessage ImportPresets(EffectSettings &settings) override
std::shared_ptr< EffectInstance > MakeInstance() const override
Make an object maintaining short-term state of an Effect.
bool LoadSettings(const CommandParameters &parms, EffectSettings &settings) const override
Restore settings from keys and values.
bool CopySettingsContents(const EffectSettings &src, EffectSettings &dst) const override
Update one settings object from another.
RegistryPaths GetFactoryPresets() const override
Report names of factory presets.
TranslatableString GetDescription() const override
bool CanExportPresets() override
RegistryPaths mFactoryPresets
EffectSettings MakeSettings() const override
OptionalMessage LoadFactoryPreset(int id, EffectSettings &settings) const override
void ShowOptions() override
wxString GetVersion() const override
bool HasOptions() override
bool SaveSettings(const EffectSettings &settings, CommandParameters &parms) const override
Store settings as keys and values.
VendorSymbol GetVendor() const override
bool SupportsAutomation() const override
Whether the effect has any automatable controls.
bool LoadPreset(const wxString &path, EffectSettings &settings) const
RealtimeSince RealtimeSupport() const override
Since which version of Audacity has the effect supported realtime?
EffectFamilySymbol GetFamily() const override
Report identifier and user-visible name of the effect protocol.
static wxString MakePluginPathString(const wxString &modulePath, const std::string &effectUIDString)
static EffectSettings MakeSettings()
static void SaveUserPreset(const EffectDefinitionInterface &effect, const RegistryPath &name, const EffectSettings &settings)
static void SaveSettings(const EffectSettings &settings, CommandParameters &parms)
static void CopySettingsContents(const EffectSettings &src, EffectSettings &dst)
static void LoadSettings(const CommandParameters &parms, EffectSettings &settings)
static OptionalMessage LoadUserPreset(const EffectDefinitionInterface &effect, const RegistryPath &name, EffectSettings &settings)
MessageBoxResult ShowMessageBox(const TranslatableString &message, MessageBoxOptions options={})
Show a modal message box with either Ok or Yes and No, and optionally Cancel.
bool GetConfig(const EffectDefinitionInterface &ident, ConfigurationType type, const RegistryPath &group, const RegistryPath &key, Value &var, const Value &defval)
wxString GetFactoryPresetsPath(const VST3::Hosting::ClassInfo &effectClassInfo)
wxString GetPresetsPath(const wxString &basePath, const VST3::Hosting::ClassInfo &effectClassInfo)
wxString GetFactoryPresetsBasePath()
Externalized state of a plug-in.