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 › Help with AudioPlayer
Page Index Toggle Pages: 1
Help with AudioPlayer (Read 962 times)
Help with AudioPlayer
Feb 9th, 2009, 4:25am
 
Im having loads of trouble playing multiple sound files with the audio player.  Currently, I have an array of AudioPlayers all initialized with separate audio files.  I have a loop that goes to each cell of the array and plays the audio file.  It looks something like:

for(int i = 0; i < player.length; i++){
player[i].play();
}

The array Player is the array of AudioPlayers.  Anybody have this problem/know how to fix it?  Thanks!!
Re: Help with AudioPlayer
Reply #1 - Feb 9th, 2009, 6:54am
 
what is the problem? sounds not playing? any error messages?
Re: Help with AudioPlayer
Reply #2 - Feb 9th, 2009, 7:24am
 
Well there are no error messages, and the audio is playing fine.  I want it to play 9  audio files at the same time though, and thats the problem.  It will just start and stop all of them and only play about half a second of each.  Any idea why this is happening?
Re: Help with AudioPlayer
Reply #3 - Feb 10th, 2009, 3:04am
 
hmm, well the below code works on my machine fine.
The mp3s I'm using are all very short, so if yours are very long perhaps there is some sort of buffer size issue, you might try different buffer sizes within the loadFile().
dan
===============
import ddf.minim.*;
Minim minim;
AudioPlayer player[]=new AudioPlayer[4];
String filenames[] = new String[]{"cake_neverThere_F_2.mp3", "missyElliot_workIt_G_1.mp3", "styx_mrRoboto_Eb_2.mp3", "who_iCantExplain_E_2.mp3"};

void setup(){
 minim = new Minim(this);
 for(int i=0;i<4;i++){
   player[i] = minim.loadFile(filenames[i], 2048);
   player[i].play();
 }
}

void draw(){}

void stop(){
for(int i=0;i<4;i++){
   player[i].close();
 }
 minim.stop();
 super.stop();
}
Page Index Toggle Pages: 1