Skip to content
Permalink
Browse files

Re-worked plug-in wrappers to all use new parameter system via Legacy…

…AudioParameter wrapper class
  • Loading branch information
hogliux committed Apr 4, 2018
1 parent 2ff4d85 commit e05a1549f226b2ae4567551508f1082c8d220058
@@ -307,6 +307,7 @@ struct GraphEditorPanel::FilterComponent : public Component
case 12: showWindow (PluginWindow::Type::generic); break;
case 20: showWindow (PluginWindow::Type::audioIO); break;
case 21: testStateSaveLoad(); break;

default: break;
}
}

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

@@ -79,6 +79,7 @@
#include "../utility/juce_FakeMouseMoveGenerator.h"
#include "../utility/juce_WindowsHooks.h"

#include "../../juce_audio_processors/format_types/juce_LegacyAudioParameter.cpp"
#include "../../juce_audio_processors/format_types/juce_VSTCommon.h"

#ifdef _MSC_VER
@@ -281,14 +282,16 @@ class JuceVSTWrapper : public AudioProcessorListener,
processor->setPlayHead (this);
processor->addListener (this);

juceParameters.update (*processor, false);

memset (&vstEffect, 0, sizeof (vstEffect));
vstEffect.interfaceIdentifier = juceVstInterfaceIdentifier;
vstEffect.dispatchFunction = dispatcherCB;
vstEffect.processAudioFunction = nullptr;
vstEffect.setParameterValueFunction = setParameterCB;
vstEffect.getParameterValueFunction = getParameterCB;
vstEffect.numPrograms = jmax (1, af->getNumPrograms());
vstEffect.numParameters = af->getNumParameters();
vstEffect.numParameters = juceParameters.getNumParameters();
vstEffect.numInputChannels = maxNumInChannels;
vstEffect.numOutputChannels = maxNumOutChannels;
vstEffect.latency = processor->getLatencySamples();
@@ -706,11 +709,10 @@ class JuceVSTWrapper : public AudioProcessorListener,
//==============================================================================
float getParameter (int32 index) const
{
if (processor == nullptr)
return 0.0f;
if (auto* param = juceParameters.getParamForIndex (index))
return param->getValue();

jassert (isPositiveAndBelow (index, processor->getNumParameters()));
return processor->getParameter (index);
return 0.0f;
}

static float getParameterCB (VstEffectInterface* vstInterface, int32 index)
@@ -720,20 +722,12 @@ class JuceVSTWrapper : public AudioProcessorListener,

void setParameter (int32 index, float value)
{
if (processor != nullptr)
if (auto* param = juceParameters.getParamForIndex (index))
{
if (auto* param = processor->getParameters()[index])
{
param->setValue (value);
param->setValue (value);

inParameterChangedCallback = true;
param->sendValueChangedMessageToListeners (value);
}
else
{
jassert (isPositiveAndBelow (index, processor->getNumParameters()));
processor->setParameter (index, value);
}
inParameterChangedCallback = true;
param->sendValueChangedMessageToListeners (value);
}
}

@@ -1472,6 +1466,8 @@ class JuceVSTWrapper : public AudioProcessorListener,
VSTMidiEventList outgoingEvents;
float editorScaleFactor = 1.0f;

LegacyAudioParametersWrapper juceParameters;

bool isProcessing = false, isBypassed = false, hasShutdown = false;
bool firstProcessCallback = true, shouldDeleteEditor = false;

@@ -1664,35 +1660,32 @@ class JuceVSTWrapper : public AudioProcessorListener,

pointer_sized_int handleGetParameterLabel (VstOpCodeArguments args)
{
if (processor != nullptr)
if (auto* param = juceParameters.getParamForIndex (args.index))
{
jassert (isPositiveAndBelow (args.index, processor->getNumParameters()));
// length should technically be kVstMaxParamStrLen, which is 8, but hosts will normally allow a bit more.
processor->getParameterLabel (args.index).copyToUTF8 ((char*) args.ptr, 24 + 1);
param->getLabel().copyToUTF8 ((char*) args.ptr, 24 + 1);
}

return 0;
}

pointer_sized_int handleGetParameterText (VstOpCodeArguments args)
{
if (processor != nullptr)
if (auto* param = juceParameters.getParamForIndex (args.index))
{
jassert (isPositiveAndBelow (args.index, processor->getNumParameters()));
// length should technically be kVstMaxParamStrLen, which is 8, but hosts will normally allow a bit more.
processor->getParameterText (args.index, 24).copyToUTF8 ((char*) args.ptr, 24 + 1);
param->getCurrentValueAsText().copyToUTF8 ((char*) args.ptr, 24 + 1);
}

return 0;
}

pointer_sized_int handleGetParameterName (VstOpCodeArguments args)
{
if (processor != nullptr)
if (auto* param = juceParameters.getParamForIndex (args.index))
{
jassert (isPositiveAndBelow (args.index, processor->getNumParameters()));
// length should technically be kVstMaxParamStrLen, which is 8, but hosts will normally allow a bit more.
processor->getParameterName (args.index, 32).copyToUTF8 ((char*) args.ptr, 32 + 1);
param->getName (32).copyToUTF8 ((char*) args.ptr, 32 + 1);
}

return 0;
@@ -1823,20 +1816,20 @@ class JuceVSTWrapper : public AudioProcessorListener,

pointer_sized_int handleIsParameterAutomatable (VstOpCodeArguments args)
{
if (processor == nullptr)
return 0;
if (auto* param = juceParameters.getParamForIndex (args.index))
{
const bool isMeter = (((param->getCategory() & 0xffff0000) >> 16) == 2);
return (param->isAutomatable() && (! isMeter) ? 1 : 0);
}

const bool isMeter = (((processor->getParameterCategory (args.index) & 0xffff0000) >> 16) == 2);
return (processor->isParameterAutomatable (args.index) && (! isMeter) ? 1 : 0);
return 0;
}

pointer_sized_int handleParameterValueForText (VstOpCodeArguments args)
{
if (processor != nullptr)
if (auto* param = juceParameters.getParamForIndex (args.index))
{
jassert (isPositiveAndBelow (args.index, processor->getNumParameters()));

if (auto* param = processor->getParameters()[args.index])
if (! LegacyAudioParameter::isLegacy (param))
{
auto value = param->getValueForText (String::fromUTF8 ((char*) args.ptr));
param->setValue (value);
@@ -2120,11 +2113,14 @@ class JuceVSTWrapper : public AudioProcessorListener,
{
if (processor != nullptr && dest != nullptr)
{
if (auto* param = processor->getParameters()[(int) paramIndex])
if (auto* param = juceParameters.getParamForIndex ((int) paramIndex))
{
String text (param->getText (value, 1024));
memcpy (dest, text.toRawUTF8(), ((size_t) text.length()) + 1);
return 0xbeef;
if (! LegacyAudioParameter::isLegacy (param))
{
String text (param->getText (value, 1024));
memcpy (dest, text.toRawUTF8(), ((size_t) text.length()) + 1);
return 0xbeef;
}
}
}

0 comments on commit e05a154

Please sign in to comment.
You can’t perform that action at this time.