Sound 1: Audio Wave

The processing library that you will need for sound input and input is the minim library.

We will be using the AudioInput class from the minim library to receive sound from the computers microphone. We will use a buffer size of 1024, which means each frame the sound will be sampled 1024 times creating 1024 values between -1.0 and 1.0. We can draw a waveform of points by equating each (x,y) value to (index of sample[0-1023],sample value). 

import ddf.minim.*;

//declaration of minim object
Minim minim;
//audio input variable
AudioInput sound;

//sound amplitude multiplier
float amplitude = 50;

void setup() {
  size(800, 800);
  
  minim = new Minim(this);
  sound = minim.getLineIn(Minim.STEREO, 1024);
  
}


void draw()
{
  background(0);
  stroke(255);
 
  // draw the waveform with a loop
  for(int i = 0; i < sound.bufferSize(); i++){
    point( i, height/2 + sound.mix.get(i)*amplitude);
  }

}