如何使用 MIDI Web API指定要发送 MIDI 消息的 channel ?
This example from the official docs展示了如何在 channel 1 上发送消息。但是在代码片段中,我没有找到任何相关的引用。
// This example sends a middle C note on message immediately on MIDI channel 1
function sendMiddleC( midiAccess, portID ) {
var noteOnMessage = [0x90, 60, 0x7f]; // note on, middle C, full velocity
var output = midiAccess.outputs.get(portID);
output.send( noteOnMessage ); //omitting the timestamp means send immediately.
}
如何在 channel 2 上发送相同的消息?
最佳答案
midi 协议(protocol)使用十六进制表示其“消息”。
前半部分用于命令,后半部分用于指定 channel 。它们是 16 个可能的 channel (MIDI channel 是 0 索引的,如文档中指定的那样)。
例子:
0x90 表示 Chan 1 (0x90) 上的Note on (0x90)
所以,如果你想在 channel 2 上发送相同的消息,你必须像这样更改它:
var noteOnMessage = [0x91, 60, 0x7f];
关于javascript - 如何指定 Web MIDI channel ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53507238/