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;
}
}