zipped project folder including all files: http://hippocamp.panicnow.net/media/simple_mp3_mixer/mp3_mixer.zip
very basic test, uses ESS plus the mp3 libs
Code:
// simple mp3 mixer using the ess library plus mp3 extensions
// wait for samples to load, click to start
// jonathan fisher 22/05/05
import krister.Ess.• ;
Channel piano, ambien;
float vol;
int oldleft, oldright;
void setup() {
size(200,100);
Ess.start(this);
piano=new Channel("piano.mp3" ;
piano.normalize();
ambien=new Channel("ambient.mp3" ;
ambien.normalize();
}
void draw() {
background(0);
stroke(255);
line(width/2,0,width/2,height);
//RIGHT HAND SAMPLE
if(mouseX > width/2){
line(width/2,mouseY,width,mouseY);
line(0,oldleft,width/2,oldleft);
vol = 1-float(mouseY)/100;
ambien.volume(vol);
println("vol right=" + vol);
oldright = mouseY;
}
else
//LEFT HAND SAMPLE
{
line(0,mouseY,width/2,mouseY);
line(width/2,oldright,width,oldright);
vol = 1-float(mouseY)/100;
piano.volume(vol);
println("vol left=" + vol);
oldleft=mouseY;
}
}
void mousePressed() {
if (piano.state==Ess.PLAYING && ambien.state==Ess.PLAYING) {
piano.stop();
ambien.stop();
}
else {
piano.play(Ess.FOREVER);
ambien.play(Ess.FOREVER);
}
}
// clean up before exiting
public void stop() {
Ess.stop();
super.stop();
}