MIDI THRU 示例
MIDI Thru 簡單易用。正常工作後,你將能夠在兩個 MIDI 裝置之間安裝 Arduino 專案,MIDI IN 到 MIDI OUT,你將能夠驗證兩個裝置是否一起執行。如果你能夠測量延遲,則會看到由於序列緩衝區捕獲和重新傳送指令而導致的增加。
// This is a simple MIDI THRU. Everything in, goes right out.
// This has been validate on an Arduino UNO and a Olimex MIDI Shield
boolean byteReady;
unsigned char midiByte;
void setup() {
// put your setup code here, to run once:
// Set MIDI baud rate:
Serial.begin(31250);
byteReady = false;
midiByte = 0;
}
// The Loop that always gets called...
void loop() {
if (byteReady) {
byteReady = false;
Serial.write(midiByte);
}
}
// The little function that gets called each time loop is called.
// This is automated somwhere in the Arduino code.
void serialEvent() {
if (Serial.available()) {
// get the new byte:
midiByte = (unsigned char)Serial.read();
byteReady = true;
}
}