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

import AudioToolbox
import CoreAudio

public typealias MIDIByte = UInt8
public typealias MIDIWord = UInt16
public typealias MIDINoteNumber = UInt8
public typealias MIDIVelocity = UInt8
public typealias MIDIChannel = UInt8

/// A Sample type, just a UInt32
public typealias Sample = UInt32

/// Callback function that can be called from C
public typealias AKCCallback = @convention(block) () -> Void

extension Collection {
    /// Return a random element from the collection
    public var randomIndex: Index {
        let offset = Int(arc4random_uniform(UInt32(Int64(count))))
        return index(startIndex, offsetBy: offset)
    }

    /// Retrieve a random element from the collection
    public func randomElement() -> Iterator.Element {
        return self[randomIndex]
    }
}

/// Helper function to convert codes for Audio Units
/// - parameter string: Four character string to convert
///
public func fourCC(_ string: String) -> UInt32 {<commit_msg>Removed randomElement since Swift now includes that natively<commit_after>//
//  AudioKitHelpers.swift
//  AudioKit
//
//  Created by <NAME>, revision history on Github.
//  Copyright © 2018 AudioKit. All rights reserved.
//

import AudioToolbox
import CoreAudio

public typealias MIDIByte = UInt8
public typealias MIDIWord = UInt16
public typealias MIDINoteNumber = UInt8
public typealias MIDIVelocity = UInt8
public typealias MIDIChannel = UInt8

/// A Sample type, just a UInt32
public typealias Sample = UInt32

/// Callback function that can be called from C
public typealias AKCCallback = @convention(block) () -> Void

extension Collection {
    /// Return a random element from the collection
    public var randomIndex: Index {
        let offset = Int(arc4random_uniform(UInt32(Int64(count))))
        return index(startIndex, offsetBy: offset)
    }
}

/// Helper function to convert codes for Audio Units
/// - parameter string: Four character string to convert
///
public func fourCC(_ string: String) -> UInt32 {
{'fraction_non_alphanumeric': 0.08360427310729215, 'fraction_numerical': 0.019507663725034836, 'mean_word_length': 3.573248407643312, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 10, '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': '3305776', 'n_tokens_mistral': 634, 'n_tokens_neox': 597, 'n_words': 230}