Browse Source

Define functions for plugin format and binary/bundle path, WIP

pull/344/head
falkTX 3 years ago
parent
commit
74f4898b2a
8 changed files with 127 additions and 0 deletions
  1. +12
    -0
      distrho/DistrhoPlugin.hpp
  2. +13
    -0
      distrho/DistrhoPluginUtils.hpp
  3. +13
    -0
      distrho/DistrhoUI.hpp
  4. +10
    -0
      distrho/src/DistrhoPlugin.cpp
  5. +16
    -0
      distrho/src/DistrhoPluginInternal.hpp
  6. +10
    -0
      distrho/src/DistrhoUI.cpp
  7. +6
    -0
      distrho/src/DistrhoUIPrivateData.hpp
  8. +47
    -0
      distrho/src/DistrhoUtils.cpp

+ 12
- 0
distrho/DistrhoPlugin.hpp View File

@@ -837,6 +837,18 @@ public:
*/
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
/**
Get the current host transport time position.@n


+ 13
- 0
distrho/DistrhoPluginUtils.hpp View File

@@ -22,6 +22,19 @@
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.


+ 13
- 0
distrho/DistrhoUI.hpp View File

@@ -131,6 +131,19 @@ public:
*/
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.



+ 10
- 0
distrho/src/DistrhoPlugin.cpp View File

@@ -100,6 +100,16 @@ double Plugin::getSampleRate() const noexcept
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
const TimePosition& Plugin::getTimePosition() const noexcept
{


+ 16
- 0
distrho/src/DistrhoPluginInternal.hpp View File

@@ -122,6 +122,8 @@ struct Plugin::PrivateData {

uint32_t bufferSize;
double sampleRate;
char* binaryFilename;
char* bundlePath;
bool canRequestParameterValueChanges;

PrivateData() noexcept
@@ -151,6 +153,8 @@ struct Plugin::PrivateData {
requestParameterValueChangeCallbackFunc(nullptr),
bufferSize(d_lastBufferSize),
sampleRate(d_lastSampleRate),
binaryFilename(nullptr),
bundlePath(nullptr),
canRequestParameterValueChanges(d_lastCanRequestParameterValueChanges)
{
DISTRHO_SAFE_ASSERT(bufferSize != 0);
@@ -225,6 +229,18 @@ struct Plugin::PrivateData {
stateDefValues = nullptr;
}
#endif

if (binaryFilename != nullptr)
{
std::free(binaryFilename);
binaryFilename = nullptr;
}

if (bundlePath != nullptr)
{
std::free(bundlePath);
bundlePath = nullptr;
}
}

#if DISTRHO_PLUGIN_WANT_MIDI_OUTPUT


+ 10
- 0
distrho/src/DistrhoUI.cpp View File

@@ -217,6 +217,16 @@ double UI::getSampleRate() const noexcept
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)
{
uiData->editParamCallback(index + uiData->parameterOffset, started);


+ 6
- 0
distrho/src/DistrhoUIPrivateData.hpp View File

@@ -308,6 +308,8 @@ struct UI::PrivateData {
#if !DISTRHO_PLUGIN_HAS_EXTERNAL_UI && !defined(DGL_FILE_BROWSER_DISABLED)
char* uiStateFileKeyRequest;
#endif
char* binaryFilename;
char* bundlePath;

// Callbacks
void* callbacksPtr;
@@ -331,6 +333,8 @@ struct UI::PrivateData {
#if !DISTRHO_PLUGIN_HAS_EXTERNAL_UI && !defined(DGL_FILE_BROWSER_DISABLED)
uiStateFileKeyRequest(nullptr),
#endif
binaryFilename(nullptr),
bundlePath(nullptr),
callbacksPtr(nullptr),
editParamCallbackFunc(nullptr),
setParamCallbackFunc(nullptr),
@@ -370,6 +374,8 @@ struct UI::PrivateData {
#if !DISTRHO_PLUGIN_HAS_EXTERNAL_UI && !defined(DGL_FILE_BROWSER_DISABLED)
std::free(uiStateFileKeyRequest);
#endif
std::free(binaryFilename);
std::free(bundlePath);
}

void editParamCallback(const uint32_t rindex, const bool started)


+ 47
- 0
distrho/src/DistrhoUtils.cpp View File

@@ -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

Loading…
Cancel
Save