Browse Source

[WIP] VST3: Fix incorrect MIDI input values for CC and Note On/Off (#453)

* Add debug prints to MidiThrough example

* Fix CC and Note On/Off calculation

Given the current normalized input, mutliply by 127 would give wrong result for some input values, dividing by 0.0078125, which is 1.0/128, fixes this

* Use std::round

* Use DPF functions for rounding

* Remove  debug prints in MidiThrough example

This reverts commit 82767715a1.
pull/473/head
FergusL falkTX <falktx@falktx.com> 10 months ago
parent
commit
c7fb0ca003
Signed by: falkTX <falktx@falktx.com> GPG Key ID: CDBAA37ABC74FBA0
1 changed files with 5 additions and 5 deletions
  1. +5
    -5
      distrho/src/DistrhoPluginVST3.cpp

+ 5
- 5
distrho/src/DistrhoPluginVST3.cpp View File

@@ -359,14 +359,14 @@ class PluginVst3
midiEvent.size = 3; midiEvent.size = 3;
midiEvent.data[0] = 0x90 | (eventStorage.noteOn.channel & 0xf); midiEvent.data[0] = 0x90 | (eventStorage.noteOn.channel & 0xf);
midiEvent.data[1] = eventStorage.noteOn.pitch; midiEvent.data[1] = eventStorage.noteOn.pitch;
midiEvent.data[2] = std::max(0, std::min(127, (int)(eventStorage.noteOn.velocity * 127)));
midiEvent.data[2] = std::max(0, std::min(127, d_roundToIntPositive(eventStorage.noteOn.velocity * 127)));
midiEvent.data[3] = 0; midiEvent.data[3] = 0;
break; break;
case NoteOff: case NoteOff:
midiEvent.size = 3; midiEvent.size = 3;
midiEvent.data[0] = 0x80 | (eventStorage.noteOff.channel & 0xf); midiEvent.data[0] = 0x80 | (eventStorage.noteOff.channel & 0xf);
midiEvent.data[1] = eventStorage.noteOff.pitch; midiEvent.data[1] = eventStorage.noteOff.pitch;
midiEvent.data[2] = std::max(0, std::min(127, (int)(eventStorage.noteOff.velocity * 127)));
midiEvent.data[2] = std::max(0, std::min(127, d_roundToIntPositive(eventStorage.noteOff.velocity * 127)));
midiEvent.data[3] = 0; midiEvent.data[3] = 0;
break; break;
/* TODO /* TODO
@@ -377,7 +377,7 @@ class PluginVst3
midiEvent.size = 3; midiEvent.size = 3;
midiEvent.data[0] = 0xA0 | (eventStorage.polyPressure.channel & 0xf); midiEvent.data[0] = 0xA0 | (eventStorage.polyPressure.channel & 0xf);
midiEvent.data[1] = eventStorage.polyPressure.pitch; midiEvent.data[1] = eventStorage.polyPressure.pitch;
midiEvent.data[2] = std::max(0, std::min(127, (int)(eventStorage.polyPressure.pressure * 127)));
midiEvent.data[2] = std::max(0, std::min(127, d_roundToIntPositive(eventStorage.polyPressure.pressure * 127)));
midiEvent.data[3] = 0; midiEvent.data[3] = 0;
break; break;
case CC_Normal: case CC_Normal:
@@ -469,7 +469,7 @@ class PluginVst3
{ {
case 128: case 128:
eventStorage.type = CC_ChannelPressure; eventStorage.type = CC_ChannelPressure;
eventStorage.midi[1] = std::max(0, std::min(127, (int)(normalized * 127)));
eventStorage.midi[1] = std::max(0, std::min(127, d_roundToIntPositive(normalized * 127)));
eventStorage.midi[2] = 0; eventStorage.midi[2] = 0;
break; break;
case 129: case 129:
@@ -480,7 +480,7 @@ class PluginVst3
default: default:
eventStorage.type = CC_Normal; eventStorage.type = CC_Normal;
eventStorage.midi[1] = cc; eventStorage.midi[1] = cc;
eventStorage.midi[2] = std::max(0, std::min(127, (int)(normalized * 127)));
eventStorage.midi[2] = std::max(0, std::min(127, d_roundToIntPositive(normalized * 127)));
break; break;
} }




Loading…
Cancel
Save