Created
December 9, 2017 23:30
-
-
Save analogcode/27b327d3ca71187ddc47715b19a50977 to your computer and use it in GitHub Desktop.
IAA MIDI in Swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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