Reputation: 21
I'm learning the AudioKit framework and it was necessary to build the framework from source as the 4.2 binaries aren't compatible with the 5.0 compiler in Xcode 10.2. I have not been able to Get MIDI output working to either a physical device or using a virtual port to another app.
I can't get the examples MIDI output playground to work. I get no errors but also no MIDI output I'm using the following:
import AudioKitPlaygrounds
import AudioKit
let midi = AudioKit.midi
midi.openOutput()
import AudioKitUI
class LiveView: AKLiveViewController, AKKeyboardDelegate {
var keyboard: AKKeyboardView!
override func viewDidLoad() {
addTitle("MIDI Output")
keyboard = AKKeyboardView(width: 440, height: 100)
keyboard.delegate = self
addView(keyboard)
addView(AKButton(title: "Go Polyphonic") { button in
self.keyboard.polyphonicMode = !self.keyboard.polyphonicMode
if self.keyboard.polyphonicMode {
button.title = "Go Monophonic"
} else {
button.title = "Go Polyphonic"
}
})
}
func noteOn(note: MIDINoteNumber) {
midi.sendEvent(AKMIDIEvent(noteOn: note, velocity: 127, channel: 3))
AKLog("sending note \(note)")
}
func noteOff(note: MIDINoteNumber) {
midi.sendEvent(AKMIDIEvent(noteOff: note, velocity: 0, channel: 3))
}
}
import PlaygroundSupport
PlaygroundPage.current.needsIndefiniteExecution = true
PlaygroundPage.current.liveView = LiveView()
Upvotes: 1
Views: 62
Reputation: 21
I figured it out. It turns out that AudioKit was actually sending on channel 4 instead of channel 3. Looks like the channel index is off by 1.
Per the developer MIDI channels are indexed from 0, not 1 so this is expected behavior
Upvotes: 1