Fixed MIDI implementation to correspond to actual MIDI
This commit is contained in:
parent
455196fe4b
commit
2c493f7dec
@ -50,7 +50,10 @@ public:
|
||||
|
||||
private:
|
||||
// MIDI
|
||||
uint16_t midiBuffer[4];
|
||||
uint8_t data;
|
||||
//uint16_t midiBuffer[4];
|
||||
uint8_t midiBuffer[16];
|
||||
|
||||
int midiBufferIndex;
|
||||
uint16_t frequency;
|
||||
//uint32_t midiTime;
|
||||
|
||||
@ -47,14 +47,25 @@ void MMidi::init()
|
||||
void MMidi::checkMidi()
|
||||
{
|
||||
while(Serial.available() > 0) {
|
||||
|
||||
data = Serial.read();
|
||||
if(data > 127) { // bitmask with 10000000 to see if byte is over 127 | data & 0x80
|
||||
midiBufferIndex = 0;
|
||||
}
|
||||
midiBuffer[midiBufferIndex] = data;
|
||||
midiBufferIndex++;
|
||||
if (midiBufferIndex > 2) {
|
||||
midiHandler();
|
||||
}
|
||||
|
||||
/*
|
||||
midiBuffer[midiBufferIndex] = Serial.read();
|
||||
if(midiBuffer[midiBufferIndex] == 0xFF) {
|
||||
midiHandler();
|
||||
midiBufferIndex = 0;
|
||||
}
|
||||
else midiBufferIndex++;
|
||||
|
||||
*/
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -110,8 +110,8 @@ void sendNoteOn(byte channel, byte pitch, byte velocity) {
|
||||
port0.write(noteOn);
|
||||
port0.write(pitch);
|
||||
port0.write(velocity);
|
||||
port0.write(endMessage);
|
||||
println('\n' + hex(noteOn) + " " + hex(pitch) + " " + hex(velocity) + " " + hex(endMessage));
|
||||
//port0.write(endMessage);
|
||||
println('\n' + hex(noteOn) + " " + hex(pitch) + " " + hex(velocity));
|
||||
|
||||
}
|
||||
|
||||
@ -123,8 +123,8 @@ void sendNoteOff(byte channel, byte pitch, byte velocity) {
|
||||
port0.write(noteOff);
|
||||
port0.write(pitch);
|
||||
port0.write(velocity);
|
||||
port0.write(endMessage);
|
||||
println('\n' + hex(noteOff) + " " + hex(pitch) + " " + hex(velocity) + " " + hex(endMessage));
|
||||
//port0.write(endMessage);
|
||||
println('\n' + hex(noteOff) + " " + hex(pitch) + " " + hex(velocity));
|
||||
|
||||
}
|
||||
|
||||
@ -136,7 +136,7 @@ void sendControlChange(byte channel, byte CC, byte value) {
|
||||
port0.write(controlChange);
|
||||
port0.write(CC);
|
||||
port0.write(value);
|
||||
port0.write(endMessage);
|
||||
println('\n' + hex(controlChange) + " " + hex(CC) + " " + hex(value) + " " + hex(endMessage));
|
||||
//port0.write(endMessage);
|
||||
println('\n' + hex(controlChange) + " " + hex(CC) + " " + hex(value));
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user