Swift CoreMIDI without Objective-C (Updated for Swift 3)

Update: Code has been added for Swift 3 and XCode 8

These examples do little to no error checking and it is assumed your system has at least one source and one destination. Run them in a macOS Playground.

List the MIDI sources and destinations (Swift 3)

 

List the MIDI sources and destinations (Swift 2)

 

Create a client, connect a destination, and play a note (Swift 3)

 

Create a client, connect a destination, and play a note (Swift 2)

 

Connect an input source and receive data via a callback (Swift 3)

 

Connect an input source and receive data via a callback (Swift 2)