From 66081465723aa501989cfc39efb97fadc16d8b8f Mon Sep 17 00:00:00 2001
From: Sophia Poirier <2997196+sophiapoirier@users.noreply.github.com>
Date: Sat, 1 Oct 2022 12:39:08 -0700
Subject: [PATCH] define named type dfx::ParameterID
---
bufferoverride/bufferoverride-base.h | 5 +-
bufferoverride/bufferoverride.h | 4 +-
bufferoverride/bufferoverrideformalities.cpp | 6 +-
bufferoverride/gui/bufferoverrideeditor.cpp | 28 +-
bufferoverride/gui/bufferoverrideeditor.h | 6 +-
dfx-library/dfxdefines.h | 7 +-
dfx-library/dfxparameter.cpp | 10 +-
dfx-library/dfxparameter.h | 6 +-
dfx-library/dfxplugin-audiounit.cpp | 60 +--
dfx-library/dfxplugin-base.h | 30 +-
dfx-library/dfxplugin-rtas.cpp | 178 +++++----
dfx-library/dfxplugin-vst.cpp | 52 +--
dfx-library/dfxplugin.cpp | 378 +++++++++----------
dfx-library/dfxplugin.h | 308 +++++++--------
dfx-library/dfxsettings.cpp | 243 ++++++------
dfx-library/dfxsettings.h | 49 ++-
dfxgui/dfxguibutton.cpp | 34 +-
dfxgui/dfxguibutton.h | 10 +-
dfxgui/dfxguicontrol.cpp | 6 +-
dfxgui/dfxguicontrol.h | 14 +-
dfxgui/dfxguicontrol.hpp | 33 +-
dfxgui/dfxguidialog.cpp | 14 +-
dfxgui/dfxguidialog.h | 8 +-
dfxgui/dfxguieditor.cpp | 278 +++++++-------
dfxgui/dfxguieditor.h | 105 +++---
dfxgui/dfxguimisc.h | 6 +-
dfxgui/dfxguislider.cpp | 39 +-
dfxgui/dfxguislider.h | 21 +-
dfxgui/dfxguitextdisplay.cpp | 14 +-
dfxgui/dfxguitextdisplay.h | 6 +-
dfxgui/idfxguicontrol.h | 8 +-
eqsync/eqsync.cpp | 4 +-
eqsync/eqsync.h | 4 +-
eqsync/gui/eqsynceditor.cpp | 12 +-
eqsync/gui/eqsynceditor.h | 6 +-
exemplar/exemplar.cpp | 136 +++----
exemplar/exemplar.h | 60 +--
fonttest/fonttest.h | 6 +-
geometer/geometer-base.h | 29 +-
geometer/geometer.cpp | 39 +-
geometer/geometer.h | 6 +-
geometer/gui/geometereditor.cpp | 18 +-
geometer/gui/geometereditor.h | 10 +-
midigater/midigater.h | 4 +-
monomaker/gui/monomakereditor.cpp | 4 +-
monomaker/monomaker.h | 4 +-
polarizer/gui/polarizereditor.cpp | 8 +-
polarizer/polarizer.h | 4 +-
rezsynth/gui/rezsyntheditor.cpp | 58 +--
rezsynth/gui/rezsyntheditor.h | 8 +-
rezsynth/rezsynth.h | 4 +-
scrubby/gui/scrubbyeditor.cpp | 65 ++--
scrubby/gui/scrubbyeditor.h | 4 +-
scrubby/scrubby.h | 6 +-
scrubby/scrubbyformalities.cpp | 5 +-
scrubby/scrubbyprocess.cpp | 12 +-
skidder/gui/skiddereditor.cpp | 10 +-
skidder/gui/skiddereditor.h | 6 +-
skidder/skidder.h | 6 +-
skidder/skiddermidi.cpp | 23 +-
slowft/slowft.cpp | 57 +--
slowft/slowft.h | 29 +-
stub-dfxplugin/dfxplugin-stub.h | 4 +-
thrush/thrush.cpp | 80 ++--
thrush/thrush.h | 28 +-
transverb/gui/transverbeditor.cpp | 72 ++--
transverb/gui/transverbeditor.h | 14 +-
transverb/transverb-base.h | 13 +-
transverb/transverb.h | 4 +-
transverb/transverbformalities.cpp | 33 +-
turntablist/turntablist.cpp | 34 +-
turntablist/turntablist.h | 6 +-
turntablist/turntablisteditor.mm | 35 +-
windowingstub/windowingstub.cpp | 6 +-
windowingstub/windowingstub.h | 4 +-
75 files changed, 1477 insertions(+), 1469 deletions(-)
diff --git a/bufferoverride/bufferoverride-base.h b/bufferoverride/bufferoverride-base.h
index ded9f5bd..d9b29177 100644
--- a/bufferoverride/bufferoverride-base.h
+++ b/bufferoverride/bufferoverride-base.h
@@ -16,7 +16,7 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Buffer Override. If not, see .
-To contact the author, use the contact form at http://destroyfx.org/
+To contact the author, use the contact form at http://destroyfx.org
------------------------------------------------------------------------*/
@@ -25,12 +25,13 @@ To contact the author, use the contact form at http://destroyfx.org/
#include
#include
+#include "dfxdefines.h"
#include "dfxmisc.h"
#include "dfxpluginproperties.h"
//-----------------------------------------------------------------------------
// these are the plugin parameters:
-enum
+enum : dfx::ParameterID
{
kDivisor,
kBufferSize_MS,
diff --git a/bufferoverride/bufferoverride.h b/bufferoverride/bufferoverride.h
index f8eed743..9d1aa423 100644
--- a/bufferoverride/bufferoverride.h
+++ b/bufferoverride/bufferoverride.h
@@ -16,7 +16,7 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Buffer Override. If not, see .
-To contact the author, use the contact form at http://destroyfx.org/
+To contact the author, use the contact form at http://destroyfx.org
------------------------------------------------------------------------*/
#pragma once
@@ -43,7 +43,7 @@ class BufferOverride final : public DfxPlugin
void processaudio(float const* const* inAudio, float* const* outAudio, size_t inNumFrames) override;
void processparameters() override;
- void parameterChanged(long inParameterIndex) override;
+ void parameterChanged(dfx::ParameterID inParameterID) override;
long dfx_GetPropertyInfo(dfx::PropertyID inPropertyID, dfx::Scope inScope, unsigned int inItemIndex, size_t& outDataSize, dfx::PropertyFlags& outFlags) override;
long dfx_GetProperty(dfx::PropertyID, dfx::Scope inScope, unsigned int inItemIndex, void* outData) override;
diff --git a/bufferoverride/bufferoverrideformalities.cpp b/bufferoverride/bufferoverrideformalities.cpp
index 7e1a8b86..8a24546f 100644
--- a/bufferoverride/bufferoverrideformalities.cpp
+++ b/bufferoverride/bufferoverrideformalities.cpp
@@ -16,7 +16,7 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Buffer Override. If not, see .
-To contact the author, use the contact form at http://destroyfx.org/
+To contact the author, use the contact form at http://destroyfx.org
------------------------------------------------------------------------*/
#include "bufferoverride-base.h"
@@ -398,9 +398,9 @@ void BufferOverride::processparameters()
}
//-------------------------------------------------------------------------
-void BufferOverride::parameterChanged(long inParameterIndex)
+void BufferOverride::parameterChanged(dfx::ParameterID inParameterID)
{
- switch (inParameterIndex)
+ switch (inParameterID)
{
case kDivisor:
case kBufferSize_MS:
diff --git a/bufferoverride/gui/bufferoverrideeditor.cpp b/bufferoverride/gui/bufferoverrideeditor.cpp
index a6c115a6..69064182 100644
--- a/bufferoverride/gui/bufferoverrideeditor.cpp
+++ b/bufferoverride/gui/bufferoverrideeditor.cpp
@@ -16,7 +16,7 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Buffer Override. If not, see .
-To contact the author, use the contact form at http://destroyfx.org/
+To contact the author, use the contact form at http://destroyfx.org
------------------------------------------------------------------------*/
#include "bufferoverrideeditor.h"
@@ -203,7 +203,7 @@ static bool bufferSizeDisplayProc(float inValue, char* outText, void* inEditor)
// Generate the display text for the divisor or buffer LFO rate.
// This depends on the slider value and whether we're synced to tempo.
-static bool lfoRateGenDisplayProc(float inValue, char* outText, void* inEditor, long rateSyncParameterID, long tempoSyncParameterID)
+static bool lfoRateGenDisplayProc(float inValue, char* outText, void* inEditor, dfx::ParameterID rateSyncParameterID, dfx::ParameterID tempoSyncParameterID)
{
auto const dgEditor = static_cast(inEditor);
if (dgEditor->getparameter_b(tempoSyncParameterID))
@@ -295,17 +295,17 @@ long BufferOverrideEditor::OpenEditor()
DGRect pos;
- auto const divisorLFORateTag = getparameter_b(kDivisorLFOTempoSync) ? kDivisorLFORate_Sync : kDivisorLFORate_Hz;
+ auto const divisorLFORateParameterID = getparameter_b(kDivisorLFOTempoSync) ? kDivisorLFORate_Sync : kDivisorLFORate_Hz;
pos.set(kDivisorLFORateSliderX, kDivisorLFORateSliderY, kLFOSliderWidth, kSliderHeight);
- mDivisorLFORateSlider = emplaceControl(this, divisorLFORateTag, pos, dfx::kAxis_Horizontal, sliderHandleImage);
+ mDivisorLFORateSlider = emplaceControl(this, divisorLFORateParameterID, pos, dfx::kAxis_Horizontal, sliderHandleImage);
mDivisorLFORateSlider->setAlternateHandle(sliderHandleImage_glowing);
pos.set(kDivisorLFODepthSliderX, kDivisorLFODepthSliderY, kLFOSliderWidth, kSliderHeight);
emplaceControl(this, kDivisorLFODepth, pos, dfx::kAxis_Horizontal, sliderHandleImage)->setAlternateHandle(sliderHandleImage_glowing);
- auto const bufferLFORateTag = getparameter_b(kBufferLFOTempoSync) ? kBufferLFORate_Sync : kBufferLFORate_Hz;
+ auto const bufferLFORateParameterID = getparameter_b(kBufferLFOTempoSync) ? kBufferLFORate_Sync : kBufferLFORate_Hz;
pos.set(kBufferLFORateSliderX, kBufferLFORateSliderY, kLFOSliderWidth, kSliderHeight);
- mBufferLFORateSlider = emplaceControl(this, bufferLFORateTag, pos, dfx::kAxis_Horizontal, sliderHandleImage);
+ mBufferLFORateSlider = emplaceControl(this, bufferLFORateParameterID, pos, dfx::kAxis_Horizontal, sliderHandleImage);
mBufferLFORateSlider->setAlternateHandle(sliderHandleImage_glowing);
pos.set(kBufferLFODepthSliderX, kBufferLFODepthSliderY, kLFOSliderWidth, kSliderHeight);
@@ -323,9 +323,9 @@ long BufferOverrideEditor::OpenEditor()
pos.set(kTempoSliderX, kTempoSliderY, kTempoSliderWidth, kSliderHeight);
emplaceControl(this, kTempo, pos, dfx::kAxis_Horizontal, sliderHandleImage)->setAlternateHandle(sliderHandleImage_glowing);
- auto const bufferSizeTag = getparameter_b(kBufferTempoSync) ? kBufferSize_Sync : kBufferSize_MS;
+ auto const bufferSizeParameterID = getparameter_b(kBufferTempoSync) ? kBufferSize_Sync : kBufferSize_MS;
pos.set(kDivisorBufferBoxX, kDivisorBufferBoxY, kDivisorBufferBoxWidth, kDivisorBufferBoxHeight);
- mDivisorBufferBox = emplaceControl(this, kDivisor, bufferSizeTag, pos, xyBoxHandleImage, nullptr,
+ mDivisorBufferBox = emplaceControl(this, kDivisor, bufferSizeParameterID, pos, xyBoxHandleImage, nullptr,
VSTGUI::CSliderBase::kLeft | VSTGUI::CSliderBase::kTop);
mDivisorBufferBox->setAlternateHandles(xyBoxHandleImage_divisor_glowing, xyBoxHandleImage_buffer_glowing);
mDivisorBufferBox->setIntegralPosition(true);
@@ -335,16 +335,16 @@ long BufferOverrideEditor::OpenEditor()
emplaceControl(this, kDivisor, pos, divisorDisplayProc, nullptr, nullptr, dfx::TextAlignment::Center, kValueDisplayFontSize * 2.0f, kLCDCyanTextColor, kValueDisplayFont);
pos.set(kBufferDisplayX, kBufferDisplayY, kOLEDDisplayWidth, kOLEDDisplayHeight);
- mBufferSizeDisplay = emplaceControl(this, bufferSizeTag, pos, bufferSizeDisplayProc, this, nullptr, dfx::TextAlignment::Center, kValueDisplayFontSize * 2.0f, kLCDCyanTextColor, kValueDisplayFont);
+ mBufferSizeDisplay = emplaceControl(this, bufferSizeParameterID, pos, bufferSizeDisplayProc, this, nullptr, dfx::TextAlignment::Center, kValueDisplayFontSize * 2.0f, kLCDCyanTextColor, kValueDisplayFont);
pos.set(kDivisorLFORateDisplayX, kDivisorLFORateDisplayY, kLCDDisplayWidth, kLCDDisplayHeight);
- mDivisorLFORateDisplay = emplaceControl(this, divisorLFORateTag, pos, divisorLFORateDisplayProc, this, nullptr, dfx::TextAlignment::Right, kValueDisplayFontSize, kLCDGreenTextColor, kValueDisplayFont);
+ mDivisorLFORateDisplay = emplaceControl(this, divisorLFORateParameterID, pos, divisorLFORateDisplayProc, this, nullptr, dfx::TextAlignment::Right, kValueDisplayFontSize, kLCDGreenTextColor, kValueDisplayFont);
pos.set(kDivisorLFODepthDisplayX, kDivisorLFODepthDisplayY, kLCDDisplayWidth, kLCDDisplayHeight);
emplaceControl(this, kDivisorLFODepth, pos, lfoDepthDisplayProc, nullptr, nullptr, dfx::TextAlignment::Right, kValueDisplayFontSize, kLCDGreenTextColor, kValueDisplayFont);
pos.set(kBufferLFORateDisplayX, kBufferLFORateDisplayY, kLCDDisplayWidth, kLCDDisplayHeight);
- mBufferLFORateDisplay = emplaceControl(this, bufferLFORateTag, pos, bufferLFORateDisplayProc, this, nullptr, dfx::TextAlignment::Right, kValueDisplayFontSize, kLCDGreenTextColor, kValueDisplayFont);
+ mBufferLFORateDisplay = emplaceControl(this, bufferLFORateParameterID, pos, bufferLFORateDisplayProc, this, nullptr, dfx::TextAlignment::Right, kValueDisplayFontSize, kLCDGreenTextColor, kValueDisplayFont);
pos.set(kBufferLFODepthDisplayX, kBufferLFODepthDisplayY, kLCDDisplayWidth, kLCDDisplayHeight);
emplaceControl(this, kBufferLFODepth, pos, lfoDepthDisplayProc, nullptr, nullptr, dfx::TextAlignment::Right, kValueDisplayFontSize, kLCDGreenTextColor, kValueDisplayFont);
@@ -445,7 +445,7 @@ void BufferOverrideEditor::CloseEditor()
//-----------------------------------------------------------------------------
-void BufferOverrideEditor::parameterChanged(long inParameterID)
+void BufferOverrideEditor::parameterChanged(dfx::ParameterID inParameterID)
{
IDGControl* slider = nullptr;
DGTextDisplay* textDisplay = nullptr;
@@ -457,7 +457,7 @@ void BufferOverrideEditor::parameterChanged(long inParameterID)
case kBufferTempoSync:
{
HandleTempoSyncChange();
- constexpr std::array parameterIDs = { kBufferSize_MS, kBufferSize_Sync };
+ constexpr std::array parameterIDs = { kBufferSize_MS, kBufferSize_Sync };
newParameterID = parameterIDs[useSyncParam];
slider = mDivisorBufferBox->getControlByParameterID(parameterIDs[!useSyncParam]);
textDisplay = mBufferSizeDisplay;
@@ -656,7 +656,7 @@ void BufferOverrideEditor::mouseovercontrolchanged(IDGControl* currentControlUnd
//-----------------------------------------------------------------------------
void BufferOverrideEditor::HandleTempoSyncChange()
{
- auto const updateTextDisplay = [this](DGTextDisplay* control, long tempoSyncParameterID)
+ auto const updateTextDisplay = [this](DGTextDisplay* control, dfx::ParameterID tempoSyncParameterID)
{
auto const allowTextEdit = !getparameter_b(tempoSyncParameterID);
control->setTextEditEnabled(allowTextEdit);
diff --git a/bufferoverride/gui/bufferoverrideeditor.h b/bufferoverride/gui/bufferoverrideeditor.h
index e2a1be83..662a0c5f 100644
--- a/bufferoverride/gui/bufferoverrideeditor.h
+++ b/bufferoverride/gui/bufferoverrideeditor.h
@@ -1,5 +1,5 @@
/*------------------------------------------------------------------------
-Copyright (C) 2001-2021 Sophia Poirier
+Copyright (C) 2001-2022 Sophia Poirier
This file is part of Buffer Override.
@@ -16,7 +16,7 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Buffer Override. If not, see .
-To contact the author, use the contact form at http://destroyfx.org/
+To contact the author, use the contact form at http://destroyfx.org
------------------------------------------------------------------------*/
#pragma once
@@ -35,7 +35,7 @@ class BufferOverrideEditor final : public DfxGuiEditor
long OpenEditor() override;
void CloseEditor() override;
- void parameterChanged(long inParameterID) override;
+ void parameterChanged(dfx::ParameterID inParameterID) override;
void mouseovercontrolchanged(IDGControl* currentControlUnderMouse) override;
private:
diff --git a/dfx-library/dfxdefines.h b/dfx-library/dfxdefines.h
index a80859bb..001cd100 100644
--- a/dfx-library/dfxdefines.h
+++ b/dfx-library/dfxdefines.h
@@ -18,7 +18,7 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Destroy FX Library. If not, see .
-To contact the author, use the contact form at http://destroyfx.org/
+To contact the author, use the contact form at http://destroyfx.org
Destroy FX is a sovereign entity comprised of Sophia Poirier and Tom Murphy 7.
These are our general global defines and constants, to be included
@@ -100,11 +100,14 @@ somewhere in the include tree for every file for a DfxPlugin.
#ifdef __cplusplus
#include
+#include
namespace dfx
{
+ using ParameterID = unsigned int;
+
// to indicate "not a real parameter" or something like that
- static constexpr long kParameterID_Invalid = -1;
+ static constexpr ParameterID kParameterID_Invalid = std::numeric_limits::max();
static constexpr size_t kParameterNameMaxLength = 64;
static constexpr size_t kPresetNameMaxLength = 64;
diff --git a/dfx-library/dfxparameter.cpp b/dfx-library/dfxparameter.cpp
index e3f95a1b..a370b639 100644
--- a/dfx-library/dfxparameter.cpp
+++ b/dfx-library/dfxparameter.cpp
@@ -18,7 +18,7 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Destroy FX Library. If not, see .
-To contact the author, use the contact form at http://destroyfx.org/
+To contact the author, use the contact form at http://destroyfx.org
Destroy FX is a sovereign entity comprised of Sophia Poirier and Tom Murphy 7.
This is our class for doing all kinds of fancy plugin parameter stuff.
@@ -807,18 +807,18 @@ DfxPreset::DfxPreset(size_t inNumParameters)
}
//-----------------------------------------------------------------------------
-void DfxPreset::setvalue(long inParameterIndex, DfxParam::Value inValue)
+void DfxPreset::setvalue(dfx::ParameterID inParameterIndex, DfxParam::Value inValue)
{
- if ((inParameterIndex >= 0) && (inParameterIndex < static_cast(mValues.size())))
+ if (inParameterIndex < mValues.size())
{
mValues[inParameterIndex] = inValue;
}
}
//-----------------------------------------------------------------------------
-DfxParam::Value DfxPreset::getvalue(long inParameterIndex) const
+DfxParam::Value DfxPreset::getvalue(dfx::ParameterID inParameterIndex) const
{
- if ((inParameterIndex >= 0) && (inParameterIndex < static_cast(mValues.size())))
+ if (inParameterIndex < mValues.size())
{
return mValues[inParameterIndex];
}
diff --git a/dfx-library/dfxparameter.h b/dfx-library/dfxparameter.h
index 7ec081ce..a69580cf 100644
--- a/dfx-library/dfxparameter.h
+++ b/dfx-library/dfxparameter.h
@@ -18,7 +18,7 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Destroy FX Library. If not, see .
-To contact the author, use the contact form at http://destroyfx.org/
+To contact the author, use the contact form at http://destroyfx.org
Destroy FX is a sovereign entity comprised of Sophia Poirier and Tom Murphy 7.
This is our class for doing all kinds of fancy plugin parameter stuff.
@@ -602,8 +602,8 @@ class DfxPreset
public:
explicit DfxPreset(size_t inNumParameters);
- void setvalue(long inParameterIndex, DfxParam::Value inValue);
- DfxParam::Value getvalue(long inParameterIndex) const;
+ void setvalue(dfx::ParameterID inParameterIndex, DfxParam::Value inValue);
+ DfxParam::Value getvalue(dfx::ParameterID inParameterIndex) const;
void setname(std::string_view inText);
std::string getname() const
{
diff --git a/dfx-library/dfxplugin-audiounit.cpp b/dfx-library/dfxplugin-audiounit.cpp
index cc4b1649..3adcbf34 100644
--- a/dfx-library/dfxplugin-audiounit.cpp
+++ b/dfx-library/dfxplugin-audiounit.cpp
@@ -18,7 +18,7 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Destroy FX Library. If not, see .
-To contact the author, use the contact form at http://destroyfx.org/
+To contact the author, use the contact form at http://destroyfx.org
Destroy FX is a sovereign entity comprised of Sophia Poirier and Tom Murphy 7.
This is our class for E-Z plugin-making and E-Z multiple-API support.
@@ -68,7 +68,7 @@ void DfxPlugin::PostConstructor()
// make the global-scope element aware of the parameters' values
// this must happen after AUBase::PostConstructor because the elements are created there
- for (long i = 0; i < getnumparameters(); i++)
+ for (dfx::ParameterID i = 0; i < getnumparameters(); i++)
{
if (!hasparameterattribute(i, DfxParam::kAttribute_Unused)) // XXX should we do it like this, or override GetParameterList?
{
@@ -298,7 +298,7 @@ OSStatus DfxPlugin::GetPropertyInfo(AudioUnitPropertyID inPropertyID,
break;
// get/set the current MIDI learner parameter
case dfx::kPluginProperty_MidiLearner:
- outDataSize = sizeof(int32_t);
+ outDataSize = sizeof(uint32_t);
outWritable = true;
break;
// get/set the MIDI assignment for a parameter
@@ -467,7 +467,7 @@ OSStatus DfxPlugin::GetProperty(AudioUnitPropertyID inPropertyID,
if ((pvt->otherDesc.format == kOtherPluginFormat_kVST) && (pvt->otherDesc.plugin.mSubType == PLUGIN_ID))
{
pvt->auParamID = pvt->otherParamID;
- pvt->auValue = expandparametervalue(static_cast(pvt->otherParamID), pvt->otherValue);
+ pvt->auValue = expandparametervalue(pvt->otherParamID, pvt->otherValue);
}
else
{
@@ -488,7 +488,7 @@ OSStatus DfxPlugin::GetProperty(AudioUnitPropertyID inPropertyID,
}
#endif
auto& value = request->value;
- auto const paramID = static_cast(inElement);
+ dfx::ParameterID const parameterID = inElement;
switch (request->inValueItem)
{
case dfx::ParameterValueItem::Current:
@@ -496,13 +496,13 @@ OSStatus DfxPlugin::GetProperty(AudioUnitPropertyID inPropertyID,
switch (request->inValueType)
{
case DfxParam::ValueType::Float:
- value.f = getparameter_f(paramID);
+ value.f = getparameter_f(parameterID);
break;
case DfxParam::ValueType::Int:
- value.i = getparameter_i(paramID);
+ value.i = getparameter_i(parameterID);
break;
case DfxParam::ValueType::Boolean:
- value.b = getparameter_b(paramID);
+ value.b = getparameter_b(parameterID);
break;
default:
assert(false);
@@ -516,13 +516,13 @@ OSStatus DfxPlugin::GetProperty(AudioUnitPropertyID inPropertyID,
switch (request->inValueType)
{
case DfxParam::ValueType::Float:
- value.f = getparameterdefault_f(paramID);
+ value.f = getparameterdefault_f(parameterID);
break;
case DfxParam::ValueType::Int:
-// value.i = getparameterdefault_i(paramID);
+// value.i = getparameterdefault_i(parameterID);
break;
case DfxParam::ValueType::Boolean:
-// value.b = getparameterdefault_b(paramID);
+// value.b = getparameterdefault_b(parameterID);
break;
default:
assert(false);
@@ -536,13 +536,13 @@ OSStatus DfxPlugin::GetProperty(AudioUnitPropertyID inPropertyID,
switch (request->inValueType)
{
case DfxParam::ValueType::Float:
- value.f = getparametermin_f(paramID);
+ value.f = getparametermin_f(parameterID);
break;
case DfxParam::ValueType::Int:
- value.i = getparametermin_i(paramID);
+ value.i = getparametermin_i(parameterID);
break;
case DfxParam::ValueType::Boolean:
-// value.b = getparametermin_b(paramID);
+// value.b = getparametermin_b(parameterID);
value.b = false;
break;
default:
@@ -557,13 +557,13 @@ OSStatus DfxPlugin::GetProperty(AudioUnitPropertyID inPropertyID,
switch (request->inValueType)
{
case DfxParam::ValueType::Float:
- value.f = getparametermax_f(paramID);
+ value.f = getparametermax_f(parameterID);
break;
case DfxParam::ValueType::Int:
- value.i = getparametermax_i(paramID);
+ value.i = getparametermax_i(parameterID);
break;
case DfxParam::ValueType::Boolean:
-// value.b = getparametermax_b(paramID);
+// value.b = getparametermax_b(parameterID);
value.b = true;
break;
default:
@@ -752,7 +752,7 @@ OSStatus DfxPlugin::GetProperty(AudioUnitPropertyID inPropertyID,
break;
// get the current MIDI learner parameter
case dfx::kPluginProperty_MidiLearner:
- *static_cast(outData) = getmidilearner();
+ *static_cast(outData) = getmidilearner();
break;
// get the MIDI assignment for a parameter
case dfx::kPluginProperty_ParameterMidiAssignment:
@@ -910,7 +910,7 @@ OSStatus DfxPlugin::SetProperty(AudioUnitPropertyID inPropertyID,
}
#endif
auto const& value = request->value;
- long paramID = inElement;
+ dfx::ParameterID const parameterID = inElement;
switch (request->inValueItem)
{
case dfx::ParameterValueItem::Current:
@@ -918,16 +918,16 @@ OSStatus DfxPlugin::SetProperty(AudioUnitPropertyID inPropertyID,
switch (request->inValueType)
{
case DfxParam::ValueType::Float:
- setparameter_f(paramID, value.f);
- postupdate_parameter(paramID);
+ setparameter_f(parameterID, value.f);
+ postupdate_parameter(parameterID);
break;
case DfxParam::ValueType::Int:
- setparameter_i(paramID, value.i);
- postupdate_parameter(paramID);
+ setparameter_i(parameterID, value.i);
+ postupdate_parameter(parameterID);
break;
case DfxParam::ValueType::Boolean:
- setparameter_b(paramID, value.b);
- postupdate_parameter(paramID);
+ setparameter_b(parameterID, value.b);
+ postupdate_parameter(parameterID);
break;
default:
assert(false);
@@ -1004,7 +1004,7 @@ OSStatus DfxPlugin::SetProperty(AudioUnitPropertyID inPropertyID,
break;
// set the current MIDI learner parameter
case dfx::kPluginProperty_MidiLearner:
- setmidilearner(*static_cast(inData));
+ setmidilearner(*static_cast(inData));
break;
// set the MIDI assignment for a parameter
case dfx::kPluginProperty_ParameterMidiAssignment:
@@ -1394,7 +1394,7 @@ OSStatus DfxPlugin::SetParameter(AudioUnitParameterID inParameterID,
OSStatus DfxPlugin::GetPresets(CFArrayRef* outData) const
{
// figure out how many valid (loaded) presets we actually have...
- long validNumPresets = 0;
+ CFIndex validNumPresets = 0;
for (size_t i = 0; i < getnumpresets(); i++)
{
// if (presetnameisvalid(i))
@@ -1404,7 +1404,7 @@ OSStatus DfxPlugin::GetPresets(CFArrayRef* outData) const
}
}
// whoops, looks like we don't actually have any presets
- AUSDK_Require(validNumPresets > 0, kAudioUnitErr_InvalidProperty);//kAudioUnitErr_PropertyNotInUse?
+ AUSDK_Require(validNumPresets > 0, kAudioUnitErr_PropertyNotInUse);
// this is just to say that the property is supported (GetPropertyInfo needs this)
if (!outData)
@@ -1522,7 +1522,7 @@ OSStatus DfxPlugin::RestoreState(CFPropertyListRef inData)
// XXX should we rethink this and load parameter settings always before mDfxSettings->restore()?
// load the parameter settings that were restored
// by the inherited base class implementation of RestoreState
- for (long i = 0; i < getnumparameters(); i++)
+ for (dfx::ParameterID i = 0; i < getnumparameters(); i++)
{
setparameter_f(i, Globals()->GetParameter(i));
}
@@ -1532,7 +1532,7 @@ OSStatus DfxPlugin::RestoreState(CFPropertyListRef inData)
#endif
// make any listeners aware of the changes in the parameter values
- for (long i = 0; i < getnumparameters(); i++)
+ for (dfx::ParameterID i = 0; i < getnumparameters(); i++)
{
postupdate_parameter(i);
}
diff --git a/dfx-library/dfxplugin-base.h b/dfx-library/dfxplugin-base.h
index 3b4a10f5..3567b904 100644
--- a/dfx-library/dfxplugin-base.h
+++ b/dfx-library/dfxplugin-base.h
@@ -18,12 +18,15 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Destroy FX Library. If not, see .
-To contact the author, use the contact form at http://destroyfx.org/
+To contact the author, use the contact form at http://destroyfx.org
------------------------------------------------------------------------*/
#pragma once
+#include "dfxdefines.h"
+
+
// should be pretty much implied:
// if the plugin is an instrument, then it uses MIDI
#if TARGET_PLUGIN_IS_INSTRUMENT
@@ -218,6 +221,19 @@ enum
+//-----------------------------------------------------------------------------
+constexpr int32_t ParameterID_ToVST(ParameterID inParameterID) noexcept
+{
+ return (inParameterID == kParameterID_Invalid) ? -1 : static_cast(inParameterID);
+}
+//-----------------------------------------------------------------------------
+constexpr ParameterID ParameterID_FromVST(int32_t inParameterIndexVST) noexcept
+{
+ return (inParameterIndexVST < 0) ? kParameterID_Invalid : static_cast(inParameterIndexVST);
+}
+
+
+
#ifdef TARGET_API_RTAS
//-----------------------------------------------------------------------------
@@ -227,21 +243,23 @@ constexpr long kParameterValueShortNameMax_RTAS = 6; // XXX hack
constexpr long kParameterID_RTASGlobalBypass = 1;
constexpr long kParameterID_RTASOffset = kParameterID_RTASGlobalBypass + 1;
//-----------------------------------------------------------------------------
-constexpr long ParameterID_ToRTAS(long inParameterID)
+constexpr long ParameterID_ToRTAS(ParameterID inParameterID) noexcept
{
- return inParameterID + kParameterID_RTASOffset;
+ auto const offsetIndex = static_cast(inParameterID) + kParameterID_RTASOffset;
+ return (inParameterID == kParameterID_Invalid) ? -1 : offsetIndex;
}
//-----------------------------------------------------------------------------
-constexpr long ParameterID_FromRTAS(long inParameterIndex_RTAS)
+constexpr ParameterID ParameterID_FromRTAS(long inParameterIndexRTAS) noexcept
{
- return inParameterIndex_RTAS - kParameterID_RTASOffset;
+ auto const offsetIndex = inParameterIndexRTAS - kParameterID_RTASOffset;
+ return (offsetIndex < 0) ? kParameterID_Invalid : static_cast(offsetIndex);
}
// XXX a hack to handle the fact that CPluginControl_Percent (annoyingly)
// automatically converts to and from internal 0-1 values and external 0-100 values
constexpr double kRTASPercentScalar = 0.01;
-#endif
+#endif // TARGET_API_RTAS
} // namespace dfx
diff --git a/dfx-library/dfxplugin-rtas.cpp b/dfx-library/dfxplugin-rtas.cpp
index 38b0ed3b..06d302e3 100644
--- a/dfx-library/dfxplugin-rtas.cpp
+++ b/dfx-library/dfxplugin-rtas.cpp
@@ -18,7 +18,7 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Destroy FX Library. If not, see .
-To contact the author, use the contact form at http://destroyfx.org/
+To contact the author, use the contact form at http://destroyfx.org
Destroy FX is a sovereign entity comprised of Sophia Poirier and Tom Murphy 7.
This is our class for E-Z plugin-making and E-Z multiple-API support.
@@ -91,9 +91,9 @@ void DfxPlugin::EffectInit()
/*
long bypassControlIndex = 0;
ComponentResult bypassResult = GetMasterBypassControl(&bypassControlIndex);
-CPluginControl_Discrete * bypassControl = dynamic_cast( GetControl(bypassControlIndex) );
-char bypassName[32];
-bypassControl->GetNameOfLength(bypassName, sizeof(bypassName)-1, 0);
+CPluginControl_Discrete* bypassControl = dynamic_cast( GetControl(bypassControlIndex) );
+char bypassName[32] {};
+bypassControl->GetNameOfLength(bypassName, std::size(bypassName) - 1, 0);
fprintf(stderr, "%s IsAutomatable() = %s (error = %ld)\n", bypassName, bypassControl->IsAutomatable() ? "true" : "false", bypassResult);
*/
}
@@ -151,7 +151,7 @@ void DfxPlugin::AddParametersToList()
DefineMasterBypassControlIndex(dfx::kParameterID_RTASGlobalBypass);
OSType paramFourCharID = 0;
- for (long i = 0; i < getnumparameters(); i++)
+ for (dfx::ParameterID i = 0; i < getnumparameters(); i++)
{
if (!parameterisvalid(i))
{
@@ -168,7 +168,7 @@ void DfxPlugin::AddParametersToList()
{
paramFourCharID = DFX_IterateAlphaNumericFourCharCode(paramFourCharID);
}
- bool const paramAutomatable = (getparameterattributes(i) & (DfxParam::kAttribute_Hidden | DfxParam::kAttribute_Unused)) ? false : true;
+ bool const paramAutomatable = !(hasparameterattribute(i, DfxParam::kAttribute_Hidden) || hasparameterattribute(i, DfxParam::kAttribute_Unused));
constexpr int numCurvedSteps = 1000;
double const stepSize_default = (paramMax_f - paramMin_f) / (double)numCurvedSteps;
auto const paramCurve = getparametercurve(i);
@@ -256,25 +256,33 @@ void DfxPlugin::AddParametersToList()
//-----------------------------------------------------------------------------
// XXX implement
-ComponentResult DfxPlugin::GetControlNameOfLength(long inParameterIndex, char * outName, long inNameLength, OSType inControllerType, FicBoolean * outReverseHighlight)
+ComponentResult DfxPlugin::GetControlNameOfLength(long inParameterIndex, char* outName, long inNameLength, OSType inControllerType, FicBoolean* outReverseHighlight)
{
- if (outName == NULL)
+ if (outName == nullptr)
+ {
return paramErr;
+ }
/*
if (inNameLength <= dfx::kParameterShortNameMax_RTAS)
{
- char * shortNameString = NULL;
+ char* shortNameString = nullptr;
if (inParameterIndex == dfx::kParameterID_RTASGlobalBypass)
+ {
shortNameString = "Bypass"; // any shortened version of this is fine
+ }
else
+ {
shortNameString = GetParameterShortName( dfx::ParameterID_FromRTAS(inParameterIndex) );
- if (shortNameString != NULL)
+ }
+ if (shortNameString != nullptr)
{
strlcpy(outName, shortNameString, inNameLength + 1);
outName[inNameLength] = 0;
- if (outReverseHighlight != NULL)
+ if (outReverseHighlight != nullptr)
+ {
*outReverseHighlight = false; // XXX assume control is not to be highlighted
+ }
return noErr;
}
}
@@ -287,14 +295,16 @@ ComponentResult DfxPlugin::GetControlNameOfLength(long inParameterIndex, char *
// XXX implement
ComponentResult DfxPlugin::GetValueString(long inParameterIndex, long inValue, StringPtr outValueString, long inMaxLength)
{
- if (outValueString == NULL)
+ if (outValueString == nullptr)
+ {
return paramErr;
+ }
/*
if (inMaxLength <= dfx::kParameterValueShortNameMax_rtas)
{
auto const shortValueString = GetParameterValueShortString(dfx::ParameterID_FromRTAS(inParameterIndex), inValue);
- if (shortValueString != NULL)
+ if (shortValueString != nullptr)
{
strlcpy((char*)(outValueString + 1), shortValueString, inMaxLength + 1);
outValueString[0] = ((signed)strlen(shortValueString) > inMaxLength) ? inMaxLength : strlen(shortValueString);
@@ -315,20 +325,22 @@ void DfxPlugin::UpdateControlValueInAlgorithm(long inParameterIndex)
return;
}
- inParameterIndex = dfx::ParameterID_FromRTAS(inParameterIndex);
- if (! parameterisvalid(inParameterIndex) )
+ auto const parameterID = dfx::ParameterID_FromRTAS(inParameterIndex);
+ if (!parameterisvalid(parameterID))
+ {
return;
+ }
- switch ( getparametervaluetype(inParameterIndex) )
+ switch (getparametervaluetype(parameterID))
{
case DfxParam::ValueType::Float:
- parameters[inParameterIndex].set_f( GetParameter_f_FromRTAS(inParameterIndex) );
+ parameters[parameterID].set_f(GetParameter_f_FromRTAS(parameterID));
break;
case DfxParam::ValueType::Int:
- parameters[inParameterIndex].set_i( GetParameter_i_FromRTAS(inParameterIndex) );
+ parameters[parameterID].set_i(GetParameter_i_FromRTAS(parameterID));
break;
case DfxParam::ValueType::Boolean:
- parameters[inParameterIndex].set_b( GetParameter_b_FromRTAS(inParameterIndex) );
+ parameters[parameterID].set_b(GetParameter_b_FromRTAS(parameterID));
break;
default:
break;
@@ -336,7 +348,7 @@ void DfxPlugin::UpdateControlValueInAlgorithm(long inParameterIndex)
}
//-----------------------------------------------------------------------------
-double DfxPlugin::GetParameter_f_FromRTAS(long inParameterID)
+double DfxPlugin::GetParameter_f_FromRTAS(dfx::ParameterID inParameterID)
{
double resultValue = dynamic_cast(GetControl(dfx::ParameterID_ToRTAS(inParameterID)))->GetContinuous();
if ( (getparameterunit(inParameterID) == DfxParam::Unit::Percent) || (getparameterunit(inParameterID) == DfxParam::Unit::DryWetMix) )
@@ -345,7 +357,7 @@ double DfxPlugin::GetParameter_f_FromRTAS(long inParameterID)
}
//-----------------------------------------------------------------------------
-int64_t DfxPlugin::GetParameter_i_FromRTAS(long inParameterID)
+int64_t DfxPlugin::GetParameter_i_FromRTAS(dfx::ParameterID inParameterID)
{
int64_t resultValue = dynamic_cast(GetControl(dfx::ParameterID_ToRTAS(inParameterID)))->GetDiscrete();
if ( getparameterusevaluestrings(inParameterID) )
@@ -354,16 +366,18 @@ int64_t DfxPlugin::GetParameter_i_FromRTAS(long inParameterID)
}
//-----------------------------------------------------------------------------
-bool DfxPlugin::GetParameter_b_FromRTAS(long inParameterID)
+bool DfxPlugin::GetParameter_b_FromRTAS(dfx::ParameterID inParameterID)
{
return (GetParameter_i_FromRTAS(inParameterID) != 0);
}
//-----------------------------------------------------------------------------
-ComponentResult DfxPlugin::IsControlAutomatable(long inControlIndex, short * outItIs)
+ComponentResult DfxPlugin::IsControlAutomatable(long inControlIndex, short* outItIs)
{
- if (outItIs == NULL)
+ if (outItIs == nullptr)
+ {
return paramErr;
+ }
// XXX test this first, since dfx::ParameterID_FromRTAS() makes it an invalid ID
if (inControlIndex == dfx::kParameterID_RTASGlobalBypass)
@@ -372,14 +386,20 @@ ComponentResult DfxPlugin::IsControlAutomatable(long inControlIndex, short * out
return noErr;
}
- inControlIndex = dfx::ParameterID_FromRTAS(inControlIndex);
- if (! parameterisvalid(inControlIndex) )
+ auto const parameterID = dfx::ParameterID_FromRTAS(inControlIndex);
+ if (!parameterisvalid(parameterID))
+ {
return paramErr;
+ }
- if ( getparameterattributes(inControlIndex) & (DfxParam::kAttribute_Unused | DfxParam::kAttribute_Hidden) )
+ if (hasparameterattribute(parameterID, DfxParam::kAttribute_Unused) || hasparameterattribute(parameterID, DfxParam::kAttribute_Hidden))
+ {
*outItIs = 0;
+ }
else
+ {
*outItIs = 1;
+ }
return noErr;
}
@@ -429,7 +449,7 @@ double CPluginControl_DfxCurved::ConvertControlToContinuous(long control) const
#pragma mark -
//-----------------------------------------------------------------------------
-ComponentResult DfxPlugin::SetChunk(OSType inChunkID, SFicPlugInChunk * chunk)
+ComponentResult DfxPlugin::SetChunk(OSType inChunkID, SFicPlugInChunk* chunk)
{
return TARGET_API_BASE_CLASS::SetChunk(inChunkID, chunk);
}
@@ -452,7 +472,7 @@ UInt32 DfxPlugin::ProcessAudio(bool inIsGlobalBypassed)
long totalInputSamples = 0; // total number of input samples in one input buffer
// use the mono channel input sample number (guaranteed to be connected)
- if (GetInputConnection(0) != NULL)
+ if (GetInputConnection(0) != nullptr)
{
totalInputSamples = GetInputConnection(0)->mNumSamplesInBuf;
}
@@ -460,17 +480,19 @@ UInt32 DfxPlugin::ProcessAudio(bool inIsGlobalBypassed)
for (SInt32 ch = 0; ch < GetNumOutputs(); ch++)
{
// XXX what to do if there are no valid connections for the channel?
- mInputAudioStreams_as[ch] = NULL;
- mOutputAudioStreams_as[ch] = NULL;
+ mInputAudioStreams_as[ch] = nullptr;
+ mOutputAudioStreams_as[ch] = nullptr;
DAEConnectionPtr outputConnection = GetOutputConnection(ch);
- if (outputConnection != NULL) // if no valid connection, don't do anything
+ if (outputConnection != nullptr) // if no valid connection, don't do anything
{
mOutputAudioStreams_as[ch] = (float*)(outputConnection->mBuffer);
DAEConnectionPtr inputConnection = GetInputConnection(ch);
- if (inputConnection != NULL) // have a valid input connection
+ if (inputConnection != nullptr) // have a valid input connection
+ {
mInputAudioStreams_as[ch] = (float*)(inputConnection->mBuffer);
+ }
else // no input connection; use default value of zero
{
// (re)allocate the zero audio buffer if it is not currently large enough for this rendering slice
@@ -484,12 +506,16 @@ UInt32 DfxPlugin::ProcessAudio(bool inIsGlobalBypassed)
if (inIsGlobalBypassed)
{
for (long i = 0; i < totalInputSamples; i++)
+ {
mOutputAudioStreams_as[ch][i] = mInputAudioStreams_as[ch][i];
+ }
}
// do the sample number adjustment
outputConnection->mNumSamplesInBuf = totalInputSamples;
- if (inputConnection != NULL)
+ if (inputConnection != nullptr)
+ {
inputConnection->mNumSamplesInBuf = 0;
+ }
}
}
@@ -508,7 +534,7 @@ UInt32 DfxPlugin::ProcessAudio(bool inIsGlobalBypassed)
#endif
//-----------------------------------------------------------------------------
-void DfxPlugin::RenderAudio(float ** inAudioStreams, float ** outAudioStreams, long inNumFramesToProcess)
+void DfxPlugin::RenderAudio(float** inAudioStreams, float** outAudioStreams, long inNumFramesToProcess)
{
preprocessaudio(dfx::math::ToUnsigned(inNumFramesToProcess));
@@ -582,7 +608,7 @@ void DfxPlugin::RenderAudio(float ** inAudioStreams, float ** outAudioStreams, l
// RTAS clip monitoring
for (SInt32 channel = 0; (channel < GetNumOutputs()) && !fClipped; channel++)
{
- if (outAudioStreams[channel] == NULL) // XXX possible in AudioSuite
+ if (outAudioStreams[channel] == nullptr) // XXX possible in AudioSuite
{
continue;
}
@@ -618,10 +644,10 @@ void DfxPlugin::RenderAudio(float ** inAudioStreams, float ** outAudioStreams, l
#pragma mark -
//-----------------------------------------------------------------------------
-CPlugInView * DfxPlugin::CreateCPlugInView()
+CPlugInView* DfxPlugin::CreateCPlugInView()
{
#if TARGET_PLUGIN_HAS_GUI
- CNoResourceView * ui = NULL;
+ std::unique_ptr ui;
try
{
if (!mCustomUI_p)
@@ -630,7 +656,7 @@ CPlugInView * DfxPlugin::CreateCPlugInView()
mCustomUI_p->GetRect( &(mPIWinRect.left), &(mPIWinRect.top), &(mPIWinRect.right), &(mPIWinRect.bottom) );
}
- ui = new CNoResourceView;
+ ui = std::make_unique();
#if PT_SDK_VERSION < 0x08000000
constexpr long viewSizeOffset = 1; // XXX +1 because of a bug where CNoResourceView::SetSize() subtracts 1 from width and height
#else
@@ -638,20 +664,20 @@ CPlugInView * DfxPlugin::CreateCPlugInView()
#endif
ui->SetSize(mPIWinRect.right+viewSizeOffset, mPIWinRect.bottom+viewSizeOffset);
- mNoUIView_p = (CTemplateNoUIView *) ui->AddView2("!NoUIView[('NoID')]", 0, 0, mPIWinRect.right, mPIWinRect.bottom, false);
+ mNoUIView_p = (CTemplateNoUIView*) ui->AddView2("!NoUIView[('NoID')]", 0, 0, mPIWinRect.right, mPIWinRect.bottom, false);
- if (mNoUIView_p != NULL)
+ if (mNoUIView_p != nullptr)
+ {
mNoUIView_p->SetCustomUI(mCustomUI_p.get());
+ }
}
catch (...)
{
mCustomUI_p.reset();
- if (ui != NULL)
- delete ui;
- ui = NULL;
+ ui.reset();
}
- return ui;
+ return ui.release();
#else
OSType meterFourCharID = 0;
@@ -676,12 +702,16 @@ CPlugInView * DfxPlugin::CreateCPlugInView()
#if TARGET_PLUGIN_HAS_GUI
//-----------------------------------------------------------------------------
-void DfxPlugin::GetViewRect(Rect * outViewRect)
+void DfxPlugin::GetViewRect(Rect* outViewRect)
{
if (!mCustomUI_p)
+ {
mCustomUI_p.reset(CreateCTemplateCustomUI(this));
- if (outViewRect == NULL)
+ }
+ if (outViewRect == nullptr)
+ {
return;
+ }
mCustomUI_p->GetRect( &(mPIWinRect.left), &(mPIWinRect.top), &(mPIWinRect.right), &(mPIWinRect.bottom) );
outViewRect->left = mPIWinRect.left;
@@ -696,7 +726,7 @@ void DfxPlugin::SetViewPort(GrafPtr inPort)
mMainPort = inPort;
CEffectProcess::SetViewPort(mMainPort);
- if (mMainPort != NULL)
+ if (mMainPort != nullptr)
{
if (mCustomUI_p)
{
@@ -710,16 +740,18 @@ void DfxPlugin::SetViewPort(GrafPtr inPort)
}
#endif
- void * windowPtr = NULL;
- #if TARGET_OS_WIN32
- windowPtr = (void*) ASI_GethWnd((WindowPtr)mMainPort);
- #elif TARGET_OS_MAC
- windowPtr = (void*) GetWindowFromPort(mMainPort);
- #endif
+ void* windowPtr = nullptr;
+ #if TARGET_OS_WIN32
+ windowPtr = (void*) ASI_GethWnd((WindowPtr)mMainPort);
+ #elif TARGET_OS_MAC
+ windowPtr = (void*) GetWindowFromPort(mMainPort);
+ #endif
mCustomUI_p->Open(windowPtr, mLeftOffset, mTopOffset);
- if (mNoUIView_p != NULL)
+ if (mNoUIView_p != nullptr)
+ {
mNoUIView_p->SetEnable(true);
+ }
#if TARGET_OS_WIN32
mCustomUI_p->Draw(mPIWinRect.left, mPIWinRect.top, mPIWinRect.right, mPIWinRect.bottom);
@@ -729,9 +761,13 @@ void DfxPlugin::SetViewPort(GrafPtr inPort)
else
{
if (mCustomUI_p)
+ {
mCustomUI_p->Close();
- if (mNoUIView_p != NULL)
+ }
+ if (mNoUIView_p != nullptr)
+ {
mNoUIView_p->SetEnable(false);
+ }
}
return;
}
@@ -743,13 +779,13 @@ long DfxPlugin::SetControlValue(long inControlIndex, long inValue)
}
//-----------------------------------------------------------------------------
-long DfxPlugin::GetControlValue(long inControlIndex, long * outValue)
+long DfxPlugin::GetControlValue(long inControlIndex, long* outValue)
{
return static_cast(CProcess::GetControlValue(inControlIndex, outValue));
}
//-----------------------------------------------------------------------------
-long DfxPlugin::GetControlDefaultValue(long inControlIndex, long * outValue)
+long DfxPlugin::GetControlDefaultValue(long inControlIndex, long* outValue)
{
return static_cast(CProcess::GetControlDefaultValue(inControlIndex, outValue));
}
@@ -778,7 +814,7 @@ int DfxPlugin::ProcessReleaseControl(long inControlIndex)
//-----------------------------------------------------------------------------
void DfxPlugin::ProcessDoIdle()
{
- this->DoIdle(NULL);
+ this->DoIdle(nullptr);
gProcessGroup->YieldCriticalSection();
}
@@ -800,17 +836,19 @@ ComponentResult DfxPlugin::SetControlHighliteInfo(long inControlIndex, short inI
}
//-----------------------------------------------------------------------------
-ComponentResult DfxPlugin::ChooseControl(Point inLocalCoord, long * outControlIndex)
+ComponentResult DfxPlugin::ChooseControl(Point inLocalCoord, long* outControlIndex)
{
- if (outControlIndex != NULL)
+ if (outControlIndex == nullptr)
{
- *outControlIndex = 0;
- if (mCustomUI_p)
- mCustomUI_p->GetControlIndexFromPoint(inLocalCoord.h, inLocalCoord.v, outControlIndex);
- return noErr;
- }
- else
return paramErr;
+ }
+
+ *outControlIndex = 0;
+ if (mCustomUI_p)
+ {
+ mCustomUI_p->GetControlIndexFromPoint(inLocalCoord.h, inLocalCoord.v, outControlIndex);
+ }
+ return noErr;
}
#ifdef TARGET_API_AUDIOSUITE
@@ -853,7 +891,7 @@ enum
#endif
//-----------------------------------------------------------------------------
-CProcessGroupInterface * CProcessGroup::CreateProcessGroup()
+CProcessGroupInterface* CProcessGroup::CreateProcessGroup()
{
return new DfxEffectGroup;
}
@@ -881,7 +919,7 @@ void DfxEffectGroup::CreateEffectTypes()
for (int i = static_cast(ePlugIn_StemFormat_FirstExplicitChoice) - 1; i <= static_cast(ePlugIn_StemFormat_LastExplicitChoice); i++)
{
effectTypeFourCharID = DFX_IterateAlphaNumericFourCharCode(effectTypeFourCharID);
- CEffectType * effectType;
+ CEffectType* effectType {};
if (i < static_cast(ePlugIn_StemFormat_FirstExplicitChoice))
{
effectType = new CEffectTypeAS(effectTypeFourCharID, PLUGIN_ID, PLUGIN_CATEGORY_RTAS);
@@ -923,7 +961,7 @@ void DfxEffectGroup::Initialize()
}
//-----------------------------------------------------------------------------
-void DfxEffectGroup::dfx_AddEffectType(CEffectType * inEffectType)
+void DfxEffectGroup::dfx_AddEffectType(CEffectType* inEffectType)
{
inEffectType->DefineTypeNames(PLUGIN_NAME_STRING);
inEffectType->DefineSampleRateSupport(eSupports48kAnd96kAnd192k);
diff --git a/dfx-library/dfxplugin-vst.cpp b/dfx-library/dfxplugin-vst.cpp
index 9326bbb3..62aa2259 100644
--- a/dfx-library/dfxplugin-vst.cpp
+++ b/dfx-library/dfxplugin-vst.cpp
@@ -18,7 +18,7 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Destroy FX Library. If not, see .
-To contact the author, use the contact form at http://destroyfx.org/
+To contact the author, use the contact form at http://destroyfx.org
Destroy FX is a sovereign entity comprised of Sophia Poirier and Tom Murphy 7.
This is our class for E-Z plugin-making and E-Z multiple-API support.
@@ -168,7 +168,7 @@ bool DfxPlugin::getEffectName(char* outText)
VstInt32 DfxPlugin::getVendorVersion()
{
- return getpluginversion();
+ return static_cast(getpluginversion());
}
bool DfxPlugin::getVendorString(char* outText)
@@ -362,13 +362,13 @@ VstInt32 DfxPlugin::setChunk(void* data, VstInt32 byteSize, bool isPreset)
//-----------------------------------------------------------------------------
void DfxPlugin::setParameter(VstInt32 index, float value)
{
- setparameter_gen(index, value);
+ setparameter_gen(dfx::ParameterID_FromVST(index), value);
}
//-----------------------------------------------------------------------------
float DfxPlugin::getParameter(VstInt32 index)
{
- return getparameter_gen(index);
+ return getparameter_gen(dfx::ParameterID_FromVST(index));
}
//-----------------------------------------------------------------------------
@@ -379,10 +379,10 @@ void DfxPlugin::getParameterName(VstInt32 index, char* name)
{
// kVstMaxParamStrLen is absurdly short for parameter names at 8-characters,
// and given that exceding that length is common, hosts prepare for that,
- // and even the Vst2Wrapper in the VST3 SDK acknowleges as much by defining
+ // and even the Vst2Wrapper in the VST3 SDK acknowledges as much by defining
// the following "extended" constant to use instead
constexpr size_t kVstExtMaxParamStrLen = 32;
- vst_strncpy(name, getparametername(index).c_str(), kVstExtMaxParamStrLen);
+ vst_strncpy(name, getparametername(dfx::ParameterID_FromVST(index)).c_str(), kVstExtMaxParamStrLen);
}
}
@@ -395,22 +395,23 @@ void DfxPlugin::getParameterDisplay(VstInt32 index, char* text)
return;
}
- if (getparameterusevaluestrings(index))
+ auto const parameterID = dfx::ParameterID_FromVST(index);
+ if (getparameterusevaluestrings(parameterID))
{
- vst_strncpy(text, getparametervaluestring(index, getparameter_i(index)).value_or("").c_str(), kVstMaxParamStrLen);
+ vst_strncpy(text, getparametervaluestring(parameterID, getparameter_i(parameterID)).value_or("").c_str(), kVstMaxParamStrLen);
return;
}
- switch (getparametervaluetype(index))
+ switch (getparametervaluetype(parameterID))
{
case DfxParam::ValueType::Float:
- snprintf(text, kVstMaxParamStrLen + 1, "%.3f", getparameter_f(index));
+ snprintf(text, kVstMaxParamStrLen + 1, "%.3f", getparameter_f(parameterID));
break;
case DfxParam::ValueType::Int:
- snprintf(text, kVstMaxParamStrLen + 1, "%" PRIi64, getparameter_i(index));
+ snprintf(text, kVstMaxParamStrLen + 1, "%" PRIi64, getparameter_i(parameterID));
break;
case DfxParam::ValueType::Boolean:
- vst_strncpy(text, getparameter_b(index) ? "on" : "off", kVstMaxParamStrLen);
+ vst_strncpy(text, getparameter_b(parameterID) ? "on" : "off", kVstMaxParamStrLen);
break;
default:
assert(false);
@@ -424,7 +425,7 @@ void DfxPlugin::getParameterLabel(VstInt32 index, char* label)
{
if (label)
{
- vst_strncpy(label, getparameterunitstring(index).c_str(), kVstMaxParamStrLen);
+ vst_strncpy(label, getparameterunitstring(dfx::ParameterID_FromVST(index)).c_str(), kVstMaxParamStrLen);
}
}
@@ -436,30 +437,31 @@ bool DfxPlugin::getParameterProperties(VstInt32 index, VstParameterProperties* p
return false;
}
*properties = {};
+ auto const parameterID = dfx::ParameterID_FromVST(index);
// note that kVstMax* are specified as "number of characters excluding the null terminator",
// and vst_strncpy behaves accordingly and writes null at array[N], however the static arrays
// in struct types (like VstParameterProperties here) size the arrays by N, meaning that
// array[N] is out of range, so we call vst_strncpy in these cases passing N-1 as max length
- vst_strncpy(properties->label, getparametername(index).c_str(), kVstMaxLabelLen - 1);
+ vst_strncpy(properties->label, getparametername(parameterID).c_str(), kVstMaxLabelLen - 1);
constexpr size_t recommendedShortLabelLength = 6; // per the VST header comment
static_assert(recommendedShortLabelLength < kVstMaxShortLabelLen);
- auto const shortName = getparametername(index, recommendedShortLabelLength);
+ auto const shortName = getparametername(parameterID, recommendedShortLabelLength);
vst_strncpy(properties->shortLabel, shortName.c_str(), kVstMaxShortLabelLen - 1);
- auto const isVisible = [this](long parameterID)
+ auto const isVisible = [this](dfx::ParameterID parameterID)
{
return !hasparameterattribute(parameterID, DfxParam::kAttribute_Unused) && !hasparameterattribute(parameterID, DfxParam::kAttribute_Hidden);
};
- if (isVisible(index))
+ if (isVisible(parameterID))
{
- properties->displayIndex = [index, isVisible]
+ properties->displayIndex = [parameterID, isVisible]
{
VstInt16 result = 0;
- for (VstInt16 parameterID = 0; parameterID <= index; parameterID++)
+ for (dfx::ParameterID i = 0; i <= parameterID; i++)
{
- if (isVisible(parameterID))
+ if (isVisible(i))
{
assert(result < std::numeric_limits::max());
result++;
@@ -470,21 +472,21 @@ bool DfxPlugin::getParameterProperties(VstInt32 index, VstParameterProperties* p
properties->flags |= kVstParameterSupportsDisplayIndex;
}
- switch (getparametervaluetype(index))
+ switch (getparametervaluetype(parameterID))
{
case DfxParam::ValueType::Boolean:
properties->flags |= kVstParameterIsSwitch;
break;
case DfxParam::ValueType::Int:
- properties->minInteger = getparametermin_i(index);
- properties->maxInteger = getparametermax_i(index);
+ properties->minInteger = getparametermin_i(parameterID);
+ properties->maxInteger = getparametermax_i(parameterID);
properties->flags |= kVstParameterUsesIntegerMinMax;
break;
default:
break;
}
- if (auto const groupIndex = getparametergroup(index))
+ if (auto const groupIndex = getparametergroup(parameterID))
{
auto const downcastWithValidation = [](auto& destination, auto const& source)
{
@@ -547,7 +549,7 @@ void DfxPlugin::processReplacing(float** inputs, float** outputs, VstInt32 sampl
if (ch == 0)
{
assert(mAsymmetricalInputAudioBuffer.size() >= static_cast(sampleFrames));
- std::copy_n(mInputAudioStreams[ch], sampleFrames, mAsymmetricalInputAudioBuffer.data());
+ std::copy_n(mInputAudioStreams[ch], dfx::math::ToUnsigned(sampleFrames), mAsymmetricalInputAudioBuffer.data());
}
inputAudio = mAsymmetricalInputAudioBuffer.data();
}
diff --git a/dfx-library/dfxplugin.cpp b/dfx-library/dfxplugin.cpp
index 54dbb0d3..31179ae6 100644
--- a/dfx-library/dfxplugin.cpp
+++ b/dfx-library/dfxplugin.cpp
@@ -18,7 +18,7 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Destroy FX Library. If not, see .
-To contact the author, use the contact form at http://destroyfx.org/
+To contact the author, use the contact form at http://destroyfx.org
Destroy FX is a sovereign entity comprised of Sophia Poirier and Tom Murphy 7.
This is our class for E-Z plugin-making and E-Z multiple-API support.
@@ -427,15 +427,15 @@ void DfxPlugin::do_reset()
#pragma mark parameters
//-----------------------------------------------------------------------------
-void DfxPlugin::initparameter_f(long inParameterIndex, std::vector const& initNames,
+void DfxPlugin::initparameter_f(dfx::ParameterID inParameterID, std::vector const& initNames,
double initValue, double initDefaultValue,
double initMin, double initMax,
DfxParam::Unit initUnit, DfxParam::Curve initCurve,
std::string_view initCustomUnitString)
{
- auto& parameter = getparameterobject(inParameterIndex);
+ auto& parameter = getparameterobject(inParameterID);
parameter.init_f(initNames, initValue, initDefaultValue, initMin, initMax, initUnit, initCurve);
- initpresetsparameter(inParameterIndex); // default empty presets with this value
+ initpresetsparameter(inParameterID); // default empty presets with this value
if (!initCustomUnitString.empty())
{
parameter.setcustomunitstring(initCustomUnitString);
@@ -443,15 +443,15 @@ void DfxPlugin::initparameter_f(long inParameterIndex, std::vector const& initNames,
+void DfxPlugin::initparameter_i(dfx::ParameterID inParameterID, std::vector const& initNames,
int64_t initValue, int64_t initDefaultValue,
int64_t initMin, int64_t initMax,
DfxParam::Unit initUnit, DfxParam::Curve initCurve,
std::string_view initCustomUnitString)
{
- auto& parameter = getparameterobject(inParameterIndex);
+ auto& parameter = getparameterobject(inParameterID);
parameter.init_i(initNames, initValue, initDefaultValue, initMin, initMax, initUnit, initCurve);
- initpresetsparameter(inParameterIndex); // default empty presets with this value
+ initpresetsparameter(inParameterID); // default empty presets with this value
if (!initCustomUnitString.empty())
{
parameter.setcustomunitstring(initCustomUnitString);
@@ -459,33 +459,33 @@ void DfxPlugin::initparameter_i(long inParameterIndex, std::vector const& initNames,
+void DfxPlugin::initparameter_b(dfx::ParameterID inParameterID, std::vector const& initNames,
bool initValue, bool initDefaultValue,
DfxParam::Unit initUnit)
{
- getparameterobject(inParameterIndex).init_b(initNames, initValue, initDefaultValue, initUnit);
- initpresetsparameter(inParameterIndex); // default empty presets with this value
+ getparameterobject(inParameterID).init_b(initNames, initValue, initDefaultValue, initUnit);
+ initpresetsparameter(inParameterID); // default empty presets with this value
}
//-----------------------------------------------------------------------------
-void DfxPlugin::initparameter_b(long inParameterIndex, std::vector const& initNames,
+void DfxPlugin::initparameter_b(dfx::ParameterID inParameterID, std::vector const& initNames,
bool initDefaultValue, DfxParam::Unit initUnit)
{
- initparameter_b(inParameterIndex, initNames, initDefaultValue, initDefaultValue, initUnit);
+ initparameter_b(inParameterID, initNames, initDefaultValue, initDefaultValue, initUnit);
}
//-----------------------------------------------------------------------------
// this is a shorcut for initializing a parameter that uses integer indexes
// into an array, with an array of strings representing its values
-void DfxPlugin::initparameter_list(long inParameterIndex, std::vector const& initNames,
+void DfxPlugin::initparameter_list(dfx::ParameterID inParameterID, std::vector const& initNames,
int64_t initValue, int64_t initDefaultValue,
int64_t initNumItems, DfxParam::Unit initUnit,
std::string_view initCustomUnitString)
{
- auto& parameter = getparameterobject(inParameterIndex);
+ auto& parameter = getparameterobject(inParameterID);
parameter.init_i(initNames, initValue, initDefaultValue, 0, initNumItems - 1, initUnit, DfxParam::Curve::Stepped);
parameter.setusevaluestrings(true); // indicate that we will use custom value display strings
- initpresetsparameter(inParameterIndex); // default empty presets with this value
+ initpresetsparameter(inParameterID); // default empty presets with this value
if (!initCustomUnitString.empty())
{
parameter.setcustomunitstring(initCustomUnitString);
@@ -493,94 +493,94 @@ void DfxPlugin::initparameter_list(long inParameterIndex, std::vector());
@@ -597,8 +597,8 @@ void DfxPlugin::randomizeparameter(long inParameterIndex)
break;
}
- update_parameter(inParameterIndex); // make the host aware of the parameter change
- postupdate_parameter(inParameterIndex); // inform any parameter listeners of the changes
+ update_parameter(inParameterID); // make the host aware of the parameter change
+ postupdate_parameter(inParameterID); // inform any parameter listeners of the changes
}
}
@@ -606,7 +606,7 @@ void DfxPlugin::randomizeparameter(long inParameterIndex)
// randomize all of the parameters at once
void DfxPlugin::randomizeparameters()
{
- for (long i = 0; i < getnumparameters(); i++)
+ for (dfx::ParameterID i = 0; i < getnumparameters(); i++)
{
if (!hasparameterattribute(i, DfxParam::kAttribute_OmitFromRandomizeAll) && !hasparameterattribute(i, DfxParam::kAttribute_Unused))
{
@@ -617,44 +617,44 @@ void DfxPlugin::randomizeparameters()
//-----------------------------------------------------------------------------
// do stuff necessary to inform the host of changes, etc.
-void DfxPlugin::update_parameter(long inParameterIndex)
+void DfxPlugin::update_parameter(dfx::ParameterID inParameterID)
{
- if (!parameterisvalid(inParameterIndex) || hasparameterattribute(inParameterIndex, DfxParam::kAttribute_Unused))
+ if (!parameterisvalid(inParameterID) || hasparameterattribute(inParameterID, DfxParam::kAttribute_Unused))
{
return;
}
#ifdef TARGET_API_AUDIOUNIT
// make the global-scope element aware of the parameter's value
- TARGET_API_BASE_CLASS::SetParameter(inParameterIndex, kAudioUnitScope_Global, AudioUnitElement(0), getparameter_f(inParameterIndex), 0);
+ TARGET_API_BASE_CLASS::SetParameter(inParameterID, kAudioUnitScope_Global, AudioUnitElement(0), getparameter_f(inParameterID), 0);
#endif
#ifdef TARGET_API_VST
auto const vstPresetIndex = getProgram();
if ((vstPresetIndex >= 0) && presetisvalid(dfx::math::ToIndex(vstPresetIndex)))
{
- setpresetparameter(dfx::math::ToIndex(vstPresetIndex), inParameterIndex, getparameter(inParameterIndex));
+ setpresetparameter(dfx::math::ToIndex(vstPresetIndex), inParameterID, getparameter(inParameterID));
}
#if TARGET_PLUGIN_HAS_GUI
// the VST2 editor interface has no real listener mechanism for parameters and therefore
// always needs notification pushed in any circumstance where a parameter value changes
- postupdate_parameter(inParameterIndex);
+ postupdate_parameter(inParameterID);
#endif
#endif
#ifdef TARGET_API_RTAS
- SetControlValue(dfx::ParameterID_ToRTAS(inParameterIndex), ConvertToDigiValue(getparameter_gen(inParameterIndex))); // XXX yeah do this?
+ SetControlValue(dfx::ParameterID_ToRTAS(inParameterID), ConvertToDigiValue(getparameter_gen(inParameterID))); // XXX yeah do this?
#endif
- parameterChanged(inParameterIndex);
+ parameterChanged(inParameterID);
}
//-----------------------------------------------------------------------------
// this will broadcast a notification to anyone interested (host, GUI, etc.)
// about a parameter change
-void DfxPlugin::postupdate_parameter(long inParameterIndex)
+void DfxPlugin::postupdate_parameter(dfx::ParameterID inParameterID)
{
- if (!parameterisvalid(inParameterIndex) || hasparameterattribute(inParameterIndex, DfxParam::kAttribute_Unused))
+ if (!parameterisvalid(inParameterID) || hasparameterattribute(inParameterID, DfxParam::kAttribute_Unused))
{
return;
}
@@ -663,19 +663,19 @@ void DfxPlugin::postupdate_parameter(long inParameterIndex)
if (std::this_thread::get_id() == mAudioRenderThreadID)
{
// defer listener notification to later, off the realtime thread
- mParametersChangedInProcessHavePosted[inParameterIndex].clear(std::memory_order_relaxed);
+ mParametersChangedInProcessHavePosted[inParameterID].clear(std::memory_order_relaxed);
return;
}
#ifdef TARGET_API_AUDIOUNIT
- AUParameterChange_TellListeners(GetComponentInstance(), inParameterIndex);
+ AUParameterChange_TellListeners(GetComponentInstance(), inParameterID);
#endif
#ifdef TARGET_API_VST
#if TARGET_PLUGIN_HAS_GUI
if (auto const guiEditor = dynamic_cast(getEditor()))
{
- guiEditor->setParameter(inParameterIndex, getparameter_gen(inParameterIndex));
+ guiEditor->setParameter(dfx::ParameterID_ToVST(inParameterID), getparameter_gen(inParameterID));
}
#endif
#endif
@@ -686,28 +686,28 @@ void DfxPlugin::postupdate_parameter(long inParameterIndex)
}
//-----------------------------------------------------------------------------
-DfxParam::Value DfxPlugin::getparameter(long inParameterIndex) const
+DfxParam::Value DfxPlugin::getparameter(dfx::ParameterID inParameterID) const
{
- if (parameterisvalid(inParameterIndex))
+ if (parameterisvalid(inParameterID))
{
- return mParameters[inParameterIndex].get();
+ return mParameters[inParameterID].get();
}
return {};
}
//-----------------------------------------------------------------------------
// return a (hopefully) 0 to 1 scalar version of the parameter's current value
-double DfxPlugin::getparameter_scalar(long inParameterIndex) const
+double DfxPlugin::getparameter_scalar(dfx::ParameterID inParameterID) const
{
- return getparameter_scalar(inParameterIndex, getparameter_f(inParameterIndex));
+ return getparameter_scalar(inParameterID, getparameter_f(inParameterID));
}
//-----------------------------------------------------------------------------
-double DfxPlugin::getparameter_scalar(long inParameterIndex, double inValue) const
+double DfxPlugin::getparameter_scalar(dfx::ParameterID inParameterID, double inValue) const
{
- if (parameterisvalid(inParameterIndex))
+ if (parameterisvalid(inParameterID))
{
- switch (getparameterunit(inParameterIndex))
+ switch (getparameterunit(inParameterID))
{
case DfxParam::Unit::Percent:
case DfxParam::Unit::DryWetMix:
@@ -716,138 +716,138 @@ double DfxPlugin::getparameter_scalar(long inParameterIndex, double inValue) con
return inValue;
// XXX should we not just use contractparametervalue() here?
default:
- return inValue / mParameters[inParameterIndex].getmax_f();
+ return inValue / mParameters[inParameterID].getmax_f();
}
}
return 0.0;
}
//-----------------------------------------------------------------------------
-std::optional DfxPlugin::getparameterifchanged_f(long inParameterIndex) const
+std::optional DfxPlugin::getparameterifchanged_f(dfx::ParameterID inParameterID) const
{
- if (getparameterchanged(inParameterIndex))
+ if (getparameterchanged(inParameterID))
{
- return getparameter_f(inParameterIndex);
+ return getparameter_f(inParameterID);
}
return {};
}
//-----------------------------------------------------------------------------
-std::optional DfxPlugin::getparameterifchanged_i(long inParameterIndex) const
+std::optional DfxPlugin::getparameterifchanged_i(dfx::ParameterID inParameterID) const
{
- if (getparameterchanged(inParameterIndex))
+ if (getparameterchanged(inParameterID))
{
- return getparameter_i(inParameterIndex);
+ return getparameter_i(inParameterID);
}
return {};
}
//-----------------------------------------------------------------------------
-std::optional DfxPlugin::getparameterifchanged_b(long inParameterIndex) const
+std::optional DfxPlugin::getparameterifchanged_b(dfx::ParameterID inParameterID) const
{
- if (getparameterchanged(inParameterIndex))
+ if (getparameterchanged(inParameterID))
{
- return getparameter_b(inParameterIndex);
+ return getparameter_b(inParameterID);
}
return {};
}
//-----------------------------------------------------------------------------
-std::optional DfxPlugin::getparameterifchanged_scalar(long inParameterIndex) const
+std::optional DfxPlugin::getparameterifchanged_scalar(dfx::ParameterID inParameterID) const
{
- if (getparameterchanged(inParameterIndex))
+ if (getparameterchanged(inParameterID))
{
- return getparameter_scalar(inParameterIndex);
+ return getparameter_scalar(inParameterID);
}
return {};
}
//-----------------------------------------------------------------------------
-std::optional DfxPlugin::getparameterifchanged_gen(long inParameterIndex) const
+std::optional DfxPlugin::getparameterifchanged_gen(dfx::ParameterID inParameterID) const
{
- if (getparameterchanged(inParameterIndex))
+ if (getparameterchanged(inParameterID))
{
- return getparameter_gen(inParameterIndex);
+ return getparameter_gen(inParameterID);
}
return {};
}
//-----------------------------------------------------------------------------
-std::string DfxPlugin::getparametername(long inParameterIndex) const
+std::string DfxPlugin::getparametername(dfx::ParameterID inParameterID) const
{
- if (parameterisvalid(inParameterIndex))
+ if (parameterisvalid(inParameterID))
{
- return mParameters[inParameterIndex].getname();
+ return mParameters[inParameterID].getname();
}
return {};
}
//-----------------------------------------------------------------------------
-std::string DfxPlugin::getparametername(long inParameterIndex, size_t inMaxLength) const
+std::string DfxPlugin::getparametername(dfx::ParameterID inParameterID, size_t inMaxLength) const
{
- if (parameterisvalid(inParameterIndex))
+ if (parameterisvalid(inParameterID))
{
- return mParameters[inParameterIndex].getname(inMaxLength);
+ return mParameters[inParameterID].getname(inMaxLength);
}
return {};
}
//-----------------------------------------------------------------------------
-DfxParam::ValueType DfxPlugin::getparametervaluetype(long inParameterIndex) const
+DfxParam::ValueType DfxPlugin::getparametervaluetype(dfx::ParameterID inParameterID) const
{
- if (parameterisvalid(inParameterIndex))
+ if (parameterisvalid(inParameterID))
{
- return mParameters[inParameterIndex].getvaluetype();
+ return mParameters[inParameterID].getvaluetype();
}
return DfxParam::ValueType::Float;
}
//-----------------------------------------------------------------------------
-DfxParam::Unit DfxPlugin::getparameterunit(long inParameterIndex) const
+DfxParam::Unit DfxPlugin::getparameterunit(dfx::ParameterID inParameterID) const
{
- if (parameterisvalid(inParameterIndex))
+ if (parameterisvalid(inParameterID))
{
- return mParameters[inParameterIndex].getunit();
+ return mParameters[inParameterID].getunit();
}
return DfxParam::Unit::Generic;
}
//-----------------------------------------------------------------------------
-bool DfxPlugin::setparametervaluestring(long inParameterIndex, int64_t inStringIndex, std::string_view inText)
+bool DfxPlugin::setparametervaluestring(dfx::ParameterID inParameterID, int64_t inStringIndex, std::string_view inText)
{
- return getparameterobject(inParameterIndex).setvaluestring(inStringIndex, inText);
+ return getparameterobject(inParameterID).setvaluestring(inStringIndex, inText);
}
//-----------------------------------------------------------------------------
-std::optional DfxPlugin::getparametervaluestring(long inParameterIndex, int64_t inStringIndex) const
+std::optional DfxPlugin::getparametervaluestring(dfx::ParameterID inParameterID, int64_t inStringIndex) const
{
- if (parameterisvalid(inParameterIndex))
+ if (parameterisvalid(inParameterID))
{
- return mParameters[inParameterIndex].getvaluestring(inStringIndex);
+ return mParameters[inParameterID].getvaluestring(inStringIndex);
}
return {};
}
//-----------------------------------------------------------------------------
-void DfxPlugin::addparametergroup(std::string const& inName, std::vector const& inParameterIndices)
+void DfxPlugin::addparametergroup(std::string const& inName, std::vector const& inParameterIndices)
{
assert(!inName.empty());
assert(!inParameterIndices.empty());
assert(std::none_of(mParameterGroups.cbegin(), mParameterGroups.cend(), [&inName](auto const& item){ return (item.first == inName); }));
assert(std::none_of(inParameterIndices.cbegin(), inParameterIndices.cend(), [this](auto index){ return getparametergroup(index).has_value(); }));
assert(std::all_of(inParameterIndices.cbegin(), inParameterIndices.cend(), std::bind_front(&DfxPlugin::parameterisvalid, this)));
- assert(std::unordered_set(inParameterIndices.cbegin(), inParameterIndices.cend()).size() == inParameterIndices.size());
+ assert(std::unordered_set(inParameterIndices.cbegin(), inParameterIndices.cend()).size() == inParameterIndices.size());
- mParameterGroups.emplace_back(inName, std::set(inParameterIndices.cbegin(), inParameterIndices.cend()));
+ mParameterGroups.emplace_back(inName, std::set(inParameterIndices.cbegin(), inParameterIndices.cend()));
}
//-----------------------------------------------------------------------------
-std::optional DfxPlugin::getparametergroup(long inParameterIndex) const
+std::optional DfxPlugin::getparametergroup(dfx::ParameterID inParameterID) const
{
- auto const foundGroup = std::find_if(mParameterGroups.cbegin(), mParameterGroups.cend(), [inParameterIndex](auto const& group)
+ auto const foundGroup = std::find_if(mParameterGroups.cbegin(), mParameterGroups.cend(), [inParameterID](auto const& group)
{
auto const& indices = group.second;
- return (indices.find(inParameterIndex) != indices.cend());
+ return (indices.find(inParameterID) != indices.cend());
});
if (foundGroup != mParameterGroups.cend())
{
@@ -867,67 +867,67 @@ std::string DfxPlugin::getparametergroupname(size_t inGroupIndex) const
}
//-----------------------------------------------------------------------------
-bool DfxPlugin::getparameterchanged(long inParameterIndex) const
+bool DfxPlugin::getparameterchanged(dfx::ParameterID inParameterID) const
{
assert(std::this_thread::get_id() == mAudioRenderThreadID); // only valid during audio rendering
- if (parameterisvalid(inParameterIndex))
+ if (parameterisvalid(inParameterID))
{
- return mParametersChangedAsOfPreProcess[inParameterIndex];
+ return mParametersChangedAsOfPreProcess[inParameterID];
}
return false;
}
//-----------------------------------------------------------------------------
-bool DfxPlugin::getparametertouched(long inParameterIndex) const
+bool DfxPlugin::getparametertouched(dfx::ParameterID inParameterID) const
{
assert(std::this_thread::get_id() == mAudioRenderThreadID); // only valid during audio rendering
- if (parameterisvalid(inParameterIndex))
+ if (parameterisvalid(inParameterID))
{
- return mParametersTouchedAsOfPreProcess[inParameterIndex];
+ return mParametersTouchedAsOfPreProcess[inParameterID];
}
return false;
}
//-----------------------------------------------------------------------------
-bool DfxPlugin::hasparameterattribute(long inParameterIndex, DfxParam::Attribute inFlag) const
+bool DfxPlugin::hasparameterattribute(dfx::ParameterID inParameterID, DfxParam::Attribute inFlag) const
{
assert(std::bitset(inFlag).count() == 1);
- return getparameterattributes(inParameterIndex) & inFlag;
+ return getparameterattributes(inParameterID) & inFlag;
}
//-----------------------------------------------------------------------------
-void DfxPlugin::addparameterattributes(long inParameterIndex, DfxParam::Attribute inFlags)
+void DfxPlugin::addparameterattributes(dfx::ParameterID inParameterID, DfxParam::Attribute inFlags)
{
- auto& parameter = getparameterobject(inParameterIndex);
+ auto& parameter = getparameterobject(inParameterID);
parameter.setattributes(parameter.getattributes() | inFlags);
}
//-----------------------------------------------------------------------------
// convenience methods for expanding and contracting parameter values
// using the min/max/curvetype/curvespec/etc. settings of a given parameter
-double DfxPlugin::expandparametervalue(long inParameterIndex, double genValue) const
+double DfxPlugin::expandparametervalue(dfx::ParameterID inParameterID, double genValue) const
{
- if (parameterisvalid(inParameterIndex))
+ if (parameterisvalid(inParameterID))
{
- return mParameters[inParameterIndex].expand(genValue);
+ return mParameters[inParameterID].expand(genValue);
}
return 0.0;
}
//-----------------------------------------------------------------------------
-double DfxPlugin::contractparametervalue(long inParameterIndex, double realValue) const
+double DfxPlugin::contractparametervalue(dfx::ParameterID inParameterID, double realValue) const
{
- if (parameterisvalid(inParameterIndex))
+ if (parameterisvalid(inParameterID))
{
- return mParameters[inParameterIndex].contract(realValue);
+ return mParameters[inParameterID].contract(realValue);
}
return 0.0;
}
//-----------------------------------------------------------------------------
-DfxParam& DfxPlugin::getparameterobject(long inParameterIndex)
+DfxParam& DfxPlugin::getparameterobject(dfx::ParameterID inParameterID)
{
- assert(parameterisvalid(inParameterIndex));
- return mParameters.at(inParameterIndex);
+ assert(parameterisvalid(inParameterID));
+ return mParameters.at(inParameterID);
}
@@ -977,7 +977,7 @@ bool DfxPlugin::loadpreset(size_t inPresetIndex)
TARGET_API_BASE_CLASS::setProgram(dfx::math::ToSigned(inPresetIndex));
#endif
- for (long i = 0; i < getnumparameters(); i++)
+ for (dfx::ParameterID i = 0; i < getnumparameters(); i++)
{
setparameter(i, getpresetparameter(inPresetIndex, i));
postupdate_parameter(i); // inform any parameter listeners of the changes
@@ -1028,7 +1028,7 @@ void DfxPlugin::postupdate_preset()
//-----------------------------------------------------------------------------
// default all empty (no name) presets with the current value of a parameter
-void DfxPlugin::initpresetsparameter(long inParameterIndex)
+void DfxPlugin::initpresetsparameter(dfx::ParameterID inParameterID)
{
// first fill in the presets with the init settings
// so that there are no "stale" unset values
@@ -1036,97 +1036,97 @@ void DfxPlugin::initpresetsparameter(long inParameterIndex)
{
if (!presetnameisvalid(i)) // only if it's an "empty" preset
{
- setpresetparameter(i, inParameterIndex, getparameter(inParameterIndex));
+ setpresetparameter(i, inParameterID, getparameter(inParameterID));
}
}
}
//-----------------------------------------------------------------------------
-DfxParam::Value DfxPlugin::getpresetparameter(size_t inPresetIndex, long inParameterIndex) const
+DfxParam::Value DfxPlugin::getpresetparameter(size_t inPresetIndex, dfx::ParameterID inParameterID) const
{
- if (parameterisvalid(inParameterIndex) && presetisvalid(inPresetIndex))
+ if (parameterisvalid(inParameterID) && presetisvalid(inPresetIndex))
{
- return mPresets[inPresetIndex].getvalue(inParameterIndex);
+ return mPresets[inPresetIndex].getvalue(inParameterID);
}
return {};
}
//-----------------------------------------------------------------------------
-double DfxPlugin::getpresetparameter_f(size_t inPresetIndex, long inParameterIndex) const
+double DfxPlugin::getpresetparameter_f(size_t inPresetIndex, dfx::ParameterID inParameterID) const
{
- if (parameterisvalid(inParameterIndex) && presetisvalid(inPresetIndex))
+ if (parameterisvalid(inParameterID) && presetisvalid(inPresetIndex))
{
- return mParameters[inParameterIndex].derive_f(mPresets[inPresetIndex].getvalue(inParameterIndex));
+ return mParameters[inParameterID].derive_f(mPresets[inPresetIndex].getvalue(inParameterID));
}
return 0.0;
}
//-----------------------------------------------------------------------------
-int64_t DfxPlugin::getpresetparameter_i(size_t inPresetIndex, long inParameterIndex) const
+int64_t DfxPlugin::getpresetparameter_i(size_t inPresetIndex, dfx::ParameterID inParameterID) const
{
- if (parameterisvalid(inParameterIndex) && presetisvalid(inPresetIndex))
+ if (parameterisvalid(inParameterID) && presetisvalid(inPresetIndex))
{
- return mParameters[inParameterIndex].derive_i(mPresets[inPresetIndex].getvalue(inParameterIndex));
+ return mParameters[inParameterID].derive_i(mPresets[inPresetIndex].getvalue(inParameterID));
}
return 0;
}
//-----------------------------------------------------------------------------
-bool DfxPlugin::getpresetparameter_b(size_t inPresetIndex, long inParameterIndex) const
+bool DfxPlugin::getpresetparameter_b(size_t inPresetIndex, dfx::ParameterID inParameterID) const
{
- if (parameterisvalid(inParameterIndex) && presetisvalid(inPresetIndex))
+ if (parameterisvalid(inParameterID) && presetisvalid(inPresetIndex))
{
- return mParameters[inParameterIndex].derive_b(mPresets[inPresetIndex].getvalue(inParameterIndex));
+ return mParameters[inParameterID].derive_b(mPresets[inPresetIndex].getvalue(inParameterID));
}
return false;
}
//-----------------------------------------------------------------------------
-void DfxPlugin::setpresetparameter(size_t inPresetIndex, long inParameterIndex, DfxParam::Value inValue)
+void DfxPlugin::setpresetparameter(size_t inPresetIndex, dfx::ParameterID inParameterID, DfxParam::Value inValue)
{
- if (parameterisvalid(inParameterIndex) && presetisvalid(inPresetIndex))
+ if (parameterisvalid(inParameterID) && presetisvalid(inPresetIndex))
{
- mPresets[inPresetIndex].setvalue(inParameterIndex, inValue);
+ mPresets[inPresetIndex].setvalue(inParameterID, inValue);
}
}
//-----------------------------------------------------------------------------
-void DfxPlugin::setpresetparameter_f(size_t inPresetIndex, long inParameterIndex, double inValue)
+void DfxPlugin::setpresetparameter_f(size_t inPresetIndex, dfx::ParameterID inParameterID, double inValue)
{
- if (parameterisvalid(inParameterIndex) && presetisvalid(inPresetIndex))
+ if (parameterisvalid(inParameterID) && presetisvalid(inPresetIndex))
{
- auto const paramValue = mParameters[inParameterIndex].pack_f(inValue);
- mPresets[inPresetIndex].setvalue(inParameterIndex, paramValue);
+ auto const paramValue = mParameters[inParameterID].pack_f(inValue);
+ mPresets[inPresetIndex].setvalue(inParameterID, paramValue);
}
}
//-----------------------------------------------------------------------------
-void DfxPlugin::setpresetparameter_i(size_t inPresetIndex, long inParameterIndex, int64_t inValue)
+void DfxPlugin::setpresetparameter_i(size_t inPresetIndex, dfx::ParameterID inParameterID, int64_t inValue)
{
- if (parameterisvalid(inParameterIndex) && presetisvalid(inPresetIndex))
+ if (parameterisvalid(inParameterID) && presetisvalid(inPresetIndex))
{
- auto const paramValue = mParameters[inParameterIndex].pack_i(inValue);
- mPresets[inPresetIndex].setvalue(inParameterIndex, paramValue);
+ auto const paramValue = mParameters[inParameterID].pack_i(inValue);
+ mPresets[inPresetIndex].setvalue(inParameterID, paramValue);
}
}
//-----------------------------------------------------------------------------
-void DfxPlugin::setpresetparameter_b(size_t inPresetIndex, long inParameterIndex, bool inValue)
+void DfxPlugin::setpresetparameter_b(size_t inPresetIndex, dfx::ParameterID inParameterID, bool inValue)
{
- if (parameterisvalid(inParameterIndex) && presetisvalid(inPresetIndex))
+ if (parameterisvalid(inParameterID) && presetisvalid(inPresetIndex))
{
- auto const paramValue = mParameters[inParameterIndex].pack_b(inValue);
- mPresets[inPresetIndex].setvalue(inParameterIndex, paramValue);
+ auto const paramValue = mParameters[inParameterID].pack_b(inValue);
+ mPresets[inPresetIndex].setvalue(inParameterID, paramValue);
}
}
//-----------------------------------------------------------------------------
-void DfxPlugin::setpresetparameter_gen(size_t inPresetIndex, long inParameterIndex, double inValue)
+void DfxPlugin::setpresetparameter_gen(size_t inPresetIndex, dfx::ParameterID inParameterID, double inValue)
{
- if (parameterisvalid(inParameterIndex) && presetisvalid(inPresetIndex))
+ if (parameterisvalid(inParameterID) && presetisvalid(inPresetIndex))
{
- auto const paramValue = mParameters[inParameterIndex].pack_f(expandparametervalue(inParameterIndex, inValue));
- mPresets[inPresetIndex].setvalue(inParameterIndex, paramValue);
+ auto const paramValue = mParameters[inParameterID].pack_f(expandparametervalue(inParameterID, inValue));
+ mPresets[inPresetIndex].setvalue(inParameterID, paramValue);
}
}
@@ -1988,21 +1988,21 @@ void DfxPlugin::do_processparameters()
#if TARGET_PLUGIN_USES_DSPCORE
//-----------------------------------------------------------------------------
-double DfxPlugin::getdspcoreparameter_gen(long inParameterIndex) const
+double DfxPlugin::getdspcoreparameter_gen(dfx::ParameterID inParameterID) const
{
- if (parameterisvalid(inParameterIndex))
+ if (parameterisvalid(inParameterID))
{
- return contractparametervalue(inParameterIndex, mParameters[inParameterIndex].derive_f(mDSPCoreParameterValuesCache[inParameterIndex]));
+ return contractparametervalue(inParameterID, mParameters[inParameterID].derive_f(mDSPCoreParameterValuesCache[inParameterID]));
}
return 0.;
}
//-----------------------------------------------------------------------------
-double DfxPlugin::getdspcoreparameter_scalar(long inParameterIndex) const
+double DfxPlugin::getdspcoreparameter_scalar(dfx::ParameterID inParameterID) const
{
- if (parameterisvalid(inParameterIndex))
+ if (parameterisvalid(inParameterID))
{
- getparameter_scalar(inParameterIndex, mParameters[inParameterIndex].derive_f(mDSPCoreParameterValuesCache[inParameterIndex]));
+ getparameter_scalar(inParameterID, mParameters[inParameterID].derive_f(mDSPCoreParameterValuesCache[inParameterID]));
}
return 0.;
}
@@ -2108,27 +2108,27 @@ fprintf(stderr, "program change: program num = %d, channel = %d, sample offset
}
//-----------------------------------------------------------------------------
-void DfxPlugin::setmidilearner(long inParameterIndex)
+void DfxPlugin::setmidilearner(dfx::ParameterID inParameterID)
{
- if (auto const assignmentData = settings_getLearningAssignData(inParameterIndex))
+ if (auto const assignmentData = settings_getLearningAssignData(inParameterID))
{
- mDfxSettings->setLearner(inParameterIndex, assignmentData->mEventBehaviorFlags,
+ mDfxSettings->setLearner(inParameterID, assignmentData->mEventBehaviorFlags,
assignmentData->mDataInt1, assignmentData->mDataInt2,
assignmentData->mDataFloat1, assignmentData->mDataFloat2);
}
- else if (getparametervaluetype(inParameterIndex) == DfxParam::ValueType::Float)
+ else if (getparametervaluetype(inParameterID) == DfxParam::ValueType::Float)
{
- mDfxSettings->setLearner(inParameterIndex);
+ mDfxSettings->setLearner(inParameterID);
}
else
{
- auto const numStates = getparametermax_i(inParameterIndex) - getparametermin_i(inParameterIndex) + 1;
- mDfxSettings->setLearner(inParameterIndex, dfx::kMidiEventBehaviorFlag_Toggle, numStates);
+ auto const numStates = getparametermax_i(inParameterID) - getparametermin_i(inParameterID) + 1;
+ mDfxSettings->setLearner(inParameterID, dfx::kMidiEventBehaviorFlag_Toggle, numStates);
}
}
//-----------------------------------------------------------------------------
-long DfxPlugin::getmidilearner() const
+dfx::ParameterID DfxPlugin::getmidilearner() const
{
return mDfxSettings->getLearner();
}
@@ -2152,26 +2152,26 @@ void DfxPlugin::resetmidilearn()
}
//-----------------------------------------------------------------------------
-void DfxPlugin::setparametermidiassignment(long inParameterIndex, dfx::ParameterAssignment const& inAssignment)
+void DfxPlugin::setparametermidiassignment(dfx::ParameterID inParameterID, dfx::ParameterAssignment const& inAssignment)
{
if (inAssignment.mEventType == dfx::MidiEventType::None)
{
- mDfxSettings->unassignParam(inParameterIndex);
+ mDfxSettings->unassignParameter(inParameterID);
}
else
{
- mDfxSettings->assignParam(inParameterIndex, inAssignment.mEventType, inAssignment.mEventChannel,
- inAssignment.mEventNum, inAssignment.mEventNum2,
- inAssignment.mEventBehaviorFlags,
- inAssignment.mDataInt1, inAssignment.mDataInt2,
- inAssignment.mDataFloat1, inAssignment.mDataFloat2);
+ mDfxSettings->assignParameter(inParameterID, inAssignment.mEventType, inAssignment.mEventChannel,
+ inAssignment.mEventNum, inAssignment.mEventNum2,
+ inAssignment.mEventBehaviorFlags,
+ inAssignment.mDataInt1, inAssignment.mDataInt2,
+ inAssignment.mDataFloat1, inAssignment.mDataFloat2);
}
}
//-----------------------------------------------------------------------------
-dfx::ParameterAssignment DfxPlugin::getparametermidiassignment(long inParameterIndex) const
+dfx::ParameterAssignment DfxPlugin::getparametermidiassignment(dfx::ParameterID inParameterID) const
{
- return mDfxSettings->getParameterAssignment(inParameterIndex);
+ return mDfxSettings->getParameterAssignment(inParameterID);
}
//-----------------------------------------------------------------------------
diff --git a/dfx-library/dfxplugin.h b/dfx-library/dfxplugin.h
index 09b0b34e..a0fc4cb0 100644
--- a/dfx-library/dfxplugin.h
+++ b/dfx-library/dfxplugin.h
@@ -18,7 +18,7 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Destroy FX Library. If not, see .
-To contact the author, use the contact form at http://destroyfx.org/
+To contact the author, use the contact form at http://destroyfx.org
Destroy FX is a sovereign entity comprised of Sophia Poirier and Tom Murphy 7.
This is our class for E-Z plugin-making and E-Z multiple-API support.
@@ -212,7 +212,7 @@ class DfxPlugin : public TARGET_API_BASE_CLASS
double mSamplesToNextBar = 0.;
bool mSamplesToNextBarIsValid = false;
- bool mPlaybackChanged = false; // whether or not the playback state or position just changed
+ bool mPlaybackChanged = false; // whether the playback state or position changed since the last audio render cycle
bool mPlaybackIsOccurring = false;
};
@@ -264,186 +264,186 @@ class DfxPlugin : public TARGET_API_BASE_CLASS
{
return mPresets.size();
}
- bool parameterisvalid(long inParameterIndex) const noexcept
+ bool parameterisvalid(dfx::ParameterID inParameterID) const noexcept
{
- return (inParameterIndex >= 0) && (static_cast(inParameterIndex) < getnumparameters());
+ return (inParameterID != dfx::kParameterID_Invalid) && (inParameterID < getnumparameters());
}
// Initialize parameters of double, int64, bool, or list type. (See dfxparameter.h)
// initNames gives different names for the parameter (not the values); each name must
// be a different length and could be used in different contexts (e.g. a control surface
// may only have room for 4 characters). The longest one is assumed to be the best name.
- void initparameter_f(long inParameterIndex, std::vector const& initNames,
+ void initparameter_f(dfx::ParameterID inParameterID, std::vector const& initNames,
double initValue, double initDefaultValue,
double initMin, double initMax,
DfxParam::Unit initUnit = DfxParam::Unit::Generic,
DfxParam::Curve initCurve = DfxParam::Curve::Linear,
std::string_view initCustomUnitString = {});
- void initparameter_i(long inParameterIndex, std::vector const& initNames,
+ void initparameter_i(dfx::ParameterID inParameterID, std::vector const& initNames,
int64_t initValue, int64_t initDefaultValue,
int64_t initMin, int64_t initMax,
DfxParam::Unit initUnit = DfxParam::Unit::Generic,
DfxParam::Curve initCurve = DfxParam::Curve::Stepped,
std::string_view initCustomUnitString = {});
- void initparameter_b(long inParameterIndex, std::vector const& initNames,
+ void initparameter_b(dfx::ParameterID inParameterID, std::vector const& initNames,
bool initValue, bool initDefaultValue,
DfxParam::Unit initUnit = DfxParam::Unit::Generic);
- void initparameter_b(long inParameterIndex, std::vector const& initNames,
+ void initparameter_b(dfx::ParameterID inParameterID, std::vector const& initNames,
bool initDefaultValue, DfxParam::Unit initUnit = DfxParam::Unit::Generic);
- void initparameter_list(long inParameterIndex, std::vector const& initNames,
+ void initparameter_list(dfx::ParameterID inParameterID, std::vector const& initNames,
int64_t initValue, int64_t initDefaultValue,
int64_t initNumItems, DfxParam::Unit initUnit = DfxParam::Unit::List,
std::string_view initCustomUnitString = {});
- void setparameterusevaluestrings(long inParameterIndex, bool inMode = true)
+ void setparameterusevaluestrings(dfx::ParameterID inParameterID, bool inMode = true)
{
- getparameterobject(inParameterIndex).setusevaluestrings(inMode);
+ getparameterobject(inParameterID).setusevaluestrings(inMode);
}
- bool getparameterusevaluestrings(long inParameterIndex) const
+ bool getparameterusevaluestrings(dfx::ParameterID inParameterID) const
{
- return parameterisvalid(inParameterIndex) ? mParameters[inParameterIndex].getusevaluestrings() : false;
+ return parameterisvalid(inParameterID) ? mParameters[inParameterID].getusevaluestrings() : false;
}
- bool setparametervaluestring(long inParameterIndex, int64_t inStringIndex, std::string_view inText);
- std::optional getparametervaluestring(long inParameterIndex, int64_t inStringIndex) const;
- std::string getparameterunitstring(long inParameterIndex) const
+ bool setparametervaluestring(dfx::ParameterID inParameterID, int64_t inStringIndex, std::string_view inText);
+ std::optional getparametervaluestring(dfx::ParameterID inParameterID, int64_t inStringIndex) const;
+ std::string getparameterunitstring(dfx::ParameterID inParameterID) const
{
- return parameterisvalid(inParameterIndex) ? mParameters[inParameterIndex].getunitstring() : std::string{};
+ return parameterisvalid(inParameterID) ? mParameters[inParameterID].getunitstring() : std::string{};
}
- void setparametercustomunitstring(long inParameterIndex, std::string_view inText)
+ void setparametercustomunitstring(dfx::ParameterID inParameterID, std::string_view inText)
{
- getparameterobject(inParameterIndex).setcustomunitstring(inText);
+ getparameterobject(inParameterID).setcustomunitstring(inText);
}
#ifdef TARGET_API_AUDIOUNIT
- CFStringRef getparametervaluecfstring(long inParameterIndex, int64_t inStringIndex) const
+ CFStringRef getparametervaluecfstring(dfx::ParameterID inParameterID, int64_t inStringIndex) const
{
- return parameterisvalid(inParameterIndex) ? mParameters[inParameterIndex].getvaluecfstring(inStringIndex) : nullptr;
+ return parameterisvalid(inParameterID) ? mParameters[inParameterID].getvaluecfstring(inStringIndex) : nullptr;
}
#endif
- void addparametergroup(std::string const& inName, std::vector const& inParameterIndices); // TODO: C++23 use std::span?
- std::optional getparametergroup(long inParameterIndex) const;
+ void addparametergroup(std::string const& inName, std::vector const& inParameterIndices); // TODO: C++23 use std::span?
+ std::optional getparametergroup(dfx::ParameterID inParameterID) const;
std::string getparametergroupname(size_t inGroupIndex) const;
- void setparameter_f(long inParameterIndex, double inValue);
- void setparameter_i(long inParameterIndex, int64_t inValue);
- void setparameter_b(long inParameterIndex, bool inValue);
- void setparameter_gen(long inParameterIndex, double inValue);
- void setparameterquietly_f(long inParameterIndex, double inValue);
- void setparameterquietly_i(long inParameterIndex, int64_t inValue);
- void setparameterquietly_b(long inParameterIndex, bool inValue);
- virtual void parameterChanged(long inParameterIndex) {}
+ void setparameter_f(dfx::ParameterID inParameterID, double inValue);
+ void setparameter_i(dfx::ParameterID inParameterID, int64_t inValue);
+ void setparameter_b(dfx::ParameterID inParameterID, bool inValue);
+ void setparameter_gen(dfx::ParameterID inParameterID, double inValue);
+ void setparameterquietly_f(dfx::ParameterID inParameterID, double inValue);
+ void setparameterquietly_i(dfx::ParameterID inParameterID, int64_t inValue);
+ void setparameterquietly_b(dfx::ParameterID inParameterID, bool inValue);
+ virtual void parameterChanged(dfx::ParameterID inParameterID) {}
// ***
- virtual void randomizeparameter(long inParameterIndex);
+ virtual void randomizeparameter(dfx::ParameterID inParameterID);
// Randomize all parameters at once. Default implementation just loops over the
// eligible parameters and calls randomizeparameter(), but this could also be
// smarter (e.g. keeping the total output volume the same).
virtual void randomizeparameters();
// broadcast changes to listeners (like GUI)
- void postupdate_parameter(long inParameterIndex);
+ void postupdate_parameter(dfx::ParameterID inParameterID);
- double getparameter_f(long inParameterIndex) const
+ double getparameter_f(dfx::ParameterID inParameterID) const
{
- return parameterisvalid(inParameterIndex) ? mParameters[inParameterIndex].get_f() : 0.0;
+ return parameterisvalid(inParameterID) ? mParameters[inParameterID].get_f() : 0.0;
}
- int64_t getparameter_i(long inParameterIndex) const
+ int64_t getparameter_i(dfx::ParameterID inParameterID) const
{
- return parameterisvalid(inParameterIndex) ? mParameters[inParameterIndex].get_i() : 0;
+ return parameterisvalid(inParameterID) ? mParameters[inParameterID].get_i() : 0;
}
- bool getparameter_b(long inParameterIndex) const
+ bool getparameter_b(dfx::ParameterID inParameterID) const
{
- return parameterisvalid(inParameterIndex) ? mParameters[inParameterIndex].get_b() : false;
+ return parameterisvalid(inParameterID) ? mParameters[inParameterID].get_b() : false;
}
- double getparameter_gen(long inParameterIndex) const
+ double getparameter_gen(dfx::ParameterID inParameterID) const
{
- return parameterisvalid(inParameterIndex) ? mParameters[inParameterIndex].get_gen() : 0.0;
+ return parameterisvalid(inParameterID) ? mParameters[inParameterID].get_gen() : 0.0;
}
// return a (hopefully) 0 to 1 scalar version of the parameter's current value
- double getparameter_scalar(long inParameterIndex) const;
- std::optional getparameterifchanged_f(long inParameterIndex) const;
- std::optional getparameterifchanged_i(long inParameterIndex) const;
- std::optional getparameterifchanged_b(long inParameterIndex) const;
- std::optional getparameterifchanged_scalar(long inParameterIndex) const;
- std::optional getparameterifchanged_gen(long inParameterIndex) const;
+ double getparameter_scalar(dfx::ParameterID inParameterID) const;
+ std::optional getparameterifchanged_f(dfx::ParameterID inParameterID) const;
+ std::optional getparameterifchanged_i(dfx::ParameterID inParameterID) const;
+ std::optional getparameterifchanged_b(dfx::ParameterID inParameterID) const;
+ std::optional getparameterifchanged_scalar(dfx::ParameterID inParameterID) const;
+ std::optional getparameterifchanged_gen(dfx::ParameterID inParameterID) const;
- double getparametermin_f(long inParameterIndex) const
+ double getparametermin_f(dfx::ParameterID inParameterID) const
{
- return parameterisvalid(inParameterIndex) ? mParameters[inParameterIndex].getmin_f() : 0.0;
+ return parameterisvalid(inParameterID) ? mParameters[inParameterID].getmin_f() : 0.0;
}
- int64_t getparametermin_i(long inParameterIndex) const
+ int64_t getparametermin_i(dfx::ParameterID inParameterID) const
{
- return parameterisvalid(inParameterIndex) ? mParameters[inParameterIndex].getmin_i() : 0;
+ return parameterisvalid(inParameterID) ? mParameters[inParameterID].getmin_i() : 0;
}
- double getparametermax_f(long inParameterIndex) const
+ double getparametermax_f(dfx::ParameterID inParameterID) const
{
- return parameterisvalid(inParameterIndex) ? mParameters[inParameterIndex].getmax_f() : 0.0;
+ return parameterisvalid(inParameterID) ? mParameters[inParameterID].getmax_f() : 0.0;
}
- int64_t getparametermax_i(long inParameterIndex) const
+ int64_t getparametermax_i(dfx::ParameterID inParameterID) const
{
- return parameterisvalid(inParameterIndex) ? mParameters[inParameterIndex].getmax_i() : 0;
+ return parameterisvalid(inParameterID) ? mParameters[inParameterID].getmax_i() : 0;
}
- double getparameterdefault_f(long inParameterIndex) const
+ double getparameterdefault_f(dfx::ParameterID inParameterID) const
{
- return parameterisvalid(inParameterIndex) ? mParameters[inParameterIndex].getdefault_f() : 0.0;
+ return parameterisvalid(inParameterID) ? mParameters[inParameterID].getdefault_f() : 0.0;
}
- int64_t getparameterdefault_i(long inParameterIndex) const
+ int64_t getparameterdefault_i(dfx::ParameterID inParameterID) const
{
- return parameterisvalid(inParameterIndex) ? mParameters[inParameterIndex].getdefault_i() : 0;
+ return parameterisvalid(inParameterID) ? mParameters[inParameterID].getdefault_i() : 0;
}
- bool getparameterdefault_b(long inParameterIndex) const
+ bool getparameterdefault_b(dfx::ParameterID inParameterID) const
{
- return parameterisvalid(inParameterIndex) ? mParameters[inParameterIndex].getdefault_b() : false;
+ return parameterisvalid(inParameterID) ? mParameters[inParameterID].getdefault_b() : false;
}
- std::string getparametername(long inParameterIndex) const;
- std::string getparametername(long inParameterIndex, size_t inMaxLength) const;
+ std::string getparametername(dfx::ParameterID inParameterID) const;
+ std::string getparametername(dfx::ParameterID inParameterID, size_t inMaxLength) const;
#ifdef TARGET_API_AUDIOUNIT
- CFStringRef getparametercfname(long inParameterIndex) const
+ CFStringRef getparametercfname(dfx::ParameterID inParameterID) const
{
- return parameterisvalid(inParameterIndex) ? mParameters[inParameterIndex].getcfname() : nullptr;
+ return parameterisvalid(inParameterID) ? mParameters[inParameterID].getcfname() : nullptr;
}
#endif
- DfxParam::ValueType getparametervaluetype(long inParameterIndex) const;
- DfxParam::Unit getparameterunit(long inParameterIndex) const;
- bool getparameterchanged(long inParameterIndex) const; // only reliable when called during processaudio
- bool getparametertouched(long inParameterIndex) const; // only reliable when called during processaudio
- DfxParam::Curve getparametercurve(long inParameterIndex) const
+ DfxParam::ValueType getparametervaluetype(dfx::ParameterID inParameterID) const;
+ DfxParam::Unit getparameterunit(dfx::ParameterID inParameterID) const;
+ bool getparameterchanged(dfx::ParameterID inParameterID) const; // only reliable when called during processaudio
+ bool getparametertouched(dfx::ParameterID inParameterID) const; // only reliable when called during processaudio
+ DfxParam::Curve getparametercurve(dfx::ParameterID inParameterID) const
{
- return parameterisvalid(inParameterIndex) ? mParameters[inParameterIndex].getcurve() : DfxParam::Curve::Linear;
+ return parameterisvalid(inParameterID) ? mParameters[inParameterID].getcurve() : DfxParam::Curve::Linear;
}
- void setparametercurve(long inParameterIndex, DfxParam::Curve inCurve)
+ void setparametercurve(dfx::ParameterID inParameterID, DfxParam::Curve inCurve)
{
- getparameterobject(inParameterIndex).setcurve(inCurve);
+ getparameterobject(inParameterID).setcurve(inCurve);
}
- double getparametercurvespec(long inParameterIndex) const
+ double getparametercurvespec(dfx::ParameterID inParameterID) const
{
- return parameterisvalid(inParameterIndex) ? mParameters[inParameterIndex].getcurvespec() : 0.0;
+ return parameterisvalid(inParameterID) ? mParameters[inParameterID].getcurvespec() : 0.0;
}
- void setparametercurvespec(long inParameterIndex, double inCurveSpec)
+ void setparametercurvespec(dfx::ParameterID inParameterID, double inCurveSpec)
{
- getparameterobject(inParameterIndex).setcurvespec(inCurveSpec);
+ getparameterobject(inParameterID).setcurvespec(inCurveSpec);
}
- bool getparameterenforcevaluelimits(long inParameterIndex) const
+ bool getparameterenforcevaluelimits(dfx::ParameterID inParameterID) const
{
- return parameterisvalid(inParameterIndex) ? mParameters[inParameterIndex].GetEnforceValueLimits() : false;
+ return parameterisvalid(inParameterID) ? mParameters[inParameterID].GetEnforceValueLimits() : false;
}
- void setparameterenforcevaluelimits(long inParameterIndex, bool inMode)
+ void setparameterenforcevaluelimits(dfx::ParameterID inParameterID, bool inMode)
{
- getparameterobject(inParameterIndex).SetEnforceValueLimits(inMode);
+ getparameterobject(inParameterID).SetEnforceValueLimits(inMode);
}
- DfxParam::Attribute getparameterattributes(long inParameterIndex) const
+ DfxParam::Attribute getparameterattributes(dfx::ParameterID inParameterID) const
{
- return parameterisvalid(inParameterIndex) ? mParameters[inParameterIndex].getattributes() : 0;
+ return parameterisvalid(inParameterID) ? mParameters[inParameterID].getattributes() : 0;
}
- bool hasparameterattribute(long inParameterIndex, DfxParam::Attribute inFlag) const;
- void setparameterattributes(long inParameterIndex, DfxParam::Attribute inFlags)
+ bool hasparameterattribute(dfx::ParameterID inParameterID, DfxParam::Attribute inFlag) const;
+ void setparameterattributes(dfx::ParameterID inParameterID, DfxParam::Attribute inFlags)
{
- getparameterobject(inParameterIndex).setattributes(inFlags);
+ getparameterobject(inParameterID).setattributes(inFlags);
}
- void addparameterattributes(long inParameterIndex, DfxParam::Attribute inFlags);
+ void addparameterattributes(dfx::ParameterID inParameterID, DfxParam::Attribute inFlags);
// convenience methods for expanding and contracting parameter values
// using the min/max/curvetype/curvespec/etc. settings of a given parameter
- double expandparametervalue(long inParameterIndex, double genValue) const;
- double contractparametervalue(long inParameterIndex, double realValue) const;
+ double expandparametervalue(dfx::ParameterID inParameterID, double genValue) const;
+ double contractparametervalue(dfx::ParameterID inParameterID, double realValue) const;
// whether or not the index is a valid preset
bool presetisvalid(size_t inPresetIndex) const noexcept;
@@ -453,7 +453,7 @@ class DfxPlugin : public TARGET_API_BASE_CLASS
virtual bool loadpreset(size_t inPresetIndex);
// set a parameter value in all of the empty (no name) presets
// to the current value of that parameter
- void initpresetsparameter(long inParameterIndex);
+ void initpresetsparameter(dfx::ParameterID inParameterID);
// set the text of a preset name
void setpresetname(size_t inPresetIndex, std::string_view inText);
// get a copy of the text of a preset name
@@ -465,14 +465,14 @@ class DfxPlugin : public TARGET_API_BASE_CLASS
{
return mCurrentPresetNum;
}
- void setpresetparameter_f(size_t inPresetIndex, long inParameterIndex, double inValue);
- void setpresetparameter_i(size_t inPresetIndex, long inParameterIndex, int64_t inValue);
- void setpresetparameter_b(size_t inPresetIndex, long inParameterIndex, bool inValue);
- void setpresetparameter_gen(size_t inPresetIndex, long inParameterIndex, double inValue);
+ void setpresetparameter_f(size_t inPresetIndex, dfx::ParameterID inParameterID, double inValue);
+ void setpresetparameter_i(size_t inPresetIndex, dfx::ParameterID inParameterID, int64_t inValue);
+ void setpresetparameter_b(size_t inPresetIndex, dfx::ParameterID inParameterID, bool inValue);
+ void setpresetparameter_gen(size_t inPresetIndex, dfx::ParameterID inParameterID, double inValue);
void postupdate_preset();
- double getpresetparameter_f(size_t inPresetIndex, long inParameterIndex) const;
- int64_t getpresetparameter_i(size_t inPresetIndex, long inParameterIndex) const;
- bool getpresetparameter_b(size_t inPresetIndex, long inParameterIndex) const;
+ double getpresetparameter_f(size_t inPresetIndex, dfx::ParameterID inParameterID) const;
+ int64_t getpresetparameter_i(size_t inPresetIndex, dfx::ParameterID inParameterID) const;
+ bool getpresetparameter_b(size_t inPresetIndex, dfx::ParameterID inParameterID) const;
bool settingsMinimalValidate(void const* inData, size_t inBufferSize) const noexcept;
@@ -582,13 +582,13 @@ class DfxPlugin : public TARGET_API_BASE_CLASS
virtual void handlemidi_cc(int inChannel, int inControllerNum, int inValue, size_t inOffsetFrames);
virtual void handlemidi_programchange(int inChannel, int inProgramNum, size_t inOffsetFrames);
- void setmidilearner(long inParameterIndex);
- long getmidilearner() const;
+ void setmidilearner(dfx::ParameterID inParameterID);
+ dfx::ParameterID getmidilearner() const;
void setmidilearning(bool inLearnMode);
bool getmidilearning() const;
void resetmidilearn();
- void setparametermidiassignment(long inParameterIndex, dfx::ParameterAssignment const& inAssignment);
- dfx::ParameterAssignment getparametermidiassignment(long inParameterIndex) const;
+ void setparametermidiassignment(dfx::ParameterID inParameterID, dfx::ParameterAssignment const& inAssignment);
+ dfx::ParameterAssignment getparametermidiassignment(dfx::ParameterID inParameterID) const;
void setMidiAssignmentsUseChannel(bool inEnable);
bool getMidiAssignmentsUseChannel() const;
void setMidiAssignmentsSteal(bool inEnable);
@@ -621,17 +621,17 @@ class DfxPlugin : public TARGET_API_BASE_CLASS
// it's the version number of the plugin that created the data)
// (presetNum of -1 indicates that we're just working with the current
// state of the plugin)
- virtual void settings_doChunkRestoreSetParameterStuff(long tag, float value, unsigned int dataVersion, std::optional presetIndex) {}
+ virtual void settings_doChunkRestoreSetParameterStuff(dfx::ParameterID parameterID, float value, unsigned int dataVersion, std::optional presetIndex) {}
//
// these can be overridden to do something and extend the MIDI event processing
- virtual void settings_doLearningAssignStuff(long tag, dfx::MidiEventType eventType, int eventChannel,
+ virtual void settings_doLearningAssignStuff(dfx::ParameterID parameterID, dfx::MidiEventType eventType, int eventChannel,
int eventNum, size_t offsetFrames, int eventNum2 = 0,
dfx::MidiEventBehaviorFlags eventBehaviorFlags = dfx::kMidiEventBehaviorFlag_None,
int data1 = 0, int data2 = 0,
float fdata1 = 0.0f, float fdata2 = 0.0f) {}
- virtual void settings_doMidiAutomatedSetParameterStuff(long tag, float value, size_t offsetFrames) {}
+ virtual void settings_doMidiAutomatedSetParameterStuff(dfx::ParameterID parameterID, float value, size_t offsetFrames) {}
// HACK: the return type is overloaded for this purpose, contains more data than used in this context
- virtual std::optional settings_getLearningAssignData(long inParameterIndex) const
+ virtual std::optional settings_getLearningAssignData(dfx::ParameterID inParameterID) const
{
return {};
}
@@ -642,20 +642,20 @@ class DfxPlugin : public TARGET_API_BASE_CLASS
#endif
#if TARGET_PLUGIN_USES_DSPCORE
- double getdspcoreparameter_f(long inParameterIndex) const
+ double getdspcoreparameter_f(dfx::ParameterID inParameterID) const
{
- return parameterisvalid(inParameterIndex) ? mParameters[inParameterIndex].derive_f(mDSPCoreParameterValuesCache[inParameterIndex]) : 0.;
+ return parameterisvalid(inParameterID) ? mParameters[inParameterID].derive_f(mDSPCoreParameterValuesCache[inParameterID]) : 0.;
}
- int64_t getdspcoreparameter_i(long inParameterIndex) const
+ int64_t getdspcoreparameter_i(dfx::ParameterID inParameterID) const
{
- return parameterisvalid(inParameterIndex) ? mParameters[inParameterIndex].derive_i(mDSPCoreParameterValuesCache[inParameterIndex]) : 0;
+ return parameterisvalid(inParameterID) ? mParameters[inParameterID].derive_i(mDSPCoreParameterValuesCache[inParameterID]) : 0;
}
- bool getdspcoreparameter_b(long inParameterIndex) const
+ bool getdspcoreparameter_b(dfx::ParameterID inParameterID) const
{
- return parameterisvalid(inParameterIndex) ? mParameters[inParameterIndex].derive_b(mDSPCoreParameterValuesCache[inParameterIndex]) : false;
+ return parameterisvalid(inParameterID) ? mParameters[inParameterID].derive_b(mDSPCoreParameterValuesCache[inParameterID]) : false;
}
- double getdspcoreparameter_gen(long inParameterIndex) const;
- double getdspcoreparameter_scalar(long inParameterIndex) const;
+ double getdspcoreparameter_gen(dfx::ParameterID inParameterID) const;
+ double getdspcoreparameter_scalar(dfx::ParameterID inParameterID) const;
#endif
// handling of AU properties specific to Logic
@@ -753,16 +753,16 @@ class DfxPlugin : public TARGET_API_BASE_CLASS
private:
- DfxParam& getparameterobject(long inParameterIndex);
+ DfxParam& getparameterobject(dfx::ParameterID inParameterID);
- void setparameter(long inParameterIndex, DfxParam::Value inValue);
- DfxParam::Value getparameter(long inParameterIndex) const;
- double getparameter_scalar(long inParameterIndex, double inValue) const;
+ void setparameter(dfx::ParameterID inParameterID, DfxParam::Value inValue);
+ DfxParam::Value getparameter(dfx::ParameterID inParameterID) const;
+ double getparameter_scalar(dfx::ParameterID inParameterID, double inValue) const;
// synchronize the underlying API/preset/etc. parameter value representation to the current value in DfxPlugin
- void update_parameter(long inParameterIndex);
+ void update_parameter(dfx::ParameterID inParameterID);
- void setpresetparameter(size_t inPresetIndex, long inParameterIndex, DfxParam::Value inValue);
- DfxParam::Value getpresetparameter(size_t inPresetIndex, long inParameterIndex) const;
+ void setpresetparameter(size_t inPresetIndex, dfx::ParameterID inParameterID, DfxParam::Value inValue);
+ DfxParam::Value getpresetparameter(size_t inPresetIndex, dfx::ParameterID inParameterID) const;
bool ischannelcountsupported(size_t inNumInputs, size_t inNumOutputs) const;
@@ -772,7 +772,7 @@ class DfxPlugin : public TARGET_API_BASE_CLASS
// the effect owns a single random engine shared by all parameters rather than each parameter owning its own for efficiency, because its state data can be quite large
dfx::math::RandomEngine mParameterRandomEngine {dfx::math::RandomSeed::Entropic};
dfx::SpinLock mParameterRandomEngineLock;
- std::vector>> mParameterGroups;
+ std::vector>> mParameterGroups;
std::vector mPresets;
std::atomic_flag mPresetChangedInProcessHasPosted;
@@ -1043,9 +1043,9 @@ class DfxPlugin : public TARGET_API_BASE_CLASS
#endif
// AU->RTAS glue convenience functions
- double GetParameter_f_FromRTAS(long inParameterID);
- int64_t GetParameter_i_FromRTAS(long inParameterID);
- bool GetParameter_b_FromRTAS(long inParameterID);
+ double GetParameter_f_FromRTAS(dfx::ParameterID inParameterID);
+ int64_t GetParameter_i_FromRTAS(dfx::ParameterID inParameterID);
+ bool GetParameter_b_FromRTAS(dfx::ParameterID inParameterID);
#if TARGET_PLUGIN_HAS_GUI
void SetViewPort(GrafPtr inPort) final;
@@ -1153,65 +1153,65 @@ class DfxPluginCore
{
return static_cast(mSampleRate);
}
- double getparameter_f(long inParameterIndex) const
+ double getparameter_f(dfx::ParameterID inParameterID) const
{
- return mDfxPlugin->getdspcoreparameter_f(inParameterIndex);
+ return mDfxPlugin->getdspcoreparameter_f(inParameterID);
}
- int64_t getparameter_i(long inParameterIndex) const
+ int64_t getparameter_i(dfx::ParameterID inParameterID) const
{
- return mDfxPlugin->getdspcoreparameter_i(inParameterIndex);
+ return mDfxPlugin->getdspcoreparameter_i(inParameterID);
}
- bool getparameter_b(long inParameterIndex) const
+ bool getparameter_b(dfx::ParameterID inParameterID) const
{
- return mDfxPlugin->getdspcoreparameter_b(inParameterIndex);
+ return mDfxPlugin->getdspcoreparameter_b(inParameterID);
}
- double getparameter_scalar(long inParameterIndex) const
+ double getparameter_scalar(dfx::ParameterID inParameterID) const
{
- return mDfxPlugin->getdspcoreparameter_scalar(inParameterIndex);
+ return mDfxPlugin->getdspcoreparameter_scalar(inParameterID);
}
- double getparameter_gen(long inParameterIndex) const
+ double getparameter_gen(dfx::ParameterID inParameterID) const
{
- return mDfxPlugin->getdspcoreparameter_gen(inParameterIndex);
+ return mDfxPlugin->getdspcoreparameter_gen(inParameterID);
}
- std::optional getparameterifchanged_f(long inParameterIndex) const
+ std::optional getparameterifchanged_f(dfx::ParameterID inParameterID) const
{
- return getparameterchanged(inParameterIndex) ? std::make_optional(getparameter_f(inParameterIndex)) : std::nullopt;
+ return getparameterchanged(inParameterID) ? std::make_optional(getparameter_f(inParameterID)) : std::nullopt;
}
- std::optional getparameterifchanged_i(long inParameterIndex) const
+ std::optional getparameterifchanged_i(dfx::ParameterID inParameterID) const
{
- return getparameterchanged(inParameterIndex) ? std::make_optional(getparameter_i(inParameterIndex)) : std::nullopt;
+ return getparameterchanged(inParameterID) ? std::make_optional(getparameter_i(inParameterID)) : std::nullopt;
}
- std::optional getparameterifchanged_b(long inParameterIndex) const
+ std::optional getparameterifchanged_b(dfx::ParameterID inParameterID) const
{
- return getparameterchanged(inParameterIndex) ? std::make_optional(getparameter_b(inParameterIndex)) : std::nullopt;
+ return getparameterchanged(inParameterID) ? std::make_optional(getparameter_b(inParameterID)) : std::nullopt;
}
- std::optional getparameterifchanged_gen(long inParameterIndex) const
+ std::optional getparameterifchanged_gen(dfx::ParameterID inParameterID) const
{
- return getparameterchanged(inParameterIndex) ? std::make_optional(getparameter_gen(inParameterIndex)) : std::nullopt;
+ return getparameterchanged(inParameterID) ? std::make_optional(getparameter_gen(inParameterID)) : std::nullopt;
}
- std::optional getparameterifchanged_scalar(long inParameterIndex) const
+ std::optional getparameterifchanged_scalar(dfx::ParameterID inParameterID) const
{
- return getparameterchanged(inParameterIndex) ? std::make_optional(getparameter_scalar(inParameterIndex)) : std::nullopt;
+ return getparameterchanged(inParameterID) ? std::make_optional(getparameter_scalar(inParameterID)) : std::nullopt;
}
- double getparametermin_f(long inParameterIndex) const
+ double getparametermin_f(dfx::ParameterID inParameterID) const
{
- return mDfxPlugin->getparametermin_f(inParameterIndex);
+ return mDfxPlugin->getparametermin_f(inParameterID);
}
- int64_t getparametermin_i(long inParameterIndex) const
+ int64_t getparametermin_i(dfx::ParameterID inParameterID) const
{
- return mDfxPlugin->getparametermin_i(inParameterIndex);
+ return mDfxPlugin->getparametermin_i(inParameterID);
}
- double getparametermax_f(long inParameterIndex) const
+ double getparametermax_f(dfx::ParameterID inParameterID) const
{
- return mDfxPlugin->getparametermax_f(inParameterIndex);
+ return mDfxPlugin->getparametermax_f(inParameterID);
}
- int64_t getparametermax_i(long inParameterIndex) const
+ int64_t getparametermax_i(dfx::ParameterID inParameterID) const
{
- return mDfxPlugin->getparametermax_i(inParameterIndex);
+ return mDfxPlugin->getparametermax_i(inParameterID);
}
- bool getparameterchanged(long inParameterIndex) const
+ bool getparameterchanged(dfx::ParameterID inParameterID) const
{
- return mDfxPlugin->getparameterchanged(inParameterIndex);
+ return mDfxPlugin->getparameterchanged(inParameterID);
}
void registerSmoothedAudioValue(dfx::ISmoothedValue* smoothedValue)
{
diff --git a/dfx-library/dfxsettings.cpp b/dfx-library/dfxsettings.cpp
index cc67383e..e0fe7af6 100644
--- a/dfx-library/dfxsettings.cpp
+++ b/dfx-library/dfxsettings.cpp
@@ -18,7 +18,7 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Destroy FX Library. If not, see .
-To contact the author, use the contact form at http://destroyfx.org/
+To contact the author, use the contact form at http://destroyfx.org
Destroy FX is a sovereign entity comprised of Sophia Poirier and Tom Murphy 7.
Welcome to our settings persistence mess.
@@ -59,17 +59,17 @@ DfxSettings::DfxSettings(uint32_t inMagic, DfxPlugin* inPlugin, size_t inSizeofE
mNumParameters(std::max(inPlugin->getnumparameters(), size_t(1))), // we need at least one parameter
mNumPresets(std::max(inPlugin->getnumpresets(), size_t(1))), // we need at least one set of parameters
mSizeOfExtendedData(inSizeofExtendedData),
- mParameterIDs(mNumParameters, dfx::kParameterID_Invalid),
+ mParameterIDMap(mNumParameters, dfx::kParameterID_Invalid),
mParameterAssignments(mNumParameters)
{
assert(inPlugin);
// default to each parameter having its ID equal its index
- std::iota(mParameterIDs.begin(), mParameterIDs.end(), 0);
+ std::iota(mParameterIDMap.begin(), mParameterIDMap.end(), 0);
// calculate some data sizes that are useful to know
mSizeOfPreset = sizeof(GenPreset) + (sizeof(*GenPreset::mParameterValues) * mNumParameters) - sizeof(GenPreset::mParameterValues);
- mSizeOfParameterIDs = sizeof(mParameterIDs.front()) * mNumParameters;
+ mSizeOfParameterIDs = sizeof(mParameterIDMap.front()) * mNumParameters;
mSizeOfPresetChunk = mSizeOfPreset // 1 preset
+ sizeof(SettingsInfo) // the special data header info
+ mSizeOfParameterIDs // the table of parameter IDs
@@ -131,13 +131,13 @@ std::vector DfxSettings::save(bool inIsPreset)
sharedChunk->mGlobalBehaviorFlags = mSettingsInfo.mGlobalBehaviorFlags;
// store the parameters' IDs
- std::copy(mParameterIDs.cbegin(), mParameterIDs.cend(), firstSharedParameterID);
+ std::copy(mParameterIDMap.cbegin(), mParameterIDMap.cend(), firstSharedParameterID);
// store only one preset setting if inIsPreset is true
if (inIsPreset)
{
dfx::StrLCpy(firstSharedPreset->mName, mPlugin->getpresetname(mPlugin->getcurrentpresetnum()), std::size(firstSharedPreset->mName));
- for (size_t i = 0; i < mNumParameters; i++)
+ for (dfx::ParameterID i = 0; i < mNumParameters; i++)
{
firstSharedPreset->mParameterValues[i] = mPlugin->getparameter_f(i);
}
@@ -151,7 +151,7 @@ std::vector DfxSettings::save(bool inIsPreset)
// copy the preset name to the chunk
dfx::StrLCpy(tempSharedPresets->mName, mPlugin->getpresetname(j), std::size(tempSharedPresets->mName));
// copy all of the parameters for this preset to the chunk
- for (size_t i = 0; i < mNumParameters; i++)
+ for (dfx::ParameterID i = 0; i < mNumParameters; i++)
{
tempSharedPresets->mParameterValues[i] = mPlugin->getpresetparameter_f(j, i);
}
@@ -319,12 +319,12 @@ try
validateRange(newParameterIDs, sizeOfStoredParameterIDs, "parameter IDs");
// create a mapping table for corresponding the incoming parameters to the
// destination parameters (in case the parameter IDs don't all match up)
- // [ the index of paramMap is the same as our parameter tag/index and the value
+ // [ the index of parameterMap is the same as our parameter tag/index and the value
// is the tag/index of the incoming parameter that corresponds, if any ]
- std::vector paramMap(mNumParameters, dfx::kParameterID_Invalid);
- for (size_t tag = 0; tag < mParameterIDs.size(); tag++)
+ std::vector parameterMap(mNumParameters, dfx::kParameterID_Invalid);
+ for (size_t i = 0; i < mParameterIDMap.size(); i++)
{
- paramMap[tag] = getParameterTagFromID(mParameterIDs[tag], {newParameterIDs, numStoredParameters});
+ parameterMap[i] = getParameterIndexFromMap(mParameterIDMap[i], {newParameterIDs, numStoredParameters});
}
// point to the next data element after the parameter IDs: the first preset name
@@ -355,24 +355,24 @@ try
}
#endif
// copy all of the parameters that we can for this preset from the chunk
- for (size_t i = 0; i < paramMap.size(); i++)
+ for (dfx::ParameterID i = 0; i < parameterMap.size(); i++)
{
- auto const mappedTag = paramMap[i];
- if (mappedTag != dfx::kParameterID_Invalid)
+ auto const mappedParameterID = parameterMap[i];
+ if ((mappedParameterID != dfx::kParameterID_Invalid) && (mappedParameterID < numStoredParameters))
{
#ifdef DFX_SUPPORT_OLD_VST_SETTINGS
// handle old-style generic VST 0.0 to 1.0 parameter values
if (oldVST)
{
- mPlugin->setparameter_gen(i, newPreset->mParameterValues[mappedTag]);
+ mPlugin->setparameter_gen(i, newPreset->mParameterValues[mappedParameterID]);
}
else
#endif
{
- mPlugin->setparameter_f(i, newPreset->mParameterValues[mappedTag]);
+ mPlugin->setparameter_f(i, newPreset->mParameterValues[mappedParameterID]);
}
// allow for additional tweaking of the stored parameter setting
- mPlugin->settings_doChunkRestoreSetParameterStuff(i, newPreset->mParameterValues[mappedTag], newSettingsInfo->mVersion, {});
+ mPlugin->settings_doChunkRestoreSetParameterStuff(i, newPreset->mParameterValues[mappedParameterID], newSettingsInfo->mVersion, {});
}
}
// point past the preset
@@ -395,24 +395,24 @@ try
}
#endif
// copy all of the parameters that we can for this preset from the chunk
- for (size_t i = 0; i < paramMap.size(); i++)
+ for (dfx::ParameterID i = 0; i < parameterMap.size(); i++)
{
- auto const mappedTag = paramMap[i];
- if (mappedTag != dfx::kParameterID_Invalid)
+ auto const mappedParameterID = parameterMap[i];
+ if ((mappedParameterID != dfx::kParameterID_Invalid) && (mappedParameterID < numStoredParameters))
{
#ifdef DFX_SUPPORT_OLD_VST_SETTINGS
// handle old-style generic VST 0.0 to 1.0 parameter values
if (oldVST)
{
- mPlugin->setpresetparameter_gen(j, i, newPreset->mParameterValues[mappedTag]);
+ mPlugin->setpresetparameter_gen(j, i, newPreset->mParameterValues[mappedParameterID]);
}
else
#endif
{
- mPlugin->setpresetparameter_f(j, i, newPreset->mParameterValues[mappedTag]);
+ mPlugin->setpresetparameter_f(j, i, newPreset->mParameterValues[mappedParameterID]);
}
// allow for additional tweaking of the stored parameter setting
- mPlugin->settings_doChunkRestoreSetParameterStuff(i, newPreset->mParameterValues[mappedTag], newSettingsInfo->mVersion, j);
+ mPlugin->settings_doChunkRestoreSetParameterStuff(i, newPreset->mParameterValues[mappedParameterID], newSettingsInfo->mVersion, j);
}
}
// point to the next preset in the received data array
@@ -434,13 +434,13 @@ if (!(oldVST && inIsPreset))
sizeOfStoredParameterAssignments = storedParameterAssignmentSize * numStoredParameters;
validateRange(newParameterAssignments, sizeOfStoredParameterAssignments, "parameter assignments");
// and load up as many of them as we can
- for (size_t i = 0; i < std::min(paramMap.size(), mParameterAssignments.size()); i++)
+ for (size_t i = 0; i < std::min(parameterMap.size(), mParameterAssignments.size()); i++)
{
- auto const mappedTag = paramMap[i];
- if ((mappedTag != dfx::kParameterID_Invalid) && (mappedTag >= 0) && (dfx::math::ToUnsigned(mappedTag) < numStoredParameters))
+ auto const mappedParameterID = parameterMap[i];
+ if ((mappedParameterID != dfx::kParameterID_Invalid) && (mappedParameterID < numStoredParameters))
{
memcpy(&(mParameterAssignments[i]),
- newParameterAssignments + (dfx::math::ToUnsigned(mappedTag) * storedParameterAssignmentSize),
+ newParameterAssignments + (mappedParameterID * storedParameterAssignmentSize),
copyParameterAssignmentSize);
}
}
@@ -724,7 +724,7 @@ bool DfxSettings::saveMidiAssignmentsToDictionary(CFMutableDictionaryRef inDicti
}
size_t assignmentsFoundCount = 0;
- for (long i = 0; i < static_cast(mNumParameters); i++)
+ for (dfx::ParameterID i = 0; i < mNumParameters; i++)
{
if (getParameterAssignmentType(i) != dfx::MidiEventType::None)
{
@@ -743,16 +743,16 @@ bool DfxSettings::saveMidiAssignmentsToDictionary(CFMutableDictionaryRef inDicti
return false;
}
- for (size_t i = 0; i < mNumParameters; i++)
+ for (dfx::ParameterID i = 0; i < mNumParameters; i++)
{
auto const assignmentCFDictionary = dfx::MakeUniqueCFType(CFDictionaryCreateMutable(kCFAllocatorDefault, 10, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
if (assignmentCFDictionary)
{
- if (getParameterID(i) == dfx::kParameterID_Invalid)
+ if (getMappedParameterID(i) == dfx::kParameterID_Invalid)
{
continue;
}
- DFX_AddNumberToCFDictionary_i(getParameterID(i), assignmentCFDictionary.get(), kDfxSettings_ParameterIDKey);
+ DFX_AddNumberToCFDictionary_i(getMappedParameterID(i), assignmentCFDictionary.get(), kDfxSettings_ParameterIDKey);
DFX_AddNumberToCFDictionary_i(static_cast(mParameterAssignments[i].mEventType),
assignmentCFDictionary.get(), kDfxSettings_MidiAssignment_mEventTypeKey);
#define ADD_ASSIGNMENT_VALUE_TO_DICT(inMember, inTypeSuffix) \
@@ -807,27 +807,27 @@ bool DfxSettings::restoreMidiAssignmentsFromDictionary(CFDictionaryRef inDiction
auto const assignmentCFDictionary = static_cast(CFArrayGetValueAtIndex(assignmentsCFArray, i));
if (assignmentCFDictionary)
{
- auto const paramID_optional = DFX_GetNumberFromCFDictionary_i(assignmentCFDictionary, kDfxSettings_ParameterIDKey);
- if (!paramID_optional)
+ auto const parameterID_optional = DFX_GetNumberFromCFDictionary_i(assignmentCFDictionary, kDfxSettings_ParameterIDKey);
+ if (!parameterID_optional)
{
continue;
}
- auto const paramTag = getParameterTagFromID(*paramID_optional);
- if (!paramTagIsValid(paramTag))
+ auto const parameterID = getParameterIndexFromMap(*parameterID_optional);
+ if (!isValidParameterID(parameterID))
{
continue;
}
#define GET_ASSIGNMENT_VALUE_FROM_DICT(inMember, inTypeSuffix) \
{ \
auto const optionalValue = DFX_GetNumberFromCFDictionary_##inTypeSuffix(assignmentCFDictionary, kDfxSettings_MidiAssignment_##inMember##Key); \
- mParameterAssignments[paramTag].inMember = static_cast(optionalValue.value_or(0)); \
- numberSuccess = optionalValue ? true : false; \
+ mParameterAssignments[parameterID].inMember = static_cast(optionalValue.value_or(0)); \
+ numberSuccess = optionalValue.has_value(); \
}
bool numberSuccess = false;
GET_ASSIGNMENT_VALUE_FROM_DICT(mEventType, i)
if (!numberSuccess)
{
- unassignParam(paramTag);
+ unassignParameter(parameterID);
continue;
}
GET_ASSIGNMENT_VALUE_FROM_DICT(mEventChannel, i)
@@ -863,8 +863,8 @@ void DfxSettings::handleCC(int inMidiChannel, int inControllerNumber, int inValu
return;
}
- handleMidi_assignParam(dfx::MidiEventType::CC, inMidiChannel, inControllerNumber, inOffsetFrames);
- handleMidi_automateParams(dfx::MidiEventType::CC, inMidiChannel, inControllerNumber, inValue, inOffsetFrames);
+ handleMidi_assignParameter(dfx::MidiEventType::CC, inMidiChannel, inControllerNumber, inOffsetFrames);
+ handleMidi_automateParameters(dfx::MidiEventType::CC, inMidiChannel, inControllerNumber, inValue, inOffsetFrames);
}
//-----------------------------------------------------------------------------------------
@@ -876,9 +876,9 @@ void DfxSettings::handleChannelAftertouch(int inMidiChannel, int inValue, size_t
}
constexpr int fakeEventNum = 0; // not used for this type of event
- handleMidi_assignParam(dfx::MidiEventType::ChannelAftertouch, inMidiChannel, fakeEventNum, inOffsetFrames);
+ handleMidi_assignParameter(dfx::MidiEventType::ChannelAftertouch, inMidiChannel, fakeEventNum, inOffsetFrames);
constexpr int fakeByte2 = 0; // not used for this type of event
- handleMidi_automateParams(dfx::MidiEventType::ChannelAftertouch, inMidiChannel, inValue, fakeByte2, inOffsetFrames);
+ handleMidi_automateParameters(dfx::MidiEventType::ChannelAftertouch, inMidiChannel, inValue, fakeByte2, inOffsetFrames);
}
//-----------------------------------------------------------------------------------------
@@ -893,8 +893,8 @@ void DfxSettings::handlePitchBend(int inMidiChannel, int inValueLSB, int inValue
// type for pitchbend as it does for some other events,
// and stuff below assumes that byte 2 means that
constexpr int fakeEventNum = 0;
- handleMidi_assignParam(dfx::MidiEventType::PitchBend, inMidiChannel, fakeEventNum, inOffsetFrames);
- handleMidi_automateParams(dfx::MidiEventType::PitchBend, inMidiChannel, inValueLSB, inValueMSB, inOffsetFrames);
+ handleMidi_assignParameter(dfx::MidiEventType::PitchBend, inMidiChannel, fakeEventNum, inOffsetFrames);
+ handleMidi_automateParameters(dfx::MidiEventType::PitchBend, inMidiChannel, inValueLSB, inValueMSB, inOffsetFrames);
}
//-----------------------------------------------------------------------------------------
@@ -905,8 +905,8 @@ void DfxSettings::handleNoteOn(int inMidiChannel, int inNoteNumber, int inVeloci
return;
}
- handleMidi_assignParam(dfx::MidiEventType::Note, inMidiChannel, inNoteNumber, inOffsetFrames);
- handleMidi_automateParams(dfx::MidiEventType::Note, inMidiChannel, inNoteNumber, inVelocity, inOffsetFrames, true);
+ handleMidi_assignParameter(dfx::MidiEventType::Note, inMidiChannel, inNoteNumber, inOffsetFrames);
+ handleMidi_automateParameters(dfx::MidiEventType::Note, inMidiChannel, inNoteNumber, inVelocity, inOffsetFrames, true);
}
//-----------------------------------------------------------------------------------------
@@ -932,9 +932,9 @@ void DfxSettings::handleNoteOff(int inMidiChannel, int inNoteNumber, int inVeloc
if (allowAssignment)
{
- handleMidi_assignParam(dfx::MidiEventType::Note, inMidiChannel, inNoteNumber, inOffsetFrames);
+ handleMidi_assignParameter(dfx::MidiEventType::Note, inMidiChannel, inNoteNumber, inOffsetFrames);
}
- handleMidi_automateParams(dfx::MidiEventType::Note, inMidiChannel, inNoteNumber, inVelocity, inOffsetFrames, false);
+ handleMidi_automateParameters(dfx::MidiEventType::Note, inMidiChannel, inNoteNumber, inVelocity, inOffsetFrames, false);
}
//-----------------------------------------------------------------------------------------
@@ -947,16 +947,16 @@ void DfxSettings::handleAllNotesOff(int inMidiChannel, size_t inOffsetFrames)
for (int i = 0; i < DfxMidi::kNumNotes; i++)
{
- handleMidi_automateParams(dfx::MidiEventType::Note, inMidiChannel, i, 0, inOffsetFrames, false);
+ handleMidi_automateParameters(dfx::MidiEventType::Note, inMidiChannel, i, 0, inOffsetFrames, false);
}
}
//-----------------------------------------------------------------------------------------
// assign an incoming MIDI event to the learner parameter
-void DfxSettings::handleMidi_assignParam(dfx::MidiEventType inEventType, int inMidiChannel, int inByte1, size_t inOffsetFrames)
+void DfxSettings::handleMidi_assignParameter(dfx::MidiEventType inEventType, int inMidiChannel, int inByte1, size_t inOffsetFrames)
{
// we don't need to make an assignment to a parameter if MIDI learning is off
- if (!mMidiLearn || !paramTagIsValid(mLearner))
+ if (!mMidiLearn || !isValidParameterID(mLearner))
{
return;
}
@@ -964,15 +964,15 @@ void DfxSettings::handleMidi_assignParam(dfx::MidiEventType inEventType, int inM
auto const handleAssignment = [this, inEventType, inMidiChannel, inOffsetFrames](int eventNum, int eventNum2)
{
// assign the learner parameter to the event that sent the message
- assignParam(mLearner, inEventType, inMidiChannel, eventNum, eventNum2,
- mLearnerEventBehaviorFlags, mLearnerDataInt1, mLearnerDataInt2,
- mLearnerDataFloat1, mLearnerDataFloat2);
+ assignParameter(mLearner, inEventType, inMidiChannel, eventNum, eventNum2,
+ mLearnerEventBehaviorFlags, mLearnerDataInt1, mLearnerDataInt2,
+ mLearnerDataFloat1, mLearnerDataFloat2);
// this is an invitation to do something more, if necessary
mPlugin->settings_doLearningAssignStuff(mLearner, inEventType, inMidiChannel, eventNum,
inOffsetFrames, eventNum2, mLearnerEventBehaviorFlags,
mLearnerDataInt1, mLearnerDataInt2, mLearnerDataFloat1, mLearnerDataFloat2);
// and then deactivate the current learner, the learning is complete
- setLearner(kNoLearner);
+ setLearner(dfx::kParameterID_Invalid);
if (getDeactivateLearningUponLearnt())
{
setLearning(false);
@@ -1017,7 +1017,8 @@ void DfxSettings::handleMidi_assignParam(dfx::MidiEventType inEventType, int inM
//-----------------------------------------------------------------------------------------
// automate assigned parameters in response to a MIDI event
-void DfxSettings::handleMidi_automateParams(dfx::MidiEventType inEventType, int inMidiChannel, int inByte1, int inByte2, size_t inOffsetFrames, bool inIsNoteOn)
+void DfxSettings::handleMidi_automateParameters(dfx::MidiEventType inEventType, int inMidiChannel,
+ int inByte1, int inByte2, size_t inOffsetFrames, bool inIsNoteOn)
{
float valueNormalized = static_cast(inByte2) * DfxMidi::kValueScalar;
if (inEventType == dfx::MidiEventType::ChannelAftertouch)
@@ -1045,9 +1046,9 @@ void DfxSettings::handleMidi_automateParams(dfx::MidiEventType inEventType, int
// search for parameters that have this MIDI event assigned to them and,
// if any are found, automate them with the event message's value
- for (size_t tag = 0; tag < mNumParameters; tag++)
+ for (dfx::ParameterID parameterID = 0; parameterID < mNumParameters; parameterID++)
{
- auto const& pa = mParameterAssignments.at(tag);
+ auto const& pa = mParameterAssignments.at(parameterID);
// if the event type doesn't match what this parameter has assigned to it,
// skip to the next parameter parameter
@@ -1097,7 +1098,7 @@ void DfxSettings::handleMidi_automateParams(dfx::MidiEventType inEventType, int
maxSteps = numSteps;
}
// get the current state of the parameter
- auto currentStep = static_cast(mPlugin->getparameter_gen(tag) * (static_cast(numSteps) - 0.01f));
+ auto currentStep = static_cast(mPlugin->getparameter_gen(parameterID) * (static_cast(numSteps) - 0.01f));
// cycle to the next state, wraparound if necessary (using maxSteps)
currentStep = (currentStep + 1) % maxSteps;
// get the 0.0 to 1.0 parameter value version of that state
@@ -1143,10 +1144,10 @@ void DfxSettings::handleMidi_automateParams(dfx::MidiEventType inEventType, int
}
// automate the parameter with the value if we've reached this point
- mPlugin->setparameter_gen(tag, valueNormalized);
- mPlugin->postupdate_parameter(tag); // notify listeners of internal parameter change
+ mPlugin->setparameter_gen(parameterID, valueNormalized);
+ mPlugin->postupdate_parameter(parameterID); // notify listeners of internal parameter change
// this is an invitation to do something more, if necessary
- mPlugin->settings_doMidiAutomatedSetParameterStuff(tag, valueNormalized, inOffsetFrames);
+ mPlugin->settings_doMidiAutomatedSetParameterStuff(parameterID, valueNormalized, inOffsetFrames);
} // end of parameters loop (for automation)
}
@@ -1157,20 +1158,20 @@ void DfxSettings::handleMidi_automateParams(dfx::MidiEventType inEventType, int
// clear all parameter assignments from the the CCs
void DfxSettings::clearAssignments()
{
- for (long i = 0; i < static_cast(mNumParameters); i++)
+ for (dfx::ParameterID i = 0; i < mNumParameters; i++)
{
- unassignParam(i);
+ unassignParameter(i);
}
}
//-----------------------------------------------------------------------------
// assign a CC to a parameter
-void DfxSettings::assignParam(long inParamTag, dfx::MidiEventType inEventType, long inEventChannel, long inEventNum,
- long inEventNum2, dfx::MidiEventBehaviorFlags inEventBehaviorFlags,
- int inDataInt1, int inDataInt2, float inDataFloat1, float inDataFloat2)
+void DfxSettings::assignParameter(dfx::ParameterID inParameterID, dfx::MidiEventType inEventType, int inEventChannel,
+ int inEventNum, int inEventNum2, dfx::MidiEventBehaviorFlags inEventBehaviorFlags,
+ int inDataInt1, int inDataInt2, float inDataFloat1, float inDataFloat2)
{
// bail if the parameter index is not valid
- if (!paramTagIsValid(inParamTag))
+ if (!isValidParameterID(inParameterID))
{
return;
}
@@ -1190,7 +1191,7 @@ void DfxSettings::assignParam(long inParamTag, dfx::MidiEventType inEventType, l
// parameter assignment(s) if using stealing
if (mStealAssignments)
{
- for (size_t i = 0; i < mNumParameters; i++)
+ for (dfx::ParameterID i = 0; i < mNumParameters; i++)
{
auto const& pa = mParameterAssignments.at(i);
// skip this parameter if the event type doesn't match
@@ -1211,17 +1212,17 @@ void DfxSettings::assignParam(long inParamTag, dfx::MidiEventType inEventType, l
// lower note overlaps with existing note assignment
if ((pa.mEventNum >= inEventNum) && (pa.mEventNum <= inEventNum2))
{
- unassignParam(i);
+ unassignParameter(i);
}
// upper note overlaps with existing note assignment
else if ((pa.mEventNum2 >= inEventNum) && (pa.mEventNum2 <= inEventNum2))
{
- unassignParam(i);
+ unassignParameter(i);
}
// current note range consumes the entire existing assignment
else if ((pa.mEventNum <= inEventNum) && (pa.mEventNum2 >= inEventNum2))
{
- unassignParam(i);
+ unassignParameter(i);
}
}
@@ -1229,43 +1230,43 @@ void DfxSettings::assignParam(long inParamTag, dfx::MidiEventType inEventType, l
// just delete the assignment if the event number matches
else if (pa.mEventNum == inEventNum)
{
- unassignParam(i);
+ unassignParameter(i);
}
}
}
// then assign the event to the desired parameter
- mParameterAssignments[inParamTag].mEventType = inEventType;
- mParameterAssignments[inParamTag].mEventChannel = inEventChannel;
- mParameterAssignments[inParamTag].mEventNum = inEventNum;
- mParameterAssignments[inParamTag].mEventNum2 = inEventNum2;
- mParameterAssignments[inParamTag].mEventBehaviorFlags = inEventBehaviorFlags;
- mParameterAssignments[inParamTag].mDataInt1 = inDataInt1;
- mParameterAssignments[inParamTag].mDataInt2 = inDataInt2;
- mParameterAssignments[inParamTag].mDataFloat1 = inDataFloat1;
- mParameterAssignments[inParamTag].mDataFloat2 = inDataFloat2;
+ mParameterAssignments[inParameterID].mEventType = inEventType;
+ mParameterAssignments[inParameterID].mEventChannel = inEventChannel;
+ mParameterAssignments[inParameterID].mEventNum = inEventNum;
+ mParameterAssignments[inParameterID].mEventNum2 = inEventNum2;
+ mParameterAssignments[inParameterID].mEventBehaviorFlags = inEventBehaviorFlags;
+ mParameterAssignments[inParameterID].mDataInt1 = inDataInt1;
+ mParameterAssignments[inParameterID].mDataInt2 = inDataInt2;
+ mParameterAssignments[inParameterID].mDataFloat1 = inDataFloat1;
+ mParameterAssignments[inParameterID].mDataFloat2 = inDataFloat2;
}
//-----------------------------------------------------------------------------
// remove any MIDI event assignment that a parameter might have
-void DfxSettings::unassignParam(long inParamTag)
+void DfxSettings::unassignParameter(dfx::ParameterID inParameterID)
{
// return if what we got is not a valid parameter index
- if (!paramTagIsValid(inParamTag))
+ if (!isValidParameterID(inParameterID))
{
return;
}
// clear the MIDI event assignment for this parameter
- mParameterAssignments[inParamTag].mEventType = dfx::MidiEventType::None;
- mParameterAssignments[inParamTag].mEventChannel = 0;
- mParameterAssignments[inParamTag].mEventNum = 0;
- mParameterAssignments[inParamTag].mEventNum2 = 0;
- mParameterAssignments[inParamTag].mEventBehaviorFlags = dfx::kMidiEventBehaviorFlag_None;
- mParameterAssignments[inParamTag].mDataInt1 = 0;
- mParameterAssignments[inParamTag].mDataInt2 = 0;
- mParameterAssignments[inParamTag].mDataFloat1 = 0.0f;
- mParameterAssignments[inParamTag].mDataFloat2 = 0.0f;
+ mParameterAssignments[inParameterID].mEventType = dfx::MidiEventType::None;
+ mParameterAssignments[inParameterID].mEventChannel = 0;
+ mParameterAssignments[inParameterID].mEventNum = 0;
+ mParameterAssignments[inParameterID].mEventNum2 = 0;
+ mParameterAssignments[inParameterID].mEventBehaviorFlags = dfx::kMidiEventBehaviorFlag_None;
+ mParameterAssignments[inParameterID].mDataInt1 = 0;
+ mParameterAssignments[inParameterID].mDataInt2 = 0;
+ mParameterAssignments[inParameterID].mDataFloat1 = 0.0f;
+ mParameterAssignments[inParameterID].mDataFloat2 = 0.0f;
}
//-----------------------------------------------------------------------------
@@ -1275,12 +1276,12 @@ void DfxSettings::setLearning(bool inLearnMode)
// erase the current learner if the state of MIDI learn is being toggled
if (inLearnMode != mMidiLearn)
{
- setLearner(kNoLearner);
+ setLearner(dfx::kParameterID_Invalid);
}
// or if it's being asked to be turned off, irregardless
else if (!inLearnMode)
{
- setLearner(kNoLearner);
+ setLearner(dfx::kParameterID_Invalid);
}
mMidiLearn = inLearnMode;
@@ -1288,33 +1289,27 @@ void DfxSettings::setLearning(bool inLearnMode)
mPlugin->postupdate_midilearn();
}
-//-----------------------------------------------------------------------------
-// just an easy way to check if a particular parameter is currently a learner
-bool DfxSettings::isLearner(long inParamTag) const noexcept
-{
- return (inParamTag == getLearner());
-}
-
//-----------------------------------------------------------------------------
// define the actively learning parameter during MIDI learn mode
-void DfxSettings::setLearner(long inParamTag, dfx::MidiEventBehaviorFlags inEventBehaviorFlags,
+void DfxSettings::setLearner(dfx::ParameterID inParameterID, dfx::MidiEventBehaviorFlags inEventBehaviorFlags,
int inDataInt1, int inDataInt2, float inDataFloat1, float inDataFloat2)
{
// allow this invalid parameter tag, and then exit
- if (inParamTag == kNoLearner)
+ if (inParameterID == dfx::kParameterID_Invalid)
{
- mLearner = kNoLearner;
+ mLearner = inParameterID;
+ mLearnerEventBehaviorFlags = dfx::kMidiEventBehaviorFlag_None;
}
else
{
// return if what we got is not a valid parameter index
- if (!paramTagIsValid(inParamTag))
+ if (!isValidParameterID(inParameterID))
{
return;
}
// cancel note range assignment if we're switching to a new learner
- if (mLearner != inParamTag)
+ if (mLearner != inParameterID)
{
mNoteRangeHalfwayDone = false;
}
@@ -1322,19 +1317,13 @@ void DfxSettings::setLearner(long inParamTag, dfx::MidiEventBehaviorFlags inEven
// only set the learner if MIDI learn is on
if (mMidiLearn)
{
- mLearner = inParamTag;
+ mLearner = inParameterID;
mLearnerEventBehaviorFlags = inEventBehaviorFlags;
mLearnerDataInt1 = inDataInt1;
mLearnerDataInt2 = inDataInt2;
mLearnerDataFloat1 = inDataFloat1;
mLearnerDataFloat2 = inDataFloat2;
}
- // unless we're making it so that there's no learner, that's okay
- else if (inParamTag == kNoLearner)
- {
- mLearner = inParamTag;
- mLearnerEventBehaviorFlags = dfx::kMidiEventBehaviorFlag_None;
- }
}
mPlugin->postupdate_midilearner();
@@ -1355,10 +1344,10 @@ void DfxSettings::setParameterMidiReset()
{
// if we're in MIDI learn mode and a parameter has been selected,
// then erase its MIDI event assigment (if it has one)
- if (mMidiLearn && (mLearner != kNoLearner))
+ if (mMidiLearn && (mLearner != dfx::kParameterID_Invalid))
{
- unassignParam(mLearner);
- setLearner(kNoLearner);
+ unassignParameter(mLearner);
+ setLearner(dfx::kParameterID_Invalid);
}
// otherwise erase all of the MIDI event assignments
else
@@ -1375,34 +1364,34 @@ void DfxSettings::setParameterMidiReset()
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//-----------------------------------------------------------------------------
-dfx::ParameterAssignment DfxSettings::getParameterAssignment(long inParamTag) const
+dfx::ParameterAssignment DfxSettings::getParameterAssignment(dfx::ParameterID inParameterID) const
{
// return a no-assignment structure if what we got is not a valid parameter index
- if (!paramTagIsValid(inParamTag))
+ if (!isValidParameterID(inParameterID))
{
return {};
}
- return mParameterAssignments[inParamTag];
+ return mParameterAssignments[inParameterID];
}
//-----------------------------------------------------------------------------
-dfx::MidiEventType DfxSettings::getParameterAssignmentType(long inParamTag) const
+dfx::MidiEventType DfxSettings::getParameterAssignmentType(dfx::ParameterID inParameterID) const
{
// return no-assignment if what we got is not a valid parameter index
- if (!paramTagIsValid(inParamTag))
+ if (!isValidParameterID(inParameterID))
{
return dfx::MidiEventType::None;
}
- return mParameterAssignments[inParamTag].mEventType;
+ return mParameterAssignments[inParameterID].mEventType;
}
//-----------------------------------------------------------------------------
// given a parameter ID, find the tag (index) for that parameter in a table of parameter IDs
-long DfxSettings::getParameterTagFromID(long inParamID, std::span inSearchIDs)
+dfx::ParameterID DfxSettings::getParameterIndexFromMap(dfx::ParameterID inParameterID, std::span inSearchIDs)
{
- auto const foundID = std::find(inSearchIDs.begin(), inSearchIDs.end(), inParamID);
+ auto const foundID = std::find(inSearchIDs.begin(), inSearchIDs.end(), inParameterID);
if (foundID != inSearchIDs.end())
{
return std::distance(inSearchIDs.begin(), foundID);
@@ -1412,9 +1401,9 @@ long DfxSettings::getParameterTagFromID(long inParamID, std::span
//-----------------------------------------------------------------------------
// search using the internal table
-long DfxSettings::getParameterTagFromID(long inParamID) const
+dfx::ParameterID DfxSettings::getParameterIndexFromMap(dfx::ParameterID inParameterID) const
{
- return getParameterTagFromID(inParamID, mParameterIDs);
+ return getParameterIndexFromMap(inParameterID, mParameterIDMap);
}
diff --git a/dfx-library/dfxsettings.h b/dfx-library/dfxsettings.h
index 07aca9f6..17b85581 100644
--- a/dfx-library/dfxsettings.h
+++ b/dfx-library/dfxsettings.h
@@ -18,7 +18,7 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Destroy FX Library. If not, see .
-To contact the author, use the contact form at http://destroyfx.org/
+To contact the author, use the contact form at http://destroyfx.org
Destroy FX is a sovereign entity comprised of Sophia Poirier and Tom Murphy 7.
This is our Destroy FX plugin data storage stuff
@@ -95,8 +95,6 @@ class DfxPlugin;
class DfxSettings
{
public:
- static constexpr long kNoLearner = -3; // for when no parameter is activated for learning
-
enum class CrisisBehavior
{
// crisis behaviors (what to do when restore sends an unexpected buffer size)
@@ -161,23 +159,22 @@ class DfxSettings
// remove MIDI event assignments from all parameters
void clearAssignments();
// assign a MIDI event to a parameter
- void assignParam(long inParamTag, dfx::MidiEventType inEventType, long inEventChannel,
- long inEventNum, long inEventNum2 = 0,
- dfx::MidiEventBehaviorFlags inEventBehaviorFlags = dfx::kMidiEventBehaviorFlag_None,
- int inDataInt1 = 0, int inDataInt2 = 0,
- float inDataFloat1 = 0.0f, float inDataFloat2 = 0.0f);
+ void assignParameter(dfx::ParameterID inParameterID, dfx::MidiEventType inEventType, int inEventChannel,
+ int inEventNum, int inEventNum2 = 0,
+ dfx::MidiEventBehaviorFlags inEventBehaviorFlags = dfx::kMidiEventBehaviorFlag_None,
+ int inDataInt1 = 0, int inDataInt2 = 0,
+ float inDataFloat1 = 0.0f, float inDataFloat2 = 0.0f);
// remove a parameter's MIDI event assignment
- void unassignParam(long inParamTag);
+ void unassignParameter(dfx::ParameterID inParameterID);
// define or report the actively learning parameter during MIDI learn mode
- void setLearner(long inParamTag, dfx::MidiEventBehaviorFlags inEventBehaviorFlags = dfx::kMidiEventBehaviorFlag_None,
+ void setLearner(dfx::ParameterID inParameterID, dfx::MidiEventBehaviorFlags inEventBehaviorFlags = dfx::kMidiEventBehaviorFlag_None,
int inDataInt1 = 0, int inDataInt2 = 0,
float inDataFloat1 = 0.0f, float inDataFloat2 = 0.0f);
auto getLearner() const noexcept
{
return mLearner.load();
}
- bool isLearner(long inParamTag) const noexcept;
// turn MIDI learning on or off
void setLearning(bool inLearnMode);
@@ -192,8 +189,8 @@ class DfxSettings
void setParameterMidiReset();
// potentially useful accessors
- dfx::ParameterAssignment getParameterAssignment(long inParamTag) const;
- dfx::MidiEventType getParameterAssignmentType(long inParamTag) const;
+ dfx::ParameterAssignment getParameterAssignment(dfx::ParameterID inParameterID) const;
+ dfx::MidiEventType getParameterAssignmentType(dfx::ParameterID inParameterID) const;
#endif // TARGET_PLUGIN_USES_MIDI
@@ -225,16 +222,16 @@ class DfxSettings
// creating the DfxSettings object, or at least before your plugin's
// constructor returns, because you don't want any set or save calls
// made before you have your parameter ID map finalized.
- void setParameterID(long inParamTag, long inNewID)
+ void setMappedParameterID(dfx::ParameterID inParameterIndex, dfx::ParameterID inMappedParameterID)
{
- if (paramTagIsValid(inParamTag))
+ if (isValidParameterID(inParameterIndex))
{
- mParameterIDs[inParamTag] = inNewID;
+ mParameterIDMap[inParameterIndex] = inMappedParameterID;
}
}
- long getParameterID(long inParamTag) const
+ dfx::ParameterID getMappedParameterID(dfx::ParameterID inParameterIndex) const
{
- return (paramTagIsValid(inParamTag)) ? mParameterIDs[inParamTag] : dfx::kParameterID_Invalid;
+ return (isValidParameterID(inParameterIndex)) ? mParameterIDMap[inParameterIndex] : dfx::kParameterID_Invalid;
}
@@ -389,17 +386,17 @@ class DfxSettings
void debugAlertCorruptData(char const* inDataItemName, size_t inDataItemSize, size_t inDataTotalSize) const;
// a simple but handy check to see if a parameter tag is valid
- bool paramTagIsValid(long inParamTag) const noexcept
+ bool isValidParameterID(dfx::ParameterID inParameterID) const noexcept
{
- return (inParamTag >= 0) && (static_cast(inParamTag) < mNumParameters);
+ return (inParameterID < mNumParameters);
}
- static long getParameterTagFromID(long inParamID, std::span inSearchIDs);
- long getParameterTagFromID(long inParamID) const;
+ static dfx::ParameterID getParameterIndexFromMap(dfx::ParameterID inParameterID, std::span inSearchIDs);
+ dfx::ParameterID getParameterIndexFromMap(dfx::ParameterID inParameterID) const;
#if TARGET_PLUGIN_USES_MIDI
- void handleMidi_assignParam(dfx::MidiEventType inEventType, int inMidiChannel, int inByte1, size_t inOffsetFrames);
- void handleMidi_automateParams(dfx::MidiEventType inEventType, int inMidiChannel, int inByte1, int inByte2, size_t inOffsetFrames, bool inIsNoteOn = false);
+ void handleMidi_assignParameter(dfx::MidiEventType inEventType, int inMidiChannel, int inByte1, size_t inOffsetFrames);
+ void handleMidi_automateParameters(dfx::MidiEventType inEventType, int inMidiChannel, int inByte1, int inByte2, size_t inOffsetFrames, bool inIsNoteOn = false);
#endif // TARGET_PLUGIN_USES_MIDI
@@ -425,14 +422,14 @@ class DfxSettings
// an ordered table of IDs for each parameter stored in each preset
// (this is so that non-parameter-compatible plugin versions can load
// settings and know which stored parameters correspond to theirs)
- std::vector mParameterIDs;
+ std::vector mParameterIDMap;
// what to do if restore() sends data with a mismatched byte size
CrisisBehavior mCrisisBehavior = CrisisBehavior::LoadWhatYouCan;
#if TARGET_PLUGIN_USES_MIDI
std::atomic mMidiLearn {false}; // switch value for MIDI learn mode
- std::atomic mLearner {kNoLearner}; // the parameter currently selected for MIDI learning
+ std::atomic mLearner {dfx::kParameterID_Invalid}; // the parameter currently selected for MIDI learning
// the array of which MIDI event, if any, is assigned to each parameter
std::vector mParameterAssignments;
diff --git a/dfxgui/dfxguibutton.cpp b/dfxgui/dfxguibutton.cpp
index c25d9ac1..11584a12 100644
--- a/dfxgui/dfxguibutton.cpp
+++ b/dfxgui/dfxguibutton.cpp
@@ -18,7 +18,7 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Destroy FX Library. If not, see .
-To contact the author, use the contact form at http://destroyfx.org/
+To contact the author, use the contact form at http://destroyfx.org
------------------------------------------------------------------------*/
#include "dfxguibutton.h"
@@ -39,9 +39,9 @@ using namespace std::placeholders;
//-----------------------------------------------------------------------------
// DGButton
//-----------------------------------------------------------------------------
-DGButton::DGButton(DfxGuiEditor* inOwnerEditor, long inParamID, DGRect const& inRegion, DGImage* inImage,
+DGButton::DGButton(DfxGuiEditor* inOwnerEditor, dfx::ParameterID inParameterID, DGRect const& inRegion, DGImage* inImage,
Mode inMode, bool inDrawMomentaryState)
-: DGControl(inRegion, inOwnerEditor, inParamID, inImage),
+: DGControl(inRegion, inOwnerEditor, dfx::ParameterID_ToVST(inParameterID), inImage),
mMode(inMode),
mDrawMomentaryState(inDrawMomentaryState),
mWraparoundValues((mMode == Mode::Increment) || (mMode == Mode::Decrement))
@@ -395,7 +395,7 @@ long DGButton::getRange() const
// Toggle Button
//-----------------------------------------------------------------------------
DGToggleImageButton::DGToggleImageButton(DfxGuiEditor* inOwnerEditor,
- long inParameterID,
+ dfx::ParameterID inParameterID,
VSTGUI::CCoord inXpos, VSTGUI::CCoord inYpos,
DGImage* inImage,
bool inDrawMomentaryState)
@@ -435,11 +435,11 @@ DGRect DGToggleImageButton::makeRegion(VSTGUI::CCoord inXpos, VSTGUI::CCoord inY
// Fine-tune Button
//-----------------------------------------------------------------------------
DGFineTuneButton::DGFineTuneButton(DfxGuiEditor* inOwnerEditor,
- long inParameterID,
- DGRect const& inRegion,
- DGImage* inImage,
- float inValueChangeAmount)
-: DGControl(inRegion, inOwnerEditor, inParameterID, inImage),
+ dfx::ParameterID inParameterID,
+ DGRect const& inRegion,
+ DGImage* inImage,
+ float inValueChangeAmount)
+: DGControl(inRegion, inOwnerEditor, dfx::ParameterID_ToVST(inParameterID), inImage),
mValueChangeAmount(inValueChangeAmount)
{
}
@@ -554,13 +554,13 @@ void DGFineTuneButton::onMouseCancelEvent(VSTGUI::MouseCancelEvent& ioEvent)
//-----------------------------------------------------------------------------
// DGValueSpot
//-----------------------------------------------------------------------------
-DGValueSpot::DGValueSpot(DfxGuiEditor* inOwnerEditor,
- long inParamID,
- DGRect const& inRegion,
- DGImage* inImage,
- double inValue)
-: DGControl(inRegion, inOwnerEditor, inParamID, inImage),
- mValueToSet(inOwnerEditor->dfxgui_ContractParameterValue(inParamID, inValue))
+DGValueSpot::DGValueSpot(DfxGuiEditor* inOwnerEditor,
+ dfx::ParameterID inParameterID,
+ DGRect const& inRegion,
+ DGImage* inImage,
+ double inValue)
+: DGControl(inRegion, inOwnerEditor, dfx::ParameterID_ToVST(inParameterID), inImage),
+ mValueToSet(inOwnerEditor->dfxgui_ContractParameterValue(inParameterID, inValue))
{
setTransparency(true);
}
@@ -763,7 +763,7 @@ void DGWebLink::onMouseCancelEvent(VSTGUI::MouseCancelEvent& ioEvent)
DGSplashScreen::DGSplashScreen(DfxGuiEditor* inOwnerEditor,
DGRect const& inClickRegion,
DGImage* inSplashImage)
-: DGControl(inClickRegion, inOwnerEditor, dfx::kParameterID_Invalid, inSplashImage, inClickRegion)
+: DGControl(inClickRegion, inOwnerEditor, dfx::ParameterID_ToVST(dfx::kParameterID_Invalid), inSplashImage, inClickRegion)
{
setTransparency(true);
diff --git a/dfxgui/dfxguibutton.h b/dfxgui/dfxguibutton.h
index 92836608..7e63d99f 100644
--- a/dfxgui/dfxguibutton.h
+++ b/dfxgui/dfxguibutton.h
@@ -18,7 +18,7 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Destroy FX Library. If not, see .
-To contact the author, use the contact form at http://destroyfx.org/
+To contact the author, use the contact form at http://destroyfx.org
------------------------------------------------------------------------*/
#pragma once
@@ -45,7 +45,7 @@ class DGButton : public DGControl
PictureReel
};
- DGButton(DfxGuiEditor* inOwnerEditor, long inParamID, DGRect const& inRegion, DGImage* inImage,
+ DGButton(DfxGuiEditor* inOwnerEditor, dfx::ParameterID inParameterID, DGRect const& inRegion, DGImage* inImage,
Mode inMode, bool inDrawMomentaryState = false);
DGButton(DfxGuiEditor* inOwnerEditor, DGRect const& inRegion, DGImage* inImage,
size_t inNumStates, Mode inMode, bool inDrawMomentaryState = false);
@@ -107,7 +107,7 @@ class DGButton : public DGControl
class DGToggleImageButton : public DGButton
{
public:
- DGToggleImageButton(DfxGuiEditor* inOwnerEditor, long inParameterID, VSTGUI::CCoord inXpos, VSTGUI::CCoord inYpos,
+ DGToggleImageButton(DfxGuiEditor* inOwnerEditor, dfx::ParameterID inParameterID, VSTGUI::CCoord inXpos, VSTGUI::CCoord inYpos,
DGImage* inImage, bool inDrawMomentaryState = false);
DGToggleImageButton(DfxGuiEditor* inOwnerEditor, VSTGUI::CCoord inXpos, VSTGUI::CCoord inYpos,
DGImage* inImage, bool inDrawMomentaryState = false);
@@ -126,7 +126,7 @@ class DGToggleImageButton : public DGButton
class DGFineTuneButton : public DGControl
{
public:
- DGFineTuneButton(DfxGuiEditor* inOwnerEditor, long inParameterID, DGRect const& inRegion,
+ DGFineTuneButton(DfxGuiEditor* inOwnerEditor, dfx::ParameterID inParameterID, DGRect const& inRegion,
DGImage* inImage, float inValueChangeAmount = 0.0001f);
void draw(VSTGUI::CDrawContext* inContext) override;
@@ -149,7 +149,7 @@ class DGFineTuneButton : public DGControl
class DGValueSpot : public DGControl
{
public:
- DGValueSpot(DfxGuiEditor* inOwnerEditor, long inParamID, DGRect const& inRegion, DGImage* inImage, double inValue);
+ DGValueSpot(DfxGuiEditor* inOwnerEditor, dfx::ParameterID inParameterID, DGRect const& inRegion, DGImage* inImage, double inValue);
void draw(VSTGUI::CDrawContext* inContext) override;
void onMouseDownEvent(VSTGUI::MouseDownEvent& ioEvent) override;
diff --git a/dfxgui/dfxguicontrol.cpp b/dfxgui/dfxguicontrol.cpp
index 3e1149bf..b83f804b 100644
--- a/dfxgui/dfxguicontrol.cpp
+++ b/dfxgui/dfxguicontrol.cpp
@@ -18,11 +18,13 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Destroy FX Library. If not, see .
-To contact the author, use the contact form at http://destroyfx.org/
+To contact the author, use the contact form at http://destroyfx.org
------------------------------------------------------------------------*/
#include "dfxguicontrol.h"
+#include "dfxplugin-base.h"
+
//-----------------------------------------------------------------------------
@@ -55,7 +57,7 @@ void detail::onMouseWheelEvent(IDGControl* inControl, VSTGUI::MouseWheelEvent& i
//-----------------------------------------------------------------------------
DGNullControl::DGNullControl(DfxGuiEditor* inOwnerEditor, DGRect const& inRegion, DGImage* inBackgroundImage)
-: DGControl(inRegion, inOwnerEditor, dfx::kParameterID_Invalid, inBackgroundImage)
+: DGControl(inRegion, inOwnerEditor, dfx::ParameterID_ToVST(dfx::kParameterID_Invalid), inBackgroundImage)
{
setMouseEnabled(false);
}
diff --git a/dfxgui/dfxguicontrol.h b/dfxgui/dfxguicontrol.h
index e474c951..c1819bb2 100644
--- a/dfxgui/dfxguicontrol.h
+++ b/dfxgui/dfxguicontrol.h
@@ -18,7 +18,7 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Destroy FX Library. If not, see .
-To contact the author, use the contact form at http://destroyfx.org/
+To contact the author, use the contact form at http://destroyfx.org
------------------------------------------------------------------------*/
#pragma once
@@ -72,8 +72,8 @@ class DGControl : public IDGControl, public T
void redraw() final;
- long getParameterID() const final;
- void setParameterID(long inParameterID) final;
+ dfx::ParameterID getParameterID() const final;
+ void setParameterID(dfx::ParameterID inParameterID) final;
bool isParameterAttached() const final;
size_t getNumStates() const final
@@ -230,12 +230,12 @@ class DGMultiControl : /*public IDGMultiControl,*/ public DGControl
void endEdit_all();
bool isEditing_any() const;
- IDGControl* getControlByParameterID(long inParameterID);
+ IDGControl* getControlByParameterID(dfx::ParameterID inParameterID);
protected:
- IDGControl* addChild(long inParameterID);
+ IDGControl* addChild(dfx::ParameterID inParameterID);
// TODO: C++23 use std::span?
- void addChildren(std::vector const& inParameterID);
+ void addChildren(std::vector const& inParameterID);
template
void forEachChild(Proc inProc);
@@ -246,7 +246,7 @@ class DGMultiControl : /*public IDGMultiControl,*/ public DGControl
class DGMultiControlChild final : public DGControl
{
public:
- DGMultiControlChild(DfxGuiEditor* inOwnerEditor, DGRect const& inRegion, long inParameterID);
+ DGMultiControlChild(DfxGuiEditor* inOwnerEditor, DGRect const& inRegion, dfx::ParameterID inParameterID);
void draw(VSTGUI::CDrawContext*) override {}
CLASS_METHODS(DGMultiControlChild, VSTGUI::CControl)
};
diff --git a/dfxgui/dfxguicontrol.hpp b/dfxgui/dfxguicontrol.hpp
index c239dba2..9831ce2c 100644
--- a/dfxgui/dfxguicontrol.hpp
+++ b/dfxgui/dfxguicontrol.hpp
@@ -18,7 +18,7 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Destroy FX Library. If not, see .
-To contact the author, use the contact form at http://destroyfx.org/
+To contact the author, use the contact form at http://destroyfx.org
------------------------------------------------------------------------*/
#include
@@ -29,6 +29,7 @@ To contact the author, use the contact form at http://destroyfx.org/
#include "dfxguieditor.h"
#include "dfxmisc.h"
+#include "dfxplugin-base.h"
@@ -122,18 +123,18 @@ void DGControl::redraw()
//-----------------------------------------------------------------------------
template
-long DGControl::getParameterID() const
+dfx::ParameterID DGControl::getParameterID() const
{
- return T::getTag();
+ return dfx::ParameterID_FromVST(T::getTag());
}
//-----------------------------------------------------------------------------
template
-void DGControl::setParameterID(long inParameterID)
+void DGControl::setParameterID(dfx::ParameterID inParameterID)
{
if (inParameterID != getParameterID())
{
- T::setTag(inParameterID);
+ T::setTag(dfx::ParameterID_ToVST(inParameterID));
initValues();
T::invalidRect(T::getViewSize());
}
@@ -143,7 +144,7 @@ void DGControl::setParameterID(long inParameterID)
template
bool DGControl::isParameterAttached() const
{
- return (getParameterID() >= 0);
+ return (getParameterID() != dfx::kParameterID_Invalid);
}
//-----------------------------------------------------------------------------
@@ -269,10 +270,10 @@ void DGControl::pullNumStatesFromParameter()
if (isParameterAttached() && mOwnerEditor)
{
size_t numStates = 0;
- auto const paramID = getParameterID();
- if (mOwnerEditor->GetParameterValueType(paramID) != DfxParam::ValueType::Float)
+ auto const parameterID = getParameterID();
+ if (mOwnerEditor->GetParameterValueType(parameterID) != DfxParam::ValueType::Float)
{
- auto const valueRange = mOwnerEditor->GetParameter_maxValue(paramID) - mOwnerEditor->GetParameter_minValue(paramID);
+ auto const valueRange = mOwnerEditor->GetParameter_maxValue(parameterID) - mOwnerEditor->GetParameter_minValue(parameterID);
numStates = static_cast(std::max(std::lround(valueRange), 0L) + 1);
}
setNumStates(numStates);
@@ -346,7 +347,7 @@ bool DGMultiControl::isEditing_any() const
//-----------------------------------------------------------------------------
template
-IDGControl* DGMultiControl::getControlByParameterID(long inParameterID)
+IDGControl* DGMultiControl::getControlByParameterID(dfx::ParameterID inParameterID)
{
if (DGControl::getParameterID() == inParameterID)
{
@@ -359,9 +360,9 @@ IDGControl* DGMultiControl::getControlByParameterID(long inParameterID)
//-----------------------------------------------------------------------------
template
-IDGControl* DGMultiControl::addChild(long inParameterID)
+IDGControl* DGMultiControl::addChild(dfx::ParameterID inParameterID)
{
- assert(inParameterID >= 0);
+ assert(inParameterID != dfx::kParameterID_Invalid);
assert(inParameterID != this->getParameterID());
auto child = std::make_unique(DGControl::getOwnerEditor(), DGControl::getViewSize(), inParameterID);
[[maybe_unused]] auto const [element, inserted] = mChildren.insert(child.get());
@@ -376,9 +377,9 @@ IDGControl* DGMultiControl::addChild(long inParameterID)
//-----------------------------------------------------------------------------
template
-void DGMultiControl::addChildren(std::vector const& inParameterIDs)
+void DGMultiControl::addChildren(std::vector const& inParameterIDs)
{
- assert(std::unordered_set(inParameterIDs.cbegin(), inParameterIDs.cend()).size() == inParameterIDs.size());
+ assert(std::unordered_set(inParameterIDs.cbegin(), inParameterIDs.cend()).size() == inParameterIDs.size());
std::for_each(inParameterIDs.cbegin(), inParameterIDs.cend(), [this](auto parameterID){ addChild(parameterID); });
}
@@ -417,7 +418,7 @@ void DGMultiControl::notifyIfChanged_all()
template
DGMultiControl::DGMultiControlChild::DGMultiControlChild(DfxGuiEditor* inOwnerEditor,
DGRect const& inRegion,
- long inParameterID)
-: DGControl(inRegion, inOwnerEditor, inParameterID)
+ dfx::ParameterID inParameterID)
+: DGControl(inRegion, inOwnerEditor, dfx::ParameterID_ToVST(inParameterID))
{
}
diff --git a/dfxgui/dfxguidialog.cpp b/dfxgui/dfxguidialog.cpp
index bfa4ec09..41e73c92 100644
--- a/dfxgui/dfxguidialog.cpp
+++ b/dfxgui/dfxguidialog.cpp
@@ -18,7 +18,7 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Destroy FX Library. If not, see .
-To contact the author, use the contact form at http://destroyfx.org/
+To contact the author, use the contact form at http://destroyfx.org
------------------------------------------------------------------------*/
#include "dfxguidialog.h"
@@ -29,6 +29,8 @@ To contact the author, use the contact form at http://destroyfx.org/
#include
#include
+#include "dfxplugin-base.h"
+
//-----------------------------------------------------------------------------
constexpr VSTGUI::CCoord kContentMargin = 20.0;
@@ -77,7 +79,7 @@ class DGDialogButton final : public VSTGUI::CTextButton
{
public:
DGDialogButton(VSTGUI::IControlListener* inListener, DGRect const& inRegion, DGDialog::Selection inSelection, VSTGUI::UTF8StringPtr inTitle)
- : VSTGUI::CTextButton(inRegion, inListener, dfx::kParameterID_Invalid, inTitle, VSTGUI::CTextButton::kKickStyle),
+ : VSTGUI::CTextButton(inRegion, inListener, dfx::ParameterID_ToVST(dfx::kParameterID_Invalid), inTitle, VSTGUI::CTextButton::kKickStyle),
mSelection(inSelection),
mIsDefaultButton(inSelection == DGDialog::kSelection_OK)
{
@@ -177,7 +179,7 @@ class DGDialogTextEdit final : public VSTGUI::CTextEdit
{
public:
DGDialogTextEdit(VSTGUI::CRect const& inRegion, VSTGUI::IControlListener* inListener)
- : VSTGUI::CTextEdit(inRegion, inListener, dfx::kParameterID_Invalid)
+ : VSTGUI::CTextEdit(inRegion, inListener, dfx::ParameterID_ToVST(dfx::kParameterID_Invalid))
{
setFontColor(DGColor::getSystem(DGColor::System::Text));
setBackColor(DGColor::getSystem(DGColor::System::TextBackground));
@@ -527,11 +529,11 @@ VSTGUI::CTextButton* DGDialog::getButton(Selection inSelection) const
//-----------------------------------------------------------------------------
// Text-Entry Dialog
//-----------------------------------------------------------------------------
-DGTextEntryDialog::DGTextEntryDialog(long inParamID, std::string const& inMessage,
+DGTextEntryDialog::DGTextEntryDialog(dfx::ParameterID inParameterID, std::string const& inMessage,
char const* inTextEntryLabel, Buttons inButtons,
char const* inOkButtonTitle, char const* inCancelButtonTitle, char const* inOtherButtonTitle)
: DGDialog(DGRect(0.0, 0.0, 247.0, 134.0), inMessage, inButtons, inOkButtonTitle, inCancelButtonTitle, inOtherButtonTitle),
- mParameterID(inParamID)
+ mParameterID(inParameterID)
{
constexpr VSTGUI::CCoord labelEditHeightOffset = (kTextEditHeight - kTextLabelHeight) / 2.0;
@@ -607,7 +609,7 @@ std::string DGTextEntryDialog::getText() const
}
//-----------------------------------------------------------------------------
-long DGTextEntryDialog::getParameterID() const noexcept
+dfx::ParameterID DGTextEntryDialog::getParameterID() const noexcept
{
return mParameterID;
}
diff --git a/dfxgui/dfxguidialog.h b/dfxgui/dfxguidialog.h
index e50ce10f..224d2359 100644
--- a/dfxgui/dfxguidialog.h
+++ b/dfxgui/dfxguidialog.h
@@ -18,7 +18,7 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Destroy FX Library. If not, see .
-To contact the author, use the contact form at http://destroyfx.org/
+To contact the author, use the contact form at http://destroyfx.org
------------------------------------------------------------------------*/
#pragma once
@@ -115,7 +115,7 @@ class DGDialog : public VSTGUI::CViewContainer, public VSTGUI::IControlListener
class DGTextEntryDialog : public DGDialog
{
public:
- DGTextEntryDialog(long inParamID, std::string const& inMessage,
+ DGTextEntryDialog(dfx::ParameterID inParameterID, std::string const& inMessage,
char const* inTextEntryLabel = nullptr, Buttons inButtons = kButtons_OKCancel,
char const* inOkButtonTitle = nullptr, char const* inCancelButtonTitle = nullptr, char const* inOtherButtonTitle = nullptr);
explicit DGTextEntryDialog(std::string const& inMessage,
@@ -128,12 +128,12 @@ class DGTextEntryDialog : public DGDialog
void setText(std::string const& inText);
std::string getText() const;
- long getParameterID() const noexcept;
+ dfx::ParameterID getParameterID() const noexcept;
CLASS_METHODS(DGTextEntryDialog, DGDialog)
private:
- long const mParameterID;
+ dfx::ParameterID const mParameterID;
VSTGUI::CTextEdit* mTextEdit = nullptr;
};
diff --git a/dfxgui/dfxguieditor.cpp b/dfxgui/dfxguieditor.cpp
index fa88c516..261841b4 100644
--- a/dfxgui/dfxguieditor.cpp
+++ b/dfxgui/dfxguieditor.cpp
@@ -18,7 +18,7 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Destroy FX Library. If not, see .
-To contact the author, use the contact form at http://destroyfx.org/
+To contact the author, use the contact form at http://destroyfx.org
------------------------------------------------------------------------*/
#include "dfxguieditor.h"
@@ -293,40 +293,40 @@ void DfxGuiEditor::setParameter(TARGET_API_EDITOR_INDEX_TYPE inParameterIndex, f
return;
}
- updateParameterControls(inParameterIndex, inValue);
+ updateParameterControls(dfx::ParameterID_FromVST(inParameterIndex), inValue);
}
//-----------------------------------------------------------------------------
-void DfxGuiEditor::updateParameterControls(long inParameterIndex, float inValue, VSTGUI::CControl* inSendingControl)
+void DfxGuiEditor::updateParameterControls(dfx::ParameterID inParameterID, float inValue, VSTGUI::CControl* inSendingControl)
{
for (auto& control : mControlsList)
{
- if ((control->getParameterID() == inParameterIndex) && (control->asCControl() != inSendingControl))
+ if ((control->getParameterID() == inParameterID) && (control->asCControl() != inSendingControl))
{
control->setValue_gen(inValue);
control->redraw(); // TODO: why is this also necessary? redraws are sometimes dropped without it
}
}
- parameterChanged(inParameterIndex);
+ parameterChanged(inParameterID);
}
//-----------------------------------------------------------------------------
void DfxGuiEditor::valueChanged(VSTGUI::CControl* inControl)
{
- auto const paramIndex = inControl->getTag();
- auto const paramValue_norm = inControl->getValueNormalized();
+ auto const parameterID = dfx::ParameterID_FromVST(inControl->getTag());
+ auto const parameterValue_norm = inControl->getValueNormalized();
- if (dfxgui_IsValidParamID(paramIndex))
+ if (dfxgui_IsValidParameterID(parameterID))
{
#ifdef TARGET_API_AUDIOUNIT
- auto const paramValue_literal = dfxgui_ExpandParameterValue(paramIndex, paramValue_norm);
+ auto const parameterValue_literal = dfxgui_ExpandParameterValue(parameterID, parameterValue_norm);
// XXX or should I call setparameter_f()?
- auto const auParam = dfxgui_MakeAudioUnitParameter(paramIndex);
- AUParameterSet(mAUEventListener.get(), inControl, &auParam, paramValue_literal, 0);
+ auto const auParam = dfxgui_MakeAudioUnitParameter(parameterID);
+ AUParameterSet(mAUEventListener.get(), inControl, &auParam, parameterValue_literal, 0);
#endif
#ifdef TARGET_API_VST
- getEffect()->setParameterAutomated(paramIndex, paramValue_norm);
+ getEffect()->setParameterAutomated(dfx::ParameterID_ToVST(parameterID), parameterValue_norm);
#endif
#ifdef TARGET_API_RTAS
// XXX though the model of calling SetControlValue might make more seem like
@@ -335,8 +335,8 @@ void DfxGuiEditor::valueChanged(VSTGUI::CControl* inControl)
// the next call to UpdateControlInAlgorithm which be deferred until the start of
// the next audio render call, which means that in the meantime getparameter_*
// methods will return the previous rather than current value
-// dfxgui_GetEffectInstance()->SetControlValue(dfx::ParameterID_ToRTAS(paramIndex), ConvertToDigiValue(paramValue_norm));
- dfxgui_GetEffectInstance()->setparameter_gen(paramIndex, paramValue_norm);
+// dfxgui_GetEffectInstance()->SetControlValue(dfx::ParameterID_ToRTAS(parameterID), ConvertToDigiValue(parameterValue_norm));
+ dfxgui_GetEffectInstance()->setparameter_gen(parameterID, parameterValue_norm);
#endif
}
}
@@ -345,18 +345,18 @@ void DfxGuiEditor::valueChanged(VSTGUI::CControl* inControl)
//-----------------------------------------------------------------------------
void DfxGuiEditor::beginEdit(int32_t inParameterIndex)
{
- if (dfxgui_IsValidParamID(inParameterIndex))
+ if (auto const parameterID = dfx::ParameterID_FromVST(inParameterIndex); dfxgui_IsValidParameterID(parameterID))
{
- automationgesture_begin(inParameterIndex);
+ automationgesture_begin(parameterID);
}
}
//-----------------------------------------------------------------------------
void DfxGuiEditor::endEdit(int32_t inParameterIndex)
{
- if (dfxgui_IsValidParamID(inParameterIndex))
+ if (auto const parameterID = dfx::ParameterID_FromVST(inParameterIndex); dfxgui_IsValidParameterID(parameterID))
{
- automationgesture_end(inParameterIndex);
+ automationgesture_end(parameterID);
}
}
#endif // !TARGET_API_VST
@@ -420,7 +420,7 @@ IDGControl* DfxGuiEditor::addControl(IDGControl* inControl)
assert(inControl);
// XXX only add it to our controls list if it is attached to a parameter (?)
- if (dfxgui_IsValidParamID(inControl->getParameterID()))
+ if (dfxgui_IsValidParameterID(inControl->getParameterID()))
{
assert(std::find(mControlsList.cbegin(), mControlsList.cend(), inControl) == mControlsList.cend());
mControlsList.push_back(inControl);
@@ -451,7 +451,7 @@ void DfxGuiEditor::removeControl(IDGControl* inControl)
}
//-----------------------------------------------------------------------------
-long DfxGuiEditor::GetWidth()
+int DfxGuiEditor::GetWidth()
{
ERect* editorRect = nullptr;
if (getRect(&editorRect) && editorRect)
@@ -462,7 +462,7 @@ long DfxGuiEditor::GetWidth()
}
//-----------------------------------------------------------------------------
-long DfxGuiEditor::GetHeight()
+int DfxGuiEditor::GetHeight()
{
ERect* editorRect = nullptr;
if (getRect(&editorRect) && editorRect)
@@ -505,14 +505,14 @@ OSStatus DfxGuiEditor::SendAUParameterEvent(AudioUnitParameterID inParameterID,
#endif
//-----------------------------------------------------------------------------
-void DfxGuiEditor::automationgesture_begin(long inParameterID)
+void DfxGuiEditor::automationgesture_begin(dfx::ParameterID inParameterID)
{
#ifdef TARGET_API_AUDIOUNIT
- SendAUParameterEvent(static_cast(inParameterID), kAudioUnitEvent_BeginParameterChangeGesture);
+ SendAUParameterEvent(inParameterID, kAudioUnitEvent_BeginParameterChangeGesture);
#endif
#ifdef TARGET_API_VST
- TARGET_API_EDITOR_BASE_CLASS::beginEdit(inParameterID);
+ TARGET_API_EDITOR_BASE_CLASS::beginEdit(dfx::ParameterID_ToVST(inParameterID));
#endif
#ifdef TARGET_API_RTAS
@@ -523,14 +523,14 @@ void DfxGuiEditor::automationgesture_begin(long inParameterID)
}
//-----------------------------------------------------------------------------
-void DfxGuiEditor::automationgesture_end(long inParameterID)
+void DfxGuiEditor::automationgesture_end(dfx::ParameterID inParameterID)
{
#ifdef TARGET_API_AUDIOUNIT
- SendAUParameterEvent(static_cast(inParameterID), kAudioUnitEvent_EndParameterChangeGesture);
+ SendAUParameterEvent(inParameterID, kAudioUnitEvent_EndParameterChangeGesture);
#endif
#ifdef TARGET_API_VST
- TARGET_API_EDITOR_BASE_CLASS::endEdit(inParameterID);
+ TARGET_API_EDITOR_BASE_CLASS::endEdit(dfx::ParameterID_ToVST(inParameterID));
#endif
#ifdef TARGET_API_RTAS
@@ -540,7 +540,7 @@ void DfxGuiEditor::automationgesture_end(long inParameterID)
}
//-----------------------------------------------------------------------------
-void DfxGuiEditor::randomizeparameter(long inParameterID, bool inWriteAutomation)
+void DfxGuiEditor::randomizeparameter(dfx::ParameterID inParameterID, bool inWriteAutomation)
{
if (inWriteAutomation)
{
@@ -556,7 +556,7 @@ void DfxGuiEditor::randomizeparameter(long inParameterID, bool inWriteAutomation
dfxgui_GetEffectInstance()->randomizeparameter(inParameterID);
if (inWriteAutomation)
{
- getEffect()->setParameterAutomated(inParameterID, getparameter_gen(inParameterID));
+ getEffect()->setParameterAutomated(dfx::ParameterID_ToVST(inParameterID), getparameter_gen(inParameterID));
}
#endif
@@ -609,7 +609,7 @@ void DfxGuiEditor::randomizeparameters(bool inWriteAutomation)
for (auto const parameterID : parameterList)
{
#ifdef TARGET_API_VST
- getEffect()->setParameterAutomated(parameterID, getparameter_gen(parameterID));
+ getEffect()->setParameterAutomated(dfx::ParameterID_ToVST(parameterID), getparameter_gen(parameterID));
#endif
automationgesture_end(parameterID);
}
@@ -617,7 +617,7 @@ void DfxGuiEditor::randomizeparameters(bool inWriteAutomation)
}
//-----------------------------------------------------------------------------
-void DfxGuiEditor::GenerateParameterAutomationSnapshot(long inParameterID)
+void DfxGuiEditor::GenerateParameterAutomationSnapshot(dfx::ParameterID inParameterID)
{
setparameter_f(inParameterID, getparameter_f(inParameterID), true);
}
@@ -632,7 +632,7 @@ void DfxGuiEditor::GenerateParametersAutomationSnapshot()
}
//-----------------------------------------------------------------------------
-std::optional DfxGuiEditor::dfxgui_GetParameterValueFromString_f(long inParameterID, std::string const& inText)
+std::optional DfxGuiEditor::dfxgui_GetParameterValueFromString_f(dfx::ParameterID inParameterID, std::string const& inText)
{
if (GetParameterValueType(inParameterID) == DfxParam::ValueType::Float)
{
@@ -655,17 +655,17 @@ std::optional DfxGuiEditor::dfxgui_GetParameterValueFromString_f(long in
}
//-----------------------------------------------------------------------------
-std::optional DfxGuiEditor::dfxgui_GetParameterValueFromString_i(long inParameterID, std::string const& inText)
+std::optional DfxGuiEditor::dfxgui_GetParameterValueFromString_i(dfx::ParameterID inParameterID, std::string const& inText)
{
if (GetParameterValueType(inParameterID) == DfxParam::ValueType::Float)
{
if (auto const newValue_f = dfxgui_GetParameterValueFromString_f(inParameterID, inText))
{
- DfxParam param;
- param.init_f({""}, 0.0, 0.0, -1.0, 1.0);
- DfxParam::Value paramValue {};
- paramValue.f = *newValue_f;
- return param.derive_i(paramValue);
+ DfxParam parameter;
+ parameter.init_f({""}, 0.0, 0.0, -1.0, 1.0);
+ DfxParam::Value parameterValue {};
+ parameterValue.f = *newValue_f;
+ return parameter.derive_i(parameterValue);
}
}
else
@@ -682,9 +682,9 @@ std::optional DfxGuiEditor::dfxgui_GetParameterValueFromString_i(long inPa
}
//-----------------------------------------------------------------------------
-bool DfxGuiEditor::dfxgui_SetParameterValueWithString(long inParameterID, std::string const& inText)
+bool DfxGuiEditor::dfxgui_SetParameterValueWithString(dfx::ParameterID inParameterID, std::string const& inText)
{
- if (dfxgui_IsValidParamID(inParameterID))
+ if (dfxgui_IsValidParameterID(inParameterID))
{
constexpr bool automationGesture = true;
if (GetParameterValueType(inParameterID) == DfxParam::ValueType::Float)
@@ -709,7 +709,7 @@ bool DfxGuiEditor::dfxgui_SetParameterValueWithString(long inParameterID, std::s
}
//-----------------------------------------------------------------------------
-bool DfxGuiEditor::dfxgui_IsValidParamID(long inParameterID)
+bool DfxGuiEditor::dfxgui_IsValidParameterID(dfx::ParameterID inParameterID)
{
if ((inParameterID == dfx::kParameterID_Invalid) || (inParameterID < 0))
{
@@ -717,14 +717,14 @@ bool DfxGuiEditor::dfxgui_IsValidParamID(long inParameterID)
}
#ifdef TARGET_API_AUDIOUNIT
// TODO: actually search parameter ID list to ensure that this ID is present?
- return (static_cast(inParameterID) <= mAUMaxParameterID);
+ return (inParameterID <= mAUMaxParameterID);
#else
return (inParameterID < GetNumParameters());
#endif
}
//-----------------------------------------------------------------------------
-void DfxGuiEditor::TextEntryForParameterValue(long inParameterID)
+void DfxGuiEditor::TextEntryForParameterValue(dfx::ParameterID inParameterID)
{
if (!getFrame())
{
@@ -764,7 +764,7 @@ void DfxGuiEditor::TextEntryForParameterValue(long inParameterID)
}
//-----------------------------------------------------------------------------
-void DfxGuiEditor::SetParameterHelpText(long inParameterID, char const* inText)
+void DfxGuiEditor::SetParameterHelpText(dfx::ParameterID inParameterID, char const* inText)
{
for (auto& control : mControlsList)
{
@@ -776,7 +776,7 @@ void DfxGuiEditor::SetParameterHelpText(long inParameterID, char const* inText)
}
//-----------------------------------------------------------------------------
-void DfxGuiEditor::SetParameterAlpha(long inParameterID, float inAlpha)
+void DfxGuiEditor::SetParameterAlpha(dfx::ParameterID inParameterID, float inAlpha)
{
for (auto& control : mControlsList)
{
@@ -906,7 +906,7 @@ void DfxGuiEditor::viewOnEvent(VSTGUI::CView* inView, VSTGUI::Event& ioEvent)
}
//-----------------------------------------------------------------------------
-double DfxGuiEditor::getparameter_f(long inParameterID)
+double DfxGuiEditor::getparameter_f(dfx::ParameterID inParameterID)
{
#ifdef TARGET_API_AUDIOUNIT
dfx::ParameterValueRequest request;
@@ -927,7 +927,7 @@ double DfxGuiEditor::getparameter_f(long inParameterID)
}
//-----------------------------------------------------------------------------
-long DfxGuiEditor::getparameter_i(long inParameterID)
+long DfxGuiEditor::getparameter_i(dfx::ParameterID inParameterID)
{
#ifdef TARGET_API_AUDIOUNIT
dfx::ParameterValueRequest request;
@@ -948,7 +948,7 @@ long DfxGuiEditor::getparameter_i(long inParameterID)
}
//-----------------------------------------------------------------------------
-bool DfxGuiEditor::getparameter_b(long inParameterID)
+bool DfxGuiEditor::getparameter_b(dfx::ParameterID inParameterID)
{
#ifdef TARGET_API_AUDIOUNIT
dfx::ParameterValueRequest request;
@@ -969,18 +969,18 @@ bool DfxGuiEditor::getparameter_b(long inParameterID)
}
//-----------------------------------------------------------------------------
-double DfxGuiEditor::getparameter_gen(long inParameterIndex)
+double DfxGuiEditor::getparameter_gen(dfx::ParameterID inParameterID)
{
#ifdef TARGET_API_VST
- return getEffect()->getParameter(inParameterIndex);
+ return getEffect()->getParameter(dfx::ParameterID_ToVST(inParameterID));
#else
- double currentValue = getparameter_f(inParameterIndex);
- return dfxgui_ContractParameterValue(inParameterIndex, currentValue);
+ double currentValue = getparameter_f(inParameterID);
+ return dfxgui_ContractParameterValue(inParameterID, currentValue);
#endif
}
//-----------------------------------------------------------------------------
-void DfxGuiEditor::setparameter_f(long inParameterID, double inValue, bool inWrapWithAutomationGesture)
+void DfxGuiEditor::setparameter_f(dfx::ParameterID inParameterID, double inValue, bool inWrapWithAutomationGesture)
{
if (inWrapWithAutomationGesture)
{
@@ -998,7 +998,7 @@ void DfxGuiEditor::setparameter_f(long inParameterID, double inValue, bool inWra
#ifdef TARGET_API_VST
auto const value_norm = dfxgui_ContractParameterValue(inParameterID, inValue);
- getEffect()->setParameterAutomated(inParameterID, value_norm);
+ getEffect()->setParameterAutomated(dfx::ParameterID_ToVST(inParameterID), value_norm);
#endif
#ifdef TARGET_API_RTAS
@@ -1013,7 +1013,7 @@ void DfxGuiEditor::setparameter_f(long inParameterID, double inValue, bool inWra
}
//-----------------------------------------------------------------------------
-void DfxGuiEditor::setparameter_i(long inParameterID, long inValue, bool inWrapWithAutomationGesture)
+void DfxGuiEditor::setparameter_i(dfx::ParameterID inParameterID, long inValue, bool inWrapWithAutomationGesture)
{
if (inWrapWithAutomationGesture)
{
@@ -1031,7 +1031,7 @@ void DfxGuiEditor::setparameter_i(long inParameterID, long inValue, bool inWrapW
#ifdef TARGET_API_VST
auto const value_norm = dfxgui_ContractParameterValue(inParameterID, inValue);
- getEffect()->setParameterAutomated(inParameterID, value_norm);
+ getEffect()->setParameterAutomated(dfx::ParameterID_ToVST(inParameterID), value_norm);
#endif
#ifdef TARGET_API_RTAS
@@ -1046,7 +1046,7 @@ void DfxGuiEditor::setparameter_i(long inParameterID, long inValue, bool inWrapW
}
//-----------------------------------------------------------------------------
-void DfxGuiEditor::setparameter_b(long inParameterID, bool inValue, bool inWrapWithAutomationGesture)
+void DfxGuiEditor::setparameter_b(dfx::ParameterID inParameterID, bool inValue, bool inWrapWithAutomationGesture)
{
if (inWrapWithAutomationGesture)
{
@@ -1063,7 +1063,7 @@ void DfxGuiEditor::setparameter_b(long inParameterID, bool inValue, bool inWrapW
#endif
#ifdef TARGET_API_VST
- getEffect()->setParameterAutomated(inParameterID, inValue ? 1.0f : 0.0f);
+ getEffect()->setParameterAutomated(dfx::ParameterID_ToVST(inParameterID), inValue ? 1.f : 0.f);
#endif
#ifdef TARGET_API_RTAS
@@ -1078,7 +1078,7 @@ void DfxGuiEditor::setparameter_b(long inParameterID, bool inValue, bool inWrapW
}
//-----------------------------------------------------------------------------
-void DfxGuiEditor::setparameter_default(long inParameterID, bool inWrapWithAutomationGesture)
+void DfxGuiEditor::setparameter_default(dfx::ParameterID inParameterID, bool inWrapWithAutomationGesture)
{
#ifdef TARGET_API_AUDIOUNIT
if (auto const parameterInfo = dfxgui_GetParameterInfo(inParameterID))
@@ -1102,7 +1102,7 @@ void DfxGuiEditor::setparameter_default(long inParameterID, bool inWrapWithAutom
#ifdef TARGET_API_VST
auto const defaultValue = GetParameter_defaultValue(inParameterID);
auto const defaultValue_norm = dfxgui_ContractParameterValue(inParameterID, defaultValue);
- getEffect()->setParameterAutomated(inParameterID, defaultValue_norm);
+ getEffect()->setParameterAutomated(dfx::ParameterID_ToVST(inParameterID), defaultValue_norm);
#endif
#ifdef TARGET_API_RTAS
@@ -1121,13 +1121,13 @@ void DfxGuiEditor::setparameters_default(bool inWrapWithAutomationGesture)
}
//-----------------------------------------------------------------------------
-std::optional DfxGuiEditor::getparametervaluestring(long inParameterID)
+std::optional DfxGuiEditor::getparametervaluestring(dfx::ParameterID inParameterID)
{
return getparametervaluestring(inParameterID, getparameter_i(inParameterID));
}
//-----------------------------------------------------------------------------
-std::optional DfxGuiEditor::getparametervaluestring(long inParameterID, int64_t inStringIndex)
+std::optional DfxGuiEditor::getparametervaluestring(dfx::ParameterID inParameterID, int64_t inStringIndex)
{
#ifdef TARGET_API_AUDIOUNIT
dfx::ParameterValueStringRequest request;
@@ -1146,51 +1146,51 @@ std::optional DfxGuiEditor::getparametervaluestring(long inParamete
}
//-----------------------------------------------------------------------------
-std::string DfxGuiEditor::getparameterunitstring(long inParameterIndex)
+std::string DfxGuiEditor::getparameterunitstring(dfx::ParameterID inParameterID)
{
#ifdef TARGET_API_AUDIOUNIT
std::array unitLabel {};
size_t dataSize = unitLabel.size() * sizeof(unitLabel.front());
auto const status = dfxgui_GetProperty(dfx::kPluginProperty_ParameterUnitLabel, dfx::kScope_Global,
- inParameterIndex, unitLabel.data(), dataSize);
+ inParameterID, unitLabel.data(), dataSize);
if (status == noErr)
{
return unitLabel.data();
}
return {};
#else
- return dfxgui_GetEffectInstance()->getparameterunitstring(inParameterIndex);
+ return dfxgui_GetEffectInstance()->getparameterunitstring(inParameterID);
#endif
}
//-----------------------------------------------------------------------------
-bool DfxGuiEditor::GetParameterUseValueStrings(long inParameterIndex)
+bool DfxGuiEditor::GetParameterUseValueStrings(dfx::ParameterID inParameterID)
{
#ifdef TARGET_API_AUDIOUNIT
- return dfxgui_GetProperty(dfx::kPluginProperty_ParameterUseValueStrings, dfx::kScope_Global, inParameterIndex).value_or(false);
+ return dfxgui_GetProperty(dfx::kPluginProperty_ParameterUseValueStrings, dfx::kScope_Global, inParameterID).value_or(false);
#else
- return dfxgui_GetEffectInstance()->getparameterusevaluestrings(inParameterIndex);
+ return dfxgui_GetEffectInstance()->getparameterusevaluestrings(inParameterID);
#endif
}
//-----------------------------------------------------------------------------
-bool DfxGuiEditor::HasParameterAttribute(long inParameterIndex, DfxParam::Attribute inFlag)
+bool DfxGuiEditor::HasParameterAttribute(dfx::ParameterID inParameterID, DfxParam::Attribute inFlag)
{
assert(inFlag);
#ifdef TARGET_API_AUDIOUNIT
- return dfxgui_GetProperty(dfx::kPluginProperty_ParameterAttributes, dfx::kScope_Global, inParameterIndex).value_or(0) & inFlag;
+ return dfxgui_GetProperty(dfx::kPluginProperty_ParameterAttributes, dfx::kScope_Global, inParameterID).value_or(0) & inFlag;
#else
- return dfxgui_GetEffectInstance()->hasparameterattribute(inParameterIndex, inFlag);
+ return dfxgui_GetEffectInstance()->hasparameterattribute(inParameterID, inFlag);
#endif
}
//-----------------------------------------------------------------------------
-std::optional DfxGuiEditor::GetParameterGroup(long inParameterIndex)
+std::optional DfxGuiEditor::GetParameterGroup(dfx::ParameterID inParameterID)
{
#ifdef TARGET_API_AUDIOUNIT
- return dfxgui_GetProperty(dfx::kPluginProperty_ParameterGroup, dfx::kScope_Global, inParameterIndex);
+ return dfxgui_GetProperty(dfx::kPluginProperty_ParameterGroup, dfx::kScope_Global, inParameterID);
#else
- return dfxgui_GetEffectInstance()->getparametergroup(inParameterIndex);
+ return dfxgui_GetEffectInstance()->getparametergroup(inParameterID);
#endif
}
@@ -1213,7 +1213,7 @@ std::string DfxGuiEditor::GetParameterGroupName(size_t inGroupIndex)
}
//-----------------------------------------------------------------------------
-std::string DfxGuiEditor::getparametername(long inParameterID)
+std::string DfxGuiEditor::getparametername(dfx::ParameterID inParameterID)
{
#ifdef TARGET_API_AUDIOUNIT
if (auto const parameterInfo = dfxgui_GetParameterInfo(inParameterID))
@@ -1234,7 +1234,7 @@ std::string DfxGuiEditor::getparametername(long inParameterID)
}
//-----------------------------------------------------------------------------
-float DfxGuiEditor::dfxgui_ExpandParameterValue(long inParameterIndex, float inValue)
+float DfxGuiEditor::dfxgui_ExpandParameterValue(dfx::ParameterID inParameterID, float inValue)
{
#ifdef TARGET_API_AUDIOUNIT
dfx::ParameterValueConversionRequest request;
@@ -1242,23 +1242,24 @@ float DfxGuiEditor::dfxgui_ExpandParameterValue(long inParameterIndex, float inV
request.inValue = inValue;
size_t dataSize = sizeof(request);
auto const status = dfxgui_GetProperty(dfx::kPluginProperty_ParameterValueConversion, dfx::kScope_Global,
- inParameterIndex, &request, dataSize);
+ inParameterID, &request, dataSize);
if (status == noErr)
{
return request.outValue;
}
else
{
- auto const auParam = dfxgui_MakeAudioUnitParameter(inParameterIndex);
+ assert(false); // really the above should not be failing
+ auto const auParam = dfxgui_MakeAudioUnitParameter(inParameterID);
return AUParameterValueFromLinear(inValue, &auParam);
}
#else
- return dfxgui_GetEffectInstance()->expandparametervalue(inParameterIndex, inValue);
+ return dfxgui_GetEffectInstance()->expandparametervalue(inParameterID, inValue);
#endif
}
//-----------------------------------------------------------------------------
-float DfxGuiEditor::dfxgui_ContractParameterValue(long inParameterIndex, float inValue)
+float DfxGuiEditor::dfxgui_ContractParameterValue(dfx::ParameterID inParameterID, float inValue)
{
#ifdef TARGET_API_AUDIOUNIT
dfx::ParameterValueConversionRequest request;
@@ -1266,7 +1267,7 @@ float DfxGuiEditor::dfxgui_ContractParameterValue(long inParameterIndex, float i
request.inValue = inValue;
size_t dataSize = sizeof(request);
auto const status = dfxgui_GetProperty(dfx::kPluginProperty_ParameterValueConversion, dfx::kScope_Global,
- inParameterIndex, &request, dataSize);
+ inParameterID, &request, dataSize);
if (status == noErr)
{
return request.outValue;
@@ -1274,77 +1275,77 @@ float DfxGuiEditor::dfxgui_ContractParameterValue(long inParameterIndex, float i
else
{
assert(false); // really the above should not be failing
- auto const auParam = dfxgui_MakeAudioUnitParameter(inParameterIndex);
+ auto const auParam = dfxgui_MakeAudioUnitParameter(inParameterID);
return AUParameterValueToLinear(inValue, &auParam);
}
#else
- return dfxgui_GetEffectInstance()->contractparametervalue(inParameterIndex, inValue);
+ return dfxgui_GetEffectInstance()->contractparametervalue(inParameterID, inValue);
#endif
}
//-----------------------------------------------------------------------------
-float DfxGuiEditor::GetParameter_minValue(long inParameterIndex)
+float DfxGuiEditor::GetParameter_minValue(dfx::ParameterID inParameterID)
{
#ifdef TARGET_API_AUDIOUNIT
- if (auto const parameterInfo = dfxgui_GetParameterInfo(inParameterIndex))
+ if (auto const parameterInfo = dfxgui_GetParameterInfo(inParameterID))
{
return parameterInfo->minValue;
}
+ return 0.f;
#else
- return dfxgui_GetEffectInstance()->getparametermin_f(inParameterIndex);
+ return dfxgui_GetEffectInstance()->getparametermin_f(inParameterID);
#endif
- return 0.0f;
}
//-----------------------------------------------------------------------------
-float DfxGuiEditor::GetParameter_maxValue(long inParameterIndex)
+float DfxGuiEditor::GetParameter_maxValue(dfx::ParameterID inParameterID)
{
#ifdef TARGET_API_AUDIOUNIT
- if (auto const parameterInfo = dfxgui_GetParameterInfo(inParameterIndex))
+ if (auto const parameterInfo = dfxgui_GetParameterInfo(inParameterID))
{
return parameterInfo->maxValue;
}
+ return 0.f;
#else
- return dfxgui_GetEffectInstance()->getparametermax_f(inParameterIndex);
+ return dfxgui_GetEffectInstance()->getparametermax_f(inParameterID);
#endif
- return 0.0f;
}
//-----------------------------------------------------------------------------
-float DfxGuiEditor::GetParameter_defaultValue(long inParameterIndex)
+float DfxGuiEditor::GetParameter_defaultValue(dfx::ParameterID inParameterID)
{
#ifdef TARGET_API_AUDIOUNIT
- if (auto const parameterInfo = dfxgui_GetParameterInfo(inParameterIndex))
+ if (auto const parameterInfo = dfxgui_GetParameterInfo(inParameterID))
{
return parameterInfo->defaultValue;
}
+ return 0.f;
#else
- return dfxgui_GetEffectInstance()->getparameterdefault_f(inParameterIndex);
+ return dfxgui_GetEffectInstance()->getparameterdefault_f(inParameterID);
#endif
- return 0.0f;
}
//-----------------------------------------------------------------------------
-DfxParam::ValueType DfxGuiEditor::GetParameterValueType(long inParameterIndex)
+DfxParam::ValueType DfxGuiEditor::GetParameterValueType(dfx::ParameterID inParameterID)
{
#ifdef TARGET_API_AUDIOUNIT
return dfxgui_GetProperty(dfx::kPluginProperty_ParameterValueType,
dfx::kScope_Global,
- inParameterIndex).value_or(DfxParam::ValueType::Float);
+ inParameterID).value_or(DfxParam::ValueType::Float);
#else
- return dfxgui_GetEffectInstance()->getparametervaluetype(inParameterIndex);
+ return dfxgui_GetEffectInstance()->getparametervaluetype(inParameterID);
#endif
}
//-----------------------------------------------------------------------------
-DfxParam::Unit DfxGuiEditor::GetParameterUnit(long inParameterIndex)
+DfxParam::Unit DfxGuiEditor::GetParameterUnit(dfx::ParameterID inParameterID)
{
#ifdef TARGET_API_AUDIOUNIT
return dfxgui_GetProperty(dfx::kPluginProperty_ParameterUnit,
dfx::kScope_Global,
- inParameterIndex).value_or(DfxParam::Unit::Generic);
+ inParameterID).value_or(DfxParam::Unit::Generic);
#else
- return dfxgui_GetEffectInstance()->getparameterunit(inParameterIndex);
+ return dfxgui_GetEffectInstance()->getparameterunit(inParameterID);
#endif
}
@@ -1382,7 +1383,7 @@ size_t DfxGuiEditor::GetNumParameters()
}
//-----------------------------------------------------------------------------
-std::vector DfxGuiEditor::GetParameterList()
+std::vector DfxGuiEditor::GetParameterList() const
{
#ifdef TARGET_API_AUDIOUNIT
std::lock_guard const guard(mParameterListLock);
@@ -1403,7 +1404,7 @@ AudioUnitParameter DfxGuiEditor::dfxgui_MakeAudioUnitParameter(AudioUnitParamete
}
//-----------------------------------------------------------------------------
-std::vector DfxGuiEditor::CreateParameterList(AudioUnitScope inScope)
+std::vector DfxGuiEditor::CreateParameterList(AudioUnitScope inScope)
{
size_t dataSize {};
dfx::PropertyFlags propFlags {};
@@ -1434,7 +1435,7 @@ std::vector DfxGuiEditor::CreateParameterList(AudioUnitScope inScope)
mAUMaxParameterID = *std::max_element(parameterList.cbegin(), parameterList.cend());
- return std::vector(parameterList.cbegin(), parameterList.cend());
+ return std::vector(parameterList.cbegin(), parameterList.cend());
}
#endif
@@ -1729,71 +1730,66 @@ void DfxGuiEditor::resetmidilearn()
}
//-----------------------------------------------------------------------------
-void DfxGuiEditor::setmidilearner(long inParameterIndex)
+void DfxGuiEditor::setmidilearner(dfx::ParameterID inParameterID)
{
- if (dfxgui_IsValidParamID(inParameterIndex) && !getmidilearning())
+ if (dfxgui_IsValidParameterID(inParameterID) && !getmidilearning())
{
setmidilearning(true);
}
#ifdef TARGET_API_AUDIOUNIT
- dfxgui_SetProperty(dfx::kPluginProperty_MidiLearner, static_cast(inParameterIndex));
+ dfxgui_SetProperty(dfx::kPluginProperty_MidiLearner, static_cast(inParameterID));
#else
- dfxgui_GetEffectInstance()->setmidilearner(inParameterIndex);
+ dfxgui_GetEffectInstance()->setmidilearner(inParameterID);
#endif
}
//-----------------------------------------------------------------------------
-long DfxGuiEditor::getmidilearner()
+dfx::ParameterID DfxGuiEditor::getmidilearner()
{
#ifdef TARGET_API_AUDIOUNIT
- return dfxgui_GetProperty(dfx::kPluginProperty_MidiLearner).value_or(dfx::kParameterID_Invalid);
+ return dfxgui_GetProperty(dfx::kPluginProperty_MidiLearner).value_or(dfx::kParameterID_Invalid);
#else
return dfxgui_GetEffectInstance()->getmidilearner();
#endif
}
//-----------------------------------------------------------------------------
-bool DfxGuiEditor::ismidilearner(long inParameterIndex)
+bool DfxGuiEditor::ismidilearner(dfx::ParameterID inParameterID)
{
- return (getmidilearner() == inParameterIndex);
+ return (getmidilearner() == inParameterID);
}
//-----------------------------------------------------------------------------
-void DfxGuiEditor::setparametermidiassignment(long inParameterIndex, dfx::ParameterAssignment const& inAssignment)
+void DfxGuiEditor::setparametermidiassignment(dfx::ParameterID inParameterID, dfx::ParameterAssignment const& inAssignment)
{
#ifdef TARGET_API_AUDIOUNIT
- dfxgui_SetProperty(dfx::kPluginProperty_ParameterMidiAssignment, dfx::kScope_Global, inParameterIndex, inAssignment);
+ dfxgui_SetProperty(dfx::kPluginProperty_ParameterMidiAssignment, dfx::kScope_Global, inParameterID, inAssignment);
#else
- dfxgui_GetEffectInstance()->setparametermidiassignment(inParameterIndex, inAssignment);
+ dfxgui_GetEffectInstance()->setparametermidiassignment(inParameterID, inAssignment);
#endif
}
//-----------------------------------------------------------------------------
-dfx::ParameterAssignment DfxGuiEditor::getparametermidiassignment(long inParameterIndex)
+dfx::ParameterAssignment DfxGuiEditor::getparametermidiassignment(dfx::ParameterID inParameterID)
{
#ifdef TARGET_API_AUDIOUNIT
- auto const opt = dfxgui_GetProperty(dfx::kPluginProperty_ParameterMidiAssignment,
- dfx::kScope_Global,
- inParameterIndex);
- if (opt.has_value())
- {
- return *opt;
- }
-
+ auto const parameterAssignment = dfxgui_GetProperty(dfx::kPluginProperty_ParameterMidiAssignment,
+ dfx::kScope_Global,
+ inParameterID);
dfx::ParameterAssignment none;
none.mEventType = dfx::MidiEventType::None;
- return none;
+ return parameterAssignment.value_or(none);
#else
- return dfxgui_GetEffectInstance()->getparametermidiassignment(inParameterIndex);
+ return dfxgui_GetEffectInstance()->getparametermidiassignment(inParameterID);
#endif
}
//-----------------------------------------------------------------------------
-void DfxGuiEditor::parametermidiunassign(long inParameterIndex)
+void DfxGuiEditor::parametermidiunassign(dfx::ParameterID inParameterID)
{
dfx::ParameterAssignment parameterAssignment;
parameterAssignment.mEventType = dfx::MidiEventType::None;
- setparametermidiassignment(inParameterIndex, parameterAssignment);
+ setparametermidiassignment(inParameterID, parameterAssignment);
}
//-----------------------------------------------------------------------------
@@ -1837,7 +1833,7 @@ bool DfxGuiEditor::getMidiAssignmentsSteal()
}
//-----------------------------------------------------------------------------
-void DfxGuiEditor::TextEntryForParameterMidiCC(long inParameterID)
+void DfxGuiEditor::TextEntryForParameterMidiCC(dfx::ParameterID inParameterID)
{
if (!getFrame())
{
@@ -2035,10 +2031,10 @@ VSTGUI::COptionMenu DfxGuiEditor::createContextualMenu(IDGControl* inControl)
{
auto const addParameterSubMenu = [this, &resultMenu](IDGControl const* control)
{
- auto const paramID = control->getParameterID();
- if (auto const parameterSubMenu = createParameterContextualMenu(paramID))
+ auto const parameterID = control->getParameterID();
+ if (auto const parameterSubMenu = createParameterContextualMenu(parameterID))
{
- resultMenu.addEntry(parameterSubMenu, getparametername(paramID));
+ resultMenu.addEntry(parameterSubMenu, getparametername(parameterID));
}
};
addParameterSubMenu(inControl);
@@ -2124,9 +2120,9 @@ VSTGUI::COptionMenu DfxGuiEditor::createContextualMenu(IDGControl* inControl)
}
//-----------------------------------------------------------------------------
-VSTGUI::SharedPointer DfxGuiEditor::createParameterContextualMenu(long inParameterID)
+VSTGUI::SharedPointer DfxGuiEditor::createParameterContextualMenu(dfx::ParameterID inParameterID)
{
- assert(dfxgui_IsValidParamID(inParameterID));
+ assert(dfxgui_IsValidParameterID(inParameterID));
auto resultMenu = VSTGUI::makeOwned