title: Emphasize peaks in audio data
body: <p>I am trying to create a music visualizer, and have made good progress, but I am stuck on trying to emphasize the peaks in the visualization. Here is a frame of a song on my visualizer
  <a href="https://i.stack.imgur.com/XdjXv.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XdjXv.png" alt="enter image description here"></a></p>
  
  <p>and here is the same frame of the song, but the video where the actual visualizer is:
  <a href="https://i.stack.imgur.com/weRwk.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/weRwk.png" alt="enter image description here"></a></p>
  
  <p>I have an algorithm to smooth it out, like this:
  <a href="https://i.stack.imgur.com/aLUIE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/aLUIE.png" alt="enter image description here"></a></p>
  
  <p>but what can I do to get the result as shown in that video? I have looked all over the web to find a solution, and have came close with this algorithm,</p>
  
  <pre><code>function ms(array) {
      var newArr = [];
      var m = math.mean(array);
      var s = math.std(array);
      for (var i in array) {
          if (array[i] - m &gt; 2 * s) {
              newArr[i] = array[i];
          } else {
              newArr[i] = array[i] / 2;
          }
      }
      return newArr;
  }
  </code></pre>
  
  <p>but it still doesnt work well. How can I go about this, and will I need the volume data for the audio as well?</p>