We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi, I'm doing a small audio player with 3 songs, each one loaded into a different player object. now, I have a pot (in arduino), and the values are received in processing. What I need is that, these values should be the overall volume 'going out' from processing. I can't set the volume for each player beacuse there's a fade in/out between each of them, and this would conflict. for the same reason, I can't check with isPlaying() which player is playing and use setGain on it. What I'd like to do is basically sticking all the players to one single output and then control the volume of this output:
//this is not working as the patch method does not work with audioplayer obj
out.patch(player1);
out.patch(player2);
out.patch(player3);
out.setGain(pot);
assuming that out is the general output.
this is the function I'm using to do the fade in/out. As you can see I need to pause and rewind ech player, but this can be done only after the fade out (2.5 seconds), and that's why I can't have the volume changing in that time
void changeSong(){
++my_player;
if(my_player == 1){
player3.shiftGain(player3.getGain(),-80,FADE);
player1.play();
player1.shiftGain(-80,volume,FADE);
player2.pause();
player2.rewind();
}else if(my_player == 2){
player1.shiftGain(player1.getGain(),-80,FADE);
player2.play();
player2.shiftGain(-80,volume,FADE);
player3.pause();
player3.rewind();
}else{
player2.shiftGain(player2.getGain(),-80,FADE);
player3.play();
player3.shiftGain(-80,volume,FADE);
player1.pause();
player1.rewind();
}
my_player%=3;
}
any suggestion?
thanks
Answers
Almost nil experience w/ Minim here.
But you should start using arrays for AudioPlayer objects:
https://Processing.org/tutorials/arrays/
http://docs.Oracle.com/javase/tutorial/java/nutsandbolts/arrays.html