 public class AKMidi: AKOperation {
     public var midiClient = MIDIClientRef()
     public var midiInPort = MIDIPortRef()
+    public var midiInPorts:[MIDIClientRef] = []
     var midiClientName:CFString = "Midi In Client"
     var midiInName:CFString = "Midi In Port"
     

    public override init() {
        super.init()
        print("howdy world, from AKMidi")
        MIDINetworkSession.defaultSession().enabled = true
        MIDINetworkSession.defaultSession().connectionPolicy = MIDINetworkConnectionPolicy.Anyone
    }
    public func openMidiIn(){
        print("Opening Midi In")
        var result = OSStatus(noErr)
        result = MIDIClientCreateWithBlock(midiClientName, &midiClient, MyMIDINotifyBlock)

        }
        let sourceCount = MIDIGetNumberOfSources()
        print("SourceCount: \(sourceCount)")
        for(var i = 0; i < sourceCount; ++i){
            let src = MIDIGetSource(i)
            var inputName : Unmanaged<CFString>?
            inputName = nil
            MIDIObjectGetStringProperty(src, kMIDIPropertyName, &inputName)
            if(namedInput.isEmpty || namedInput == (inputName?.takeRetainedValue())! as String){
                midiInPorts.append(MIDIPortRef())
                result = MIDIInputPortCreateWithBlock(midiClient, midiInName, &midiInPorts[i], MyMIDIReadBlock)
                if result == OSStatus(noErr) {
                    print("created midiInPort")
                } else {
                    print("error creating midiInPort : \(result)")
                }
                print("inputName \(inputName!.takeRetainedValue())")
                MIDIPortConnectSource(midiInPorts[i], src, nil)
            }
        }
    }//end openMidiIn
    
