Fixed MIDI implementation to correspond to actual MIDI
This commit is contained in:
@@ -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++;
|
||||
|
||||
*/
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user