Playing multiple sounds simultaneously with AVAudioPlayer
Could someone help me with a function that fires multiple AVAudioPlayer
s at the same time? Right now I am trying to get a total of twelve AVAudioPlayer
s to fire at once if twelve buttons are activated, but there is a delay and it sounds like someone is running their finger down a piano instead of hitting all the keys at once.
I've looked at Audio Queue Services and can't understand how to actually implement that into code, but it says it can 开发者_运维问答play synchronized sounds. I'm not sure sure how to set all of it up. I'm trying to remake a Tone Grid app.
Why don't you use http://www.hollance.com/2011/02/soundbankplayer-using-openal-to-play-musical-instruments-in-your-ios-app/
There you have a polyphonic player, beautifully coded and ready to rock!
I used it in my first app a while back: http://itunes.apple.com/gb/app/chordwheel-pro/id406836326?mt=8
Are you calling the method prepareToPlay
on all 12 AVAudioPlayer
instances. From the docs: "Calling this method, preloads the buffers and acquires hardware, to minimize delay."
See the AVAudioPlayer class reference.
精彩评论