Arduino做midi键盘出现问题
2020-04-251.2万
AI 快速预览详细
本文介绍了使用Arduino制作MIDI键盘时遇到的串口收发不稳定问题。通过调整串口波特率和优化noteOn函数,解决了MIDI消息发送不完整的问题。示例程序中,通过设置串口波特率为31250,并在noteOn函数中正确发送MIDI命令、音符值和速度值,确保了MIDI信号的稳定传输。
|
用Arduino做的midi键盘,然后用loopmidi来生成port口,然后再用hairlessMidi来转换,但是出现问题,求大神解决! +0.89 - Warning: got a status byte when we were expecting 1 more data bytes, sending possibly incomplete MIDI message 0x80 可能是串口的收发不稳定? void setup() { // Set MIDI baud rate: Serial.begin(31250); } void loop() { // play notes from F#-0 (0x1E) to F#-5 (0x5A): //Note on channel 1 (0x90), some note value (note), middle velocity (0x45): noteOn(0x90, 0x3C, 0x45); delay(100); //Note on channel 1 (0x90), some note value (note), silent velocity (0x00): noteOn(0x90, 0x3C, 0x00); delay(100); Serial.write(cmd, ,pitch, ,velocity); } // plays a MIDI note. Doesn't check to see that cmd is greater than 127, or that // data values are less than 127: void noteOn(int cmd, int pitch, int velocity) { Serial.write(cmd); Serial.write(pitch); Serial.write(velocity); } 这是上面的示例程序 |




