From 961e82c1e387ce5a12f5fea779b8d345cad4a20b Mon Sep 17 00:00:00 2001 From: Keith Shepherd Date: Sun, 29 Dec 2024 13:24:35 -0500 Subject: [PATCH] Fixed Preset Storage and Binned Values There were a number of bugs with how parameters were being stored after the underlying storage was changed to use 32bit values instead of 8bit. Fixed the bugs and updated the parameters for all effects to be able to use floats where necessary. --- .../Effect-Modules/autopan_module.cpp | 24 ++- .../Effect-Modules/base_effect_module.cpp | 172 ++++++++++-------- .../Effect-Modules/base_effect_module.h | 69 ++++--- .../Effect-Modules/chopper_module.cpp | 22 +-- .../Effect-Modules/chorus_module.cpp | 36 ++-- .../Effect-Modules/compressor_module.cpp | 30 +-- .../Effect-Modules/crusher_module.cpp | 18 +- .../Effect-Modules/looper_module.cpp | 14 +- .../Effect-Modules/metro_module.cpp | 16 +- .../modulated_tremolo_module.cpp | 24 ++- .../Effect-Modules/multi_delay_module.cpp | 64 +++---- .../Effect-Modules/overdrive_module.cpp | 18 +- .../Effect-Modules/pitch_shifter_module.cpp | 30 +-- .../Effect-Modules/reverb_delay_module.cpp | 123 +++++++------ .../Effect-Modules/reverb_module.cpp | 30 +-- .../Effect-Modules/tuner_module.cpp | 2 +- Software/GuitarPedal/UI/CustomMappedValues.h | 2 +- Software/GuitarPedal/UI/guitar_pedal_ui.cpp | 20 +- Software/GuitarPedal/guitar_pedal_storage.cpp | 20 +- Software/GuitarPedal/guitar_pedal_storage.h | 4 +- 20 files changed, 394 insertions(+), 344 deletions(-) diff --git a/Software/GuitarPedal/Effect-Modules/autopan_module.cpp b/Software/GuitarPedal/Effect-Modules/autopan_module.cpp index 6eea15c..fe77522 100644 --- a/Software/GuitarPedal/Effect-Modules/autopan_module.cpp +++ b/Software/GuitarPedal/Effect-Modules/autopan_module.cpp @@ -7,20 +7,26 @@ static const char *s_waveBinNames[8] = {"Sine", "Triangle", "Saw", "Ramp", "Squa static const int s_paramCount = 4; static const ParameterMetaData s_metaData[s_paramCount] = { - {name : "Wet", valueType : ParameterValueType::FloatMagnitude, defaultValue : 127, knobMapping : 0, midiCCMapping : 20}, + {name : "Wet", valueType : ParameterValueType::Float, defaultValue : {.float_value = 1.0f}, knobMapping : 0, midiCCMapping : 20}, { name : "Osc Wave", valueType : ParameterValueType::Binned, valueBinCount : 8, valueBinNames : s_waveBinNames, - defaultValue : 0, + defaultValue : {.uint_value = 0}, knobMapping : 2, midiCCMapping : 21 }, - {name : "Osc Freq", valueType : ParameterValueType::FloatMagnitude, defaultValue : 12, knobMapping : 1, midiCCMapping : 1}, + { + name : "Osc Freq", + valueType : ParameterValueType::Float, + defaultValue : {.float_value = 0.1f}, + knobMapping : 1, + midiCCMapping : 1 + }, {name : "Stereo", valueType : ParameterValueType::Bool, - defaultValue : 0, + defaultValue : {.uint_value = 0}, knobMapping : -1, midiCCMapping : 23}}; // 0 is Mono (even if fed stereo) 1 is Stereo @@ -56,7 +62,7 @@ void AutoPanModule::ProcessMono(float in) { // Calculate Pan Oscillation m_freqOsc.SetWaveform(GetParameterAsBinnedValue(1) - 1); m_freqOsc.SetAmp(0.5f); - m_freqOsc.SetFreq(m_freqOscFreqMin + (GetParameterAsMagnitude(2) * m_freqOscFreqMax)); + m_freqOsc.SetFreq(m_freqOscFreqMin + (GetParameterAsFloat(2) * m_freqOscFreqMax)); float mod = 0.5f + m_freqOsc.Process(); if (GetParameterRaw(2) == 0) { @@ -75,8 +81,8 @@ void AutoPanModule::ProcessMono(float in) { float audioRightWet = m_audioRight * (r * (cosf(angle) + sinf(angle))); // Handle the wet / dry mix - m_audioLeft = audioLeftWet * GetParameterAsMagnitude(0) + m_audioLeft * (1.0f - GetParameterAsMagnitude(0)); - m_audioRight = audioRightWet * GetParameterAsMagnitude(0) + m_audioRight * (1.0f - GetParameterAsMagnitude(0)); + m_audioLeft = audioLeftWet * GetParameterAsFloat(0) + m_audioLeft * (1.0f - GetParameterAsFloat(0)); + m_audioRight = audioRightWet * GetParameterAsFloat(0) + m_audioRight * (1.0f - GetParameterAsFloat(0)); } void AutoPanModule::ProcessStereo(float inL, float inR) { @@ -100,8 +106,8 @@ void AutoPanModule::ProcessStereo(float inL, float inR) { float audioRightWet = 0.5f * (1.0f - adjustedPan) * mSignal - sSignal; // Handle the wet / dry mix - m_audioLeft = audioLeftWet * GetParameterAsMagnitude(0) + m_audioLeft * (1.0f - GetParameterAsMagnitude(0)); - m_audioRight = audioRightWet * GetParameterAsMagnitude(0) + m_audioRight * (1.0f - GetParameterAsMagnitude(0)); + m_audioLeft = audioLeftWet * GetParameterAsFloat(0) + m_audioLeft * (1.0f - GetParameterAsFloat(0)); + m_audioRight = audioRightWet * GetParameterAsFloat(0) + m_audioRight * (1.0f - GetParameterAsFloat(0)); } void AutoPanModule::SetTempo(uint32_t bpm) { diff --git a/Software/GuitarPedal/Effect-Modules/base_effect_module.cpp b/Software/GuitarPedal/Effect-Modules/base_effect_module.cpp index f00b0e7..f462367 100644 --- a/Software/GuitarPedal/Effect-Modules/base_effect_module.cpp +++ b/Software/GuitarPedal/Effect-Modules/base_effect_module.cpp @@ -39,10 +39,13 @@ void BaseEffectModule::InitParams(int count) { // Init all parameters to their default value or zero if there is no meta data for (int i = 0; i < m_paramCount; i++) { if (m_paramMetaData != NULL) { - if (GetParameterType(i) == ParameterValueType::FloatMagnitude) { - SetParameterAsFloat(i, (float)m_paramMetaData[i].defaultValue); + if ((ParameterValueType)GetParameterType(i) == ParameterValueType::Float) { + uint32_t tmp; + float value = m_paramMetaData[i].defaultValue.float_value; + std::memcpy(&tmp, &value, sizeof(float)); + m_params[i] = tmp; } else { - m_params[i] = m_paramMetaData[i].defaultValue; + m_params[i] = m_paramMetaData[i].defaultValue.uint_value; } } else { @@ -90,8 +93,8 @@ int BaseEffectModule::GetParameterBinCount(int parameter_id) { return -1; } - // Make sure this is a Binned Int type parameter - if (m_paramMetaData[parameter_id].valueType != 3) { + // Check to see if this is a binned type, if not return -1 + if ((ParameterValueType)GetParameterType(parameter_id) != ParameterValueType::Binned) { return -1; } @@ -105,71 +108,56 @@ const char **BaseEffectModule::GetParameterBinNames(int parameter_id) { } // Make sure this is a Binned Int type parameter - if (m_paramMetaData[parameter_id].valueType != 3) { + int binCount = GetParameterBinCount(parameter_id); + + // If this is not a binned value type aways return NULL + if (binCount == -1) { return NULL; } return m_paramMetaData[parameter_id].valueBinNames; } -uint8_t BaseEffectModule::GetParameterRaw(int parameter_id) { +const float BaseEffectModule::GetParameterDefaultValueAsFloat(int parameter_id) { // Make sure parameter_id is valid. - if (m_params == NULL || parameter_id < 0 || parameter_id >= m_paramCount) { - return 0; + if (m_params == NULL || parameter_id < 0 || parameter_id >= m_paramCount || m_paramMetaData == NULL) { + return 0.0f; } - return m_params[parameter_id]; + return m_paramMetaData[parameter_id].defaultValue.float_value; } -float BaseEffectModule::GetParameterAsMagnitude(int parameter_id) { - if (GetParameterType(parameter_id) == ParameterValueType::FloatMagnitude) { - return GetParameterAsFloat(parameter_id) / (float)GetParameterMax(parameter_id); - } else { - return (float)GetParameterRaw(parameter_id) / ((float)GetParameterMax(parameter_id)); +uint32_t BaseEffectModule::GetParameterRaw(int parameter_id) { + // Make sure parameter_id is valid. + if (m_params == NULL || parameter_id < 0 || parameter_id >= m_paramCount) { + return 0; } + + return m_params[parameter_id]; } float BaseEffectModule::GetParameterAsFloat(int parameter_id) { - float ret; - uint32_t tmp = m_params[parameter_id]; if (parameter_id >= 0 || parameter_id < m_paramCount) { + float ret; + uint32_t tmp = m_params[parameter_id]; std::memcpy(&ret, &tmp, sizeof(float)); return ret; } return -1.0f; } -void BaseEffectModule::SetParameterAsFloat(int parameter_id, float f) { - if (parameter_id >= 0 || parameter_id < m_paramCount) { - uint32_t tmp; - std::memcpy(&tmp, &f, sizeof(float)); - // Only update the value if it changed. - if (tmp != m_params[parameter_id]) { - m_params[parameter_id] = tmp; - - // Notify anyone listening if the parameter actually changed. - ParameterChanged(parameter_id); - } - } -} - -bool BaseEffectModule::GetParameterAsBool(int parameter_id) { return (GetParameterRaw(parameter_id) > 63); } +bool BaseEffectModule::GetParameterAsBool(int parameter_id) { return (GetParameterRaw(parameter_id) > 0); } int BaseEffectModule::GetParameterAsBinnedValue(int parameter_id) { int binCount = GetParameterBinCount(parameter_id); - // Make this is a binned value + // If this is not a binned value type aways return 1 if (binCount == -1) { return 1; } - // Get the Bin number from a raw value stored as 0..127 - float binSize = 128.0f / binCount; - float midPoint = (0.5f - (1.0f / 128.0f)); - float offset = (1.0f / 128.0f); - - // Calculate the bin - int bin = (int)(((GetParameterRaw(parameter_id) + midPoint) / binSize) + offset) + 1; + // Calculate the bin as raw stored value + 1 + int bin = (int)(GetParameterRaw(parameter_id) + 1); // A little sanity checking, make sure the bin is clamped to 1..BinCount if (bin < 1) { @@ -236,11 +224,6 @@ void BaseEffectModule::SetParameterRaw(int parameter_id, uint32_t value) { return; } - // Make sure the value is valid. - if (value < (uint32_t)GetParameterMin(parameter_id) || value > (uint32_t)GetParameterMax(parameter_id)) { - return; - } - // Only update the value if it changed. if (value != m_params[parameter_id]) { m_params[parameter_id] = value; @@ -253,54 +236,91 @@ void BaseEffectModule::SetParameterRaw(int parameter_id, uint32_t value) { void BaseEffectModule::SetParameterAsMagnitude(int parameter_id, float value) { int min = GetParameterMin(parameter_id); int max = GetParameterMax(parameter_id); - // Make sure the value is in the valid range. - if (value < 0.0f) { - SetParameterRaw(parameter_id, min); - return; - } else if (value > 1.0f) { - SetParameterRaw(parameter_id, max); - return; - } - if (GetParameterType(parameter_id) == ParameterValueType::FloatMagnitude) { + + // Handle different ParameterValueTypes Correctly + ParameterValueType paramType = (ParameterValueType)GetParameterType(parameter_id); + + if (paramType == ParameterValueType::Raw) { + // Make sure the value is in the valid range. + if (value < 0.0f) { + SetParameterRaw(parameter_id, min); + return; + } else if (value > 1.0f) { + SetParameterRaw(parameter_id, max); + return; + } + } else if (paramType == ParameterValueType::Float) { + // Make sure the value is in the valid range. + if (value < 0.0f) { + SetParameterAsFloat(parameter_id, min); + return; + } else if (value > 1.0f) { + SetParameterAsFloat(parameter_id, max); + return; + } + + // Use the 0..1 magnitue to set the underlying value to between min..max float tmp = (value * ((float)max - (float)min) + (float)min); SetParameterAsFloat(parameter_id, tmp); - } else { - SetParameterRaw(parameter_id, (uint32_t)(value * (max - min) + min)); + } else if (paramType == ParameterValueType::Bool) { + // Set the Bool Value to False if the magnitude is less then 0.5f, true otherwise + if (value < 0.5f) { + SetParameterAsBool(parameter_id, false); + return; + } else { + SetParameterAsBool(parameter_id, true); + return; + } + } else if (paramType == ParameterValueType::Binned) { + // Make sure the value is in the valid range. + if (value < 0.0f) { + SetParameterAsBinnedValue(parameter_id, 1); + return; + } else if (value > 1.0f) { + SetParameterAsBinnedValue(parameter_id, GetParameterBinCount(parameter_id)); + return; + } + + // Map values 0..1 to the bins equally + int mappedBin = (int)(value * GetParameterBinCount(parameter_id) + 1); + SetParameterAsBinnedValue(parameter_id, mappedBin); + } +} + +void BaseEffectModule::SetParameterAsFloat(int parameter_id, float value) { + if (parameter_id >= 0 || parameter_id < m_paramCount) { + uint32_t tmp; + std::memcpy(&tmp, &value, sizeof(float)); + + // Only update the value if it changed. + if (tmp != m_params[parameter_id]) { + m_params[parameter_id] = tmp; + + // Notify anyone listening if the parameter actually changed. + ParameterChanged(parameter_id); + } } } void BaseEffectModule::SetParameterAsBool(int parameter_id, bool value) { if (value) { - SetParameterRaw(parameter_id, GetParameterMax(parameter_id)); + // Set raw value to 1 for True + SetParameterRaw(parameter_id, 1U); } else { - SetParameterRaw(parameter_id, GetParameterMin(parameter_id)); + // Set raw value to 0 for False + SetParameterRaw(parameter_id, 0U); } } -void BaseEffectModule::SetParameterAsBinnedValue(int parameter_id, u_int8_t bin) { +void BaseEffectModule::SetParameterAsBinnedValue(int parameter_id, int value) { int binCount = GetParameterBinCount(parameter_id); // Make sure that this is a binned type value and we're within range - if (binCount == -1 || bin < 1 || bin > binCount) { + if (binCount == -1 || value < 1 || value > binCount) { return; } - // Map the Bin number into a raw value mapped in 0..127 - float binSize = 128.0f / binCount; - - // Calculate the raw value - int rawValue = (int)(((bin - 1) * binSize) + (binSize / 2.0f)); - - // A little sanity checking to make sure the raw value is within proper range - if (rawValue < 0) { - rawValue = 0; - } - - if (rawValue > 127) { - rawValue = 127; - } - - SetParameterRaw(parameter_id, rawValue); + SetParameterRaw(parameter_id, value - 1); } void BaseEffectModule::ProcessMono(float in) { diff --git a/Software/GuitarPedal/Effect-Modules/base_effect_module.h b/Software/GuitarPedal/Effect-Modules/base_effect_module.h index 69186c5..56a9d5c 100644 --- a/Software/GuitarPedal/Effect-Modules/base_effect_module.h +++ b/Software/GuitarPedal/Effect-Modules/base_effect_module.h @@ -14,13 +14,18 @@ namespace bkshepherd { /** Parameter Value Types */ enum ParameterValueType { - Raw, // Raw Parameter Value (0 .. 127) - FloatMagnitude, // Float Magnitude Value (0.0f - 1.0f) + Raw, // Raw 32bit Unsigned Int Parameter Value + Float, // Float Value Bool, // Boolean Value Binned, // Binned Value (1 to valueBinCount) ParameterValueType_LAST, // Last enum item }; +union ParameterValue { + uint32_t uint_value; + float float_value; +}; + // Meta data for an individual Effect Parameter. Effects may have zero or more Parameters. // This data structure contains information about the Effect Parameter. struct ParameterMetaData { @@ -28,11 +33,11 @@ struct ParameterMetaData { ParameterValueType valueType; // The Type of this Parameter value. int valueBinCount; // The number of distinct choices allowed for this parameter value const char **valueBinNames; // The human readable display names for the bins - int defaultValue; // The Default Value set for this parameter the first time the device is powered up - int knobMapping; // The ID of the Physical Knob mapped to this Parameter. -1 if this Parameter is not controlled by a Knob - int midiCCMapping; // The Midi CC ID mapped to this Parameter. -1 of this Parameter is not controllable via Midi CC messages - int minValue = 0; // The minimum value of the parameter - int maxValue = 127; // The maximum value of the parameter + ParameterValue defaultValue; // The Raw Default Value set for this parameter the first time the device is powered up + int knobMapping; // The ID of the Physical Knob mapped to this Parameter. -1 if this Parameter is not controlled by a Knob + int midiCCMapping; // The Midi CC ID mapped to this Parameter. -1 of this Parameter is not controllable via Midi CC messages + int minValue = 0; // The minimum value of the parameter + int maxValue = 1; // The maximum value of the parameter float fineStepSize = 0.01f; // For Float Parameters, this will set the fineStepSize multiple in the menu }; @@ -92,13 +97,13 @@ class BaseEffectModule { const char *GetParameterName(int parameter_id); /** Gets the Type of an Effect Parameter - \return an int representing Type of the Effect Parameter. 0 is raw u_int8_t, 1 is Float Magnitude, 2 is Bool, 3 is Binned Int + \return an int representing Type of the Effect Parameter. 0 is raw u_int32_t, 1 is Float, 2 is Bool, 3 is Binned Int (return -1 is this is unknown) */ int GetParameterType(int parameter_id); /** Gets the Bin Count of a Binned Int Effect Parameter - \return the number of Bins for this Binned Int type Efffect Parameter or -1 if this isn't a Binned Int type parameter + \return the number of Bins for this Binned Int type Effect Parameter or -1 if this isn't a Binned Int type parameter */ int GetParameterBinCount(int parameter_id); @@ -108,17 +113,23 @@ class BaseEffectModule { */ const char **GetParameterBinNames(int parameter_id); - /** Gets the Raw uint8_t value of an Effect Parameter + /** Gets the Default Value for an Effect Parameter as a Float value \param parameter_id Id of the parameter to retrieve. - \return the Value (0..127) of the specified parameter. + \return the float Value of the specified parameter. */ - uint8_t GetParameterRaw(int parameter_id); + const float GetParameterDefaultValueAsFloat(int parameter_id); - /** Gets the value of an Effect Parameter as a magnitude mapped to a float 0..1 + /** Gets the Raw uint32_t value of an Effect Parameter \param parameter_id Id of the parameter to retrieve. - \return the Value of the specified parameter mapped to a float (0..1) + \return the raw Value of the specified parameter. */ - float GetParameterAsMagnitude(int parameter_id); + uint32_t GetParameterRaw(int parameter_id); + + /** Gets the value of an Effect Parameter as a float + \param parameter_id Id of the parameter to retrieve. + \return the float Value for given parameter. + */ + float GetParameterAsFloat(int parameter_id); /** Gets the value of an Effect Parameter as a bool (True of False) \param parameter_id Id of the parameter to retrieve. @@ -146,15 +157,23 @@ class BaseEffectModule { /** Sets the Raw Value for a Particular Effect Parameter. If the Parameter ID isn't valid, there is no effect. \param parameter_id Id of the parameter to set (0 .. m_paramCount - 1). - \param value Value to set on the parameter. + \param value the uint32_t Value to set on the parameter. */ void SetParameterRaw(int parameter_id, uint32_t value); /** Sets the Value for a Particular Effect Parameter using a float magnitude (0..1). If the Parameter ID isn't valid, there is no - effect. \param parameter_id Id of the parameter to set. \param value the float magnitude value to set the parameter to. + effect. + \param parameter_id Id of the parameter to set. + \param value the float magnitude value to set the parameter to. */ void SetParameterAsMagnitude(int parameter_id, float value); + /** Sets the Value for a Particular Effect Parameter using a float. If the Parameter ID isn't valid, there is no effect. + \param parameter_id Id of the parameter to set. + \param value the Float value to set the paramter to. + */ + void SetParameterAsFloat(int parameter_id, float value); + /** Sets the Value for a Particular Effect Parameter using a bool. If the Parameter ID isn't valid, there is no effect. \param parameter_id Id of the parameter to set. \param value the bool value to set the paramter to. @@ -165,7 +184,7 @@ class BaseEffectModule { \param parameter_id Id of the parameter to set. \param value the int value (1..Bin Count) of the bin to set the paramter to. */ - void SetParameterAsBinnedValue(int parameter_id, u_int8_t bin); + void SetParameterAsBinnedValue(int parameter_id, int value); /** Processes the Effect in Mono for a single sample. This should only be called once per sample. Also, if this is called, don't call ProcessStereo too. \param in Input sample. @@ -233,14 +252,6 @@ class BaseEffectModule { */ int GetParameterMax(int parameter_id); - void SetParameterAsFloat(int parameter_id, float f); - - /** Gets the parameter id as a float value - \param parameter_id Id of the parameter to set (0 .. m_paramCount - 1). - \return float value for given parameter. - */ - float GetParameterAsFloat(int parameter_id); - /** Gets the Fine Step size for the parameter id as a float value \param parameter_id Id of the parameter to set (0 .. m_paramCount - 1). \return Fine step size for given parameter. @@ -256,11 +267,11 @@ class BaseEffectModule { */ virtual bool AlternateFootswitchForTempo() const { return true; }; /** Overridable callback when alternate footswitch is pressed */ - virtual void AlternateFootswitchPressed(){}; + virtual void AlternateFootswitchPressed() {}; /** Overridable callback when alternate footswitch is released */ - virtual void AlternateFootswitchReleased(){}; + virtual void AlternateFootswitchReleased() {}; /** Overridable callback when alternate footswitch is held for 1 second */ - virtual void AlternateFootswitchHeldFor1Second(){}; + virtual void AlternateFootswitchHeldFor1Second() {}; protected: /** Initializes the Parameter Storage and creates space for the specified number of stored Effect Parameters diff --git a/Software/GuitarPedal/Effect-Modules/chopper_module.cpp b/Software/GuitarPedal/Effect-Modules/chopper_module.cpp index c31ba30..0dca3a5 100644 --- a/Software/GuitarPedal/Effect-Modules/chopper_module.cpp +++ b/Software/GuitarPedal/Effect-Modules/chopper_module.cpp @@ -6,25 +6,25 @@ using namespace bkshepherd; static const int s_paramCount = 4; static const ParameterMetaData s_metaData[s_paramCount] = {{ name : "Wet", - valueType : ParameterValueType::FloatMagnitude, + valueType : ParameterValueType::Float, valueBinCount : 0, - defaultValue : 63, + defaultValue : {.float_value = 0.5f}, knobMapping : 0, midiCCMapping : 20 }, { name : "Tempo", - valueType : ParameterValueType::FloatMagnitude, + valueType : ParameterValueType::Float, valueBinCount : 0, - defaultValue : 63, + defaultValue : {.float_value = 0.5f}, knobMapping : 1, midiCCMapping : 23 }, { name : "Duty", - valueType : ParameterValueType::FloatMagnitude, + valueType : ParameterValueType::Float, valueBinCount : 0, - defaultValue : 38, + defaultValue : {.float_value = 0.25f}, knobMapping : 2, midiCCMapping : 24 }, @@ -32,7 +32,7 @@ static const ParameterMetaData s_metaData[s_paramCount] = {{ name : "Pattern", valueType : ParameterValueType::Binned, valueBinCount : 14, - defaultValue : 0, + defaultValue : {.uint_value = 0}, knobMapping : 3, midiCCMapping : 25 }}; @@ -68,9 +68,9 @@ void ChopperModule::ProcessMono(float in) { BaseEffectModule::ProcessMono(in); // Setup the Effect - m_chopper.SetFreq(m_tempoFreqMin + (GetParameterAsMagnitude(1) * (m_tempoFreqMax - m_tempoFreqMin))); + m_chopper.SetFreq(m_tempoFreqMin + (GetParameterAsFloat(1) * (m_tempoFreqMax - m_tempoFreqMin))); m_chopper.SetAmp(1.0f); - m_chopper.SetPw(m_pulseWidthMin + (GetParameterAsMagnitude(2) * (m_pulseWidthMax - m_pulseWidthMin))); + m_chopper.SetPw(m_pulseWidthMin + (GetParameterAsFloat(2) * (m_pulseWidthMax - m_pulseWidthMin))); m_chopper.SetPattern(GetParameterAsBinnedValue(3) - 1); // Calculate the Effect @@ -80,7 +80,7 @@ void ChopperModule::ProcessMono(float in) { float audioLeftWet = m_cachedEffectMagnitudeValue * m_audioLeft; // Handle the wet / dry mix - m_audioLeft = audioLeftWet * GetParameterAsMagnitude(0) + m_audioLeft * (1.0f - GetParameterAsMagnitude(0)); + m_audioLeft = audioLeftWet * GetParameterAsFloat(0) + m_audioLeft * (1.0f - GetParameterAsFloat(0)); m_audioRight = m_audioLeft; } @@ -96,7 +96,7 @@ void ChopperModule::ProcessStereo(float inL, float inR) { float audioRightWet = m_cachedEffectMagnitudeValue * m_audioRight; // Handle the wet / dry mix - m_audioRight = audioRightWet * GetParameterAsMagnitude(0) + m_audioRight * (1.0f - GetParameterAsMagnitude(0)); + m_audioRight = audioRightWet * GetParameterAsFloat(0) + m_audioRight * (1.0f - GetParameterAsFloat(0)); } void ChopperModule::SetTempo(uint32_t bpm) { diff --git a/Software/GuitarPedal/Effect-Modules/chorus_module.cpp b/Software/GuitarPedal/Effect-Modules/chorus_module.cpp index d0932c3..d05226a 100644 --- a/Software/GuitarPedal/Effect-Modules/chorus_module.cpp +++ b/Software/GuitarPedal/Effect-Modules/chorus_module.cpp @@ -5,41 +5,41 @@ using namespace bkshepherd; static const int s_paramCount = 5; static const ParameterMetaData s_metaData[s_paramCount] = {{ name : "Wet", - valueType : ParameterValueType::FloatMagnitude, + valueType : ParameterValueType::Float, valueBinCount : 0, - defaultValue : 83, + defaultValue : {.float_value = 0.65f}, knobMapping : 0, midiCCMapping : 20 }, { name : "Delay", - valueType : ParameterValueType::FloatMagnitude, + valueType : ParameterValueType::Float, valueBinCount : 0, - defaultValue : 64, + defaultValue : {.float_value = 0.5f}, knobMapping : 1, midiCCMapping : 21 }, { name : "LFO Freq", - valueType : ParameterValueType::FloatMagnitude, + valueType : ParameterValueType::Float, valueBinCount : 0, - defaultValue : 35, + defaultValue : {.float_value = 0.25f}, knobMapping : 2, midiCCMapping : 22 }, { name : "LFO Depth", - valueType : ParameterValueType::FloatMagnitude, + valueType : ParameterValueType::Float, valueBinCount : 0, - defaultValue : 40, + defaultValue : {.float_value = 0.3f}, knobMapping : 3, midiCCMapping : 23 }, { name : "Feedback", - valueType : ParameterValueType::FloatMagnitude, + valueType : ParameterValueType::Float, valueBinCount : 0, - defaultValue : 30, + defaultValue : {.float_value = 0.25f}, knobMapping : 4, midiCCMapping : 24 }}; @@ -74,15 +74,15 @@ void ChorusModule::ProcessMono(float in) { BaseEffectModule::ProcessMono(in); // Calculate the effect - m_chorus.SetDelay(GetParameterAsMagnitude(1)); - m_chorus.SetLfoFreq(m_lfoFreqMin + (GetParameterAsMagnitude(2) * GetParameterAsMagnitude(2) * (m_lfoFreqMax - m_lfoFreqMin))); - m_chorus.SetLfoDepth(GetParameterAsMagnitude(3)); - m_chorus.SetFeedback(GetParameterAsMagnitude(4)); + m_chorus.SetDelay(GetParameterAsFloat(1)); + m_chorus.SetLfoFreq(m_lfoFreqMin + (GetParameterAsFloat(2) * GetParameterAsFloat(2) * (m_lfoFreqMax - m_lfoFreqMin))); + m_chorus.SetLfoDepth(GetParameterAsFloat(3)); + m_chorus.SetFeedback(GetParameterAsFloat(4)); m_chorus.Process(m_audioLeft); - m_audioLeft = m_chorus.GetLeft() * GetParameterAsMagnitude(0) + m_audioLeft * (1.0f - GetParameterAsMagnitude(0)); - m_audioRight = m_chorus.GetRight() * GetParameterAsMagnitude(0) + m_audioRight * (1.0f - GetParameterAsMagnitude(0)); + m_audioLeft = m_chorus.GetLeft() * GetParameterAsFloat(0) + m_audioLeft * (1.0f - GetParameterAsFloat(0)); + m_audioRight = m_chorus.GetRight() * GetParameterAsFloat(0) + m_audioRight * (1.0f - GetParameterAsFloat(0)); } void ChorusModule::ProcessStereo(float inL, float inR) { @@ -93,14 +93,14 @@ void ChorusModule::ProcessStereo(float inL, float inR) { BaseEffectModule::ProcessStereo(m_audioLeft, inR); // Calculate the effect - m_audioRight = m_chorus.GetRight() * GetParameterAsMagnitude(0) + m_audioRight * (1.0f - GetParameterAsMagnitude(0)); + m_audioRight = m_chorus.GetRight() * GetParameterAsFloat(0) + m_audioRight * (1.0f - GetParameterAsFloat(0)); } float ChorusModule::GetBrightnessForLED(int led_id) { float value = BaseEffectModule::GetBrightnessForLED(led_id); if (led_id == 1) { - return value * GetParameterAsMagnitude(0); + return value * GetParameterAsFloat(0); } return value; diff --git a/Software/GuitarPedal/Effect-Modules/compressor_module.cpp b/Software/GuitarPedal/Effect-Modules/compressor_module.cpp index fa98857..c346eac 100644 --- a/Software/GuitarPedal/Effect-Modules/compressor_module.cpp +++ b/Software/GuitarPedal/Effect-Modules/compressor_module.cpp @@ -6,41 +6,41 @@ static const int s_paramCount = 5; static const ParameterMetaData s_metaData[s_paramCount] = { { name : "Level", - valueType : ParameterValueType::FloatMagnitude, + valueType : ParameterValueType::Float, valueBinCount : 0, - defaultValue : 64, + defaultValue : {.float_value = 0.5f}, knobMapping : 0, midiCCMapping : -1 }, { name : "Ratio", - valueType : ParameterValueType::FloatMagnitude, + valueType : ParameterValueType::Float, valueBinCount : 0, - defaultValue : 64, + defaultValue : {.float_value = 0.5f}, knobMapping : 1, midiCCMapping : -1 }, { name : "Thresh", - valueType : ParameterValueType::FloatMagnitude, + valueType : ParameterValueType::Float, valueBinCount : 0, - defaultValue : 64, + defaultValue : {.float_value = 0.5f}, knobMapping : 2, midiCCMapping : -1 }, { name : "Attack", - valueType : ParameterValueType::FloatMagnitude, + valueType : ParameterValueType::Float, valueBinCount : 0, - defaultValue : 64, + defaultValue : {.float_value = 0.5f}, knobMapping : 3, midiCCMapping : -1 }, { name : "Release", - valueType : ParameterValueType::FloatMagnitude, + valueType : ParameterValueType::Float, valueBinCount : 0, - defaultValue : 64, + defaultValue : {.float_value = 0.5f}, knobMapping : 4, midiCCMapping : -1 }, @@ -74,14 +74,14 @@ void CompressorModule::ParameterChanged(int parameter_id) { case 1: { const float ratioMin = 1.0f; const float ratioMax = 40.0f; - float ratio = ratioMin + (GetParameterAsMagnitude(1) * (ratioMax - ratioMin)); + float ratio = ratioMin + (GetParameterAsFloat(1) * (ratioMax - ratioMin)); m_compressor.SetRatio(ratio); break; } case 2: { const float thresholdMin = 0.0f; const float thresholdMax = 80.0f; - float threshold = thresholdMin + (GetParameterAsMagnitude(2) * (thresholdMax - thresholdMin)); + float threshold = thresholdMin + (GetParameterAsFloat(2) * (thresholdMax - thresholdMin)); // This is in dB so it is supposed to be 0dB to -80dB m_compressor.SetThreshold(-threshold); break; @@ -89,14 +89,14 @@ void CompressorModule::ParameterChanged(int parameter_id) { case 3: { const float attackMin = 0.001f; const float attackMax = 10.0f; - float attack = attackMin + (GetParameterAsMagnitude(3) * (attackMax - attackMin)); + float attack = attackMin + (GetParameterAsFloat(3) * (attackMax - attackMin)); m_compressor.SetAttack(attack); break; } case 4: { const float releaseMin = 0.001f; const float releaseMax = 10.0f; - float release = releaseMin + (GetParameterAsMagnitude(4) * (releaseMax - releaseMin)); + float release = releaseMin + (GetParameterAsFloat(4) * (releaseMax - releaseMin)); m_compressor.SetRelease(release); break; } @@ -106,7 +106,7 @@ void CompressorModule::ParameterChanged(int parameter_id) { void CompressorModule::ProcessMono(float in) { const float compressor_out = m_compressor.Process(in); - const float level = m_levelMin + (GetParameterAsMagnitude(0) * (m_levelMax - m_levelMin)); + const float level = m_levelMin + (GetParameterAsFloat(0) * (m_levelMax - m_levelMin)); m_audioLeft = compressor_out * level; m_audioRight = m_audioLeft; diff --git a/Software/GuitarPedal/Effect-Modules/crusher_module.cpp b/Software/GuitarPedal/Effect-Modules/crusher_module.cpp index 4565a52..3a4102c 100644 --- a/Software/GuitarPedal/Effect-Modules/crusher_module.cpp +++ b/Software/GuitarPedal/Effect-Modules/crusher_module.cpp @@ -5,9 +5,9 @@ using namespace bkshepherd; static const int s_paramCount = 3; static const ParameterMetaData s_metaData[s_paramCount] = {{ name : "Level", - valueType : ParameterValueType::FloatMagnitude, + valueType : ParameterValueType::Float, valueBinCount : 0, - defaultValue : 40, + defaultValue : {.float_value = 0.3f}, knobMapping : 0, midiCCMapping : -1 }, @@ -15,15 +15,15 @@ static const ParameterMetaData s_metaData[s_paramCount] = {{ name : "Bits", valueType : ParameterValueType::Binned, valueBinCount : 32, - defaultValue : 32, + defaultValue : {.uint_value = 32}, knobMapping : 1, midiCCMapping : -1 }, { name : "Cutoff", - valueType : ParameterValueType::FloatMagnitude, + valueType : ParameterValueType::Float, valueBinCount : 0, - defaultValue : 64, + defaultValue : {.float_value = 0.5f}, knobMapping : 2, midiCCMapping : -1 }}; @@ -55,8 +55,8 @@ void CrusherModule::Init(float sample_rate) { void CrusherModule::ProcessMono(float in) { BaseEffectModule::ProcessMono(in); - float level = m_levelMin + (GetParameterAsMagnitude(0) * (m_levelMax - m_levelMin)); - float cutoff = m_cutoffMin + GetParameterAsMagnitude(2) * (m_cutoffMax - m_cutoffMin); + float level = m_levelMin + (GetParameterAsFloat(0) * (m_levelMax - m_levelMin)); + float cutoff = m_cutoffMin + GetParameterAsFloat(2) * (m_cutoffMax - m_cutoffMin); float bits = (float)GetParameterAsBinnedValue(1); m_tone.SetFreq(cutoff); @@ -69,8 +69,8 @@ void CrusherModule::ProcessMono(float in) { void CrusherModule::ProcessStereo(float inL, float inR) { BaseEffectModule::ProcessStereo(inL, inR); - float level = m_levelMin + (GetParameterAsMagnitude(0) * (m_levelMax - m_levelMin)); - float cutoff = m_cutoffMin + GetParameterAsMagnitude(2) * (m_cutoffMax - m_cutoffMin); + float level = m_levelMin + (GetParameterAsFloat(0) * (m_levelMax - m_levelMin)); + float cutoff = m_cutoffMin + GetParameterAsFloat(2) * (m_cutoffMax - m_cutoffMin); float bits = (float)GetParameterAsBinnedValue(1); m_tone.SetFreq(cutoff); diff --git a/Software/GuitarPedal/Effect-Modules/looper_module.cpp b/Software/GuitarPedal/Effect-Modules/looper_module.cpp index 6ecd969..609d552 100644 --- a/Software/GuitarPedal/Effect-Modules/looper_module.cpp +++ b/Software/GuitarPedal/Effect-Modules/looper_module.cpp @@ -15,17 +15,17 @@ static const int s_paramCount = 3; static const ParameterMetaData s_metaData[s_paramCount] = { { name : "Input Level", - valueType : ParameterValueType::FloatMagnitude, + valueType : ParameterValueType::Float, valueBinCount : 0, - defaultValue : 64, + defaultValue : {.float_value = 0.5f}, knobMapping : 0, midiCCMapping : -1 }, { name : "Loop Level", - valueType : ParameterValueType::FloatMagnitude, + valueType : ParameterValueType::Float, valueBinCount : 0, - defaultValue : 64, + defaultValue : {.float_value = 0.5f}, knobMapping : 1, midiCCMapping : -1 }, @@ -34,7 +34,7 @@ static const ParameterMetaData s_metaData[s_paramCount] = { valueType : ParameterValueType::Binned, valueBinCount : 4, valueBinNames : s_loopModeNames, - defaultValue : 0, + defaultValue : {.uint_value = 0}, knobMapping : 2, midiCCMapping : -1 }, @@ -88,9 +88,9 @@ void LooperModule::AlternateFootswitchHeldFor1Second() { void LooperModule::ProcessMono(float in) { BaseEffectModule::ProcessMono(in); - const float inputLevel = m_inputLevelMin + (GetParameterAsMagnitude(0) * (m_inputLevelMax - m_inputLevelMin)); + const float inputLevel = m_inputLevelMin + (GetParameterAsFloat(0) * (m_inputLevelMax - m_inputLevelMin)); - const float loopLevel = m_loopLevelMin + (GetParameterAsMagnitude(1) * (m_loopLevelMax - m_loopLevelMin)); + const float loopLevel = m_loopLevelMin + (GetParameterAsFloat(1) * (m_loopLevelMax - m_loopLevelMin)); float input = in * inputLevel; diff --git a/Software/GuitarPedal/Effect-Modules/metro_module.cpp b/Software/GuitarPedal/Effect-Modules/metro_module.cpp index df63459..d7b1bc9 100644 --- a/Software/GuitarPedal/Effect-Modules/metro_module.cpp +++ b/Software/GuitarPedal/Effect-Modules/metro_module.cpp @@ -53,17 +53,17 @@ constexpr uint32_t maxTempo = 250; static const int s_paramCount = 3; static const ParameterMetaData s_metaData[s_paramCount] = {{ name : "Tempo", - valueType : ParameterValueType::FloatMagnitude, + valueType : ParameterValueType::Float, valueBinCount : 0, - defaultValue : 63, + defaultValue : {.float_value = 0.5f}, knobMapping : 0, midiCCMapping : 23 }, { name : "Mix", - valueType : ParameterValueType::FloatMagnitude, + valueType : ParameterValueType::Float, valueBinCount : 0, - defaultValue : 10, + defaultValue : {.float_value = 0.08f}, knobMapping : 1, midiCCMapping : 21 }, @@ -72,7 +72,7 @@ static const ParameterMetaData s_metaData[s_paramCount] = {{ valueType : ParameterValueType::Binned, valueBinCount : 3, valueBinNames : TimeSignatureLabels, - defaultValue : 0, + defaultValue : {.uint_value = 0}, knobMapping : 2, midiCCMapping : -1 }}; @@ -121,7 +121,7 @@ void MetroModule::Init(float sample_rate) { void MetroModule::ParameterChanged(int parameter_id) { if (parameter_id == 0) { - m_bpm = minTempo + GetParameterAsMagnitude(0) * static_cast(maxTempo - minTempo); + m_bpm = minTempo + GetParameterAsFloat(0) * static_cast(maxTempo - minTempo); } } @@ -152,7 +152,7 @@ void MetroModule::ProcessMono(float in) { BaseEffectModule::ProcessMono(in); float sig = Process(); // Adjust the level - float level = (m_levelMin + (GetParameterAsMagnitude(1) * (m_levelMax - m_levelMin))); + float level = (m_levelMin + (GetParameterAsFloat(1) * (m_levelMax - m_levelMin))); m_audioLeft = sig * level + in * (1.0f - level); m_audioRight = m_audioLeft; } @@ -161,7 +161,7 @@ void MetroModule::ProcessStereo(float inL, float inR) { BaseEffectModule::ProcessStereo(inL, inR); float sig = Process(); // Adjust the level - float level = (m_levelMin + (GetParameterAsMagnitude(1) * (m_levelMax - m_levelMin))); + float level = (m_levelMin + (GetParameterAsFloat(1) * (m_levelMax - m_levelMin))); m_audioLeft = sig * level + inL * (1.0f - level); m_audioRight = sig * level + inR * (1.0f - level); } diff --git a/Software/GuitarPedal/Effect-Modules/modulated_tremolo_module.cpp b/Software/GuitarPedal/Effect-Modules/modulated_tremolo_module.cpp index 0194d6d..e997098 100644 --- a/Software/GuitarPedal/Effect-Modules/modulated_tremolo_module.cpp +++ b/Software/GuitarPedal/Effect-Modules/modulated_tremolo_module.cpp @@ -12,22 +12,28 @@ static const ParameterMetaData s_metaData[s_paramCount] = { valueType : ParameterValueType::Binned, valueBinCount : 8, valueBinNames : s_waveBinNames, - defaultValue : 0, + defaultValue : {.uint_value = 0}, knobMapping : 3, midiCCMapping : 20 }, - {name : "Depth", valueType : ParameterValueType::FloatMagnitude, defaultValue : 74, knobMapping : 1, midiCCMapping : 21}, - {name : "Freq", valueType : ParameterValueType::FloatMagnitude, defaultValue : 67, knobMapping : 0, midiCCMapping : 1}, + {name : "Depth", valueType : ParameterValueType::Float, defaultValue : {.float_value = 0.5f}, knobMapping : 1, midiCCMapping : 21}, + {name : "Freq", valueType : ParameterValueType::Float, defaultValue : {.float_value = 0.5f}, knobMapping : 0, midiCCMapping : 1}, { name : "Osc Wave", valueType : ParameterValueType::Binned, valueBinCount : 8, valueBinNames : s_waveBinNames, - defaultValue : 0, + defaultValue : {.uint_value = 0}, knobMapping : 4, midiCCMapping : 23 }, - {name : "Osc Freq", valueType : ParameterValueType::FloatMagnitude, defaultValue : 12, knobMapping : 2, midiCCMapping : 24}}; + { + name : "Osc Freq", + valueType : ParameterValueType::Float, + defaultValue : {.float_value = 0.1f}, + knobMapping : 2, + midiCCMapping : 24 + }}; // Default Constructor ModulatedTremoloModule::ModulatedTremoloModule() @@ -61,17 +67,17 @@ void ModulatedTremoloModule::ProcessMono(float in) { // Calculate Tremolo Frequency Oscillation m_freqOsc.SetWaveform(GetParameterAsBinnedValue(3) - 1); m_freqOsc.SetAmp(0.5f); - m_freqOsc.SetFreq(m_freqOscFreqMin + (GetParameterAsMagnitude(4) * m_freqOscFreqMax)); + m_freqOsc.SetFreq(m_freqOscFreqMin + (GetParameterAsFloat(4) * m_freqOscFreqMax)); float mod = 0.5f + m_freqOsc.Process(); - if (GetParameterRaw(4) == 0) { + if (GetParameterAsFloat(4) <= 0.01f) { mod = 1.0f; } // Calculate the effect m_tremolo.SetWaveform(GetParameterAsBinnedValue(0) - 1); - m_tremolo.SetDepth(GetParameterAsMagnitude(1)); - m_tremolo.SetFreq(m_tremoloFreqMin + ((GetParameterAsMagnitude(2) * m_tremoloFreqMax) * mod)); + m_tremolo.SetDepth(GetParameterAsFloat(1)); + m_tremolo.SetFreq(m_tremoloFreqMin + ((GetParameterAsFloat(2) * m_tremoloFreqMax) * mod)); // Ease the effect value into it's target to avoid clipping with square or sawtooth waves fonepole(m_cachedEffectMagnitudeValue, m_tremolo.Process(1.0f), .01f); diff --git a/Software/GuitarPedal/Effect-Modules/multi_delay_module.cpp b/Software/GuitarPedal/Effect-Modules/multi_delay_module.cpp index 2712b08..59b61f2 100644 --- a/Software/GuitarPedal/Effect-Modules/multi_delay_module.cpp +++ b/Software/GuitarPedal/Effect-Modules/multi_delay_module.cpp @@ -37,9 +37,9 @@ static const char *s_typeBinNames[] = {"Follower", "Time"}; static const int s_paramCount = 13; static const ParameterMetaData s_metaData[s_paramCount] = {{ name : "Wet %", - valueType : ParameterValueType::FloatMagnitude, + valueType : ParameterValueType::Float, valueBinCount : 0, - defaultValue : 0, + defaultValue : {.float_value = 0.0f}, knobMapping : 0, midiCCMapping : 20, minValue : 0, @@ -47,9 +47,9 @@ static const ParameterMetaData s_metaData[s_paramCount] = {{ }, { name : "Delay L ms", - valueType : ParameterValueType::FloatMagnitude, + valueType : ParameterValueType::Float, valueBinCount : 0, - defaultValue : 0, + defaultValue : {.float_value = 0.0f}, knobMapping : 1, midiCCMapping : 21, minValue : 0, @@ -58,9 +58,9 @@ static const ParameterMetaData s_metaData[s_paramCount] = {{ }, { name : "Delay R ms", - valueType : ParameterValueType::FloatMagnitude, + valueType : ParameterValueType::Float, valueBinCount : 0, - defaultValue : 0, + defaultValue : {.float_value = 0.0f}, knobMapping : 2, midiCCMapping : 22, minValue : 0, @@ -69,9 +69,9 @@ static const ParameterMetaData s_metaData[s_paramCount] = {{ }, { name : "Feedback", - valueType : ParameterValueType::FloatMagnitude, + valueType : ParameterValueType::Float, valueBinCount : 0, - defaultValue : 0, + defaultValue : {.float_value = 0.0f}, knobMapping : 3, midiCCMapping : 31, minValue : 0, @@ -82,15 +82,15 @@ static const ParameterMetaData s_metaData[s_paramCount] = {{ valueType : ParameterValueType::Binned, valueBinCount : 2, valueBinNames : s_typeBinNames, - defaultValue : 0, + defaultValue : {.uint_value = 0}, knobMapping : 1, midiCCMapping : 20 }, { name : "Shift Tap 1", - valueType : ParameterValueType::FloatMagnitude, + valueType : ParameterValueType::Float, valueBinCount : 0, - defaultValue : 0, + defaultValue : {.float_value = 0.0f}, knobMapping : -1, midiCCMapping : 27, minValue : -12, @@ -99,9 +99,9 @@ static const ParameterMetaData s_metaData[s_paramCount] = {{ }, { name : "Shift Tap 2", - valueType : ParameterValueType::FloatMagnitude, + valueType : ParameterValueType::Float, valueBinCount : 0, - defaultValue : 0, + defaultValue : {.float_value = 0.0f}, knobMapping : -1, midiCCMapping : 28, minValue : -12, @@ -110,9 +110,9 @@ static const ParameterMetaData s_metaData[s_paramCount] = {{ }, { name : "Shift Tap 3", - valueType : ParameterValueType::FloatMagnitude, + valueType : ParameterValueType::Float, valueBinCount : 0, - defaultValue : 0, + defaultValue : {.float_value = 0.0f}, knobMapping : -1, midiCCMapping : 29, minValue : -12, @@ -121,9 +121,9 @@ static const ParameterMetaData s_metaData[s_paramCount] = {{ }, { name : "Shift Tap 4", - valueType : ParameterValueType::FloatMagnitude, + valueType : ParameterValueType::Float, valueBinCount : 0, - defaultValue : 0, + defaultValue : {.float_value = 0.0f}, knobMapping : -1, midiCCMapping : 30, minValue : -12, @@ -132,9 +132,9 @@ static const ParameterMetaData s_metaData[s_paramCount] = {{ }, { name : "Delay Tap 1", - valueType : ParameterValueType::FloatMagnitude, + valueType : ParameterValueType::Float, valueBinCount : 0, - defaultValue : 0, + defaultValue : {.float_value = 0.0f}, knobMapping : -1, midiCCMapping : 23, minValue : 0, @@ -143,9 +143,9 @@ static const ParameterMetaData s_metaData[s_paramCount] = {{ }, { name : "Delay Tap 2", - valueType : ParameterValueType::FloatMagnitude, + valueType : ParameterValueType::Float, valueBinCount : 0, - defaultValue : 0, + defaultValue : {.float_value = 0.0f}, knobMapping : -1, midiCCMapping : 24, minValue : 0, @@ -154,9 +154,9 @@ static const ParameterMetaData s_metaData[s_paramCount] = {{ }, { name : "Delay Tap 3", - valueType : ParameterValueType::FloatMagnitude, + valueType : ParameterValueType::Float, valueBinCount : 0, - defaultValue : 0, + defaultValue : {.float_value = 0.0f}, knobMapping : -1, midiCCMapping : 25, minValue : 0, @@ -165,9 +165,9 @@ static const ParameterMetaData s_metaData[s_paramCount] = {{ }, { name : "Delay Tap 4", - valueType : ParameterValueType::FloatMagnitude, + valueType : ParameterValueType::Float, valueBinCount : 0, - defaultValue : 0, + defaultValue : {.float_value = 0.0f}, knobMapping : -1, midiCCMapping : 26, minValue : 0, @@ -201,9 +201,9 @@ void MultiDelayModule::Init(float sample_rate) { delayLineLeft0.Init(); delayLineRight0.Init(); delays[0].del = &delayLineLeft0; - delays[0].currentDelay = GetParameterAsMagnitude(1); + delays[0].currentDelay = GetParameterAsFloat(1); delays[1].del = &delayLineRight0; - delays[1].currentDelay = GetParameterAsMagnitude(2); + delays[1].currentDelay = GetParameterAsFloat(2); for (int i = 0; i < 4; ++i) { ps_taps[i].Init(sample_rate); @@ -232,7 +232,7 @@ void MultiDelayModule::ParameterChanged(int parameter_id) { } } else if (parameter_id > 4 && parameter_id < 9 && m_isInitialized == true) { ps_taps[parameter_id - 5].SetTransposition(m_pitchShiftMin + - (m_pitchShiftMax - m_pitchShiftMin) * GetParameterAsMagnitude(parameter_id)); + (m_pitchShiftMax - m_pitchShiftMin) * GetParameterAsFloat(parameter_id)); } else if (parameter_id > 8 && parameter_id < 11) { m_tapTargetDelay[parameter_id - 9] = 48.0f * GetParameterAsFloat(parameter_id); } @@ -248,7 +248,7 @@ void MultiDelayModule::ProcessMono(float in) { BaseEffectModule::ProcessMono(in); float taps[2]; - float sig = delays[0].Process(GetParameterAsMagnitude(3), m_audioLeft) / 3.f; + float sig = delays[0].Process(GetParameterAsFloat(3), m_audioLeft) / 3.f; for (int i = 0; i < 2; ++i) { PreProcessTaps(&tap_delays[i], m_tapTargetDelay[i]); taps[i] = delays[0].del->Read(tap_delays[i]); @@ -259,7 +259,7 @@ void MultiDelayModule::ProcessMono(float in) { sig += taps[0] / 3.f + taps[1] / 3.f; - m_audioLeft = sig * GetParameterAsMagnitude(0) + m_audioLeft * (1.0f - GetParameterAsMagnitude(0)); + m_audioLeft = sig * GetParameterAsFloat(0) + m_audioLeft * (1.0f - GetParameterAsFloat(0)); m_audioRight = m_audioLeft; } @@ -270,7 +270,7 @@ void MultiDelayModule::ProcessStereo(float inL, float inR) { // Do the base stereo calculation (which resets the right signal to be the inputR instead of combined mono) BaseEffectModule::ProcessStereo(m_audioLeft, inR); float taps[2]; - float sig = delays[1].Process(GetParameterAsMagnitude(3), m_audioRight) / 3.f; + float sig = delays[1].Process(GetParameterAsFloat(3), m_audioRight) / 3.f; for (int i = 0; i < 2; ++i) { PreProcessTaps(&tap_delays[i + 2], m_tapTargetDelay[i + 2]); taps[i] = delays[1].del->Read(tap_delays[i + 2]); @@ -280,7 +280,7 @@ void MultiDelayModule::ProcessStereo(float inL, float inR) { } sig += taps[0] / 3.f + taps[1] / 3.f; - m_audioRight = sig * GetParameterAsMagnitude(0) + m_audioRight * (1.0f - GetParameterAsMagnitude(0)); + m_audioRight = sig * GetParameterAsFloat(0) + m_audioRight * (1.0f - GetParameterAsFloat(0)); } void MultiDelayModule::SetTempo(uint32_t bpm) { diff --git a/Software/GuitarPedal/Effect-Modules/overdrive_module.cpp b/Software/GuitarPedal/Effect-Modules/overdrive_module.cpp index 3f1202e..a08f811 100644 --- a/Software/GuitarPedal/Effect-Modules/overdrive_module.cpp +++ b/Software/GuitarPedal/Effect-Modules/overdrive_module.cpp @@ -5,17 +5,17 @@ using namespace bkshepherd; static const int s_paramCount = 2; static const ParameterMetaData s_metaData[s_paramCount] = {{ name : "Drive", - valueType : ParameterValueType::FloatMagnitude, + valueType : ParameterValueType::Float, valueBinCount : 0, - defaultValue : 57, + defaultValue : {.float_value = 0.45f}, knobMapping : 1, midiCCMapping : 1 }, { name : "Level", - valueType : ParameterValueType::FloatMagnitude, + valueType : ParameterValueType::Float, valueBinCount : 0, - defaultValue : 40, + defaultValue : {.float_value = 0.3f}, knobMapping : 0, midiCCMapping : 21 }}; @@ -51,11 +51,11 @@ void OverdriveModule::ProcessMono(float in) { BaseEffectModule::ProcessMono(in); // Calculate the effect - m_overdriveLeft.SetDrive(m_driveMin + (GetParameterAsMagnitude(0) * (m_driveMax - m_driveMin))); + m_overdriveLeft.SetDrive(m_driveMin + (GetParameterAsFloat(0) * (m_driveMax - m_driveMin))); m_audioLeft = m_overdriveLeft.Process(m_audioLeft); // Adjust the level - m_audioLeft = m_audioLeft * (m_levelMin + (GetParameterAsMagnitude(1) * (m_levelMax - m_levelMin))); + m_audioLeft = m_audioLeft * (m_levelMin + (GetParameterAsFloat(1) * (m_levelMax - m_levelMin))); m_audioRight = m_audioLeft; } @@ -67,18 +67,18 @@ void OverdriveModule::ProcessStereo(float inL, float inR) { BaseEffectModule::ProcessStereo(m_audioLeft, inR); // Calculate the effect - m_overdriveRight.SetDrive(m_driveMin + (GetParameterAsMagnitude(0) * (m_driveMax - m_driveMin))); + m_overdriveRight.SetDrive(m_driveMin + (GetParameterAsFloat(0) * (m_driveMax - m_driveMin))); m_audioRight = m_overdriveRight.Process(m_audioRight); // Adjust the level - m_audioRight = m_audioRight * (m_levelMin + (GetParameterAsMagnitude(1) * (m_levelMax - m_levelMin))); + m_audioRight = m_audioRight * (m_levelMin + (GetParameterAsFloat(1) * (m_levelMax - m_levelMin))); } float OverdriveModule::GetBrightnessForLED(int led_id) { float value = BaseEffectModule::GetBrightnessForLED(led_id); if (led_id == 1) { - return value * GetParameterAsMagnitude(0); + return value * GetParameterAsFloat(0); } return value; diff --git a/Software/GuitarPedal/Effect-Modules/pitch_shifter_module.cpp b/Software/GuitarPedal/Effect-Modules/pitch_shifter_module.cpp index f585ef1..65c54d0 100644 --- a/Software/GuitarPedal/Effect-Modules/pitch_shifter_module.cpp +++ b/Software/GuitarPedal/Effect-Modules/pitch_shifter_module.cpp @@ -25,15 +25,15 @@ static const ParameterMetaData s_metaData[s_paramCount] = { valueType : ParameterValueType::Binned, valueBinCount : 8, valueBinNames : s_semitoneBinNames, - defaultValue : 0, + defaultValue : {.uint_value = 0}, knobMapping : 0, midiCCMapping : -1 }, { name : "Crossfade", - valueType : ParameterValueType::FloatMagnitude, + valueType : ParameterValueType::Float, valueBinCount : 0, - defaultValue : 127, + defaultValue : {.float_value = 1.0f}, knobMapping : 1, midiCCMapping : -1 }, @@ -42,7 +42,7 @@ static const ParameterMetaData s_metaData[s_paramCount] = { valueType : ParameterValueType::Binned, valueBinCount : 2, valueBinNames : s_directionBinNames, - defaultValue : 0, + defaultValue : {.uint_value = 0}, knobMapping : 2, midiCCMapping : -1 }, @@ -51,23 +51,23 @@ static const ParameterMetaData s_metaData[s_paramCount] = { valueType : ParameterValueType::Binned, valueBinCount : 2, valueBinNames : s_modeBinNames, - defaultValue : 0, + defaultValue : {.uint_value = 0}, knobMapping : 3, midiCCMapping : -1 }, { name : "Shift", - valueType : ParameterValueType::FloatMagnitude, + valueType : ParameterValueType::Float, valueBinCount : 0, - defaultValue : 0, + defaultValue : {.float_value = 0.0f}, knobMapping : 4, midiCCMapping : -1 }, { name : "Return", - valueType : ParameterValueType::FloatMagnitude, + valueType : ParameterValueType::Float, valueBinCount : 0, - defaultValue : 0, + defaultValue : {.float_value = 0.0f}, knobMapping : 5, midiCCMapping : -1 }, @@ -142,7 +142,7 @@ void PitchShifterModule::Init(float sample_rate) { pitchShifter.SetDelSize(k_defaultSamplesDelayPitchShifter); pitchCrossfade.Init(CROSSFADE_CPOW); - pitchCrossfade.SetPos(GetParameterAsMagnitude(1)); + pitchCrossfade.SetPos(GetParameterAsFloat(1)); m_latching = GetParameterAsBinnedValue(3) == 1; @@ -152,8 +152,8 @@ void PitchShifterModule::Init(float sample_rate) { SetTranspose(m_semitoneTarget); - m_samplesToDelayShift = static_cast(static_cast(k_maxSamplesMaxTime) * GetParameterAsMagnitude(4)); - m_samplesToDelayReturn = static_cast(static_cast(k_maxSamplesMaxTime) * GetParameterAsMagnitude(5)); + m_samplesToDelayShift = static_cast(static_cast(k_maxSamplesMaxTime) * GetParameterAsFloat(4)); + m_samplesToDelayReturn = static_cast(static_cast(k_maxSamplesMaxTime) * GetParameterAsFloat(5)); } void PitchShifterModule::ParameterChanged(int parameter_id) { @@ -163,16 +163,16 @@ void PitchShifterModule::ParameterChanged(int parameter_id) { // Change semitone when semitone knob is turned or direction is changed ProcessSemitoneTargetChange(); } else if (parameter_id == 1) { - pitchCrossfade.SetPos(GetParameterAsMagnitude(1)); + pitchCrossfade.SetPos(GetParameterAsFloat(1)); } else if (parameter_id == 3) { m_latching = GetParameterAsBinnedValue(3) == 1; if (!m_latching) { pitchShifter.SetDelSize(k_defaultSamplesDelayPitchShifter); } } else if (parameter_id == 4) { - m_samplesToDelayShift = static_cast(static_cast(k_maxSamplesMaxTime) * GetParameterAsMagnitude(4)); + m_samplesToDelayShift = static_cast(static_cast(k_maxSamplesMaxTime) * GetParameterAsFloat(4)); } else if (parameter_id == 5) { - m_samplesToDelayReturn = static_cast(static_cast(k_maxSamplesMaxTime) * GetParameterAsMagnitude(5)); + m_samplesToDelayReturn = static_cast(static_cast(k_maxSamplesMaxTime) * GetParameterAsFloat(5)); } // Parameters changed, reset the transposition target just in case (mostly diff --git a/Software/GuitarPedal/Effect-Modules/reverb_delay_module.cpp b/Software/GuitarPedal/Effect-Modules/reverb_delay_module.cpp index 19c6d99..09bf60e 100644 --- a/Software/GuitarPedal/Effect-Modules/reverb_delay_module.cpp +++ b/Software/GuitarPedal/Effect-Modules/reverb_delay_module.cpp @@ -20,49 +20,49 @@ static const int s_paramCount = static const ParameterMetaData s_metaData[s_paramCount] = { { name : "Delay Time", - valueType : ParameterValueType::FloatMagnitude, + valueType : ParameterValueType::Float, valueBinCount : 0, - defaultValue : 57, + defaultValue : {.float_value = 0.45f}, knobMapping : 0, midiCCMapping : 1 }, // mod { name : "D Feedback", - valueType : ParameterValueType::FloatMagnitude, + valueType : ParameterValueType::Float, valueBinCount : 0, - defaultValue : 57, + defaultValue : {.float_value = 0.45f}, knobMapping : 1, midiCCMapping : 22 }, { name : "Delay Mix", - valueType : ParameterValueType::FloatMagnitude, + valueType : ParameterValueType::Float, valueBinCount : 0, - defaultValue : 57, + defaultValue : {.float_value = 0.45f}, knobMapping : 2, midiCCMapping : 23 }, { name : "Reverb Time", - valueType : ParameterValueType::FloatMagnitude, + valueType : ParameterValueType::Float, valueBinCount : 0, - defaultValue : 57, + defaultValue : {.float_value = 0.45f}, knobMapping : 3, midiCCMapping : 24 }, { name : "Reverb Damp", - valueType : ParameterValueType::FloatMagnitude, + valueType : ParameterValueType::Float, valueBinCount : 0, - defaultValue : 40, + defaultValue : {.float_value = 0.4f}, knobMapping : 4, midiCCMapping : 25 }, // mod { name : "Reverb Mix", - valueType : ParameterValueType::FloatMagnitude, + valueType : ParameterValueType::Float, valueBinCount : 0, - defaultValue : 57, + defaultValue : {.float_value = 0.45f}, knobMapping : 5, midiCCMapping : 26 }, @@ -71,7 +71,7 @@ static const ParameterMetaData s_metaData[s_paramCount] = { valueType : ParameterValueType::Binned, valueBinCount : 3, valueBinNames : s_delayModes, - defaultValue : 0, + defaultValue : {.uint_value = 0}, knobMapping : -1, midiCCMapping : 27 }, @@ -79,7 +79,7 @@ static const ParameterMetaData s_metaData[s_paramCount] = { name : "Series D>R", valueType : ParameterValueType::Bool, valueBinCount : 0, - defaultValue : 0, + defaultValue : {.uint_value = 0}, knobMapping : -1, midiCCMapping : 28 }, @@ -87,24 +87,31 @@ static const ParameterMetaData s_metaData[s_paramCount] = { name : "Reverse", valueType : ParameterValueType::Bool, valueBinCount : 0, - defaultValue : 0, + defaultValue : {.uint_value = 0}, knobMapping : -1, midiCCMapping : 29 }, - {name : "Octave", valueType : ParameterValueType::Bool, valueBinCount : 0, defaultValue : 0, knobMapping : -1, midiCCMapping : 30}, + { + name : "Octave", + valueType : ParameterValueType::Bool, + valueBinCount : 0, + defaultValue : {.uint_value = 0}, + knobMapping : -1, + midiCCMapping : 30 + }, { name : "Delay LPF", - valueType : ParameterValueType::FloatMagnitude, + valueType : ParameterValueType::Float, valueBinCount : 0, - defaultValue : 120, + defaultValue : {.float_value = 0.95f}, knobMapping : -1, midiCCMapping : 31 }, // mod /*11*/ { name : "D Spread", - valueType : ParameterValueType::FloatMagnitude, + valueType : ParameterValueType::Float, valueBinCount : 0, - defaultValue : 30, + defaultValue : {.float_value = 0.25f}, knobMapping : -1, midiCCMapping : 32 }, @@ -113,23 +120,23 @@ static const ParameterMetaData s_metaData[s_paramCount] = { name : "Dual Delay", valueType : ParameterValueType::Bool, valueBinCount : 0, - defaultValue : 0, + defaultValue : {.uint_value = 0}, knobMapping : -1, midiCCMapping : 33 }, { name : "Mod Amt", - valueType : ParameterValueType::FloatMagnitude, + valueType : ParameterValueType::Float, valueBinCount : 0, - defaultValue : 20, + defaultValue : {.float_value = 0.15f}, knobMapping : -1, midiCCMapping : 34 }, { name : "Mod Rate", - valueType : ParameterValueType::FloatMagnitude, + valueType : ParameterValueType::Float, valueBinCount : 0, - defaultValue : 30, + defaultValue : {.float_value = 0.25f}, knobMapping : -1, midiCCMapping : 35 }, @@ -138,7 +145,7 @@ static const ParameterMetaData s_metaData[s_paramCount] = { valueType : ParameterValueType::Binned, valueBinCount : 5, valueBinNames : s_modParamNames, - defaultValue : 0, + defaultValue : {.uint_value = 0}, knobMapping : -1, midiCCMapping : 36 }, @@ -147,7 +154,7 @@ static const ParameterMetaData s_metaData[s_paramCount] = { valueType : ParameterValueType::Binned, valueBinCount : 5, valueBinNames : s_waveBinNames, - defaultValue : 0, + defaultValue : {.uint_value = 0}, knobMapping : -1, midiCCMapping : 37 }, @@ -155,7 +162,7 @@ static const ParameterMetaData s_metaData[s_paramCount] = { name : "Sync Mod F", valueType : ParameterValueType::Bool, valueBinCount : 0, - defaultValue : 0, + defaultValue : {.uint_value = 0}, knobMapping : -1, midiCCMapping : 38 }}; @@ -185,7 +192,7 @@ ReverbDelayModule::~ReverbDelayModule() { void ReverbDelayModule::UpdateLEDRate() { // Update the LED oscillator frequency based on the current timeParam - float timeParam = GetParameterAsMagnitude(0); + float timeParam = GetParameterAsFloat(0); float delaySamples = m_delaySamplesMin + (m_delaySamplesMax - m_delaySamplesMin) * timeParam; float delayFreq = effect_samplerate / delaySamples; led_osc.SetFreq(delayFreq / 2.0); @@ -196,7 +203,7 @@ void ReverbDelayModule::CalculateDelayMix() { // A computationally cheap mostly energy constant crossfade from SignalSmith Blog // https://signalsmith-audio.co.uk/writing/2021/cheap-energy-crossfade/ - float delMixKnob = GetParameterAsMagnitude(2); + float delMixKnob = GetParameterAsFloat(2); float x2 = 1.0 - delMixKnob; float A = delMixKnob * x2; float B = A * (1.0 + 1.4186 * A); @@ -212,7 +219,7 @@ void ReverbDelayModule::CalculateReverbMix() { // A computationally cheap mostly energy constant crossfade from SignalSmith Blog // https://signalsmith-audio.co.uk/writing/2021/cheap-energy-crossfade/ - float revMixKnob = GetParameterAsMagnitude(5); + float revMixKnob = GetParameterAsFloat(5); float x2 = 1.0 - revMixKnob; float A = revMixKnob * x2; float B = A * (1.0 + 1.4186 * A); @@ -291,8 +298,8 @@ void ReverbDelayModule::ParameterChanged(int parameter_id) { delayRight.secondTapOn = false; } } else if (parameter_id == 10) { - delayLeft.toneOctLP.SetFreq(m_delaylpFreqMin + (m_delaylpFreqMax - m_delaylpFreqMin) * GetParameterAsMagnitude(10)); - delayRight.toneOctLP.SetFreq(m_delaylpFreqMin + (m_delaylpFreqMax - m_delaylpFreqMin) * GetParameterAsMagnitude(10)); + delayLeft.toneOctLP.SetFreq(m_delaylpFreqMin + (m_delaylpFreqMax - m_delaylpFreqMin) * GetParameterAsFloat(10)); + delayRight.toneOctLP.SetFreq(m_delaylpFreqMin + (m_delaylpFreqMax - m_delaylpFreqMin) * GetParameterAsFloat(10)); } } @@ -311,17 +318,17 @@ void ReverbDelayModule::ProcessModulation() { float freq = (effect_samplerate / delayLeft.delayTarget) / dividor; modOsc.SetFreq(freq); } else { - modOsc.SetFreq(m_modOscFreqMin + (m_modOscFreqMax - m_modOscFreqMin) * GetParameterAsMagnitude(14)); + modOsc.SetFreq(m_modOscFreqMin + (m_modOscFreqMax - m_modOscFreqMin) * GetParameterAsFloat(14)); } // Ease the effect value into it's target to avoid clipping with square or sawtooth waves fonepole(m_currentMod, modOsc.Process(), .01f); float mod = m_currentMod; - float mod_amount = GetParameterAsMagnitude(13); + float mod_amount = GetParameterAsFloat(13); // {"None", "DelayTime", "DelayLevel", "ReverbLevel", "DelayPan"}; if (modParam == 1) { - float timeParam = GetParameterAsMagnitude(0); + float timeParam = GetParameterAsFloat(0); delayLeft.delayTarget = m_delaySamplesMin + (m_delaySamplesMax - m_delaySamplesMin) * timeParam + mod * mod_amount * 500; delayRight.delayTarget = m_delaySamplesMin + (m_delaySamplesMax - m_delaySamplesMin) * timeParam + mod * mod_amount * 500; @@ -348,13 +355,13 @@ void ReverbDelayModule::ProcessMono(float in) { BaseEffectModule::ProcessMono(in); // Calculate the effect - float timeParam = GetParameterAsMagnitude(0); + float timeParam = GetParameterAsFloat(0); delayLeft.delayTarget = m_delaySamplesMin + (m_delaySamplesMax - m_delaySamplesMin) * timeParam; delayRight.delayTarget = m_delaySamplesMin + (m_delaySamplesMax - m_delaySamplesMin) * timeParam; - delayLeft.feedback = GetParameterAsMagnitude(1); - delayRight.feedback = GetParameterAsMagnitude(1); + delayLeft.feedback = GetParameterAsFloat(1); + delayRight.feedback = GetParameterAsFloat(1); delayLeft.reverseMode = GetParameterAsBool(8); delayRight.reverseMode = GetParameterAsBool(8); @@ -365,12 +372,12 @@ void ReverbDelayModule::ProcessMono(float in) { delayLeft.dual_delay = GetParameterAsBool(12); delayRight.dual_delay = GetParameterAsBool(12); - if (GetParameterAsMagnitude(12)) { // If dual delay is turned on, spread controls the L/R panning of the two delays - delayLeft.level = GetParameterAsMagnitude(11) + 1.0; - delayRight.level = 1.0 - GetParameterAsMagnitude(11); + if (GetParameterAsFloat(12)) { // If dual delay is turned on, spread controls the L/R panning of the two delays + delayLeft.level = GetParameterAsFloat(11) + 1.0; + delayRight.level = 1.0 - GetParameterAsFloat(11); - delayLeft.level_reverse = 1.0 - GetParameterAsMagnitude(11); - delayRight.level_reverse = GetParameterAsMagnitude(11) + 1.0; + delayLeft.level_reverse = 1.0 - GetParameterAsFloat(11); + delayRight.level_reverse = GetParameterAsFloat(11) + 1.0; } else { // If dual delay is off reset the levels to normal, spread controls the amount of additional delay applied to the right // channel @@ -382,9 +389,9 @@ void ReverbDelayModule::ProcessMono(float in) { // Calculate Reverb Params reverb_level = 1.0; - m_reverbStereo.SetFeedback(m_timeMin + GetParameterAsMagnitude(3) * (m_timeMax - m_timeMin)); + m_reverbStereo.SetFeedback(m_timeMin + GetParameterAsFloat(3) * (m_timeMax - m_timeMin)); float invertedFreq = - 1.0 - GetParameterAsMagnitude(4); // Invert the damping param so that knob left is less dampening, knob right is more dampening + 1.0 - GetParameterAsFloat(4); // Invert the damping param so that knob left is less dampening, knob right is more dampening invertedFreq = invertedFreq * invertedFreq; // also square it for exponential taper (more control over lower frequencies) m_reverbStereo.SetLpFreq(m_lpFreqMin + invertedFreq * (m_lpFreqMax - m_lpFreqMin)); @@ -397,7 +404,7 @@ void ReverbDelayModule::ProcessMono(float in) { // float delRight_out = delLeft_out; // Calculate any delay spread - delaySpread.delayTarget = m_delaySpreadMin + (m_delaySpreadMax - m_delaySpreadMin) * GetParameterAsMagnitude(11); + delaySpread.delayTarget = m_delaySpreadMin + (m_delaySpreadMax - m_delaySpreadMin) * GetParameterAsFloat(11); float delSpread_out = delaySpread.Process(delRight_out); if (GetParameterRaw(11) > 0 && !GetParameterAsBool(12)) { delRight_out = delSpread_out; @@ -438,13 +445,13 @@ void ReverbDelayModule::ProcessStereo(float inL, float inR) { ProcessModulation(); // Calculate the effect - float timeParam = GetParameterAsMagnitude(0); + float timeParam = GetParameterAsFloat(0); delayLeft.delayTarget = m_delaySamplesMin + (m_delaySamplesMax - m_delaySamplesMin) * timeParam; delayRight.delayTarget = m_delaySamplesMin + (m_delaySamplesMax - m_delaySamplesMin) * timeParam; - delayLeft.feedback = GetParameterAsMagnitude(1); - delayRight.feedback = GetParameterAsMagnitude(1); + delayLeft.feedback = GetParameterAsFloat(1); + delayRight.feedback = GetParameterAsFloat(1); delayLeft.reverseMode = GetParameterAsBool(8); delayRight.reverseMode = GetParameterAsBool(8); @@ -455,12 +462,12 @@ void ReverbDelayModule::ProcessStereo(float inL, float inR) { delayLeft.dual_delay = GetParameterAsBool(12); delayRight.dual_delay = GetParameterAsBool(12); - if (GetParameterAsMagnitude(12)) { // If dual delay is turned on, spread controls the L/R panning of the two delays - delayLeft.level = GetParameterAsMagnitude(11) + 1.0; - delayRight.level = 1.0 - GetParameterAsMagnitude(11); + if (GetParameterAsFloat(12)) { // If dual delay is turned on, spread controls the L/R panning of the two delays + delayLeft.level = GetParameterAsFloat(11) + 1.0; + delayRight.level = 1.0 - GetParameterAsFloat(11); - delayLeft.level_reverse = 1.0 - GetParameterAsMagnitude(11); - delayRight.level_reverse = GetParameterAsMagnitude(11) + 1.0; + delayLeft.level_reverse = 1.0 - GetParameterAsFloat(11); + delayRight.level_reverse = GetParameterAsFloat(11) + 1.0; } else { // If dual delay is off reset the levels to normal, spread controls the amount of additional delay applied to the right // channel @@ -472,9 +479,9 @@ void ReverbDelayModule::ProcessStereo(float inL, float inR) { // Calculate Reverb Params reverb_level = 1.0; - m_reverbStereo.SetFeedback(m_timeMin + GetParameterAsMagnitude(3) * (m_timeMax - m_timeMin)); + m_reverbStereo.SetFeedback(m_timeMin + GetParameterAsFloat(3) * (m_timeMax - m_timeMin)); float invertedFreq = - 1.0 - GetParameterAsMagnitude(4); // Invert the damping param so that knob left is less dampening, knob right is more dampening + 1.0 - GetParameterAsFloat(4); // Invert the damping param so that knob left is less dampening, knob right is more dampening invertedFreq = invertedFreq * invertedFreq; // also square it for exponential taper (more control over lower frequencies) m_reverbStereo.SetLpFreq(m_lpFreqMin + invertedFreq * (m_lpFreqMax - m_lpFreqMin)); @@ -485,7 +492,7 @@ void ReverbDelayModule::ProcessStereo(float inL, float inR) { float delRight_out = delayRight.Process(m_audioRight); // Calculate any delay spread - delaySpread.delayTarget = m_delaySpreadMin + (m_delaySpreadMax - m_delaySpreadMin) * GetParameterAsMagnitude(11); + delaySpread.delayTarget = m_delaySpreadMin + (m_delaySpreadMax - m_delaySpreadMin) * GetParameterAsFloat(11); float delSpread_out = delaySpread.Process(delRight_out); if (GetParameterRaw(11) > 0 && !GetParameterAsBool(12)) { // If spread > 0 and dual delay isn't on delRight_out = delSpread_out; diff --git a/Software/GuitarPedal/Effect-Modules/reverb_module.cpp b/Software/GuitarPedal/Effect-Modules/reverb_module.cpp index cc5a380..1bfe2d4 100644 --- a/Software/GuitarPedal/Effect-Modules/reverb_module.cpp +++ b/Software/GuitarPedal/Effect-Modules/reverb_module.cpp @@ -5,25 +5,25 @@ using namespace bkshepherd; static const int s_paramCount = 3; static const ParameterMetaData s_metaData[s_paramCount] = {{ name : "Time", - valueType : ParameterValueType::FloatMagnitude, + valueType : ParameterValueType::Float, valueBinCount : 0, - defaultValue : 57, + defaultValue : {.float_value = 0.45f}, knobMapping : 0, midiCCMapping : 1 }, { name : "Damp", - valueType : ParameterValueType::FloatMagnitude, + valueType : ParameterValueType::Float, valueBinCount : 0, - defaultValue : 40, + defaultValue : {.float_value = 0.3f}, knobMapping : 1, midiCCMapping : 21 }, { name : "Mix", - valueType : ParameterValueType::FloatMagnitude, + valueType : ParameterValueType::Float, valueBinCount : 0, - defaultValue : 57, + defaultValue : {.float_value = 0.45f}, knobMapping : 2, midiCCMapping : 22 }}; @@ -63,15 +63,15 @@ void ReverbModule::ProcessMono(float in) { sendr = m_audioRight; // Calculate the effect - m_reverbStereo->SetFeedback(m_timeMin + GetParameterAsMagnitude(0) * (m_timeMax - m_timeMin)); + m_reverbStereo->SetFeedback(m_timeMin + GetParameterAsFloat(0) * (m_timeMax - m_timeMin)); float invertedFreq = - 1.0 - GetParameterAsMagnitude(1); // Invert the damping param so that knob left is less dampening, knob right is more dampening + 1.0 - GetParameterAsFloat(1); // Invert the damping param so that knob left is less dampening, knob right is more dampening invertedFreq = invertedFreq * invertedFreq; // also square it for exponential taper (more control over lower frequencies) m_reverbStereo->SetLpFreq(m_lpFreqMin + invertedFreq * (m_lpFreqMax - m_lpFreqMin)); m_reverbStereo->Process(sendl, sendr, &wetl, &wetr); - m_audioLeft = wetl * GetParameterAsMagnitude(2) + sendl * (1.0 - GetParameterAsMagnitude(2)); - m_audioRight = wetr * GetParameterAsMagnitude(2) + sendr * (1.0 - GetParameterAsMagnitude(2)); + m_audioLeft = wetl * GetParameterAsFloat(2) + sendl * (1.0 - GetParameterAsFloat(2)); + m_audioRight = wetr * GetParameterAsFloat(2) + sendr * (1.0 - GetParameterAsFloat(2)); } void ReverbModule::ProcessStereo(float inL, float inR) { @@ -83,22 +83,22 @@ void ReverbModule::ProcessStereo(float inL, float inR) { sendr = m_audioRight; // Calculate the effect - m_reverbStereo->SetFeedback(m_timeMin + GetParameterAsMagnitude(0) * (m_timeMax - m_timeMin)); + m_reverbStereo->SetFeedback(m_timeMin + GetParameterAsFloat(0) * (m_timeMax - m_timeMin)); float invertedFreq = - 1.0 - GetParameterAsMagnitude(1); // Invert the damping param so that knob left is less dampening, knob right is more dampening + 1.0 - GetParameterAsFloat(1); // Invert the damping param so that knob left is less dampening, knob right is more dampening invertedFreq = invertedFreq * invertedFreq; // also square it for exponential taper (more control over lower frequencies) m_reverbStereo->SetLpFreq(m_lpFreqMin + invertedFreq * (m_lpFreqMax - m_lpFreqMin)); m_reverbStereo->Process(sendl, sendr, &wetl, &wetr); - m_audioLeft = wetl * GetParameterAsMagnitude(2) + inL * (1.0 - GetParameterAsMagnitude(2)); - m_audioRight = wetr * GetParameterAsMagnitude(2) + inR * (1.0 - GetParameterAsMagnitude(2)); + m_audioLeft = wetl * GetParameterAsFloat(2) + inL * (1.0 - GetParameterAsFloat(2)); + m_audioRight = wetr * GetParameterAsFloat(2) + inR * (1.0 - GetParameterAsFloat(2)); } float ReverbModule::GetBrightnessForLED(int led_id) { float value = BaseEffectModule::GetBrightnessForLED(led_id); if (led_id == 1) { - return value; // * GetParameterAsMagnitude(0); + return value; // * GetParameterAsFloat(0); } return value; diff --git a/Software/GuitarPedal/Effect-Modules/tuner_module.cpp b/Software/GuitarPedal/Effect-Modules/tuner_module.cpp index 79670c8..764fff6 100644 --- a/Software/GuitarPedal/Effect-Modules/tuner_module.cpp +++ b/Software/GuitarPedal/Effect-Modules/tuner_module.cpp @@ -11,7 +11,7 @@ const char k_notes[12][3] = {"C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A static const int s_paramCount = 1; static const ParameterMetaData s_metaData[s_paramCount] = { - {name : "Mute", valueType : ParameterValueType::Bool, defaultValue : 127, knobMapping : 0, midiCCMapping : -1}, + {name : "Mute", valueType : ParameterValueType::Bool, defaultValue : {.uint_value = 1}, knobMapping : 0, midiCCMapping : -1}, }; // Default Constructor diff --git a/Software/GuitarPedal/UI/CustomMappedValues.h b/Software/GuitarPedal/UI/CustomMappedValues.h index 4c2218f..a1329d0 100644 --- a/Software/GuitarPedal/UI/CustomMappedValues.h +++ b/Software/GuitarPedal/UI/CustomMappedValues.h @@ -37,7 +37,7 @@ class MyMappedFloatValue : public MappedValue { * even for positive numbers */ MyMappedFloatValue(float min, float max, float defaultValue, Mapping mapping = Mapping::lin, const char *unitStr = "", - uint8_t numDecimals = 1, bool forceSign = false, float coarseStepSize0to1_ = 0.05f, + uint8_t numDecimals = 2, bool forceSign = false, float coarseStepSize0to1_ = 0.05f, float fineStepSize0to1_ = 0.01f); ~MyMappedFloatValue() override {} diff --git a/Software/GuitarPedal/UI/guitar_pedal_ui.cpp b/Software/GuitarPedal/UI/guitar_pedal_ui.cpp index ca55b5f..690515c 100644 --- a/Software/GuitarPedal/UI/guitar_pedal_ui.cpp +++ b/Software/GuitarPedal/UI/guitar_pedal_ui.cpp @@ -61,10 +61,10 @@ void GuitarPedalUI::UpdateActiveEffectParameterValue(int paramID, bool showChang // Update the UI based on the parameter type if (parameterType == -1 || parameterType == 0) { - // Unknown, Raw value or Float Magnitude Types + // Unknown or Raw value Types m_activeEffectSettingIntValues[paramID]->Set(activeEffect->GetParameterRaw(paramID)); } else if (parameterType == 1) { - // Unknown, Raw value or Float Magnitude Types + // Float Types m_activeEffectSettingFloatValues[paramID]->Set(activeEffect->GetParameterAsFloat(paramID)); } else if (parameterType == 2) { // Bool Type @@ -228,11 +228,11 @@ void GuitarPedalUI::InitEffectUiPages() { m_activeEffectSettingsMenuItems[i].type = AbstractMenu::ItemType::valueItem; m_activeEffectSettingIntValues[i] = new MappedIntValue(minValue, maxValue, activeEffect->GetParameterRaw(i), 1, 5); m_activeEffectSettingsMenuItems[i].asMappedValueItem.valueToModify = m_activeEffectSettingIntValues[i]; - } else if (parameterType == ParameterValueType::FloatMagnitude) { + } else if (parameterType == ParameterValueType::Float) { float minValue = (float)activeEffect->GetParameterMin(i); float maxValue = (float)activeEffect->GetParameterMax(i); float fineStep = activeEffect->GetParameterFineStepSize(i); - // Raw32 value or Float Magnitude Types + // Float Types m_activeEffectSettingsMenuItems[i].type = AbstractMenu::ItemType::valueItem; m_activeEffectSettingFloatValues[i] = new MyMappedFloatValue(minValue, maxValue, activeEffect->GetParameterAsFloat(i)); m_activeEffectSettingFloatValues[i]->SetFineStepSize(fineStep); @@ -432,10 +432,10 @@ void GuitarPedalUI::UpdateUI(float elapsedTime) { // Binned Value Type if (activeEffect->GetParameterBinNames(i) == NULL) { // Handle when Bins have no String Name - activeEffect->SetParameterAsBinnedValue(i, m_activeEffectSettingIntValues[i]->Get()); + m_activeEffectSettingIntValues[i]->Set(activeEffect->GetParameterAsBinnedValue(i)); } else { // Handle when Bins are using String Name - activeEffect->SetParameterAsBinnedValue(i, m_activeEffectSettingStringValues[i]->GetIndex() + 1); + m_activeEffectSettingStringValues[i]->SetIndex(activeEffect->GetParameterAsBinnedValue(i) - 1); } } } @@ -445,10 +445,10 @@ void GuitarPedalUI::UpdateUI(float elapsedTime) { int parameterType = activeEffect->GetParameterType(i); if (parameterType == -1 || parameterType == 0) { - // Unknown, Raw value or Float Magnitude Types + // Unknown or Raw value Types activeEffect->SetParameterRaw(i, m_activeEffectSettingIntValues[i]->Get()); } else if (parameterType == 1) { - // Unknown, Raw value or Float Magnitude Types + // Float Type activeEffect->SetParameterAsFloat(i, m_activeEffectSettingFloatValues[i]->Get()); } else if (parameterType == 2) { // Bool Type @@ -457,10 +457,10 @@ void GuitarPedalUI::UpdateUI(float elapsedTime) { // Binned Value Type if (activeEffect->GetParameterBinNames(i) == NULL) { // Handle when Bins have no String Name - m_activeEffectSettingIntValues[i]->Set(activeEffect->GetParameterAsBinnedValue(i)); + activeEffect->SetParameterAsBinnedValue(i, m_activeEffectSettingIntValues[i]->Get()); } else { // Handle when Bins are using String Name - m_activeEffectSettingStringValues[i]->SetIndex(activeEffect->GetParameterAsBinnedValue(i) - 1); + activeEffect->SetParameterAsBinnedValue(i, m_activeEffectSettingStringValues[i]->GetIndex() + 1); } } } diff --git a/Software/GuitarPedal/guitar_pedal_storage.cpp b/Software/GuitarPedal/guitar_pedal_storage.cpp index 7f81239..61ca2fa 100644 --- a/Software/GuitarPedal/guitar_pedal_storage.cpp +++ b/Software/GuitarPedal/guitar_pedal_storage.cpp @@ -51,15 +51,15 @@ void InitPersistantStorage() { ++globalEffectsSettingMemIdx; for (int paramID = 0; paramID < paramCount; paramID++) { - defaultSettings.globalEffectsSettings[globalEffectsSettingMemIdx] = availableEffects[effectID]->GetParameterRaw(paramID); - - if (availableEffects[effectID]->GetParameterType(paramID) == ParameterValueType::FloatMagnitude) { + // Floats are handled special (stored into the u_int32_t bytes) + if ((ParameterValueType)availableEffects[effectID]->GetParameterType(paramID) == ParameterValueType::Float) { uint32_t tmp; - float f = defaultSettings.globalEffectsSettings[globalEffectsSettingMemIdx] = availableEffects[effectID]->GetParameterAsFloat(paramID); + float f = availableEffects[effectID]->GetParameterAsFloat(paramID); std::memcpy(&tmp, &f, sizeof(float)); defaultSettings.globalEffectsSettings[globalEffectsSettingMemIdx] = tmp; } else { - defaultSettings.globalEffectsSettings[globalEffectsSettingMemIdx] = availableEffects[effectID]->GetParameterRaw(paramID); + defaultSettings.globalEffectsSettings[globalEffectsSettingMemIdx] = + availableEffects[effectID]->GetParameterRaw(paramID); } ++globalEffectsSettingMemIdx; @@ -142,7 +142,7 @@ void LoadPresetFromPersistentStorage(uint32_t effectID, uint32_t presetID) { startIdx = availableEffects[effectID]->GetSettingsArrayStartIdx() + 2 + (paramCount * presetID); for (int paramID = 0; paramID < paramCount; paramID++) { - if (availableEffects[effectID]->GetParameterType(paramID) == ParameterValueType::FloatMagnitude) { + if ((ParameterValueType)availableEffects[effectID]->GetParameterType(paramID) == ParameterValueType::Float) { uint32_t tmp = settings.globalEffectsSettings[startIdx + paramID]; float f; std::memcpy(&f, &tmp, sizeof(float)); @@ -171,7 +171,7 @@ void LoadEffectSettingsFromPersistantStorage() { if (paramCount == prevParamCount) { for (uint32_t paramID = 0; paramID < paramCount; paramID++) { uint32_t value = settings.globalEffectsSettings[globalEffectsSettingMemIdx]; - if (availableEffects[effectID]->GetParameterType(paramID) == ParameterValueType::FloatMagnitude) { + if ((ParameterValueType)availableEffects[effectID]->GetParameterType(paramID) == ParameterValueType::Float) { float tmp; std::memcpy(&tmp, &value, sizeof(float)); availableEffects[effectID]->SetParameterAsFloat(paramID, tmp); @@ -188,7 +188,7 @@ void LoadEffectSettingsFromPersistantStorage() { else if (prevParamCount < paramCount) { for (uint32_t paramID = 0; paramID < prevParamCount; paramID++) { uint32_t value = settings.globalEffectsSettings[globalEffectsSettingMemIdx]; - if (availableEffects[effectID]->GetParameterType(paramID) == ParameterValueType::FloatMagnitude) { + if ((ParameterValueType)availableEffects[effectID]->GetParameterType(paramID) == ParameterValueType::Float) { float tmp; std::memcpy(&tmp, &value, sizeof(float)); availableEffects[effectID]->SetParameterAsFloat(paramID, tmp); @@ -229,7 +229,7 @@ void SaveEffectSettingsToPersitantStorageForEffectID(int effectID, uint32_t pres bool canWriteNewPreset = true; Settings &settings = storage.GetSettings(); uint32_t globalEffectsMaxIdx = settings.globalEffectsSettings[0U]; - + // Save Effect Parameters to Persistant Storage based on values from the specified active effect if (effectID >= 0 && effectID < availableEffectsCount) { int paramCount = availableEffects[effectID]->GetParameterCount(); @@ -253,7 +253,7 @@ void SaveEffectSettingsToPersitantStorageForEffectID(int effectID, uint32_t pres if (canWriteNewPreset) { for (int paramID = 0; paramID < paramCount; paramID++) { - if (availableEffects[effectID]->GetParameterType(paramID) == ParameterValueType::FloatMagnitude) { + if ((ParameterValueType)availableEffects[effectID]->GetParameterType(paramID) == ParameterValueType::Float) { uint32_t tmp; float f = availableEffects[effectID]->GetParameterAsFloat(paramID); std::memcpy(&tmp, &f, sizeof(float)); diff --git a/Software/GuitarPedal/guitar_pedal_storage.h b/Software/GuitarPedal/guitar_pedal_storage.h index a384d67..3285b49 100644 --- a/Software/GuitarPedal/guitar_pedal_storage.h +++ b/Software/GuitarPedal/guitar_pedal_storage.h @@ -3,7 +3,7 @@ #define GUITAR_PEDAL_STORAGE_H // Peristant Storage Settings -#define SETTINGS_FILE_FORMAT_VERSION 3 +#define SETTINGS_FILE_FORMAT_VERSION 4 // Arbitrarily limiting this to 4KB of stored presets since this sits in DTCMRAM which is limited to 128KB. // TODO: In the future it would be better if this worked with the QSPI directly instead of using @@ -22,7 +22,7 @@ struct Settings { bool globalRelayBypassEnabled; bool globalSplitMonoInputToStereo; - // Set aside a block of memory for individual effect params. + // Set aside a block of memory for individual effect params. // Please note this MUST be a fixed amount of memory in the struct and cannot be a pointer to dynamic memory! // If you try to use a pointer it will only save the pointer address to QSPI storage and not any of the contents // of that dynamic memory. This is a limitation of the way the PersistantStorage helper class works.