Reputation: 33402
I am writing a simple iOS app that will include a piano.
I only need something very basic, and I'm probably going with this approach:
My understanding is that one AVAudioPlayer
instance can only be used with one sound. Therefore, I'd have to create many AVAudioPlayer
s (88 to be precise), one for every piano key.
My question is, how memory-intensive is AVAudioPlayer
? Can I just initialize the program by creating 88 AVAudioPlayer
s, keeping them in memory, and using them as appropriate? Or is the memory footprint of an AVAudioPlayer
too big, and should I only alloc/release the AVAudioPlayer
s as necessary? If so, will allocating/releasing the players be quick enough so that the user doesn't notice any lag?
Upvotes: 0
Views: 382
Reputation: 18497
This project uses OpenAL SoundBankPlayer as a solution for that functionality. Another approach is to use a soundFont and a Sampler AudioUnit. Very optimized for music creation type apps. Good details and source code: AudioGraph
Upvotes: 1