Skip to content

Instantly share code, notes, and snippets.

@analogcode
Created December 9, 2017 23:30
Show Gist options
  • Save analogcode/27b327d3ca71187ddc47715b19a50977 to your computer and use it in GitHub Desktop.
Save analogcode/27b327d3ca71187ddc47715b19a50977 to your computer and use it in GitHub Desktop.
IAA MIDI in Swift
// in ViewDidLoad in ParentViewController.Swift
// IAA MIDI
var callbackStruct = AudioOutputUnitMIDICallbacks(
userData: nil,
MIDIEventProc: {
(first, status, data1, data2, offset) in
AudioKit.midi.sendMessage([MIDIByte(status), MIDIByte(data1), MIDIByte(data2)])},
MIDISysExProc: {
(firstPointer, secondPinter, anotherInt32) in
print("Not handling sysex")}
)
let connectIAAMDI = AudioUnitSetProperty(AudioKit.engine.outputNode.audioUnit!,
kAudioOutputUnitProperty_MIDICallbacks,
kAudioUnitScope_Global,
0,
&callbackStruct,
UInt32(MemoryLayout<AudioOutputUnitMIDICallbacks>.size))
if connectIAAMDI != 0 {
AKLog("Something bad happened")
}
// Setup AudioBus MIDI Input
setupAudioBusInput()
startObservingInterAppAudioConnections()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment