mwg API
    Preparing search index...

    Function waveformEnvelope

    • A waveform reduced to buckets min/max pairs, what an oscilloscope or overview strip draws: each bucket covers an equal span of the samples (the last may be shorter), so a peak that lasts one sample still shows, which a plain average would erase.

      Parameters

      • samples: Float32Array
      • buckets: number

      Returns WaveformBucket[]

      import { waveformEnvelope } from '@datamoc/mwg/audio';

      const view = waveformEnvelope(new Float32Array([0, 1, -1, 0.5]), 2);
      console.log(view); // [{ min: 0, max: 1 }, { min: -1, max: 0.5 }]