Created
January 26, 2015 06:29
-
-
Save JRHeaton/c9a8e501b74e2a199e3e to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| import CoreMIDI | |
| extension MIDIPacket { | |
| static func channel(status: UInt8, data1: UInt8, data2: UInt8) -> MIDIPacket { | |
| let newPacket = UnsafeMutablePointer<MIDIPacket>.alloc(1) | |
| newPacket.memory.length = 3 | |
| withUnsafePointer(&newPacket.memory.data, { (ptr) -> () in | |
| let dataPtr = UnsafeMutablePointer<UInt8>(ptr) | |
| dataPtr[0] = status | |
| dataPtr[1] = data1 | |
| dataPtr[2] = data2 | |
| }) | |
| let ret = newPacket.memory | |
| newPacket.dealloc(1) | |
| return ret | |
| } | |
| } | |
| logPacket(MIDIPacket.channel(0x90, data1: 20, data2: 127)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment