title: HTML 5 Audio lib - How to get the average value of the music table
body: <p>I have found there a nice and working perfectly fine tutorial to play with music with a web library.</p>
  
  <p>Everything is working fine but I would like to have the "average value" of the music I play. Let me explain that. Currently: music is loaded,</p>
  
  <pre><code>function loadSound(url) {
          var request = new XMLHttpRequest();
          request.open('GET', url, true);
          request.responseType = 'arraybuffer';
  
          // When loaded decode the data
          request.onload = function() {
  
              // decode the data
              context.decodeAudioData(request.response, function(buffer) {
                  // when the audio is decoded play the sound
                  playSound(buffer);
              }, onError);
          }
          request.send();
      }
  </code></pre>
  
  <p>and buffer played. I can easily find the average value of the buffer that way: </p>
  
  <pre><code>var getAverage = function(dataArray){
          var total = 0,                               // initialize to 0
              i = 0, length = dataArray.length;
          while(i &lt; length) total += dataArray[i++];   // add all
          return length ? total / length : 0;          // divide (when length !== 0)
      }
  </code></pre>
  
  <p>used there</p>
  
  <pre><code>javascriptNode.onaudioprocess = function() {
  
          // get the average for the first channel
          var array =  new Uint8Array(analyser.frequencyBinCount);
          analyser.getByteFrequencyData(array);
  
          // clear the current state
          ctx.clearRect(0, 0, 1000, 325);
  
          // set the fill style
          ctx.fillStyle=gradient;
          drawSpectrum(array);
          var averageVal = getAverage(array);
  </code></pre>
  
  <p>But what about the "global" value and not only the one put in the buffer?</p>
  
  <p>In a word: how to recover the global Uint8Array object from the loaded mp3, and not only the parsed buffer?</p>
  
  <p>Many thanks for you help!</p>