【问题标题】:Why Arduino Midi Library reads hexadecimal F7 as 0为什么 Arduino Midi 库将十六进制 F7 读取为 0
【发布时间】:2014-04-10 16:15:23
【问题描述】:

我已将效果处理器 midi 连接到 shield 中的 arduino midi 我正在尝试使用 arduino 的 Midi 库读取来自我的效果处理器的 sysex 消息 一切运行良好,但是当涉及到十六进制数 F7 时,我的 arduino 读取为 0。 我知道 F7 是 247 有人知道为什么会这样吗?

我用这个代码

#include <MIDI.h>

void handle_sysex(byte *a,byte sizeofsysex)
{
 Serial.println(sizeofsysex,DEC);
 for(int n=0;n<sizeofsysex;n++)
{
Serial.print(a[n]);
Serial.print("  ");
}
 Serial.print('\n');
}
void setup() {
Serial.begin(9600);
// Initiate MIDI communications, listen to all channels
MIDI.begin(MIDI_CHANNEL_OMNI);    
MIDI.setHandleSystemExclusive(handle_sysex);
}
void loop() {
// Call MIDI.read the fastest you can for real-time performance.
MIDI.read();
}

【问题讨论】:

  • 这是唯一错误的数字吗?或者它是一个值范围?你怎么知道正在发送什么值?
  • 是的,它是唯一的,我知道因为我还连接了 Midi Ox 以检查 arduino 是否读取正确
  • 难道F7 是“消息结尾”字符,它只是被转换为“字符串结尾”吗?见en.wikipedia.org/wiki/…
  • @Floris 在 MIDI 中,0 是有效的数据字节;转换 F7 将是一个可怕的错误。

标签: arduino midi sysex


【解决方案1】:

这是在 github 上讨论的,看起来这是由 #67#66 修复的错误。处理函数的 args 也发生了变化,第二个 arg 现在是 unsigned size 以允许大小超过 255。

【讨论】:

    猜你喜欢
    • 2015-11-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-12-12
    • 1970-01-01
    • 2017-09-16
    • 1970-01-01
    • 2010-09-19
    相关资源
    最近更新 更多