<commit_before>//
//  AKMIDI.swift
//  AudioKit
//
//  Created by <NAME>, revision history on Github.
//  Copyright © 2018 AudioKit. All rights reserved.
//

import CoreMIDI

/// MIDI input and output handler
///
/// You add MIDI listeners like this:
/// ```
/// var midi = AudioKit.midi
/// midi.openInput()
/// midi.addListener(someClass)
/// ```
/// ...where someClass conforms to the AKMIDIListener protocol
///
/// You then implement the methods you need from AKMIDIListener and use the data how you need.
///
open class AKMIDI {

    // MARK: - Properties

    /// MIDI Client Reference
    open var client = MIDIClientRef()

    /// MIDI Client Name
    internal let clientName: CFString = "MIDI Client" as CFString

    /// Array of MIDI In ports
    var inputPorts = [MIDIUniqueID: MIDIPortRef]()

    /// Virtual MIDI Input destination
    open var virtualInput = MIDIPortRef()

    /// MIDI In Port Name
    internal let inputPortName: CFString = "MIDI In Port" as CFString

    /// MIDI Out Port Reference
    public var outputPort = MIDIPortRef()

    /// Virtual MIDI output
    open var virtualOutput = MIDIPortRef()

    /// MIDI Out Port Name
    var outputPortName: CFString = "MIDI Out Port" as CFString

    /// Array of MIDI Endpoints
    open var endpoints = [MIDIUniqueID: MIDIEndpointRef]()

    /// Array of all listeners
    var listeners = [AKMIDIListener]()

    var transformers = [AKMIDITransformer]()

    // MARK: - Initialization

    /// Initialize the AKMIDI system
    @objc public init() {
        AKLog("Initializing MIDI")

        #if os(iOS)
        MIDINetworkSession.default().isEnabled = true
        MIDINetworkSession.default().connectionPolicy =
            MIDINetworkConnectionPolicy.anyone
        #endif

        if client == 0 {
            let result = MIDIClientCreateWithBlock(clientName, &client) {
                let messageID = $0.pointee.messageID

                switch messageID {
                case .msgSetupChanged:
                    for listener in self.listeners {
                        listener.receivedMIDISetupChange()
                    }
                case .msgPropertyChanged:
                    let rawPtr = UnsafeRawPointer($0)
                    let propChange = rawPtr.assumingMemoryBound(to: MIDIObjectPropertyChangeNotification.self).pointee
                    for listener in self.listeners {
                        listener.receivedMIDIPropertyChange(propertyChangeInfo: propChange)
                    }
                default:
                    for listener in self.listeners {
                        listener.receivedMIDINotification(notification: $0.pointee)
                    }
                }
            }
            if result != noErr {
                AKLog("Error creating MIDI client : \(result)")
            }
        }
    }

    // MARK: - SYSEX

    internal var isReceivingSysex: Bool = false
    func startReceivingSysex(with midiBytes: [MIDIByte]) {
        AKLog("Starting to receive Sysex")
        isReceivingSysex = true
        incomingSysex = midiBytes
    }
    func stopReceivingSysex() {
        AKLog("Done receiving Sysex")
        isReceivingSysex = false
    }
    var incomingSysex = [MIDIByte]()
}
<commit_msg>Making some variables public in AKMIDI<commit_after>//
//  AKMIDI.swift
//  AudioKit
//
//  Created by <NAME>, revision history on Github.
//  Copyright © 2018 AudioKit. All rights reserved.
//

import CoreMIDI

/// MIDI input and output handler
///
/// You add MIDI listeners like this:
/// ```
/// var midi = AudioKit.midi
/// midi.openInput()
/// midi.addListener(someClass)
/// ```
/// ...where someClass conforms to the AKMIDIListener protocol
///
/// You then implement the methods you need from AKMIDIListener and use the data how you need.
///
open class AKMIDI {

    // MARK: - Properties

    /// MIDI Client Reference
    open var client = MIDIClientRef()

    /// MIDI Client Name
    internal let clientName: CFString = "MIDI Client" as CFString

    /// Array of MIDI In ports
    public var inputPorts = [MIDIUniqueID: MIDIPortRef]()

    /// Virtual MIDI Input destination
    open var virtualInput = MIDIPortRef()

    /// MIDI In Port Name
    internal let inputPortName: CFString = "MIDI In Port" as CFString

    /// MIDI Out Port Reference
    public var outputPort = MIDIPortRef()

    /// Virtual MIDI output
    open var virtualOutput = MIDIPortRef()

    /// MIDI Out Port Name
    var outputPortName: CFString = "MIDI Out Port" as CFString

    /// Array of MIDI Endpoints
    open var endpoints = [MIDIUniqueID: MIDIEndpointRef]()

    /// Array of all listeners
    public var listeners = [AKMIDIListener]()

    public var transformers = [AKMIDITransformer]()

    // MARK: - Initialization

    /// Initialize the AKMIDI system
    @objc public init() {
        AKLog("Initializing MIDI")

        #if os(iOS)
        MIDINetworkSession.default().isEnabled = true
        MIDINetworkSession.default().connectionPolicy =
            MIDINetworkConnectionPolicy.anyone
        #endif

        if client == 0 {
            let result = MIDIClientCreateWithBlock(clientName, &client) {
                let messageID = $0.pointee.messageID

                switch messageID {
                case .msgSetupChanged:
                    for listener in self.listeners {
                        listener.receivedMIDISetupChange()
                    }
                case .msgPropertyChanged:
                    let rawPtr = UnsafeRawPointer($0)
                    let propChange = rawPtr.assumingMemoryBound(to: MIDIObjectPropertyChangeNotification.self).pointee
                    for listener in self.listeners {
                        listener.receivedMIDIPropertyChange(propertyChangeInfo: propChange)
                    }
                default:
                    for listener in self.listeners {
                        listener.receivedMIDINotification(notification: $0.pointee)
                    }
                }
            }
            if result != noErr {
                AKLog("Error creating MIDI client : \(result)")
            }
        }
    }

    // MARK: - SYSEX

    internal var isReceivingSysex: Bool = false
    func startReceivingSysex(with midiBytes: [MIDIByte]) {
        AKLog("Starting to receive Sysex")
        isReceivingSysex = true
        incomingSysex = midiBytes
    }
    func stopReceivingSysex() {
        AKLog("Done receiving Sysex")
        isReceivingSysex = false
    }
    var incomingSysex = [MIDIByte]()
}

{'fraction_non_alphanumeric': 0.08960244648318043, 'fraction_numerical': 0.0024464831804281344, 'mean_word_length': 1.91358574610245, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '4717837', 'n_tokens_mistral': 1944, 'n_tokens_neox': 1773, 'n_words': 514}