![](/img/trans.png)
[英]Sending MIDI notes through a virtual port within iOS using AudioKit
[英]sending sound files as MIDI notes using AudioKit on IOS
我有一个 IOS 应用程序,它使用 AudioKit 播放与 Pad 相关的声音的音频文件。 所以,我希望应用程序支持 MIDI 文件。 我想知道如何使用 MIDI 导出这些声音文件,以便在 Garage Band 等应用程序上播放它们
发送 MIDI:
// to send between app, create a virtual port:
AudioKit.midi.createVirtualOutputPort()
// you can specify which outputs you want to open, or open all by default:
AudioKit.midi.openOutput()
// to send a noteOn message:
AudioKit.midi.sendNoteOnMessage(noteNumber: aNoteNumber, velocity: aVelocity)
// to send a noteOff message:
AudioKit.midi.sendNoteOffMessage(noteNumber: aNoteNumber, velocity: 0)
要接收 MIDI,您需要有一个实现AKMIDIListener
协议的类(它甚至可以是您的 ViewController,但可能不应该是)。 此类允许您实现诸如receivedMIDINoteOn
类的方法来处理传入事件。
class ClassThatImplementsMIDIListener: AKMIDIListener {
func receivedMIDINoteOn(noteNumber: MIDINoteNumber,
velocity: MIDIVelocity,
channel: MIDIChannel) {
// handle the MIDI event in your app, e.g., trigger you sound file
}
}
设置很简单:
// if you want to receive midi from other apps, create a virtual in
AudioKit.midi.createVirtualInputPort()
// you can specify which inputs you want to open, or open them all by default
AudioKit.midi.openInput()
// add your listener
AudioKit.midi.addListener(classImplementingMIDIListener)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.