title: Web audio api misreporting length of buffer?
body: <p>I'm doing some web audio stuff on chrome and i noticed the buffer.length property does not match what I see in Sonar. Web audio claims my file is 1391324 samples long, or ~31.6 seconds. Sonar is showing me 1278279 samples, or ~29 seconds. The file properties in windows confirm Sonar's numbers as well. Its a normal 16-bit, 44.1k wav file. Whats could be going on here?</p>
  
  <p><strong>Edit:</strong> It appears chrome resamples the audio to 48k. Why??? I want my same wav file, thanks. Firefox does not do this and gives me the correct length.</p>
  
  <p>Try it on chrome and firefox using this fiddle: <a href="http://jsfiddle.net/kV7aV/2/" rel="nofollow">http://jsfiddle.net/kV7aV/2/</a>
  and use this file: <a href="https://dl.dropboxusercontent.com/u/75652364/amp.wav" rel="nofollow">https://dl.dropboxusercontent.com/u/75652364/amp.wav</a></p>
  
  <p>Fiddle code to make SO happy:</p>
  
  <p>html:</p>
  
  <pre><code>&lt;input type="file" id="audio_file" accept="audio/wav" multiple /&gt;
  &lt;p id="output"&gt;&lt;/p&gt;
  &lt;p id="output2"&gt;&lt;/p&gt;
  </code></pre>
  
  <p>js:</p>
  
  <pre><code>var fileInput = document.getElementById("audio_file");
  var output = document.getElementById("output");
  var output2 = document.getElementById("output2");
  
  window.AudioContext = window.AudioContext || window.webkitAudioContext;
  
  var context = new AudioContext();
  
  fileInput.onchange = function (evt) {
  
      var files = evt.target.files; // FileList object
  
      for (var f = 0; f &lt; files.length; f++) {
  
          var reader = new FileReader();
  
          reader.onload = function (e) {
              context.decodeAudioData(e.target.result, function (buffer) {
                  console.log(buffer.length);
                  output.innerHTML = buffer.length;
  
                  var data = buffer.getChannelData(0);
  
                  // undefined in firefox
                  console.log(data[1391323]);
                  output2.innerHTML = data[1391323];
  
              });
  
          };
  
          reader.readAsArrayBuffer(files[f]);
  
      }
  
  };
  </code></pre>