diff --git a/source/backend/engine/CarlaEngineData.cpp b/source/backend/engine/CarlaEngineData.cpp index 1270805a1..9af889c9f 100644 --- a/source/backend/engine/CarlaEngineData.cpp +++ b/source/backend/engine/CarlaEngineData.cpp @@ -50,7 +50,7 @@ uint8_t EngineControlEvent::convertToMidiData(const uint8_t channel, uint8_t dat if (midiValue >= 0) data[2] = uint8_t(midiValue); else - data[2] = uint8_t(carla_fixedValue(0.0f, 1.0f, normalizedValue) * static_cast(MAX_MIDI_VALUE-1)); + data[2] = uint8_t(carla_fixedValue(0.0f, 1.0f, normalizedValue) * static_cast(MAX_MIDI_VALUE-1) + 0.5f); } return 3; diff --git a/source/backend/plugin/CarlaPluginBridge.cpp b/source/backend/plugin/CarlaPluginBridge.cpp index 76f968d01..04ae4bb6c 100644 --- a/source/backend/plugin/CarlaPluginBridge.cpp +++ b/source/backend/plugin/CarlaPluginBridge.cpp @@ -1580,7 +1580,7 @@ public: fShmRtClientControl.writeByte(3); // size fShmRtClientControl.writeByte(uint8_t(MIDI_STATUS_CONTROL_CHANGE | (event.channel & MIDI_CHANNEL_BIT))); fShmRtClientControl.writeByte(uint8_t(ctrlEvent.param)); - fShmRtClientControl.writeByte(uint8_t(ctrlEvent.normalizedValue*127.0f)); + fShmRtClientControl.writeByte(uint8_t(ctrlEvent.normalizedValue*127.0f + 0.5f)); } break; } diff --git a/source/backend/plugin/CarlaPluginFluidSynth.cpp b/source/backend/plugin/CarlaPluginFluidSynth.cpp index 8236a192c..abb71842a 100644 --- a/source/backend/plugin/CarlaPluginFluidSynth.cpp +++ b/source/backend/plugin/CarlaPluginFluidSynth.cpp @@ -1304,7 +1304,7 @@ public: if ((pData->options & PLUGIN_OPTION_SEND_CONTROL_CHANGES) != 0 && ctrlEvent.param < MAX_MIDI_VALUE) { - fluid_synth_cc(fSynth, event.channel, ctrlEvent.param, int(ctrlEvent.normalizedValue*127.0f)); + fluid_synth_cc(fSynth, event.channel, ctrlEvent.param, int(ctrlEvent.normalizedValue*127.0f + 0.5f)); } break; } diff --git a/source/backend/plugin/CarlaPluginJack.cpp b/source/backend/plugin/CarlaPluginJack.cpp index 5a18c38e5..5c5047aaf 100644 --- a/source/backend/plugin/CarlaPluginJack.cpp +++ b/source/backend/plugin/CarlaPluginJack.cpp @@ -1134,7 +1134,7 @@ public: fShmRtClientControl.writeByte(3); // size fShmRtClientControl.writeByte(uint8_t(MIDI_STATUS_CONTROL_CHANGE | (event.channel & MIDI_CHANNEL_BIT))); fShmRtClientControl.writeByte(uint8_t(ctrlEvent.param)); - fShmRtClientControl.writeByte(uint8_t(ctrlEvent.normalizedValue*127.0f)); + fShmRtClientControl.writeByte(uint8_t(ctrlEvent.normalizedValue*127.0f + 0.5f)); } break; diff --git a/source/backend/plugin/CarlaPluginJuce.cpp b/source/backend/plugin/CarlaPluginJuce.cpp index de8277550..b37ed29dc 100644 --- a/source/backend/plugin/CarlaPluginJuce.cpp +++ b/source/backend/plugin/CarlaPluginJuce.cpp @@ -1151,7 +1151,7 @@ public: uint8_t midiData[3]; midiData[0] = uint8_t(MIDI_STATUS_CONTROL_CHANGE | (event.channel & MIDI_CHANNEL_BIT)); midiData[1] = uint8_t(ctrlEvent.param); - midiData[2] = uint8_t(ctrlEvent.normalizedValue*127.0f); + midiData[2] = uint8_t(ctrlEvent.normalizedValue*127.0f + 0.5f); fMidiBuffer.addEvent(midiData, 3, static_cast(event.time)); } @@ -1173,7 +1173,7 @@ public: fMidiBuffer.addEvent(midiData, 3, static_cast(event.time)); midiData[1] = MIDI_CONTROL_BANK_SELECT__LSB; - midiData[2] = uint8_t(ctrlEvent.normalizedValue*127.0f); + midiData[2] = uint8_t(ctrlEvent.normalizedValue*127.0f + 0.5f); fMidiBuffer.addEvent(midiData, 3, static_cast(event.time)); } break; @@ -1190,7 +1190,7 @@ public: { uint8_t midiData[3]; midiData[0] = uint8_t(MIDI_STATUS_PROGRAM_CHANGE | (event.channel & MIDI_CHANNEL_BIT)); - midiData[1] = uint8_t(ctrlEvent.normalizedValue*127.0f); + midiData[1] = uint8_t(ctrlEvent.normalizedValue*127.0f + 0.5f); fMidiBuffer.addEvent(midiData, 2, static_cast(event.time)); } break; diff --git a/source/backend/plugin/CarlaPluginLADSPADSSI.cpp b/source/backend/plugin/CarlaPluginLADSPADSSI.cpp index a3429809a..afddfc659 100644 --- a/source/backend/plugin/CarlaPluginLADSPADSSI.cpp +++ b/source/backend/plugin/CarlaPluginLADSPADSSI.cpp @@ -1732,7 +1732,7 @@ public: seqEvent.type = SND_SEQ_EVENT_CONTROLLER; seqEvent.data.control.channel = event.channel; seqEvent.data.control.param = ctrlEvent.param; - seqEvent.data.control.value = int8_t(ctrlEvent.normalizedValue*127.0f); + seqEvent.data.control.value = int8_t(ctrlEvent.normalizedValue*127.0f + 0.5f); } #ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH diff --git a/source/backend/plugin/CarlaPluginLV2.cpp b/source/backend/plugin/CarlaPluginLV2.cpp index c6eb09855..8217491b9 100644 --- a/source/backend/plugin/CarlaPluginLV2.cpp +++ b/source/backend/plugin/CarlaPluginLV2.cpp @@ -4092,7 +4092,7 @@ public: uint8_t midiData[3]; midiData[0] = uint8_t(MIDI_STATUS_CONTROL_CHANGE | (event.channel & MIDI_CHANNEL_BIT)); midiData[1] = uint8_t(ctrlEvent.param); - midiData[2] = uint8_t(ctrlEvent.normalizedValue*127.0f); + midiData[2] = uint8_t(ctrlEvent.normalizedValue*127.0f + 0.5f); const uint32_t mtime(isSampleAccurate ? startTime : eventTime); diff --git a/source/backend/plugin/CarlaPluginNative.cpp b/source/backend/plugin/CarlaPluginNative.cpp index 99cf4df91..d8035cbd2 100644 --- a/source/backend/plugin/CarlaPluginNative.cpp +++ b/source/backend/plugin/CarlaPluginNative.cpp @@ -2065,7 +2065,7 @@ public: nativeEvent.time = isSampleAccurate ? startTime : eventTime; nativeEvent.data[0] = uint8_t(MIDI_STATUS_CONTROL_CHANGE | (event.channel & MIDI_CHANNEL_BIT)); nativeEvent.data[1] = uint8_t(ctrlEvent.param); - nativeEvent.data[2] = uint8_t(ctrlEvent.normalizedValue*127.0f); + nativeEvent.data[2] = uint8_t(ctrlEvent.normalizedValue*127.0f + 0.5f); nativeEvent.size = 3; } diff --git a/source/backend/plugin/CarlaPluginSFZero.cpp b/source/backend/plugin/CarlaPluginSFZero.cpp index 6eda39cff..a16ad03d1 100644 --- a/source/backend/plugin/CarlaPluginSFZero.cpp +++ b/source/backend/plugin/CarlaPluginSFZero.cpp @@ -471,7 +471,7 @@ public: if ((pData->options & PLUGIN_OPTION_SEND_CONTROL_CHANGES) != 0 && ctrlEvent.param < MAX_MIDI_VALUE) { - fSynth.handleController(event.channel+1, ctrlEvent.param, int(ctrlEvent.normalizedValue*127.0f)); + fSynth.handleController(event.channel+1, ctrlEvent.param, int(ctrlEvent.normalizedValue*127.0f + 0.5f)); } break; diff --git a/source/backend/plugin/CarlaPluginVST2.cpp b/source/backend/plugin/CarlaPluginVST2.cpp index efe42e57b..f3db14431 100644 --- a/source/backend/plugin/CarlaPluginVST2.cpp +++ b/source/backend/plugin/CarlaPluginVST2.cpp @@ -1502,7 +1502,7 @@ public: vstMidiEvent.deltaFrames = static_cast(isSampleAccurate ? startTime : eventTime); vstMidiEvent.midiData[0] = char(MIDI_STATUS_CONTROL_CHANGE | (event.channel & MIDI_CHANNEL_BIT)); vstMidiEvent.midiData[1] = char(ctrlEvent.param); - vstMidiEvent.midiData[2] = char(ctrlEvent.normalizedValue*127.0f); + vstMidiEvent.midiData[2] = char(ctrlEvent.normalizedValue*127.0f + 0.5f); } #ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH