Fixed MIDI implementation to correspond to actual MIDI

This commit is contained in:
Jakob Bak
2012-08-25 20:12:02 +02:00
parent 455196fe4b
commit 2c493f7dec
4 changed files with 22 additions and 8 deletions
+4 -1
View File
@@ -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;
+12 -1
View File
@@ -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++;
*/
}
}