测试已测试 | ✗ |
语言语言 | SwiftSwift |
许可证 | MIT |
发布最后发布 | 2017年5月 |
SwiftSwift 版本 | 3.0 |
SPM支持 SPM | ✗ |
由 taisuke fujita 管理。
使用 Swift 的 iOS MIDI 序列器。
R9MIDISequencer 现在具有一个完整的 MIDI 序列器,带 EXS24 和 SoundFont 采样器,可以绑定到您的乐器以实现令人惊叹且准确的播放。
使用采样器播放音符
import R9MIDISequencer
let url = Bundle.main.url(forResource: “Sound Font File Name”,
withExtension: "sf2",
subdirectory: "Sounds")
let sampler = Sampler(bankURL: url!, program: 0, bankMSB: 0x79, bankLSB: 0, channelNumber: 1)
// Play the note C
sampler.startNoteWithNumber(36)
// Play the note G
sampler.startNoteWithNumber(43)
使用序列器播放 MIDI 文件
let sequencer = Sequencer(sampler: sampler, enableLooping: true)
let midiUrl = Bundle.main.url(forResource: “MIDI File",
withExtension: "mid")
sequencer.playWithMidiURL(midiUrl)
MIDI 消息回调
class GameScene: SKScene, MIDIMessageListener {
override func didMoveToView(view: SKView) {
...Initialize sampler
let sequencer = Sequencer(sampler: sampler, enableLooping: true)
sequencer.addListener(self)
...Play MIDI
}
func midiNoteOn(note: UInt32, velocity: UInt32, channel: UInt32) {
// Call back of note on message.
}
func midiNoteOff(note: UInt32, channel: UInt32) {
// Call back of note off message.
}
func midiSequenceDidFinish() {
// Call back of finish MIDI sequence.
}
}