var audioContext = new (window.AudioContext || window.webkitAudioContext)()
var analyser = audioContext.createAnalyser()
var biquadFilter = audioContext.createBiquadFilter()
var audioBuffer = new Float32Array(analyser.fftSize)
var frequencyData = new Uint8Array(analyser.frequencyBinCount)
var waveform = new Waveform('#waveform')
var frequencyBars = new FrequencyBars('#frequency-bars')
var pitchDetector = new (Module().PitchDetector)('default', analyser.fftSize, 1, audioContext.sampleRate)
var $pitch = document.querySelector('#pitch')

biquadFilter.type = 'lowpass'
biquadFilter.frequency.value = 440

navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia
navigator.getUserMedia({audio: true}, function (stream) {
  audioContext.createMediaStreamSource(stream).connect(biquadFilter)
  biquadFilter.connect(analyser)
}, function () {})

function noteFromFrequency(frequency) {
  var noteNum = 12 * (Math.log(frequency / 440) / Math.log(2))
  return Math.round(noteNum) + 69
}

function frequencyFromNote(note) {
  return 440 * Math.pow(2, (note - 69) / 12)
}

function centsDiffFromFrequency(frequency, note) {
  return Math.floor(1200 * Math.log(frequency / frequencyFromNote(note)) / Math.log(2))
}

var noteStrings = ['C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#', 'A', 'A#', 'B']

process()
function process() {
  requestAnimationFrame(process)
  analyser.getFloatTimeDomainData(audioBuffer)
  analyser.getByteFrequencyData(frequencyData)
  waveform.update(audioBuffer)
  frequencyBars.update(frequencyData)

  var frequency = pitchDetector.getPitch(audioBuffer)
  if (frequency) {
    var note = noteFromFrequency(frequency)
    var noteString = noteStrings[note % 12] || ''
    var centsDiff = centsDiffFromFrequency(frequency, note)
    $pitch.innerHTML = noteString + ', ' + centsDiff + ' cents, ' + frequency.toFixed(1) + ' Hz'
  }
}
@@ -73,22 +73,26 @@
 )()%0Avar 
-analys
+biquadFilt
 er = aud
@@ -111,186 +111,213 @@
 eate
-Analyser()%0Avar biquadFilter = audioContext.createBiquadFilter()%0Avar audioBuffer = new Float32Array(analyser.fftSize)%0Avar frequencyData = new Uint8Array(analyser.frequencyBin
+BiquadFilter()%0Avar scriptProcessor = audioContext.createScriptProcessor(4096, 1, 1)%0Avar pitchDetector = new (Module().PitchDetector)(%0A      'default', scriptProcessor.bufferSize, 1, audio
 Co
-u
 nt
+ext.sampleRate
 )%0Ava
@@ -416,114 +416,8 @@
 s')%0A
-var pitchDetector = new (Module().PitchDetector)('default', analyser.fftSize, 1, audioContext.sampleRate)%0A
 var 
@@ -755,23 +755,30 @@
 connect(
-analyse
+scriptProcesso
 r)%0A%7D, fu
@@ -1246,164 +1246,180 @@
 '%5D%0A%0A
-process()%0Afunction process() %7B%0A  requestAnimationFrame(process)%0A  analyser.getFloatTimeDomainData(audioBuffer)%0A  analyser.getByteFrequencyData(frequency
+scriptProcessor.connect(audioContext.destination)%0AscriptProcessor.addEventListener('audioprocess', function (event) %7B%0A  var audioBuffer = event.inputBuffer.getChannel
 Data
+(0
 )%0A  
@@ -1448,16 +1448,19 @@
 uffer)%0A 
+ //
  frequen
@@ -1818,8 +1818,9 @@
 z'%0A  %7D%0A%7D
+)

replace Analyser with ScriptProcessor