diff --git a/Software/GuitarPedal/Effect-Modules/base_effect_module.cpp b/Software/GuitarPedal/Effect-Modules/base_effect_module.cpp index f462367..20e54e6 100644 --- a/Software/GuitarPedal/Effect-Modules/base_effect_module.cpp +++ b/Software/GuitarPedal/Effect-Modules/base_effect_module.cpp @@ -241,14 +241,8 @@ void BaseEffectModule::SetParameterAsMagnitude(int parameter_id, float value) { 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; - } + // This is an unsupported operation, so do nothing. + return; } else if (paramType == ParameterValueType::Float) { // Make sure the value is in the valid range. if (value < 0.0f) { @@ -366,7 +360,17 @@ void BaseEffectModule::ParameterChanged(int parameter_id) { } void BaseEffectModule::MidiCCValueNotification(uint8_t control_num, uint8_t value) { - // Do nothing + // Handle the incoming Midi CC Value Notification if needed + int effectParamID = GetMappedParameterIDForMidiCC(control_num); + + // If there is a param mapped to this CC value we need to handle it appropriately + if (effectParamID != -1) { + // Midi Value gets mapped into a 0.0-1.0 float and the sets the parameter value using the SetParameterAsMagnitude function + // Essentially Midi values 0..127 will behave the same was as turning a Pot on the guitar pedal from full off to full on. + // This works for all parameter types except RAW. + float mag = (float)value / 127.0f; + SetParameterAsMagnitude(effectParamID, mag); + } } void BaseEffectModule::UpdateUI(float elapsedTime) { diff --git a/Software/GuitarPedal/guitar_pedal.cpp b/Software/GuitarPedal/guitar_pedal.cpp index 1f78aa5..82c2fa8 100644 --- a/Software/GuitarPedal/guitar_pedal.cpp +++ b/Software/GuitarPedal/guitar_pedal.cpp @@ -187,9 +187,9 @@ static void AudioCallback(AudioHandle::InputBuffer in, AudioHandle::OutputBuffer // persistant storage If there is only one footswitch, it will do // parameter saving here when held instead of tuner quick switching later if (hardware.switches[hardware.GetPreferredSwitchIDForSpecialFunctionType(SpecialFunctionType::Bypass)].TimeHeldMs() > 2000 && - hardware.switches[hardware.GetPreferredSwitchIDForSpecialFunctionType(SpecialFunctionType::Alternate)].TimeHeldMs() > 2000 && - !guitarPedalUI.IsShowingSavingSettingsScreen() && - !ignoreBypassSwitchUntilNextActuation) { + hardware.switches[hardware.GetPreferredSwitchIDForSpecialFunctionType(SpecialFunctionType::Alternate)].TimeHeldMs() > + 2000 && + !guitarPedalUI.IsShowingSavingSettingsScreen() && !ignoreBypassSwitchUntilNextActuation) { needToSaveSettingsForActiveEffect = true; ignoreBypassSwitchUntilNextActuation = true; @@ -496,14 +496,15 @@ void HandleMidiMessage(MidiEvent m) { case ControlChange: { if (activeEffect != NULL) { ControlChangeEvent p = m.AsControlChange(); + + // Notify the activeEffect to handle this midi cc / value + activeEffect->MidiCCValueNotification(p.control_number, p.value); + + // Notify the UI to update if this CC message was mapped to an EffectParameter int effectParamID = activeEffect->GetMappedParameterIDForMidiCC(p.control_number); if (effectParamID != -1) { - activeEffect->SetParameterRaw(effectParamID, p.value); - guitarPedalUI.UpdateActiveEffectParameterValue(effectParamID, activeEffect->GetParameterRaw(effectParamID)); - } else { - // Notify the activeEffect, just in case there is custom handling for this midi cc / value - activeEffect->MidiCCValueNotification(p.control_number, p.value); + guitarPedalUI.UpdateActiveEffectParameterValue(effectParamID, false); } } break;