ios - 在 IOS 上使用 AudioKit 将声音文件作为 MIDI 音符发送
问题描述
我有一个 IOS 应用程序,它使用 AudioKit 来播放与 Pad 相关的声音的 AudioFiles。所以,我希望应用程序支持 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)
推荐阅读
- python - 尝试安装 Heroku 软件包时收到错误消息
- python-3.x - Cherrypy NGINX 错误:/some/path 的 403 目录索引被禁止
- php - 使用php将带有输入值的数组发送到数据库
- twilio - 发送 VCF 文件 (Vcard) 无法通过 WhatsApp 或 SMS,我做错了什么?
- php - 如何在 PHP 中检索 Posted JSON、构造字符串和电子邮件
- java - 在 Java 中导入自定义类,使用命令行
- c# - 当我发布解决方案时,ConnectionStrings 不起作用
- android - 使用资产管理器的空点对象
- vue.js - Rails Vuejs - 在滚动上更改导航链接颜色不起作用
- python - 如何填充 help() 中的各个方面