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