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.
IndexProgramming Questions & HelpSound,  Music Libraries › Trouble with AudioPlayer... pls help!
Page Index Toggle Pages: 1
Trouble with AudioPlayer... pls help! (Read 564 times)
Trouble with AudioPlayer... pls help!
May 18th, 2009, 6:31pm
 
Hi,
I'm trying to make a player that changes songs with buttons, but I've been having problems with the way I make the songs actually change.... The first song plays ok, but when I try to play the second an error always comes up, or the application just fails. I've changed the code like a million times, but anything seems to work.
This is my code, I hope someone can help me soon.

Thnks.


//importa las librerias
import ddf.minim.signals.*;
import ddf.minim.*;
import ddf.minim.analysis.*;
import ddf.minim.effects.*;

//lo del sonido
Minim minim;
AudioPlayer primera;

AudioPlayer segunda;






//estos float son los que sirven para cada segmento, son 20 segmentos y sus ubicaciones
//en x y y.
float[] x = new float[20];
float[] y = new float[20];
float segLength = 9;

void setup() {
 size(800,600,P2D);
 minim = new Minim(this);

 primera = minim.loadFile("I'm Yours.mp3", 512);

 segunda = minim.loadFile("Sentimento Pentimento.mp3",512);

 loop();






 strokeJoin(ROUND);
 smooth();
 strokeWeight(3);
 stroke(0,100);
}

void draw() {
 background(255);

 //botones de las canciones
 fill(255,230,20);
 ellipse(200,50,50,50);
 fill(253,141,21);
 ellipse(300,50,50,50);
 fill(238,68,150);
 ellipse(400, 50, 50, 50);
 fill(255,0,0);
 ellipse(500,50,50,50);
 fill(150,34,150);
 ellipse(600,50,50,50);

 //culebra
 dragSegment(0, mouseX, mouseY);

 for(int i=0; i<x.length-1; i++) {
   dragSegment(i+1, x[i], y[i]);
 }

 for(int e = 0; e < primera.bufferSize() - 1; e++)
 {
   stroke(139,2,24);
   strokeWeight(2);
   //line(x1,y1,x2,y2)
   line(e, 200 +primera.left.get(e)*100, e*2, 200 + primera.left.get(e+1)*50);
   line(e, 400 + primera.right.get(e)*50, e*2, 400 + primera.right.get(e+1)*100);


 }



}



//lo de los segmentos de la culebra
void dragSegment(int i, float xin, float yin) {

 strokeJoin(ROUND);
 smooth();
 strokeWeight(3);
 stroke(0,100);

 float dx = xin - x[i];
 float dy = yin - y[i];
 float angle = atan2(dy, dx);  
 x[i] = xin - cos(angle) * segLength;
 y[i] = yin - sin(angle) * segLength;
 segment(x[i], y[i], angle);
}

//void mouseReleased ();

void segment(float x, float y, float a) {
 pushMatrix();
 translate(x, y);
 rotate(a);
 line(0, 0, segLength, 0);
 popMatrix();
}

void mouseReleased() {
 if((mouseX>175) && (mouseX<225) && (mouseY>25) && (mouseY<75)) {

   primera.play();

 }
 else {
   primera.play()
   stop();
   
 }

//  if((mouseX>275) && (mouseX<325) && (mouseY>25) && (mouseY<75)) {

 //  segunda.play();

 
// }else {
//   segunda.play();
//   stop();
// }





}

void stop()
{


primera.close();
//segunda.close();
 minim.stop();


 super.stop();
}



Page Index Toggle Pages: 1