<commit_before>//
//  AKMIDIEndpointInfo.swift
//  AudioKit
//
//  Created by dejaWorks, revision history on Githbub.
//  Copyright © 2018 AudioKit. All rights reserved.
//

/// MIDI Endpoint Information
public struct EndpointInfo: Hashable {

    /// Unique name
    public var name = ""

    /// Dispaly name
    public var displayName = ""
    /// Model information
    public var model = ""

    /// Manufacturer
    public var manufacturer = ""

    /// Image?
    public var image = ""

    /// Driver Owner
    public var driverOwner = ""

    /// MIDIUniqueID
    public var midiUniqueID: MIDIUniqueID

    /// MIDIEndpointRef
    public var midiEndpointRef: MIDIEndpointRef

    /// MIDIPortRef (this will be set|unset when input|output open|close)
    public var midiPortRef: MIDIPortRef?

    /// Equatable
    public static func == (lhs: EndpointInfo, rhs: EndpointInfo) -> Bool {
        return lhs.hashValue == rhs.hashValue
    }
    /// Hashable
    public func hash(into hasher: inout Hasher) {
        hasher.combine(name)
        hasher.combine(displayName)
        hasher.combine(model)
        hasher.combine(manufacturer)
        hasher.combine(image)
        hasher.combine(driverOwner)
        hasher.combine(midiUniqueID)
        // midiPortRef is not added into the hash because midiPortRef is changing with every app launch
    }

}

extension Collection where Iterator.Element == MIDIEndpointRef {
    var endpointInfos: [EndpointInfo] {
        return self.map { (element: MIDIEndpointRef) -> EndpointInfo in
            EndpointInfo(
                name:
                    getMIDIObjectStringProperty(ref: element, property: kMIDIPropertyName),
                displayName:
                    getMIDIObjectStringProperty(ref: element, property: kMIDIPropertyDisplayName),
                model:
                    getMIDIObjectStringProperty(ref: element, property: kMIDIPropertyModel),
                manufacturer:
                    getMIDIObjectStringProperty(ref: element, property: kMIDIPropertyManufacturer),
                image:
                    getMIDIObjectStringProperty(ref: element, property: kMIDIPropertyImage),
                driverOwner:
                    getMIDIObjectStringProperty(ref: element, property: kMIDIPropertyDriverOwner),
                midiUniqueID:
                    getMIDIObjectIntegerProperty(ref: element, property: kMIDIPropertyUniqueID),
                midiEndpointRef: element
            )
        }
    }
}

extension AKMIDI {
    /// Destinations
    public var destinationInfos: [EndpointInfo] {
        return MIDIDestinations().endpointInfos
    }

    /// Inputs
    public var inputInfos: [EndpointInfo] {
        return MIDISources().endpointInfos
    }
}
<commit_msg>EndpointInfo is now Codable.<commit_after>//
//  AKMIDIEndpointInfo.swift
//  AudioKit
//
//  Created by dejaWorks, revision history on Githbub.
//  Copyright © 2018 AudioKit. All rights reserved.
//

/// MIDI Endpoint Information

public struct EndpointInfo:Hashable, Codable {

    /// Unique name
    public var name = ""

    /// Dispaly name
    public var displayName = ""
    /// Model information
    public var model = ""

    /// Manufacturer
    public var manufacturer = ""

    /// Image?
    public var image = ""

    /// Driver Owner
    public var driverOwner = ""

    /// MIDIUniqueID
    public var midiUniqueID: MIDIUniqueID

    /// MIDIEndpointRef
    public var midiEndpointRef: MIDIEndpointRef

    /// MIDIPortRef (this will be set|unset when input|output open|close)
    public var midiPortRef: MIDIPortRef?

    /// Equatable
    public static func == (lhs: EndpointInfo, rhs: EndpointInfo) -> Bool {
        return lhs.hashValue == rhs.hashValue
    }
    /// Hashable
    public func hash(into hasher: inout Hasher) {
        hasher.combine(name)
        hasher.combine(displayName)
        hasher.combine(model)
        hasher.combine(manufacturer)
        hasher.combine(image)
        hasher.combine(driverOwner)
        hasher.combine(midiUniqueID)
        hasher.combine(midiPortRef)
    }

    
    /// init
    public init(name:String,
         displayName:String,
         model:String,
         manufacturer:String,
         image:String,
         driverOwner:String,
         midiUniqueID: MIDIUniqueID,
         midiEndpointRef:MIDIEndpointRef,
         midiPortRef:MIDIPortRef? = nil ) {
        self.name = name
        self.displayName = displayName
        self.model = model
        self.manufacturer = manufacturer
        self.image = image
        self.driverOwner = driverOwner
        self.midiUniqueID = midiUniqueID
        self.midiEndpointRef = midiEndpointRef
        self.midiPortRef = midiPortRef
    }

}

extension Collection where Iterator.Element == MIDIEndpointRef {
    var endpointInfos: [EndpointInfo] {
        return self.map { (element: MIDIEndpointRef) -> EndpointInfo in
            EndpointInfo(
                name:
                    getMIDIObjectStringProperty(ref: element, property: kMIDIPropertyName),
                displayName:
                    getMIDIObjectStringProperty(ref: element, property: kMIDIPropertyDisplayName),
                model:
                    getMIDIObjectStringProperty(ref: element, property: kMIDIPropertyModel),
                manufacturer:
                    getMIDIObjectStringProperty(ref: element, property: kMIDIPropertyManufacturer),
                image:
                    getMIDIObjectStringProperty(ref: element, property: kMIDIPropertyImage),
                driverOwner:
                    getMIDIObjectStringProperty(ref: element, property: kMIDIPropertyDriverOwner),
                midiUniqueID:
                    getMIDIObjectIntegerProperty(ref: element, property: kMIDIPropertyUniqueID),
                midiEndpointRef: element
            )
        }
    }
}

extension AKMIDI {
    /// Destinations
    public var destinationInfos: [EndpointInfo] {
        return MIDIDestinations().endpointInfos
    }

    /// Inputs
    public var inputInfos: [EndpointInfo] {
        return MIDISources().endpointInfos
    }
}

{'fraction_non_alphanumeric': 0.08186274509803922, 'fraction_numerical': 0.00130718954248366, 'mean_word_length': 2.176440062272963, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7239948', 'n_tokens_mistral': 1770, 'n_tokens_neox': 1669, 'n_words': 386}