We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexDiscussionExhibition › simple mp3 mixer
Page Index Toggle Pages: 1
simple mp3 mixer (Read 1840 times)
simple mp3 mixer
May 22nd, 2005, 7:36pm
 
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();
}


Page Index Toggle Pages: 1