Skip to content

Commit

Permalink
Re-worked plug-in wrappers to all use new parameter system via Legacy…
Browse files Browse the repository at this point in the history
…AudioParameter wrapper class
  • Loading branch information
hogliux committed Apr 4, 2018
1 parent 2ff4d85 commit e05a154
Show file tree
Hide file tree
Showing 13 changed files with 834 additions and 771 deletions.
1 change: 1 addition & 0 deletions extras/AudioPluginHost/Source/GraphEditorPanel.cpp
Expand Up @@ -307,6 +307,7 @@ struct GraphEditorPanel::FilterComponent : public Component
case 12: showWindow (PluginWindow::Type::generic); break; case 12: showWindow (PluginWindow::Type::generic); break;
case 20: showWindow (PluginWindow::Type::audioIO); break; case 20: showWindow (PluginWindow::Type::audioIO); break;
case 21: testStateSaveLoad(); break; case 21: testStateSaveLoad(); break;

default: break; default: break;
} }
} }
Expand Down
168 changes: 102 additions & 66 deletions modules/juce_audio_plugin_client/AAX/juce_AAX_Wrapper.cpp

Large diffs are not rendered by default.

308 changes: 148 additions & 160 deletions modules/juce_audio_plugin_client/AU/juce_AU_Wrapper.mm

Large diffs are not rendered by default.

170 changes: 80 additions & 90 deletions modules/juce_audio_plugin_client/AU/juce_AUv3_Wrapper.mm

Large diffs are not rendered by default.

72 changes: 34 additions & 38 deletions modules/juce_audio_plugin_client/VST/juce_VST_Wrapper.cpp
Expand Up @@ -79,6 +79,7 @@
#include "../utility/juce_FakeMouseMoveGenerator.h" #include "../utility/juce_FakeMouseMoveGenerator.h"
#include "../utility/juce_WindowsHooks.h" #include "../utility/juce_WindowsHooks.h"


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


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


juceParameters.update (*processor, false);

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


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


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


void setParameter (int32 index, float value) 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; inParameterChangedCallback = true;
param->sendValueChangedMessageToListeners (value); param->sendValueChangedMessageToListeners (value);
}
else
{
jassert (isPositiveAndBelow (index, processor->getNumParameters()));
processor->setParameter (index, value);
}
} }
} }


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


LegacyAudioParametersWrapper juceParameters;

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


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


pointer_sized_int handleGetParameterLabel (VstOpCodeArguments args) 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. // 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; return 0;
} }


pointer_sized_int handleGetParameterText (VstOpCodeArguments args) 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. // 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; return 0;
} }


pointer_sized_int handleGetParameterName (VstOpCodeArguments args) 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. // 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; return 0;
Expand Down Expand Up @@ -1823,20 +1816,20 @@ class JuceVSTWrapper : public AudioProcessorListener,


pointer_sized_int handleIsParameterAutomatable (VstOpCodeArguments args) pointer_sized_int handleIsParameterAutomatable (VstOpCodeArguments args)
{ {
if (processor == nullptr) if (auto* param = juceParameters.getParamForIndex (args.index))
return 0; {
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 0;
return (processor->isParameterAutomatable (args.index) && (! isMeter) ? 1 : 0);
} }


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

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


Expand Down

0 comments on commit e05a154

Please sign in to comment.