title: Playing a chord with OscillatorNodes using the Web Audio API
body: <p>I would like to play a chord using OscillatorNodes:</p>
  
  <pre><code>var ac = new (window.AudioContext || window.webkitAudioContext);
  // C4, E4, G4
  var freqs = [261.63, 329.63, 392.00];
  for(var i=0;i&lt;freqs.length;i++) {
    var o = ac.createOscillator();
    o.frequency.value = freqs[i];
    o.connect(ac.destination);
    o.noteOn(0);
    setTimeout(function() {o.noteOff(0)}, 1000);
  }
  </code></pre>
  
  <p>But this approach sounds like a mess (<a href="https://dl.dropbox.com/u/56227900/one_audiocontext.wav" rel="noreferrer">here's what it sounds like</a>). If I try creating new AudioContexts for each note in the chord, then it sounds fine (<a href="https://dl.dropbox.com/u/56227900/multiple_audiocontexts.wav" rel="noreferrer">like this</a>):</p>
  
  <pre><code>// C4, E4, G4
  var freqs = [261.63, 329.63, 392.00];
  for(var i=0;i&lt;freqs.length;i++) {
    var ac = new (window.AudioContext || window.webkitAudioContext);
    var o = ac.createOscillator();
    o.frequency.value = freqs[i];
    o.connect(ac.destination);
    o.noteOn(0);
    setTimeout(function() {o.noteOff(0)}, 1000);
  }
  </code></pre>
  
  <p>But I read that you're only supposed to have one AudioContext. What am I doing wrong?</p>