我在一个类上使用AudioKit的AKMIDIListener协议(protocol)来监听MIDI消息。对于Note On
之类的标准消息,此方法工作正常,但SysEx
消息未通过。
func receivedMIDINoteOn(noteNumber: MIDINoteNumber, velocity: MIDIVelocity, channel: MIDIChannel) {
NSLog("Note On \(noteNumber), \(velocity), \(channel)") // works perfectly
}
func receivedMIDISystemCommand(_ data: [MIDIByte]) {
NSLog("SysEx \(data)") // never triggers
// More code to handle the messages...
}
SysEx消息是从外部硬件或测试软件发送的。我已经使用MIDI监视应用程序来确保消息正确发送,但是在我的应用程序中它们没有触发
receivedMIDISystemCommand
。是否需要其他步骤来接收缺少的SysEx消息?
在此先感谢您提供任何线索。
最佳答案
编辑:感谢您提请我们注意。 SysEx接收问题现已在AudioKit的开发分支中得到解决:https://github.com/AudioKit/AudioKit/pull/1017
--
代替
NSLog("SysEx \(data)")
你有没有尝试过?
if let sysExCommand = AKMIDISystemCommand(rawValue: data[0]) {
print("MIDI System Command: \(sysExCommand)")
}
AKMIDISystemCommand会将您的SysEx数据转换为更有用的数据,其定义如下:
public enum AKMIDISystemCommand: MIDIByte {
/// Trivial Case of None
case none = 0
/// System Exclusive
case sysex = 240
/// Song Position
case songPosition = 242
/// Song Selection
case songSelect = 243
/// Request Tune
case tuneRequest = 246
/// End System Exclusive
case sysexEnd = 247
/// Clock
case clock = 248
/// Start
case start = 250
/// Continue
case `continue` = 251
/// Stop
case stop = 252
/// Active Sensing
case activeSensing = 254
/// System Reset
case sysReset = 255
}
-马修@ Audiokit