Expand Up
@@ -87,7 +87,7 @@ typedef struct _VstTimeInfo {
int32_t flags;
} VstTimeInfo;
}
} // extern "C"
// --------------------------------------------------------------------------------------------------------------------
Expand All
@@ -105,25 +105,25 @@ static const requestParameterValueChangeFunc requestParameterValueChangeCallback
struct ParameterAndNotesHelper
{
float * parameterValues;
#if DISTRHO_PLUGIN_HAS_UI
#if DISTRHO_PLUGIN_HAS_UI
bool * parameterChecks;
# if DISTRHO_PLUGIN_WANT_MIDI_INPUT
# if DISTRHO_PLUGIN_WANT_MIDI_INPUT
SmallStackBuffer notesRingBuffer;
# endif
#endif
# endif
#endif
ParameterAndNotesHelper ()
: parameterValues(nullptr )
#if DISTRHO_PLUGIN_HAS_UI
#if DISTRHO_PLUGIN_HAS_UI
, parameterChecks(nullptr )
# if DISTRHO_PLUGIN_WANT_MIDI_INPUT
# if DISTRHO_PLUGIN_WANT_MIDI_INPUT
, notesRingBuffer(StackBuffer_INIT)
# endif
#endif
# endif
#endif
{
#if DISTRHO_PLUGIN_HAS_UI && DISTRHO_PLUGIN_WANT_MIDI_INPUT && ! defined(DISTRHO_PROPER_CPP11_SUPPORT)
#if DISTRHO_PLUGIN_HAS_UI && DISTRHO_PLUGIN_WANT_MIDI_INPUT && ! defined(DISTRHO_PROPER_CPP11_SUPPORT)
std::memset (¬esRingBuffer, 0 , sizeof (notesRingBuffer));
#endif
#endif
}
virtual ~ParameterAndNotesHelper ()
Expand All
@@ -133,18 +133,18 @@ struct ParameterAndNotesHelper
delete[] parameterValues;
parameterValues = nullptr ;
}
#if DISTRHO_PLUGIN_HAS_UI
#if DISTRHO_PLUGIN_HAS_UI
if (parameterChecks != nullptr )
{
delete[] parameterChecks;
parameterChecks = nullptr ;
}
#endif
#endif
}
#if DISTRHO_PLUGIN_WANT_STATE
#if DISTRHO_PLUGIN_WANT_STATE
virtual void setStateFromUI (const char * key, const char * value) = 0;
#endif
#endif
};
#if DISTRHO_PLUGIN_HAS_UI
Expand Down
Expand Up
@@ -179,19 +179,19 @@ class UIVst
d_nextBundlePath,
plugin->getInstancePointer(),
scaleFactor)
# if !DISTRHO_PLUGIN_HAS_EXTERNAL_UI
# if !DISTRHO_PLUGIN_HAS_EXTERNAL_UI
, fKeyboardModifiers (0 )
# endif
# if DISTRHO_PLUGIN_WANT_MIDI_INPUT
# endif
# if DISTRHO_PLUGIN_WANT_MIDI_INPUT
, fNotesRingBuffer ()
# endif
# endif
{
# if DISTRHO_PLUGIN_WANT_MIDI_INPUT
# if DISTRHO_PLUGIN_WANT_MIDI_INPUT
fNotesRingBuffer .setRingBuffer (&uiHelper->notesRingBuffer , false );
# endif
# endif
}
// -------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------
void idle ()
{
Expand Down
Expand Up
@@ -232,7 +232,7 @@ class UIVst
fUI .notifyScaleFactorChanged (scaleFactor);
}
// -------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------
// functions called from the plugin side, may block
#if DISTRHO_PLUGIN_WANT_STATE
Expand All
@@ -242,7 +242,7 @@ class UIVst
}
#endif
# if !DISTRHO_PLUGIN_HAS_EXTERNAL_UI
# if !DISTRHO_PLUGIN_HAS_EXTERNAL_UI
int handlePluginKeyEvent (const bool down, const int32_t index, const intptr_t value)
{
d_stdout (" handlePluginKeyEvent %i %i %li\n " , down, index , (long int )value);
Expand Down
Expand Up
@@ -278,9 +278,9 @@ class UIVst
value >= 0 ? static_cast <uint >(value) : 0 ,
fKeyboardModifiers ) ? 1 : 0 ;
}
# endif // !DISTRHO_PLUGIN_HAS_EXTERNAL_UI
# endif // !DISTRHO_PLUGIN_HAS_EXTERNAL_UI
// -------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------
protected:
inline intptr_t hostCallback (const VST_HOST_OPCODE opcode,
Expand All
@@ -300,23 +300,23 @@ class UIVst
void setParameterValue (const uint32_t index, const float realValue)
{
const ParameterRanges& ranges (fPlugin ->getParameterRanges (index ));
const float perValue ( ranges.getNormalizedValue (realValue) );
const float perValue = ranges.getNormalizedValue (realValue);
fPlugin ->setParameterValue (index , realValue);
hostCallback (VST_HOST_OPCODE_00, index , 0 , nullptr , perValue);
}
void setSize (uint width, uint height)
{
# ifdef DISTRHO_OS_MAC
# ifdef DISTRHO_OS_MAC
const double scaleFactor = fUI .getScaleFactor ();
width /= scaleFactor;
height /= scaleFactor;
# endif
# endif
hostCallback (VST_HOST_OPCODE_0F, width, height);
}
# if DISTRHO_PLUGIN_WANT_MIDI_INPUT
# if DISTRHO_PLUGIN_WANT_MIDI_INPUT
void sendNote (const uint8_t channel, const uint8_t note, const uint8_t velocity)
{
uint8_t midiData[3 ];
Expand All
@@ -326,14 +326,14 @@ class UIVst
fNotesRingBuffer .writeCustomData (midiData, 3 );
fNotesRingBuffer .commitWrite ();
}
# endif
# endif
# if DISTRHO_PLUGIN_WANT_STATE
# if DISTRHO_PLUGIN_WANT_STATE
void setState (const char * const key, const char * const value)
{
fUiHelper ->setStateFromUI (key, value);
}
# endif
# endif
private:
// Vst stuff
Expand All
@@ -344,48 +344,44 @@ class UIVst
// Plugin UI
UIExporter fUI ;
# if !DISTRHO_PLUGIN_HAS_EXTERNAL_UI
# if !DISTRHO_PLUGIN_HAS_EXTERNAL_UI
uint16_t fKeyboardModifiers ;
# endif
# if DISTRHO_PLUGIN_WANT_MIDI_INPUT
# endif
# if DISTRHO_PLUGIN_WANT_MIDI_INPUT
RingBufferControl<SmallStackBuffer> fNotesRingBuffer ;
# endif
# endif
// -------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------
// Callbacks
#define handlePtr ((UIVst*)ptr)
static void editParameterCallback (void * ptr, uint32_t index, bool started)
static void editParameterCallback (void * const ptr, const uint32_t index, const bool started)
{
handlePtr ->editParameter (index , started);
static_cast <UIVst*>(ptr) ->editParameter (index , started);
}
static void setParameterCallback (void * ptr, uint32_t rindex, float value)
static void setParameterCallback (void * const ptr, const uint32_t rindex, const float value)
{
handlePtr ->setParameterValue (rindex , value);
static_cast <UIVst*>(ptr) ->setParameterValue (rindex , value);
}
static void setSizeCallback (void * ptr, uint width, uint height)
static void setSizeCallback (void * const ptr, const uint width, const uint height)
{
handlePtr ->setSize (width, height);
static_cast <UIVst*>(ptr) ->setSize (width, height);
}
# if DISTRHO_PLUGIN_WANT_MIDI_INPUT
static void sendNoteCallback (void * ptr, uint8_t channel, uint8_t note, uint8_t velocity)
# if DISTRHO_PLUGIN_WANT_MIDI_INPUT
static void sendNoteCallback (void * const ptr, const uint8_t channel, const uint8_t note, const uint8_t velocity)
{
handlePtr ->sendNote (channel, note, velocity);
static_cast <UIVst*>(ptr) ->sendNote (channel, note, velocity);
}
# endif
# endif
# if DISTRHO_PLUGIN_WANT_STATE
static void setStateCallback (void * ptr, const char * key, const char * value)
# if DISTRHO_PLUGIN_WANT_STATE
static void setStateCallback (void * const ptr, const char * const key, const char * const value)
{
handlePtr ->setState (key, value);
static_cast <UIVst*>(ptr) ->setState (key, value);
}
# endif
#undef handlePtr
#endif
};
#endif // DISTRHO_PLUGIN_HAS_UI
Expand All
@@ -412,11 +408,11 @@ class PluginVst : public ParameterAndNotesHelper
parameterValues[i] = NAN;
}
#if DISTRHO_PLUGIN_WANT_MIDI_INPUT
#if DISTRHO_PLUGIN_WANT_MIDI_INPUT
fMidiEventCount = 0 ;
#endif
#endif
#if DISTRHO_PLUGIN_HAS_UI
#if DISTRHO_PLUGIN_HAS_UI
fVstUI = nullptr ;
fVstRect .top = 0 ;
fVstRect .left = 0 ;
Expand All
@@ -430,51 +426,51 @@ class PluginVst : public ParameterAndNotesHelper
memset (parameterChecks, 0 , sizeof (bool )*parameterCount);
}
# if DISTRHO_OS_MAC
# ifdef __LP64__
# if DISTRHO_OS_MAC
# ifdef __LP64__
fUsingNsView = true ;
# else
# ifndef DISTRHO_NO_WARNINGS
# warning 32bit VST UIs on OSX only work if the host supports "hasCockosViewAsConfig"
# endif
# else
# ifndef DISTRHO_NO_WARNINGS
# warning 32bit VST UIs on macOS only work if the host supports "hasCockosViewAsConfig"
# endif
fUsingNsView = false ;
# endif
# endif // DISTRHO_OS_MAC
# endif
# endif // DISTRHO_OS_MAC
# if DISTRHO_PLUGIN_WANT_MIDI_INPUT
# if DISTRHO_PLUGIN_WANT_MIDI_INPUT
fNotesRingBuffer .setRingBuffer (¬esRingBuffer, true );
# endif
#endif // DISTRHO_PLUGIN_HAS_UI
# endif
#endif // DISTRHO_PLUGIN_HAS_UI
#if DISTRHO_PLUGIN_WANT_STATE
#if DISTRHO_PLUGIN_WANT_STATE
fStateChunk = nullptr ;
for (uint32_t i=0 , count=fPlugin .getStateCount (); i<count; ++i)
{
const String& dkey (fPlugin .getStateKey (i));
fStateMap [dkey] = fPlugin .getStateDefaultValue (i);
}
#endif
#endif
}
~PluginVst ()
{
#if DISTRHO_PLUGIN_WANT_STATE
#if DISTRHO_PLUGIN_WANT_STATE
if (fStateChunk != nullptr )
{
delete[] fStateChunk ;
fStateChunk = nullptr ;
}
fStateMap .clear ();
#endif
#endif
}
intptr_t vst_dispatcher (const int32_t opcode, const int32_t index, const intptr_t value, void * const ptr, const float opt)
{
#if DISTRHO_PLUGIN_WANT_STATE
#if DISTRHO_PLUGIN_WANT_STATE
intptr_t ret = 0 ;
#endif
#endif
switch (opcode)
{
Expand Down
Expand Up
@@ -546,10 +542,10 @@ class PluginVst : public ParameterAndNotesHelper
case VST_EFFECT_OPCODE_SET_SAMPLE_RATE:
fPlugin .setSampleRate (opt, true );
#if DISTRHO_PLUGIN_HAS_UI
#if DISTRHO_PLUGIN_HAS_UI
if (fVstUI != nullptr )
fVstUI ->setSampleRate (opt);
#endif
#endif
break ;
case VST_EFFECT_OPCODE_SET_BLOCK_SIZE:
Expand All
@@ -559,12 +555,12 @@ class PluginVst : public ParameterAndNotesHelper
case VST_EFFECT_OPCODE_SUSPEND:
if (value != 0 )
{
#if DISTRHO_PLUGIN_WANT_MIDI_INPUT
#if DISTRHO_PLUGIN_WANT_MIDI_INPUT
fMidiEventCount = 0 ;
// tell host we want MIDI events
hostCallback (VST_HOST_OPCODE_06);
#endif
#endif
// deactivate for possible changes
fPlugin .deactivateIfNeeded ();
Expand All
@@ -587,17 +583,17 @@ class PluginVst : public ParameterAndNotesHelper
}
break ;
#if DISTRHO_PLUGIN_HAS_UI
#if DISTRHO_PLUGIN_HAS_UI
case VST_EFFECT_OPCODE_WINDOW_GETRECT:
if (fVstUI != nullptr )
{
fVstRect .right = fVstUI ->getWidth ();
fVstRect .bottom = fVstUI ->getHeight ();
# ifdef DISTRHO_OS_MAC
# ifdef DISTRHO_OS_MAC
const double scaleFactor = fVstUI ->getScaleFactor ();
fVstRect .right /= scaleFactor;
fVstRect .bottom /= scaleFactor;
# endif
# endif
}
else
{
Expand Down
Expand Up
@@ -628,45 +624,42 @@ class PluginVst : public ParameterAndNotesHelper
delete fVstUI ; // for hosts which don't pair create/destroy calls (Minihost Modular)
fVstUI = nullptr ;
#if DISTRHO_OS_MAC
if (! fUsingNsView )
{
# if DISTRHO_OS_MAC
if (! fUsingNsView )
{
d_stderr (" Host doesn't support hasCockosViewAsConfig, cannot use UI" );
return 0 ;
}
# endif
fVstUI = new UIVst (fAudioMaster , fEffect , this , &fPlugin , (intptr_t )ptr, fLastScaleFactor );
d_stderr (" Host doesn't support hasCockosViewAsConfig, cannot use UI" );
return 0 ;
}
#endif
fVstUI = new UIVst (fAudioMaster , fEffect , this , &fPlugin , (intptr_t )ptr, fLastScaleFactor );
#if DISTRHO_PLUGIN_WANT_FULL_STATE
// Update current state from plugin side
for (StringMap::const_iterator cit=fStateMap .begin (), cite=fStateMap .end (); cit != cite; ++cit)
{
const String& key = cit->first ;
fStateMap [key] = fPlugin .getStateValue (key);
}
#endif
#if DISTRHO_PLUGIN_WANT_FULL_STATE
// Update current state from plugin side
for (StringMap::const_iterator cit=fStateMap .begin (), cite=fStateMap .end (); cit != cite; ++cit)
{
const String& key = cit->first ;
fStateMap [key] = fPlugin .getStateValue (key);
}
#endif
#if DISTRHO_PLUGIN_WANT_STATE
// Set state
for (StringMap::const_iterator cit=fStateMap .begin (), cite=fStateMap .end (); cit != cite; ++cit)
{
const String& key = cit->first ;
const String& value = cit->second ;
#if DISTRHO_PLUGIN_WANT_STATE
// Set state
for (StringMap::const_iterator cit=fStateMap .begin (), cite=fStateMap .end (); cit != cite; ++cit)
{
const String& key ( cit->first ) ;
const String& value ( cit->second ) ;
// TODO skip DSP only states
// TODO skip DSP only states
fVstUI ->setStateFromPlugin (key, value);
}
#endif
fVstUI ->setStateFromPlugin (key, value);
}
#endif
for (uint32_t i=0 , count=fPlugin .getParameterCount (); i < count; ++i)
setParameterValueFromPlugin (i, fPlugin .getParameterValue (i));
for (uint32_t i=0 , count=fPlugin .getParameterCount (); i < count; ++i)
setParameterValueFromPlugin (i, fPlugin .getParameterValue (i));
fVstUI ->idle ();
return 1 ;
}
break ;
fVstUI ->idle ();
return 1 ;
case VST_EFFECT_OPCODE_WINDOW_DESTROY:
if (fVstUI != nullptr )
Expand All
@@ -682,7 +675,7 @@ class PluginVst : public ParameterAndNotesHelper
fVstUI ->idle ();
break ;
# if !DISTRHO_PLUGIN_HAS_EXTERNAL_UI
# if !DISTRHO_PLUGIN_HAS_EXTERNAL_UI
case VST_EFFECT_OPCODE_3B: // key down
if (fVstUI != nullptr )
return fVstUI ->handlePluginKeyEvent (true , index , value);
Expand All
@@ -692,10 +685,10 @@ class PluginVst : public ParameterAndNotesHelper
if (fVstUI != nullptr )
return fVstUI ->handlePluginKeyEvent (false , index , value);
break ;
# endif
#endif // DISTRHO_PLUGIN_HAS_UI
# endif
#endif // DISTRHO_PLUGIN_HAS_UI
#if DISTRHO_PLUGIN_WANT_STATE
#if DISTRHO_PLUGIN_WANT_STATE
case VST_EFFECT_OPCODE_17: // get chunk
{
if (ptr == nullptr )
Expand All
@@ -717,14 +710,14 @@ class PluginVst : public ParameterAndNotesHelper
}
else
{
# if DISTRHO_PLUGIN_WANT_FULL_STATE
# if DISTRHO_PLUGIN_WANT_FULL_STATE
// Update current state
for (StringMap::const_iterator cit=fStateMap .begin (), cite=fStateMap .end (); cit != cite; ++cit)
{
const String& key = cit->first ;
fStateMap [key] = fPlugin .getStateValue (key);
}
# endif
# endif
String chunkStr;
Expand Down
Expand Up
@@ -805,13 +798,13 @@ class PluginVst : public ParameterAndNotesHelper
setStateFromUI (key, value);
# if DISTRHO_PLUGIN_HAS_UI
# if DISTRHO_PLUGIN_HAS_UI
if (fVstUI != nullptr )
{
// TODO skip DSP only states
fVstUI ->setStateFromPlugin (key, value);
}
# endif
# endif
// get next key
size = std::strlen (value)+1 ;
Expand Down
Expand Up
@@ -848,10 +841,10 @@ class PluginVst : public ParameterAndNotesHelper
fvalue = std::atof (value);
fPlugin .setParameterValue (i, fvalue);
# if DISTRHO_PLUGIN_HAS_UI
# if DISTRHO_PLUGIN_HAS_UI
if (fVstUI != nullptr )
setParameterValueFromPlugin (i, fvalue);
# endif
# endif
break ;
}
Expand All
@@ -864,9 +857,9 @@ class PluginVst : public ParameterAndNotesHelper
return 1 ;
}
#endif // DISTRHO_PLUGIN_WANT_STATE
#endif // DISTRHO_PLUGIN_WANT_STATE
#if DISTRHO_PLUGIN_WANT_MIDI_INPUT
#if DISTRHO_PLUGIN_WANT_MIDI_INPUT
case VST_EFFECT_OPCODE_19: // process events
if (! fPlugin .isActive ())
{
Expand Down
Expand Up
@@ -899,7 +892,7 @@ class PluginVst : public ParameterAndNotesHelper
}
}
break ;
#endif
#endif
case VST_EFFECT_OPCODE_PARAM_ISAUTOMATABLE:
if (index < static_cast <int32_t >(fPlugin .getParameterCount ()))
Expand All
@@ -915,44 +908,44 @@ class PluginVst : public ParameterAndNotesHelper
case VST_EFFECT_OPCODE_SUPPORTS:
if (const char * const canDo = (const char *)ptr)
{
#if DISTRHO_OS_MAC && DISTRHO_PLUGIN_HAS_UI
#if DISTRHO_OS_MAC && DISTRHO_PLUGIN_HAS_UI
if (std::strcmp (canDo, " hasCockosViewAsConfig" ) == 0 )
{
fUsingNsView = true ;
return 0xbeef0000 ;
}
#endif
#ifndef DISTRHO_OS_MAC
#endif
#ifndef DISTRHO_OS_MAC
if (std::strcmp (canDo, " supportsViewDpiScaling" ) == 0 )
return 1 ;
#endif
#endif
if (std::strcmp (canDo, " receiveVstEvents" ) == 0 ||
std::strcmp (canDo, " receiveVstMidiEvent" ) == 0 )
#if DISTRHO_PLUGIN_WANT_MIDI_INPUT
#if DISTRHO_PLUGIN_WANT_MIDI_INPUT
return 1 ;
#else
#else
return -1 ;
#endif
#endif
if (std::strcmp (canDo, " sendVstEvents" ) == 0 ||
std::strcmp (canDo, " sendVstMidiEvent" ) == 0 )
#if DISTRHO_PLUGIN_WANT_MIDI_OUTPUT
#if DISTRHO_PLUGIN_WANT_MIDI_OUTPUT
return 1 ;
#else
#else
return -1 ;
#endif
#endif
if (std::strcmp (canDo, " receiveVstTimeInfo" ) == 0 )
#if DISTRHO_PLUGIN_WANT_TIMEPOS
#if DISTRHO_PLUGIN_WANT_TIMEPOS
return 1 ;
#else
#else
return -1 ;
#endif
#endif
if (std::strcmp (canDo, " offline" ) == 0 )
return -1 ;
}
break ;
case VST_EFFECT_OPCODE_CUSTOM:
#if DISTRHO_PLUGIN_HAS_UI && !defined(DISTRHO_OS_MAC)
#if DISTRHO_PLUGIN_HAS_UI && !defined(DISTRHO_OS_MAC)
if (index == d_cconst (' P' , ' r' , ' e' , ' S' ) && value == d_cconst (' A' , ' e' , ' C' , ' s' ))
{
if (d_isEqual (fLastScaleFactor , opt))
Expand All
@@ -963,7 +956,7 @@ class PluginVst : public ParameterAndNotesHelper
if (fVstUI != nullptr )
fVstUI ->notifyScaleFactorChanged (opt);
}
#endif
#endif
break ;
// case effStartProcess:
Expand Down
Expand Up
@@ -1002,10 +995,10 @@ class PluginVst : public ParameterAndNotesHelper
fPlugin .setParameterValue (index , realValue);
#if DISTRHO_PLUGIN_HAS_UI
#if DISTRHO_PLUGIN_HAS_UI
if (fVstUI != nullptr )
setParameterValueFromPlugin (index , realValue);
#endif
#endif
}
void vst_processReplacing (const float ** const inputs, float ** const outputs, const int32_t sampleFrames)
Expand All
@@ -1022,7 +1015,7 @@ class PluginVst : public ParameterAndNotesHelper
return ;
}
#if DISTRHO_PLUGIN_WANT_TIMEPOS
#if DISTRHO_PLUGIN_WANT_TIMEPOS
static constexpr const int kWantVstTimeFlags = 0x2602 ;
if (const VstTimeInfo* const vstTimeInfo = (const VstTimeInfo*)hostCallback (VST_HOST_OPCODE_07, 0 , kWantVstTimeFlags ))
Expand Down
Expand Up
@@ -1075,10 +1068,10 @@ class PluginVst : public ParameterAndNotesHelper
fPlugin .setTimePosition (fTimePosition );
}
#endif
#endif
#if DISTRHO_PLUGIN_WANT_MIDI_INPUT
# if DISTRHO_PLUGIN_HAS_UI
#if DISTRHO_PLUGIN_WANT_MIDI_INPUT
# if DISTRHO_PLUGIN_HAS_UI
if (fMidiEventCount != kMaxMidiEvents && fNotesRingBuffer .isDataAvailableForReading ())
{
uint8_t midiData[3 ];
Expand All
@@ -1098,18 +1091,18 @@ class PluginVst : public ParameterAndNotesHelper
break ;
}
}
# endif
# endif
fPlugin .run (inputs, outputs, sampleFrames, fMidiEvents , fMidiEventCount );
fMidiEventCount = 0 ;
#else
#else
fPlugin .run (inputs, outputs, sampleFrames);
#endif
#endif
updateParameterOutputsAndTriggers ();
}
// -------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------
friend class UIVst ;
Expand All
@@ -1124,34 +1117,34 @@ class PluginVst : public ParameterAndNotesHelper
// Temporary data
char fProgramName [32 ];
#if DISTRHO_PLUGIN_WANT_MIDI_INPUT
#if DISTRHO_PLUGIN_WANT_MIDI_INPUT
uint32_t fMidiEventCount ;
MidiEvent fMidiEvents [kMaxMidiEvents ];
#endif
#endif
#if DISTRHO_PLUGIN_WANT_TIMEPOS
#if DISTRHO_PLUGIN_WANT_TIMEPOS
TimePosition fTimePosition ;
#endif
#endif
// UI stuff
#if DISTRHO_PLUGIN_HAS_UI
#if DISTRHO_PLUGIN_HAS_UI
UIVst* fVstUI ;
vst_rect fVstRect ;
float fLastScaleFactor ;
# if DISTRHO_OS_MAC
# if DISTRHO_OS_MAC
bool fUsingNsView ;
# endif
# if DISTRHO_PLUGIN_WANT_MIDI_INPUT
# endif
# if DISTRHO_PLUGIN_WANT_MIDI_INPUT
RingBufferControl<SmallStackBuffer> fNotesRingBuffer ;
# endif
#endif
# endif
#endif
#if DISTRHO_PLUGIN_WANT_STATE
#if DISTRHO_PLUGIN_WANT_STATE
char * fStateChunk ;
StringMap fStateMap ;
#endif
#endif
// -------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------
// host callback
intptr_t hostCallback (const VST_HOST_OPCODE opcode,
Expand All
@@ -1163,7 +1156,7 @@ class PluginVst : public ParameterAndNotesHelper
return fAudioMaster (fEffect , opcode, index , value, ptr, opt);
}
// -------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------
// functions called from the plugin side, RT no block
void updateParameterOutputsAndTriggers ()
Expand All
@@ -1180,17 +1173,17 @@ class PluginVst : public ParameterAndNotesHelper
if (d_isEqual (curValue, parameterValues[i]))
continue ;
#if DISTRHO_PLUGIN_HAS_UI
#if DISTRHO_PLUGIN_HAS_UI
if (fVstUI != nullptr )
setParameterValueFromPlugin (i, curValue);
else
#endif
#endif
parameterValues[i] = curValue;
#ifndef DPF_VST_SHOW_PARAMETER_OUTPUTS
#ifndef DPF_VST_SHOW_PARAMETER_OUTPUTS
// skip automating parameter outputs from plugin if we disable them on VST
continue ;
#endif
#endif
}
else if ((fPlugin .getParameterHints (i) & kParameterIsTrigger ) == kParameterIsTrigger )
{
Expand All
@@ -1200,10 +1193,10 @@ class PluginVst : public ParameterAndNotesHelper
if (d_isEqual (curValue, fPlugin .getParameterRanges (i).def ))
continue ;
#if DISTRHO_PLUGIN_HAS_UI
#if DISTRHO_PLUGIN_HAS_UI
if (fVstUI != nullptr )
setParameterValueFromPlugin (i, curValue);
#endif
#endif
fPlugin .setParameterValue (i, curValue);
}
else
Expand All
@@ -1220,28 +1213,29 @@ class PluginVst : public ParameterAndNotesHelper
#endif
}
#if DISTRHO_PLUGIN_HAS_UI
#if DISTRHO_PLUGIN_HAS_UI
void setParameterValueFromPlugin (const uint32_t index, const float realValue)
{
parameterValues[index ] = realValue;
parameterChecks[index ] = true ;
}
#endif
#endif
#if DISTRHO_PLUGIN_WANT_PARAMETER_VALUE_CHANGE_REQUEST
#if DISTRHO_PLUGIN_WANT_PARAMETER_VALUE_CHANGE_REQUEST
bool requestParameterValueChange (const uint32_t index, const float value)
{
hostCallback (VST_HOST_OPCODE_00, index , 0 , nullptr , value);
const ParameterRanges& ranges (fPlugin .getParameterRanges (index ));
hostCallback (VST_HOST_OPCODE_00, index , 0 , nullptr , ranges.getNormalizedValue (value));
return true ;
}
static bool requestParameterValueChangeCallback (void * const ptr, const uint32_t index, const float value)
{
return ((PluginVst*)ptr)->requestParameterValueChange (index , value);
}
#endif
#endif
#if DISTRHO_PLUGIN_WANT_MIDI_OUTPUT
#if DISTRHO_PLUGIN_WANT_MIDI_OUTPUT
bool writeMidi (const MidiEvent& midiEvent)
{
if (midiEvent.size > 4 )
Expand All
@@ -1254,7 +1248,7 @@ class PluginVst : public ParameterAndNotesHelper
vstEvents.events [0 ] = (VstEvent*)&vstMidiEvent;
vstMidiEvent.type = 1 ;
vstMidiEvent.byteSize = static_cast <int32_t >(sizeof (VstMidiEvent));;
vstMidiEvent.byteSize = static_cast <int32_t >(sizeof (VstMidiEvent));
vstMidiEvent.deltaFrames = midiEvent.frame ;
for (uint8_t i=0 ; i<midiEvent.size ; ++i)
Expand All
@@ -1265,19 +1259,19 @@ class PluginVst : public ParameterAndNotesHelper
static bool writeMidiCallback (void * ptr, const MidiEvent& midiEvent)
{
return (( PluginVst*) ptr)->writeMidi (midiEvent);
return static_cast < PluginVst*>( ptr)->writeMidi (midiEvent);
}
#endif
#endif
#if DISTRHO_PLUGIN_WANT_STATE
// -------------------------------------------------------------------
#if DISTRHO_PLUGIN_WANT_STATE
// ----------------------------------------------------------------------------------------------------------------
// functions called from the UI side, may block
# if DISTRHO_PLUGIN_HAS_UI
# if DISTRHO_PLUGIN_HAS_UI
void setStateFromUI (const char * const key, const char * const value) override
# else
# else
void setStateFromUI (const char * const key, const char * const value)
# endif
# endif
{
fPlugin .setState (key, value);
Expand All
@@ -1299,7 +1293,7 @@ class PluginVst : public ParameterAndNotesHelper
d_stderr (" Failed to find plugin state with key \" %s\" " , key);
}
#endif
#endif
};
// --------------------------------------------------------------------------------------------------------------------
Expand Down
Expand Up
@@ -1598,7 +1592,7 @@ static void VST_FUNCTION_INTERFACE vst_processReplacingCallback(vst_effect* cons
pluginPtr->vst_processReplacing (const_cast <const float **>(inputs), outputs, sampleFrames);
}
// -----------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
END_NAMESPACE_DISTRHO
Expand Down
Expand Up
@@ -1676,9 +1670,9 @@ const vst_effect* VSTPluginMain(const vst_host_callback audioMaster)
effect->version = sPlugin ->getVersion ();
// VST doesn't support parameter outputs. we can fake them, but it is a hack. Disabled by default.
#ifdef DPF_VST_SHOW_PARAMETER_OUTPUTS
#ifdef DPF_VST_SHOW_PARAMETER_OUTPUTS
const int numParams = sPlugin ->getParameterCount ();
#else
#else
int numParams = 0 ;
bool outputsReached = false ;
Expand All
@@ -1693,7 +1687,7 @@ const vst_effect* VSTPluginMain(const vst_host_callback audioMaster)
}
outputsReached = true ;
}
#endif
#endif
// plugin fields
effect->num_params = numParams;
Expand Down
Expand Up
@@ -1731,4 +1725,4 @@ const vst_effect* VSTPluginMain(const vst_host_callback audioMaster)
return effect;
}
// -----------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------