Browse Source

Add Plugin::isDummyInstance() method, useful for some plugins

Signed-off-by: falkTX <falktx@falktx.com>
pull/349/head
falkTX 3 years ago
parent
commit
ad055720fc
Signed by: falkTX <falktx@falktx.com> GPG Key ID: CDBAA37ABC74FBA0
7 changed files with 29 additions and 4 deletions
  1. +8
    -0
      distrho/DistrhoPlugin.hpp
  2. +6
    -0
      distrho/src/DistrhoPlugin.cpp
  3. +7
    -4
      distrho/src/DistrhoPluginInternal.hpp
  4. +2
    -0
      distrho/src/DistrhoPluginLADSPA+DSSI.cpp
  5. +2
    -0
      distrho/src/DistrhoPluginLV2export.cpp
  6. +2
    -0
      distrho/src/DistrhoPluginVST2.cpp
  7. +2
    -0
      distrho/src/DistrhoPluginVST3.cpp

+ 8
- 0
distrho/DistrhoPlugin.hpp View File

@@ -845,6 +845,14 @@ public:
*/ */
const char* getBundlePath() const noexcept; const char* getBundlePath() const noexcept;


/**
Check if this plugin instance is a "dummy" one used for plugin meta-data/information export.@n
When true no processing will be done, the plugin is created only to extract information.@n
In DPF, LADSPA/DSSI, VST2 and VST3 formats create one global instance per plugin binary
while LV2 creates one when generating turtle meta-data.
*/
bool isDummyInstance() 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


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

@@ -24,6 +24,7 @@ START_NAMESPACE_DISTRHO
uint32_t d_nextBufferSize = 0; uint32_t d_nextBufferSize = 0;
double d_nextSampleRate = 0.0; double d_nextSampleRate = 0.0;
const char* d_nextBundlePath = nullptr; const char* d_nextBundlePath = nullptr;
bool d_nextPluginIsDummy = false;
bool d_nextCanRequestParameterValueChanges = false; bool d_nextCanRequestParameterValueChanges = false;


