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

/// AudioKit version of Apple's Mixer Node
open class AKMixer: AKNode, AKToggleable {
    fileprivate let mixerAU = AVAudioMixerNode()

    /// Output Volume (Default 1)
    open dynamic var volume: Double = 1.0 {
        didSet {
            volume = max(volume, 0)
            mixerAU.outputVolume = Float(volume)
        }
    }

    fileprivate var lastKnownVolume: Double = 1.0

    /// Determine if the mixer is serving any output or if it is stopped.
    open dynamic var isStarted: Bool {
        return volume != 0.0
    }

    /// Initialize the mixer node with no inputs, to be connected later
    ///
    /// - parameter inputs: A varaiadic list of AKNodes
    ///
    public override init() {
        super.init()
        self.avAudioNode = mixerAU
        AudioKit.engine.attach(self.avAudioNode)
    }

    /// Initialize the mixer node with multiple inputs
    ///
    /// - parameter inputs: A varaiadic list of AKNodes
    ///
    public init(_ inputs: AKNode?...) {
        super.init()
        self.avAudioNode = mixerAU
        AudioKit.engine.attach(self.avAudioNode)
        for input in inputs {
            connect(input)
        }
    }

    /// Connnect another input after initialization
    ///
    /// - parameter input: AKNode to connect
    ///
    open func connect(_ input: AKNode?) {
        var wasRunning = false
        if AudioKit.engine.isRunning {
            wasRunning = true
            AudioKit.stop()
        }
        if let existingInput = input {
            existingInput.connectionPoints.append(AVAudioConnectionPoint(node: mixerAU, bus: mixerAU.numberOfInputs))
            AudioKit.engine.connect(existingInput.avAudioNode,
                                    to: existingInput.connectionPoints,
                                    fromBus: 0,
                                    format: AudioKit.format)
        }
        if wasRunning {
            AudioKit.start()
        }<commit_msg>Added constructor to AKMixer.swift to accept a swift array of AKNode objects<commit_after>//
//  AKMixer.swift
//  AudioKit
//
//  Created by <NAME>, revision history on Github.
//  Copyright © 2017 <NAME>. All rights reserved.
//

/// AudioKit version of Apple's Mixer Node
open class AKMixer: AKNode, AKToggleable {
    fileprivate let mixerAU = AVAudioMixerNode()

    /// Output Volume (Default 1)
    open dynamic var volume: Double = 1.0 {
        didSet {
            volume = max(volume, 0)
            mixerAU.outputVolume = Float(volume)
        }
    }

    fileprivate var lastKnownVolume: Double = 1.0

    /// Determine if the mixer is serving any output or if it is stopped.
    open dynamic var isStarted: Bool {
        return volume != 0.0
    }

    /// Initialize the mixer node with no inputs, to be connected later
    ///
    /// - parameter inputs: A varaiadic list of AKNodes
    ///
    public override init() {
        super.init()
        self.avAudioNode = mixerAU
        AudioKit.engine.attach(self.avAudioNode)
    }

    /// Initialize the mixer node with multiple inputs
    ///
    /// - parameter inputs: A varaiadic list of AKNodes
    ///
    public init(_ inputs: AKNode?...) {
        super.init()
        self.avAudioNode = mixerAU
        AudioKit.engine.attach(self.avAudioNode)
        for input in inputs {
            connect(input)
        }
    }
    
    /// Initialize the mixer node with multiple inputs
    ///
    /// - parameter inputs: An array of AKNodes
    ///
    public init(_ inputs: [AKNode]) {
        super.init()
        self.avAudioNode = mixerAU
        AudioKit.engine.attach(self.avAudioNode)
        for input in inputs {
            connect(input)
        }
    }

    /// Connnect another input after initialization
    ///
    /// - parameter input: AKNode to connect
    ///
    open func connect(_ input: AKNode?) {
        var wasRunning = false
        if AudioKit.engine.isRunning {
            wasRunning = true
            AudioKit.stop()
        }
        if let existingInput = input {
            existingInput.connectionPoints.append(AVAudioConnectionPoint(node: mixerAU, bus: mixerAU.numberOfInputs))
            AudioKit.engine.connect(existingInput.avAudioNode,
                                    to: existingInput.connectionPoints,
                                    fromBus: 0,
                                    format: AudioKit.format)
        }
        if wasRunning {
            AudioKit.start()
        }
{'fraction_non_alphanumeric': 0.09258856770267333, 'fraction_numerical': 0.005650945446642034, 'mean_word_length': 1.7070588235294117, 'pattern_counts': {'":': 0, '<': 7, '<?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': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4433617', 'n_tokens_mistral': 1297, 'n_tokens_neox': 1203, 'n_words': 371}