<commit_before>var SoundCloudAudioSource = function(player) {
    var self = this

    var audioCtx = new (window.AudioContext || window.webkitAudioContext)

    var analyser = audioCtx.createAnalyser()
    analyser.fftSize = 256
    analyser.connect(audioCtx.destination)

    var source = audioCtx.createMediaElementSource(player)
    source.connect(analyser)

    //

    this.lastVolume = 0
    this.volume = 0
    this.lastVolumes = [0,0,0,0]
    this.volumes = [0,0,0,0]
    this.streamData = new Uint8Array(analyser.frequencyBinCount)

    //

    this.playStream = function(streamUrl) {
        player.addEventListener('ended', function(){
            self.directStream('coasting')
        });
        player.setAttribute('src', streamUrl)
        player.play()
    }

    var sampleAudioStream = function() {

        // get data
        analyser.getByteFrequencyData(self.streamData)

        // calculate an overall volume value
        var total = 0
        for (var i = 0; i < self.streamData.length; i++) {
            total += (self.streamData[i]/255)
        }
        self.lastVolume = self.volume
        self.volume = total/self.streamData.length // float between 0 and 1

        var volumes = []
        for (var i=0; i<4; i++) {
            volumes[i] = 0
            for(var j=0; j<self.streamData.length/4; j++) {
                volumes[i] += (self.streamData[j]/255)
            }
            volumes[i] = volumes[i]/ (self.streamData.length/4)
        }
        self.lastVolumes = self.volumes
        self.volumes = volumes
    }
    setInterval(sampleAudioStream, 100)
}

var Visualizer = function() {

    this.init = function(options) {
        audioSource = options.audioSource

        var field = Field(document.getElementById(options.containerId))
        var centerX = field.getWidth()/2
        var centerY = field.getHeight()/2

        function parseAudioFrame() {
            volume = (audioSource.volume)*1000

            
            field.click(centerX, centerY, volume, volume*0.90)

            if(audioSource.volume-audioSource.lastVolume > 0.01 ) field.click(centerX, centerY, volume*1.20, volume*0.95)
        }

        function random(max) {
            return Math.floor((Math.random() * max) + 1);
        }
        
        function loop() {<commit_msg>formating<commit_after>var SoundCloudAudioSource = function(player) {
    var self = this

    var audioCtx = new (window.AudioContext || window.webkitAudioContext)

    var analyser = audioCtx.createAnalyser()
    analyser.fftSize = 256
    analyser.connect(audioCtx.destination)

    var source = audioCtx.createMediaElementSource(player)
    source.connect(analyser)

    //

    this.lastVolume = 0
    this.volume = 0
    this.lastVolumes = [0,0,0,0]
    this.volumes = [0,0,0,0]
    this.streamData = new Uint8Array(analyser.frequencyBinCount)

    //

    this.playStream = function(streamUrl) {
        player.addEventListener('ended', function(){
            self.directStream('coasting')
        });
        player.setAttribute('src', streamUrl)
        player.play()
    }

    var sampleAudioStream = function() {

        // get data
        analyser.getByteFrequencyData(self.streamData)

        // calculate an overall volume value
        var total = 0
        for (var i = 0; i < self.streamData.length; i++) {
            total += (self.streamData[i]/255)
        }
        self.lastVolume = self.volume
        self.volume = total/self.streamData.length // float between 0 and 1

        // calculate volumes in 4 frequency groups
        var volumes = []
        for (var i=0; i<4; i++) {
            volumes[i] = 0
            for(var j=0; j<self.streamData.length/4; j++) {
                volumes[i] += (self.streamData[j]/255)
            }
            volumes[i] = volumes[i]/ (self.streamData.length/4)
        }
        self.lastVolumes = self.volumes
        self.volumes = volumes
    }
    setInterval(sampleAudioStream, 100)
}

var Visualizer = function() {

    this.init = function(options) {
        audioSource = options.audioSource

        var field = Field(document.getElementById(options.containerId))
        var centerX = field.getWidth()/2
        var centerY = field.getHeight()/2

        function parseAudioFrame() {
            volume = (audioSource.volume)*1000
            field.click(centerX, centerY, volume, volume*0.90)
            if(audioSource.volume-audioSource.lastVolume > 0.01 ) field.click(centerX, centerY, volume*1.20, volume*0.95)
        }

        function random(max) {
            return Math.floor((Math.random() * max) + 1);
        }
        
        function loop() {
{'fraction_non_alphanumeric': 0.11795092552733534, 'fraction_numerical': 0.022600086095566078, 'mean_word_length': 2.163376446562287, 'pattern_counts': {'":': 0, '<': 9, '<?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': '1710947', 'n_tokens_mistral': 1440, 'n_tokens_neox': 1376, 'n_words': 274}