Browse Source

support channel aftertouch

pull/1639/head
bsp2 6 years ago
parent
commit
073b54d039
2 changed files with 25 additions and 14 deletions
  1. +17
    -11
      include/midi.hpp
  2. +8
    -3
      src/Core/MIDIToCVInterface.cpp

+ 17
- 11
include/midi.hpp View File

@@ -11,21 +11,27 @@ namespace rack {




struct MidiMessage { struct MidiMessage {
uint8_t cmd = 0x00;
uint8_t data1 = 0x00;
uint8_t data2 = 0x00;
uint8_t cmd = 0u;
uint8_t data1 = 0u;
uint8_t data2 = 0u;


uint8_t channel() {
return cmd & 0xf;
uint8_t channel() const {
return cmd & 15u;
} }
uint8_t status() {
return (cmd >> 4) & 0xf;
uint8_t status() const {
return (cmd >> 4) & 15u;
} }
uint8_t note() {
return data1 & 0x7f;
uint8_t note() const {
return data1 & 127u;
} }
uint8_t value() {
return data2 & 0x7f;
uint8_t value() const {
return data2 & 127u;
}
uint8_t getData1() const {
return data1 & 127u;
}
uint8_t getData2() const {
return data2 & 127u;
} }
}; };




+ 8
- 3
src/Core/MIDIToCVInterface.cpp View File

@@ -280,7 +280,7 @@ struct MIDIToCVInterface : Module {
// note on // note on
case 0x9: { case 0x9: {
if (msg.value() > 0) { if (msg.value() > 0) {
noteData[msg.note()].velocity = msg.value();
noteData[msg.note()].velocity = msg.getData2();
pressNote(msg.note()); pressNote(msg.note());
} }
else { else {
@@ -288,15 +288,20 @@ struct MIDIToCVInterface : Module {
releaseNote(msg.note()); releaseNote(msg.note());
} }
} break; } break;
// channel aftertouch
// polyphonic aftertouch
case 0xa: { case 0xa: {
uint8_t note = msg.note(); uint8_t note = msg.note();
noteData[note].aftertouch = msg.value();
noteData[note].aftertouch = msg.getData2();
} break; } break;
// cc // cc
case 0xb: { case 0xb: {
processCC(msg); processCC(msg);
} break; } break;
// channel aftertouch
case 0xd: {
for(uint8_t noteIdx = 0u; noteIdx < 128u; noteIdx++)
noteData[noteIdx].aftertouch = msg.getData1();
} break;
// pitch wheel // pitch wheel
case 0xe: { case 0xe: {
pitch = msg.value() * 128 + msg.note(); pitch = msg.value() * 128 + msg.note();


Loading…
Cancel
Save