getPeaks(length) {
    if (this.buffer) {
      // set length to window's width if no length is provided
      if (!length) {
        length = window.innerWidth * 5;
      }
      if (this.buffer) {
        var buffer = this.buffer;
        var sampleSize = buffer.length / length;
        var sampleStep = ~~(sampleSize / 10) || 1;
        var channels = buffer.numberOfChannels;
        var peaks = new Float32Array(Math.round(length));

        for (var c = 0; c < channels; c++) {
          var chan = buffer.getChannelData(c);
          for (var i = 0; i < length; i++) {
            var start = ~~(i * sampleSize);
            var end = ~~(start + sampleSize);
            var max = 0;
            for (var j = start; j < end; j += sampleStep) {
              var value = chan[j];
              if (value > max) {
                max = value;
                // faster than Math.abs
              } else if (-value > max) {
                max = value;
              }
            }
            if (c === 0 || Math.abs(max) > peaks[i]) {
              peaks[i] = max;
            }
          }
        }

        return peaks;
      }
    } else {
      throw 'Cannot load peaks yet, buffer is not loaded';
    }
  }
Returns an array of amplitude peaks in a p5.SoundFile that can be
used to draw a static waveform. Scans through the p5.SoundFile's
audio buffer to find the greatest amplitudes. Accepts one
parameter, 'length', which determines size of the array.
Larger arrays result in more precise waveform visualizations.

Inspired by Wavesurfer.js.

@method  getPeaks
@for p5.SoundFile
@params {Number} [length] length is the size of the returned array.
                         Larger length results in more precision.
                         Defaults to 5*width of the browser window.
@returns {Float32Array} Array of peaks.