Browse Source

Fix inaccurate midi CC rounding (#1612)

* Fix incorrect rounding of midi CC when passed to LV2

* Fix inaccurate MIDI CC rounding everywhere
tags/v2.4.4
Florian Jung GitHub 2 years ago
parent
commit
9b79fcc97c
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 12 additions and 12 deletions
  1. +1
    -1
      source/backend/engine/CarlaEngineData.cpp
  2. +1
    -1
      source/backend/plugin/CarlaPluginBridge.cpp
  3. +1
    -1
      source/backend/plugin/CarlaPluginFluidSynth.cpp
  4. +1
    -1
      source/backend/plugin/CarlaPluginJack.cpp
  5. +3
    -3
      source/backend/plugin/CarlaPluginJuce.cpp
  6. +1
    -1
      source/backend/plugin/CarlaPluginLADSPADSSI.cpp
  7. +1
    -1
      source/backend/plugin/CarlaPluginLV2.cpp
  8. +1
    -1
      source/backend/plugin/CarlaPluginNative.cpp
  9. +1
    -1
      source/backend/plugin/CarlaPluginSFZero.cpp
  10. +1
    -1
      source/backend/plugin/CarlaPluginVST2.cpp

+ 1
- 1
source/backend/engine/CarlaEngineData.cpp View File

@@ -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<float>(0.0f, 1.0f, normalizedValue) * static_cast<float>(MAX_MIDI_VALUE-1));
data[2] = uint8_t(carla_fixedValue<float>(0.0f, 1.0f, normalizedValue) * static_cast<float>(MAX_MIDI_VALUE-1) + 0.5f);
}
return 3;



+ 1
- 1
source/backend/plugin/CarlaPluginBridge.cpp View File

@@ -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;
}


+ 1
- 1
source/backend/plugin/CarlaPluginFluidSynth.cpp View File

@@ -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;
}


+ 1
- 1
source/backend/plugin/CarlaPluginJack.cpp View File

@@ -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;



+ 3
- 3
source/backend/plugin/CarlaPluginJuce.cpp View File

@@ -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<int>(event.time));
}
@@ -1173,7 +1173,7 @@ public:
fMidiBuffer.addEvent(midiData, 3, static_cast<int>(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<int>(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<int>(event.time));
}
break;


+ 1
- 1
source/backend/plugin/CarlaPluginLADSPADSSI.cpp View File

@@ -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


+ 1
- 1
source/backend/plugin/CarlaPluginLV2.cpp View File

@@ -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);



+ 1
- 1
source/backend/plugin/CarlaPluginNative.cpp View File

@@ -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;
}



+ 1
- 1
source/backend/plugin/CarlaPluginSFZero.cpp View File

@@ -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;


+ 1
- 1
source/backend/plugin/CarlaPluginVST2.cpp View File

@@ -1502,7 +1502,7 @@ public:
vstMidiEvent.deltaFrames = static_cast<int32_t>(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


Loading…
Cancel
Save