Skip to content

Commit

Permalink
define named type dfx::ParameterID
Browse files Browse the repository at this point in the history
  • Loading branch information
sophiapoirier committed Oct 1, 2022
1 parent a0c076d commit 6608146
Show file tree
Hide file tree
Showing 75 changed files with 1,477 additions and 1,469 deletions.
5 changes: 3 additions & 2 deletions bufferoverride/bufferoverride-base.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <http:https://www.gnu.org/licenses/>.
To contact the author, use the contact form at http:https://destroyfx.org/
To contact the author, use the contact form at http:https://destroyfx.org
------------------------------------------------------------------------*/


Expand All @@ -25,12 +25,13 @@ To contact the author, use the contact form at http:https://destroyfx.org/
#include <atomic>
#include <type_traits>

#include "dfxdefines.h"
#include "dfxmisc.h"
#include "dfxpluginproperties.h"

//-----------------------------------------------------------------------------
// these are the plugin parameters:
enum
enum : dfx::ParameterID
{
kDivisor,
kBufferSize_MS,
Expand Down
4 changes: 2 additions & 2 deletions bufferoverride/bufferoverride.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <http:https://www.gnu.org/licenses/>.
To contact the author, use the contact form at http:https://destroyfx.org/
To contact the author, use the contact form at http:https://destroyfx.org
------------------------------------------------------------------------*/

#pragma once
Expand All @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions bufferoverride/bufferoverrideformalities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <http:https://www.gnu.org/licenses/>.
To contact the author, use the contact form at http:https://destroyfx.org/
To contact the author, use the contact form at http:https://destroyfx.org
------------------------------------------------------------------------*/

#include "bufferoverride-base.h"
Expand Down Expand Up @@ -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:
Expand Down
28 changes: 14 additions & 14 deletions bufferoverride/gui/bufferoverrideeditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <http:https://www.gnu.org/licenses/>.
To contact the author, use the contact form at http:https://destroyfx.org/
To contact the author, use the contact form at http:https://destroyfx.org
------------------------------------------------------------------------*/

#include "bufferoverrideeditor.h"
Expand Down Expand Up @@ -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<DfxGuiEditor*>(inEditor);
if (dgEditor->getparameter_b(tempoSyncParameterID))
Expand Down Expand Up @@ -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<DGSlider>(this, divisorLFORateTag, pos, dfx::kAxis_Horizontal, sliderHandleImage);
mDivisorLFORateSlider = emplaceControl<DGSlider>(this, divisorLFORateParameterID, pos, dfx::kAxis_Horizontal, sliderHandleImage);
mDivisorLFORateSlider->setAlternateHandle(sliderHandleImage_glowing);

pos.set(kDivisorLFODepthSliderX, kDivisorLFODepthSliderY, kLFOSliderWidth, kSliderHeight);
emplaceControl<DGSlider>(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<DGSlider>(this, bufferLFORateTag, pos, dfx::kAxis_Horizontal, sliderHandleImage);
mBufferLFORateSlider = emplaceControl<DGSlider>(this, bufferLFORateParameterID, pos, dfx::kAxis_Horizontal, sliderHandleImage);
mBufferLFORateSlider->setAlternateHandle(sliderHandleImage_glowing);

pos.set(kBufferLFODepthSliderX, kBufferLFODepthSliderY, kLFOSliderWidth, kSliderHeight);
Expand All @@ -323,9 +323,9 @@ long BufferOverrideEditor::OpenEditor()
pos.set(kTempoSliderX, kTempoSliderY, kTempoSliderWidth, kSliderHeight);
emplaceControl<DGSlider>(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<DGXYBox>(this, kDivisor, bufferSizeTag, pos, xyBoxHandleImage, nullptr,
mDivisorBufferBox = emplaceControl<DGXYBox>(this, kDivisor, bufferSizeParameterID, pos, xyBoxHandleImage, nullptr,
VSTGUI::CSliderBase::kLeft | VSTGUI::CSliderBase::kTop);
mDivisorBufferBox->setAlternateHandles(xyBoxHandleImage_divisor_glowing, xyBoxHandleImage_buffer_glowing);
mDivisorBufferBox->setIntegralPosition(true);
Expand All @@ -335,16 +335,16 @@ long BufferOverrideEditor::OpenEditor()
emplaceControl<DGTextDisplay>(this, kDivisor, pos, divisorDisplayProc, nullptr, nullptr, dfx::TextAlignment::Center, kValueDisplayFontSize * 2.0f, kLCDCyanTextColor, kValueDisplayFont);

pos.set(kBufferDisplayX, kBufferDisplayY, kOLEDDisplayWidth, kOLEDDisplayHeight);
mBufferSizeDisplay = emplaceControl<DGTextDisplay>(this, bufferSizeTag, pos, bufferSizeDisplayProc, this, nullptr, dfx::TextAlignment::Center, kValueDisplayFontSize * 2.0f, kLCDCyanTextColor, kValueDisplayFont);
mBufferSizeDisplay = emplaceControl<DGTextDisplay>(this, bufferSizeParameterID, pos, bufferSizeDisplayProc, this, nullptr, dfx::TextAlignment::Center, kValueDisplayFontSize * 2.0f, kLCDCyanTextColor, kValueDisplayFont);

pos.set(kDivisorLFORateDisplayX, kDivisorLFORateDisplayY, kLCDDisplayWidth, kLCDDisplayHeight);
mDivisorLFORateDisplay = emplaceControl<DGTextDisplay>(this, divisorLFORateTag, pos, divisorLFORateDisplayProc, this, nullptr, dfx::TextAlignment::Right, kValueDisplayFontSize, kLCDGreenTextColor, kValueDisplayFont);
mDivisorLFORateDisplay = emplaceControl<DGTextDisplay>(this, divisorLFORateParameterID, pos, divisorLFORateDisplayProc, this, nullptr, dfx::TextAlignment::Right, kValueDisplayFontSize, kLCDGreenTextColor, kValueDisplayFont);

pos.set(kDivisorLFODepthDisplayX, kDivisorLFODepthDisplayY, kLCDDisplayWidth, kLCDDisplayHeight);
emplaceControl<DGTextDisplay>(this, kDivisorLFODepth, pos, lfoDepthDisplayProc, nullptr, nullptr, dfx::TextAlignment::Right, kValueDisplayFontSize, kLCDGreenTextColor, kValueDisplayFont);

pos.set(kBufferLFORateDisplayX, kBufferLFORateDisplayY, kLCDDisplayWidth, kLCDDisplayHeight);
mBufferLFORateDisplay = emplaceControl<DGTextDisplay>(this, bufferLFORateTag, pos, bufferLFORateDisplayProc, this, nullptr, dfx::TextAlignment::Right, kValueDisplayFontSize, kLCDGreenTextColor, kValueDisplayFont);
mBufferLFORateDisplay = emplaceControl<DGTextDisplay>(this, bufferLFORateParameterID, pos, bufferLFORateDisplayProc, this, nullptr, dfx::TextAlignment::Right, kValueDisplayFontSize, kLCDGreenTextColor, kValueDisplayFont);

pos.set(kBufferLFODepthDisplayX, kBufferLFODepthDisplayY, kLCDDisplayWidth, kLCDDisplayHeight);
emplaceControl<DGTextDisplay>(this, kBufferLFODepth, pos, lfoDepthDisplayProc, nullptr, nullptr, dfx::TextAlignment::Right, kValueDisplayFontSize, kLCDGreenTextColor, kValueDisplayFont);
Expand Down Expand Up @@ -445,7 +445,7 @@ void BufferOverrideEditor::CloseEditor()


//-----------------------------------------------------------------------------
void BufferOverrideEditor::parameterChanged(long inParameterID)
void BufferOverrideEditor::parameterChanged(dfx::ParameterID inParameterID)
{
IDGControl* slider = nullptr;
DGTextDisplay* textDisplay = nullptr;
Expand All @@ -457,7 +457,7 @@ void BufferOverrideEditor::parameterChanged(long inParameterID)
case kBufferTempoSync:
{
HandleTempoSyncChange();
constexpr std::array<long, 2> parameterIDs = { kBufferSize_MS, kBufferSize_Sync };
constexpr std::array<dfx::ParameterID, 2> parameterIDs = { kBufferSize_MS, kBufferSize_Sync };
newParameterID = parameterIDs[useSyncParam];
slider = mDivisorBufferBox->getControlByParameterID(parameterIDs[!useSyncParam]);
textDisplay = mBufferSizeDisplay;
Expand Down Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions bufferoverride/gui/bufferoverrideeditor.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*------------------------------------------------------------------------
Copyright (C) 2001-2021 Sophia Poirier
Copyright (C) 2001-2022 Sophia Poirier
This file is part of Buffer Override.
Expand All @@ -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 <http:https://www.gnu.org/licenses/>.
To contact the author, use the contact form at http:https://destroyfx.org/
To contact the author, use the contact form at http:https://destroyfx.org
------------------------------------------------------------------------*/

#pragma once
Expand All @@ -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:
Expand Down
7 changes: 5 additions & 2 deletions dfx-library/dfxdefines.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <http:https://www.gnu.org/licenses/>.
To contact the author, use the contact form at http:https://destroyfx.org/
To contact the author, use the contact form at http:https://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
Expand Down Expand Up @@ -100,11 +100,14 @@ somewhere in the include tree for every file for a DfxPlugin.
#ifdef __cplusplus

#include <cstddef>
#include <limits>

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<ParameterID>::max();

static constexpr size_t kParameterNameMaxLength = 64;
static constexpr size_t kPresetNameMaxLength = 64;
Expand Down
10 changes: 5 additions & 5 deletions dfx-library/dfxparameter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <http:https://www.gnu.org/licenses/>.
To contact the author, use the contact form at http:https://destroyfx.org/
To contact the author, use the contact form at http:https://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.
Expand Down Expand Up @@ -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<long>(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<long>(mValues.size())))
if (inParameterIndex < mValues.size())
{
return mValues[inParameterIndex];
}
Expand Down
6 changes: 3 additions & 3 deletions dfx-library/dfxparameter.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <http:https://www.gnu.org/licenses/>.
To contact the author, use the contact form at http:https://destroyfx.org/
To contact the author, use the contact form at http:https://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.
Expand Down Expand Up @@ -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
{
Expand Down

0 comments on commit 6608146

Please sign in to comment.