// Example by Krister Olsson
import krister.Ess.*;
AudioChannel myChannel;
void setup() {
size(256,200);
background(0,0,255);
// start up Ess
Ess.start(this);
// load "cell.aif" into a new AudioChannel
myChannel=new AudioChannel("cell.aif");
// start playing
myChannel.play();
}
void draw() {
stroke(255,10);
// overlay an average of the samples in the buffer being played
float inc=myChannel.buffer.length/256.0f;
for (int i=0;i<256;i++) {
int y=(int)(100+myChannel.buffer[(int)(i*inc)]*100);
line(i-200,y-200,i+200,y+200);
}
}
// we are done, clean up Ess
public void stop() {
Ess.stop();
super.stop();
}
|