title: Web audio: Can't get ScriptProcessor node to work in Chrome
body: <p>In web audio, I can't get the ScriptProcessor node to work in Chrome, although it works fine in Firefox.</p>
  
  <pre><code>// Create audio context (Chrome/Firefox)
  var context;
  if (window.AudioContext) {
      context = new AudioContext(); 
  } else {
      context = new webkitAudioContext(); 
  }
  
  // Create oscillator and start it
  oscillator = context.createOscillator();
  oscillator.start(0);
  
  // Set up a script node that sets output to white noise
  var myscriptnode = context.createScriptProcessor(4096, 1, 1);
  myscriptnode.onaudioprocess = function(event) {
      console.log('Processing buffer');
      var output = event.outputBuffer.getChannelData(0);
      for (i = 0; i &lt; output.length; i++) {
          output[i] = Math.random() / 10;
      }
  };
  
  // Connect oscillator to script node and script node to destination
  // (should output white noise)
  oscillator.connect(myscriptnode);
  myscriptnode.connect(context.destination);
  
  // NOTE: This commented-out code connects oscillator directly to
  // destination, which works in Chrome as well as Firefox.
  //oscillator.connect(context.destination);
  </code></pre>
  
  <p>Expected result of this sample is that it should play white noise at 1/10 volume (the oscillator is actually ignored).</p>
  
  <p>You can try this code at <a href="http://jsfiddle.net/78yKV/3/" rel="nofollow">http://jsfiddle.net/78yKV/3/</a> - be aware that on Firefox this URL will play white noise straight away! On Chrome 30, it doesn't give any errors, but also doesn't give any audio output. I also checked in Chrome 31 beta but saw the same results. The 'Processing buffer' log entry never appears.</p>
  
  <p>To test the general audio system, if you uncomment the last line and connect the oscillator directly to the destination, it does play audio (the oscillator tone) correctly on Chrome. But I can't get the ScriptProcessor to work on Chrome.</p>
  
  <p>I searched the net for tutorials etc. with ScriptProcessor but those I found either didn't come with runnable examples or didn't work (or were too complex).</p>
  
  <p>(Just to make clear - this is a stripped-down sample and doesn't relate in any way to what I'm actually trying to do, so please don't tell me that I shouldn't use a ScriptProcessor to generate white noise. That's not what it's for; I do absolutely need ScriptProcessor to work for my real usage.)</p>
  
  <p>I think most likely I am doing something very stupid like I have the wrong event name or something like that, but I can't find it. Can anyone help?</p>