Processing Forum
class Audio { void playSound(int selected, float volume) { //loads a sound into a channel myChannel = (AudioChannel[])expand(myChannel, myChannel.length + 1); //expand the array to
make room for the new audio track
myChannel[myChannel.length - 1] = new AudioChannel(selected + ".mp3"); //add the new rack myChannel[myChannel.length - 1].volume(volume); //set the volume myChannel[myChannel.length - 1].play(); //play the channel myChannel[myChannel.length - 1].cue(1); //increase the cue, to fix a problem where the cue
reads "0" for the first frame, setting off the terminator } void advance() { //runs every frame for (int i = 0; i < myChannel.length; i++) { //run for every channel if(myChannel[i].cue == 0) { //if the channel has finished playing... myChannel = (AudioChannel[])subset(myChannel,1,myChannel.length - 1); //delete the channel } } } }
Thanks for any help!