Quote:
Originally Posted by tackey123
Does anyone know how to write code that would do this:
I have about 12 short audio files (mpegs).
I want to hit a "PLAY" button and have one of those audio files chosen at random to play. It would loop twice and then on the third loop it should crossfade into another randomly chosen piece of audio.
That's it. No stop or pause buttons. Just PLAY and the audio files are chosen to randomly play, crossfading into each other.
|
I would use rand() look at my code below on how to do it... hope I help
Code:
-(IBAction)pushrandomsound {
int rNumber = rand() % 5; //put how many cases you have here
switch (rNumber) {
case 0:
//insert code to play sound 1 here
break;
case 1:
//insert code to play sound 2 here
break;
case 2:
//insert code to play sound 3 here
break;
case 3:
//insert code to play sound 4 here
break;
case 4:
//insert code to play sound 5 here
break;
default:
break;
}
}