function getPeaks(length, buffer) {
    /*
      Set the parameters needed to build the SVG.
    */
    var sampleSize = buffer.length / length;
    var sampleStep = ~~(sampleSize / 10) || 1;
    var numberOfChannels = buffer.numberOfChannels;
    var mergedPeaks = [];

    /*
      Iterate over the channels and find the peaks.
    */
    for (var channelNumber = 0; channelNumber < numberOfChannels; channelNumber++) {
      /*
        Initialize the peaks array and set the channel data to what
        the buffer has in its channel data.
      */
      var _peaks = [];
      var channelData = buffer.getChannelData(channelNumber);

      /*
        Iterate over peaks with respect to the sample size.
      */
      for (var peakNumber = 0; peakNumber < length; peakNumber++) {
        /*
          Gt the start and end peak.
        */
        var start = ~~(peakNumber * sampleSize);
        var end = ~~(start + sampleSize);

        /*
          Set min and max to the channel data first peak.
        */
        var min = channelData[0];
        var max = channelData[0];

        /*
          Iterate over the parts of the song starting to the
          ending to display the waveform.
        */
        for (var sampleIndex = start; sampleIndex < end; sampleIndex += sampleStep) {
          var value = channelData[sampleIndex];

          if (value > max) {
            max = value;
          }
          if (value < min) {
            min = value;
          }
        }

        /*
          Set the max and min for the peak.
        */
        _peaks[2 * peakNumber] = max;
        _peaks[2 * peakNumber + 1] = min;

        /*
          Merge the peaks
        */
        if (channelNumber === 0 || max > mergedPeaks[2 * peakNumber]) {
          mergedPeaks[2 * peakNumber] = max;
        }

        if (channelNumber === 0 || min < mergedPeaks[2 * peakNumber + 1]) {
          mergedPeaks[2 * peakNumber + 1] = min;
        }
      }
    }

    /*
      Returns the merged peaks.
    */
    return mergedPeaks;
  }
Get the peaks of the audio for the waveform.

@param {number} length - The sample size of the audio.
@param {array} buffer - The array buffer used to find the peaks in the audio.