@@ -837,6 +837,18 @@ public: | |||||
*/ | */ | ||||
double getSampleRate() const noexcept; | double getSampleRate() const noexcept; | ||||
/** | |||||
Get the absolute filename of the plugin binary. | |||||
Under certain systems or plugin formats the binary will be inside the plugin bundle. | |||||
*/ | |||||
const char* getBinaryFilename() const noexcept; | |||||
/** | |||||
Get the bundle path where the plugin resides. | |||||
Can return null if the plugin is not available in a bundle (if it is a single binary). | |||||
*/ | |||||
const char* getBundlePath() const noexcept; | |||||
#if DISTRHO_PLUGIN_WANT_TIMEPOS | #if DISTRHO_PLUGIN_WANT_TIMEPOS | ||||
/** | /** | ||||
Get the current host transport time position.@n | Get the current host transport time position.@n | ||||
@@ -22,6 +22,19 @@ | |||||
START_NAMESPACE_DISTRHO | START_NAMESPACE_DISTRHO | ||||
// ----------------------------------------------------------------------------------------------------------- | // ----------------------------------------------------------------------------------------------------------- | ||||
// misc functions | |||||
/** | |||||
Get a string representation of the current plugin format we are building against.@n | |||||
This can be "JACK/Standalone", "LADSPA", "DSSI", "LV2", "VST2" or "VST3".@n | |||||
This string is purely informational and must not be used to tweak plugin behaviour. | |||||
@note DO NOT CHANGE PLUGIN BEHAVIOUR BASED ON PLUGIN FORMAT. | |||||
*/ | |||||
const char* getPluginFormatName() noexcept; | |||||
// ----------------------------------------------------------------------------------------------------------- | |||||
// Plugin helper classes | |||||
/** | /** | ||||
Handy class to help keep audio buffer in sync with incoming MIDI events. | Handy class to help keep audio buffer in sync with incoming MIDI events. | ||||
@@ -131,6 +131,19 @@ public: | |||||
*/ | */ | ||||
double getSampleRate() const noexcept; | double getSampleRate() const noexcept; | ||||
/** | |||||
Get the absolute filename of the UI binary.@n | |||||
Under certain systems or plugin formats the binary will be inside the plugin bundle.@n | |||||
Also, in some formats or setups, this file might not be the same as the DSP/plugin side (because of DSP/UI separation). | |||||
*/ | |||||
const char* getBinaryFilename() const noexcept; | |||||
/** | |||||
Get the bundle path where the UI resides.@n | |||||
Can return null if the UI is not available in a bundle (if it is a single binary). | |||||
*/ | |||||
const char* getBundlePath() const noexcept; | |||||
/** | /** | ||||
editParameter. | editParameter. | ||||
@@ -100,6 +100,16 @@ double Plugin::getSampleRate() const noexcept | |||||
return pData->sampleRate; | return pData->sampleRate; | ||||
} | } | ||||
const char* Plugin::getBinaryFilename() const noexcept | |||||
{ | |||||
return pData->binaryFilename; | |||||
} | |||||
const char* Plugin::getBundlePath() const noexcept | |||||
{ | |||||
return pData->bundlePath; | |||||
} | |||||
#if DISTRHO_PLUGIN_WANT_TIMEPOS | #if DISTRHO_PLUGIN_WANT_TIMEPOS | ||||
const TimePosition& Plugin::getTimePosition() const noexcept | const TimePosition& Plugin::getTimePosition() const noexcept | ||||
{ | { | ||||
@@ -122,6 +122,8 @@ struct Plugin::PrivateData { | |||||
uint32_t bufferSize; | uint32_t bufferSize; | ||||
double sampleRate; | double sampleRate; | ||||
char* binaryFilename; | |||||
char* bundlePath; | |||||
bool canRequestParameterValueChanges; | bool canRequestParameterValueChanges; | ||||
PrivateData() noexcept | PrivateData() noexcept | ||||
@@ -151,6 +153,8 @@ struct Plugin::PrivateData { | |||||
requestParameterValueChangeCallbackFunc(nullptr), | requestParameterValueChangeCallbackFunc(nullptr), | ||||
bufferSize(d_lastBufferSize), | bufferSize(d_lastBufferSize), | ||||
sampleRate(d_lastSampleRate), | sampleRate(d_lastSampleRate), | ||||
binaryFilename(nullptr), | |||||
bundlePath(nullptr), | |||||
canRequestParameterValueChanges(d_lastCanRequestParameterValueChanges) | canRequestParameterValueChanges(d_lastCanRequestParameterValueChanges) | ||||
{ | { | ||||
DISTRHO_SAFE_ASSERT(bufferSize != 0); | DISTRHO_SAFE_ASSERT(bufferSize != 0); | ||||
@@ -225,6 +229,18 @@ struct Plugin::PrivateData { | |||||
stateDefValues = nullptr; | stateDefValues = nullptr; | ||||
} | } | ||||
#endif | #endif | ||||
if (binaryFilename != nullptr) | |||||
{ | |||||
std::free(binaryFilename); | |||||
binaryFilename = nullptr; | |||||
} | |||||
if (bundlePath != nullptr) | |||||
{ | |||||
std::free(bundlePath); | |||||
bundlePath = nullptr; | |||||
} | |||||
} | } | ||||
#if DISTRHO_PLUGIN_WANT_MIDI_OUTPUT | #if DISTRHO_PLUGIN_WANT_MIDI_OUTPUT | ||||
@@ -217,6 +217,16 @@ double UI::getSampleRate() const noexcept | |||||
return uiData->sampleRate; | return uiData->sampleRate; | ||||
} | } | ||||
const char* UI::getBinaryFilename() const noexcept | |||||
{ | |||||
return uiData->binaryFilename; | |||||
} | |||||
const char* UI::getBundlePath() const noexcept | |||||
{ | |||||
return uiData->bundlePath; | |||||
} | |||||
void UI::editParameter(uint32_t index, bool started) | void UI::editParameter(uint32_t index, bool started) | ||||
{ | { | ||||
uiData->editParamCallback(index + uiData->parameterOffset, started); | uiData->editParamCallback(index + uiData->parameterOffset, started); | ||||
@@ -308,6 +308,8 @@ struct UI::PrivateData { | |||||
#if !DISTRHO_PLUGIN_HAS_EXTERNAL_UI && !defined(DGL_FILE_BROWSER_DISABLED) | #if !DISTRHO_PLUGIN_HAS_EXTERNAL_UI && !defined(DGL_FILE_BROWSER_DISABLED) | ||||
char* uiStateFileKeyRequest; | char* uiStateFileKeyRequest; | ||||
#endif | #endif | ||||
char* binaryFilename; | |||||
char* bundlePath; | |||||
// Callbacks | // Callbacks | ||||
void* callbacksPtr; | void* callbacksPtr; | ||||
@@ -331,6 +333,8 @@ struct UI::PrivateData { | |||||
#if !DISTRHO_PLUGIN_HAS_EXTERNAL_UI && !defined(DGL_FILE_BROWSER_DISABLED) | #if !DISTRHO_PLUGIN_HAS_EXTERNAL_UI && !defined(DGL_FILE_BROWSER_DISABLED) | ||||
uiStateFileKeyRequest(nullptr), | uiStateFileKeyRequest(nullptr), | ||||
#endif | #endif | ||||
binaryFilename(nullptr), | |||||
bundlePath(nullptr), | |||||
callbacksPtr(nullptr), | callbacksPtr(nullptr), | ||||
editParamCallbackFunc(nullptr), | editParamCallbackFunc(nullptr), | ||||
setParamCallbackFunc(nullptr), | setParamCallbackFunc(nullptr), | ||||
@@ -370,6 +374,8 @@ struct UI::PrivateData { | |||||
#if !DISTRHO_PLUGIN_HAS_EXTERNAL_UI && !defined(DGL_FILE_BROWSER_DISABLED) | #if !DISTRHO_PLUGIN_HAS_EXTERNAL_UI && !defined(DGL_FILE_BROWSER_DISABLED) | ||||
std::free(uiStateFileKeyRequest); | std::free(uiStateFileKeyRequest); | ||||
#endif | #endif | ||||
std::free(binaryFilename); | |||||
std::free(bundlePath); | |||||
} | } | ||||
void editParamCallback(const uint32_t rindex, const bool started) | void editParamCallback(const uint32_t rindex, const bool started) | ||||
@@ -0,0 +1,47 @@ | |||||
/* | |||||
* DISTRHO Plugin Framework (DPF) | |||||
* Copyright (C) 2012-2021 Filipe Coelho <falktx@falktx.com> | |||||
* | |||||
* Permission to use, copy, modify, and/or distribute this software for any purpose with | |||||
* or without fee is hereby granted, provided that the above copyright notice and this | |||||
* permission notice appear in all copies. | |||||
* | |||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD | |||||
* TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN | |||||
* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL | |||||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER | |||||
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN | |||||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |||||
*/ | |||||
START_NAMESPACE_DISTRHO | |||||
#ifdef DISTRHO_PLUGIN_TARGET_JACK | |||||
#endif | |||||
// ----------------------------------------------------------------------- | |||||
const char* getPluginFormatName() noexcept | |||||
{ | |||||
#if defined(DISTRHO_PLUGIN_TARGET_CARLA) | |||||
return "Carla"; | |||||
#elif defined(DISTRHO_PLUGIN_TARGET_JACK) | |||||
return "JACK/Standalone"; | |||||
#elif defined(DISTRHO_PLUGIN_TARGET_LADSPA) | |||||
return "LADSPA"; | |||||
#elif defined(DISTRHO_PLUGIN_TARGET_DSSI) | |||||
return "DSSI"; | |||||
#elif defined(DISTRHO_PLUGIN_TARGET_LV2) | |||||
return "LV2"; | |||||
#elif defined(DISTRHO_PLUGIN_TARGET_VST2) | |||||
return "VST2"; | |||||
#elif defined(DISTRHO_PLUGIN_TARGET_VST3) | |||||
return "VST3"; | |||||
#else | |||||
return "Unknown"; | |||||
#endif | |||||
} | |||||
// ----------------------------------------------------------------------- | |||||
END_NAMESPACE_DISTRHO |