/* ------------------------------------------------------------------------------------------------------------ /* ------------------------------------------------------------------------------------------------------------
@@ -106,6 +107,11 @@ const char* Plugin::getBundlePath() const noexcept
return pData->bundlePath; return pData->bundlePath;
} }


bool Plugin::isDummyInstance() const noexcept
{
return pData->isDummy;
}

#if DISTRHO_PLUGIN_WANT_TIMEPOS #if DISTRHO_PLUGIN_WANT_TIMEPOS
const TimePosition& Plugin::getTimePosition() const noexcept const TimePosition& Plugin::getTimePosition() const noexcept
{ {


+ 7
- 4
distrho/src/DistrhoPluginInternal.hpp View File

@@ -34,6 +34,7 @@ static const uint32_t kMaxMidiEvents = 512;
extern uint32_t d_nextBufferSize; extern uint32_t d_nextBufferSize;
extern double d_nextSampleRate; extern double d_nextSampleRate;
extern const char* d_nextBundlePath; extern const char* d_nextBundlePath;
extern bool d_nextPluginIsDummy;
extern bool d_nextCanRequestParameterValueChanges; extern bool d_nextCanRequestParameterValueChanges;


// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
@@ -84,6 +85,8 @@ static void fillInPredefinedPortGroupData(const uint32_t groupId, PortGroup& por
// Plugin private data // Plugin private data


struct Plugin::PrivateData { struct Plugin::PrivateData {
const bool canRequestParameterValueChanges;
const bool isDummy;
bool isProcessing; bool isProcessing;


#if DISTRHO_PLUGIN_NUM_INPUTS+DISTRHO_PLUGIN_NUM_OUTPUTS > 0 #if DISTRHO_PLUGIN_NUM_INPUTS+DISTRHO_PLUGIN_NUM_OUTPUTS > 0
@@ -124,10 +127,11 @@ struct Plugin::PrivateData {
uint32_t bufferSize; uint32_t bufferSize;
double sampleRate; double sampleRate;
char* bundlePath; char* bundlePath;
bool canRequestParameterValueChanges;


PrivateData() noexcept PrivateData() noexcept
: isProcessing(false),
: canRequestParameterValueChanges(d_nextCanRequestParameterValueChanges),
isDummy(d_nextPluginIsDummy),
isProcessing(false),
#if DISTRHO_PLUGIN_NUM_INPUTS+DISTRHO_PLUGIN_NUM_OUTPUTS > 0 #if DISTRHO_PLUGIN_NUM_INPUTS+DISTRHO_PLUGIN_NUM_OUTPUTS > 0
audioPorts(nullptr), audioPorts(nullptr),
#endif #endif
@@ -153,8 +157,7 @@ struct Plugin::PrivateData {
requestParameterValueChangeCallbackFunc(nullptr), requestParameterValueChangeCallbackFunc(nullptr),
bufferSize(d_nextBufferSize), bufferSize(d_nextBufferSize),
sampleRate(d_nextSampleRate), sampleRate(d_nextSampleRate),
bundlePath(d_nextBundlePath != nullptr ? strdup(d_nextBundlePath) : nullptr),
canRequestParameterValueChanges(d_nextCanRequestParameterValueChanges)
bundlePath(d_nextBundlePath != nullptr ? strdup(d_nextBundlePath) : nullptr)
{ {
DISTRHO_SAFE_ASSERT(bufferSize != 0); DISTRHO_SAFE_ASSERT(bufferSize != 0);
DISTRHO_SAFE_ASSERT(d_isNotZero(sampleRate)); DISTRHO_SAFE_ASSERT(d_isNotZero(sampleRate));


+ 2
- 0
distrho/src/DistrhoPluginLADSPA+DSSI.cpp View File

@@ -553,9 +553,11 @@ static const struct DescriptorInitializer
// Create dummy plugin to get data from // Create dummy plugin to get data from
d_nextBufferSize = 512; d_nextBufferSize = 512;
d_nextSampleRate = 44100.0; d_nextSampleRate = 44100.0;
d_nextPluginIsDummy = true;
const PluginExporter plugin(nullptr, nullptr, nullptr); const PluginExporter plugin(nullptr, nullptr, nullptr);
d_nextBufferSize = 0; d_nextBufferSize = 0;
d_nextSampleRate = 0.0; d_nextSampleRate = 0.0;
d_nextPluginIsDummy = false;


// Get port count, init // Get port count, init
ulong port = 0; ulong port = 0;


+ 2
- 0
distrho/src/DistrhoPluginLV2export.cpp View File

@@ -231,9 +231,11 @@ void lv2_generate_ttl(const char* const basename)
// Dummy plugin to get data from // Dummy plugin to get data from
d_nextBufferSize = 512; d_nextBufferSize = 512;
d_nextSampleRate = 44100.0; d_nextSampleRate = 44100.0;
d_nextPluginIsDummy = true;
PluginExporter plugin(nullptr, nullptr, nullptr); PluginExporter plugin(nullptr, nullptr, nullptr);
d_nextBufferSize = 0; d_nextBufferSize = 0;
d_nextSampleRate = 0.0; d_nextSampleRate = 0.0;
d_nextPluginIsDummy = false;


const String pluginDLL(basename); const String pluginDLL(basename);
const String pluginTTL(pluginDLL + ".ttl"); const String pluginTTL(pluginDLL + ".ttl");


+ 2
- 0
distrho/src/DistrhoPluginVST2.cpp View File

@@ -1406,6 +1406,7 @@ static intptr_t vst_dispatcherCallback(AEffect* effect, int32_t opcode, int32_t
// set valid but dummy values // set valid but dummy values
d_nextBufferSize = 512; d_nextBufferSize = 512;
d_nextSampleRate = 44100.0; d_nextSampleRate = 44100.0;
d_nextPluginIsDummy = true;
d_nextCanRequestParameterValueChanges = true; d_nextCanRequestParameterValueChanges = true;
} }


@@ -1417,6 +1418,7 @@ static intptr_t vst_dispatcherCallback(AEffect* effect, int32_t opcode, int32_t
// unset // unset
d_nextBufferSize = 0; d_nextBufferSize = 0;
d_nextSampleRate = 0.0; d_nextSampleRate = 0.0;
d_nextPluginIsDummy = false;
d_nextCanRequestParameterValueChanges = false; d_nextCanRequestParameterValueChanges = false;


*(PluginExporter**)ptr = &plugin; *(PluginExporter**)ptr = &plugin;


+ 2
- 0
distrho/src/DistrhoPluginVST3.cpp View File

@@ -3544,10 +3544,12 @@ static const PluginExporter& _getPluginInfo()
{ {
d_nextBufferSize = 512; d_nextBufferSize = 512;
d_nextSampleRate = 44100.0; d_nextSampleRate = 44100.0;
d_nextPluginIsDummy = true;
d_nextCanRequestParameterValueChanges = true; d_nextCanRequestParameterValueChanges = true;
static const PluginExporter gPluginInfo(nullptr, nullptr, nullptr); static const PluginExporter gPluginInfo(nullptr, nullptr, nullptr);
d_nextBufferSize = 0; d_nextBufferSize = 0;
d_nextSampleRate = 0.0; d_nextSampleRate = 0.0;
d_nextPluginIsDummy = false;
d_nextCanRequestParameterValueChanges = false; d_nextCanRequestParameterValueChanges = false;


return gPluginInfo; return gPluginInfo;


Loading…
Cancel
Save