18#include <wx/filename.h>
20#include <pluginterfaces/vst/ivsteditcontroller.h>
21#include <pluginterfaces/vst/ivstparameterchanges.h>
37 PWSTR commonFolderPath {
nullptr };
38 auto cleanup =
finally([&](){ CoTaskMemFree(commonFolderPath); });
39 if(SHGetKnownFolderPath(FOLDERID_ProgramData, KF_FLAG_DEFAULT , NULL, &commonFolderPath) == S_OK)
40 return wxString(commonFolderPath) +
"\\VST3 Presets\\";
43 return wxString(
"/Library/Audio/Presets/");
45 return wxString(
"/usr/local/share/vst3/presets/");
49wxString
GetPresetsPath(
const wxString& basePath,
const VST3::Hosting::ClassInfo& effectClassInfo)
51 wxRegEx fixName(R
"([\\*?/:<>|])");
52 wxString companyName = wxString (effectClassInfo.vendor()).Trim();
53 wxString pluginName = wxString (effectClassInfo.name()).Trim();
55 fixName.ReplaceAll( &companyName, { "_" });
56 fixName.ReplaceAll( &pluginName, {
"_" });
59 result.SetPath(basePath);
60 result.AppendDir(companyName);
61 result.AppendDir(pluginName);
62 auto path = result.GetPath();
71 return wxString::Format(
"%s;%s", modulePath, effectUIDString);
75 std::string* effectUIDString)
77 const auto sep = pluginPath.Find(
';',
true);
78 if(sep != wxNOT_FOUND &&
82 static_cast<size_t>(sep) < pluginPath.Length() - 1)
84 if(modulePath !=
nullptr)
85 *modulePath = pluginPath.Left(sep);
86 if(effectUIDString !=
nullptr)
87 *effectUIDString = pluginPath.Mid(
static_cast<size_t>(sep) + 1);
95 static const wxCSConv csConv { wxFONTENCODING_UTF16 };
96 return {
reinterpret_cast<const char*
>(
str), csConv };
101 auto suffix =
ToWxString(parameterInfo.shortTitle);
106 return wxString::Format(
"%lu_",
static_cast<unsigned long>(parameterInfo.id)) + suffix;
108 return wxString::Format(
"%lu",
static_cast<unsigned long>(parameterInfo.id));
113 const auto pos =
key.Find(
'_');
114 const auto idStr = pos == wxNOT_FOUND ?
key :
key.Left(pos);
115 unsigned long value { };
116 if(idStr.ToULong(&value))
118 paramId =
static_cast<Steinberg::Vst::ParamID
>(value);
126 return wxString::Format(
"%d:%d",
127 static_cast<int>(unitId),
128 static_cast<int>(programIndex));
133 auto parts = wxSplit(presetId,
':');
135 if(parts.size() == 2 && parts[0].ToLong(&nums[0]) && parts[1].ToLong(&nums[1]))
137 unitId =
static_cast<Steinberg::Vst::UnitID
>(nums[0]);
138 programIndex =
static_cast<Steinberg::int32
>(nums[1]);
155 Steinberg::Buffer buffer(
str.length() / 4 * 3);
160 buffer.setSize(numBytes);
163 result->mBuffer.take(buffer);
static Steinberg::IPtr< PresetsBufferStream > fromString(const wxString &str)
wxString toString() const
static wxString MakePluginPathString(const wxString &modulePath, const std::string &effectUIDString)
static bool ParseFactoryPresetID(const wxString &presetId, Steinberg::Vst::UnitID &unitId, Steinberg::int32 &programIndex)
static wxString GetFactoryPresetsPath(const VST3::Hosting::ClassInfo &effectClassInfo)
static wxString MakeFactoryPresetID(Steinberg::Vst::UnitID unitId, Steinberg::int32 programIndex)
static wxString ToWxString(const Steinberg::Vst::TChar *str)
static bool ParseAutomationParameterKey(const wxString &key, Steinberg::Vst::ParamID ¶mId)
static wxString MakeAutomationParameterKey(const Steinberg::Vst::ParameterInfo &info)
static bool ParsePluginPath(const wxString &pluginPath, wxString *modulePath, std::string *effectUIDString)
STRINGS_API wxString Encode(const void *in, int len)
STRINGS_API int Decode(const wxString &in, void *out)
wxString GetFactoryPresetsBasePath()
wxString GetPresetsPath(const wxString &basePath, const VST3::Hosting::ClassInfo &effectClassInfo)