[英]Sending MIDI SysEx messages with the Arduino?
I would like to send a MIDI SysEx message like this to my Roland JX8P Synth. 我想将这样的MIDI SysEx消息发送到我的Roland JX8P Synth。
F0 41 36 06 21 20 01 22 1B F7 F0 41 36 06 21 20 01 22 1B F7
This message would alter the VCF cutoff frequency of the synth. 该消息将改变合成器的VCF截止频率。 1B is a variable hexadecimal value, swinging from 00 to 7F, relative to cutoff frequency. 1B是可变的十六进制值,相对于截止频率从00到7F摆动。
In the MIDI library I've found the documentation for sending a SysEx message. 在MIDI库中,我找到了发送SysEx消息的文档。
sendSysEx (int length, const byte *const array, bool ArrayContainsBoundaries=false)
From what I can tell bool ArrayContainsBoundaries specifies whether or not you want the library to include the F0 and F7 message start/stop tags (I don't so I'll set it to true). 从我可以告诉bool ArrayContainsBoundaries指定您是否希望库包含F0和F7消息开始/停止标记(我不这样做,我将其设置为true)。 Int length denotes the message length in bytes(my message is 10 bytes, so this will be 10). Int length表示消息长度(以字节为单位)(我的消息是10个字节,因此这将是10)。
What I'm confused about is the array. 我困惑的是阵列。 Instead of storing all the values in the array can I just specify them like this? 我可以像这样指定它们,而不是将所有值存储在数组中吗?
MIDI.sendSysEx(10,0xF0 0x41 0x36 0x06 0x21 0x20 0x01 0x22 0x1B 0xF7,true);
Also, is adding the prefix 0x the correct way to specify the bytes here? 另外,添加前缀0x是否正确指定字节?
The basic answer is "no": 基本答案是“不”:
Your sendSysEx()
function is looking for take two or three parameters: 你的sendSysEx()
函数正在寻找两个或三个参数:
By trying to pass your array data like this: 通过尝试传递您的数组数据,如下所示:
MIDI.sendSysEx(10,0xF0 0x41 0x36 0x06 0x21 0x20 0x01 0x22 0x1B 0xF7,true);
You are doing one of two things: 你正在做两件事之一:
no matching function for call to
error. 这使得你no matching function for call to
错误。 So, one way to call your function is like this: 所以,调用你的函数的一种方法是这样的:
byte data[] = { 0xF0, 0x41, 0x36, 0x06, 0x21, 0x20, 0x01, 0x22, 0x1B, 0xF7 };
sendSysEx(10, data, true);
In C++11 you can get closer to what you want by initializing the list in the function call, something like sendSysEx(10,{0xF0, 0x41, 0x36, 0x06, 0x21, 0x20, 0x01, 0x22, 0x1B, 0xF7}, true);
在C ++ 11中,您可以通过初始化函数调用中的列表来更接近您想要的内容,例如sendSysEx(10,{0xF0, 0x41, 0x36, 0x06, 0x21, 0x20, 0x01, 0x22, 0x1B, 0xF7}, true);
, however, you'll find that might run into another problem (depending on your toolchain): the compiler may assume that your initializer lists like that are lists of int
s, not byte
s, which will also cause a compiler error, unless you specifically told your compiler to assume integer literals to be 8 bits. 但是,您会发现可能会遇到另一个问题(取决于您的工具链):编译器可能会假设您的初始化程序列表是int
的列表,而不是byte
s,这也会导致编译器错误,除非您特别告诉你的编译器假设整数文字为8位。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.