     /// - parameter namedInput: String containing the name of the MIDI Input
     ///
     public func openInput(_ namedInput: String = "") {
-        var result = noErr
-        
         let sourceCount = MIDIGetNumberOfSources()
         
         for i in 0 ..< sourceCount {
             let src = MIDIGetSource(i)
-            var tempName: Unmanaged<CFString>? = nil
-            
-            MIDIObjectGetStringProperty(src, kMIDIPropertyName, &tempName)
-            let inputNameStr = (tempName?.takeRetainedValue())! as String
+
+            let inputNameStr = GetMIDIObjectProperty(ref: src, property: kMIDIPropertyName)
+
             if namedInput.isEmpty || namedInput == inputNameStr {
                 
                 inputPorts[namedInput] = MIDIPortRef()

//  Copyright © 2016 AudioKit. All rights reserved.
//

extension AKMIDI {
    
    /// Array of input names
    public var inputNames: [String] {
        var nameArray = [String]()
        let sourceCount = MIDIGetNumberOfSources()
        
        for i in 0 ..< sourceCount {
            let source = MIDIGetSource(i)
            var inputName: Unmanaged<CFString>?
            inputName = nil
            MIDIObjectGetStringProperty(source, kMIDIPropertyName, &inputName)
            let inputNameStr = (inputName?.takeRetainedValue())! as String
            nameArray.append(inputNameStr)
        }
        return nameArray
    }
    
    /// Add a listener to the listeners

                    }
                }
                
                let result = MIDIInputPortCreateWithBlock(client, inputPortName, &port, readBlock)
                
                inputPorts[namedInput] = port
                
