Seems like I can control core audio directly from the command line in Swift. no horrid Xcode is involved.
One quick example seems to be worth a thousand words, so here's a version of PlaySoftMidi.cpp converted to Swift.
*PlaySoftMidi* has been in the Mac Developer library since 2007 and is just about the only program I can understand that *uses* the CoreAudio stuff.
If you have swift2.1 on your machine save PlaySoftMidi.swift in a file and give the command:
And the program will play samples from the inbuilt synthesizer.
Here are the programs:
These two program also show the equivalence between C++ and Swift
For example in C++ we say:
And to use a constant just refer to it by name.
And In Swift we say:
And to use a value say something like: Midi.kMidiMessageProgramChange.rawValue
I hope this is not a trend - just when you though programming language couldn't get any more verbose, they did.
Type casts seem to be functions. If x in Swift is an Int and I want to convert it to a variable y of type UInt32 I say:
And NOT y = (UInt32) x -- *horay* say I.
When I've got a socket interface working I'll connect this to Erlang so that I can hit the midi interface from Erlang -- then the fun can begin.