This reference is for Processing 3.0+. If you have a previous version, use the reference included with your software in the Help menu. If you see any errors or have suggestions, please let us know. If you prefer a more technical reference, visit the Processing Core Javadoc and Libraries Javadoc.

Name

Waveform

Examples
import processing.sound.*;

SoundFile sample;
Waveform waveform;

int samples = 100;

public void setup()
{
  size(640, 360);
  background(255);

  sample = new SoundFile(this, "beat.aiff");
  sample.loop();

  waveform = new Waveform(this, samples);
  waveform.input(sample);
}

public void draw()
{
  background(0);
  stroke(255);
  strokeWeight(2);
  noFill();


  waveform.analyze();

  beginShape();
  for(int i = 0; i < samples; i++)
  {
    vertex(
      map(i, 0, samples, 0, width),
      map(waveform.data[i], -1, 1, 0, height)
    );
  }
  endShape();
}
Description This is a Waveform analyzer. It returns the waveform of the of an audio stream the moment it is queried with the analyze() method.
Constructor
Waveform(parent, nsamples)
Parameters
parent PApplet: typically use "this"
nsamples int: number of waveform samples that you want to be able to read at once (a positive integer).
Updated on January 1, 2021 03:38:11am EST