<commit_before>'use strict'

const audio = document.querySelector('audio')
const audioContext = new window.AudioContext
const audioSource = audioContext.createMediaElementSource(audio)
const analyser = audioContext.createAnalyser()
var frequencyData = new Uint8Array(200)

audioSource.connect(analyser)
audioSource.connect(audioContext.destination)

const height = window.screen.height / 3
const width = window.screen.width - 200
const bar = '1'
const visualizer = d3.select('#visualizer')
  .append('svg')
  .attr('height', height)
  .attr('width', width)

visualizer.selectAll('rect')
  .data(frequencyData)
  .enter()
  .append('rect')
  .attr('x', (d, i) => i * (width / frequencyData.length))
  .attr('width', width / frequencyData.length - bar)

function updateChart () {
  window.requestAnimationFrame(updateChart)
  analyser.getByteFrequencyData(frequencyData)

  visualizer.selectAll('rect')
   .data(frequencyData)
   .attr('y', d => height - d)
   .attr('height', d => d)
   .attr('fill', d => `rgb(${d}, ${d - 100}, ${d -50})`)
}

updateChart()<commit_msg>Add webkit support for AudioContext<commit_after>const audio = document.querySelector('audio')
const audioContext = new (window.AudioContext || window.webkitAudioContext)
const audioSource = audioContext.createMediaElementSource(audio)
const analyser = audioContext.createAnalyser()
let frequencyData = new Uint8Array(200)

audioSource.connect(analyser)
audioSource.connect(audioContext.destination)

const height = window.screen.height / 3
const width = window.screen.width - 200
const bar = '1'
const visualizer = d3.select('#visualizer')
  .append('svg')
  .attr('height', height)
  .attr('width', width)

visualizer.selectAll('rect')
  .data(frequencyData)
  .enter()
  .append('rect')
  .attr('x', (d, i) => i * (width / frequencyData.length))
  .attr('width', width / frequencyData.length - bar)

function updateVisualizer () {
  window.requestAnimationFrame(updateVisualizer)
  analyser.getByteFrequencyData(frequencyData)

  visualizer.selectAll('rect')
   .data(frequencyData)
   .attr('y', d => height - d)
   .attr('height', d => d)
   .attr('fill', d => `rgb(${d}, ${d - 100}, ${d -50})`)
}

updateVisualizer()
{'fraction_non_alphanumeric': 0.15570776255707763, 'fraction_numerical': 0.0136986301369863, 'mean_word_length': 5.103064066852368, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '4375387', 'n_tokens_mistral': 714, 'n_tokens_neox': 692, 'n_words': 152}