Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Mockup & CodeGen, iPhone & iPad
($9.99)

Make your own iPhone apps
and run them live!
(free)

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 10-08-2009, 10:26 AM   #1 (permalink)
Registered Member
 
Join Date: Sep 2009
Age: 15
Posts: 93
Default Making audio files play at random and crossfade? *HELP*

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.
tackey123 is offline   Reply With Quote
Old 10-09-2009, 10:46 AM   #2 (permalink)
Registered Member
 
Join Date: Sep 2009
Age: 15
Posts: 93
Default

Anybody???
tackey123 is offline   Reply With Quote
Old 10-10-2009, 02:21 AM   #3 (permalink)
Registered Member
 
Join Date: Aug 2008
Location: Pune, India
Posts: 314
Send a message via Skype™ to Akshay Shah
Default

Hey... Even i want to do something same...
But i am stuck at how to play few items one after another?
Do you know?
Any sample code help would be much appreciated..
Thanks..
__________________
If you think I did help you, you can always thank me by buying
iHoldMore - A very nice and addictive game...

Need a mobile app. Contact Us.
Ruby Solutions Pvt. Ltd.
You can mail me at akshay@ruby-solutions.com
Akshay Shah is offline   Reply With Quote
Old 10-10-2009, 02:32 AM   #4 (permalink)
David Porter Apps
 
bobbypage's Avatar
 
Join Date: Aug 2009
Posts: 71
Default

Quote:
Originally Posted by tackey123 View Post
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;
      }
}
bobbypage is offline   Reply With Quote
Old 09-24-2011, 12:45 PM   #5 (permalink)
Registered Member
 
Join Date: Feb 2010
Posts: 12
Default

Quote:
Originally Posted by tackey123 View Post
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.
Crossfade:

I am trying that to work.

Earlier I tried with one audio player but that won't crossfade.

AVAudioPlayer Class Reference:"Play multiple sounds simultaneously, one sound per audio player, with precise synchronization"



So I am going to try with two or more.

Will update.
gammapoint is offline   Reply With Quote
Reply

Bookmarks

Tags
audio, crossfade, help!, random

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 266
19 members and 247 guests
ADY, AragornSG, Bertrand21, Dani77, Dattee, Duncan C, fkmtc, HDshot, HemiMG, JasonR, mer10, prchn4christ, Promo Dispenser, Punkjumper, Rudy, sacha1996, sneaky, spiderguy84, theone8one
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,885
Threads: 89,231
Posts: 380,768
Top Poster: BrianSlick (7,129)
Welcome to our newest member, bookesp
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 03:13 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0