Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to play combined sound as if emanating from a crowd of sound-producing objects

Consider that I have 100 instances of a "squeaker" class. Each "squeaker" object is capable of individually emitting a squeak sound. Each squeaker entity uses the same .mp3 resource. When all the squeakers are presented together on screen (for example as little characters), I want them all to squeak at approximately (but not exactly) the same time so that their combined squeaks are heard together as a crowd of squeakers.

Targeting iOS, what approach (and audio/sound framework) do you recommend? Has anyone done this before? Code samples?

like image 253
Todd Hopkinson Avatar asked Nov 28 '25 01:11

Todd Hopkinson


1 Answers

First of all, do not use MP3. The iPhone/iPod/iPad uses hardware accelerated sound decoding for the first instance of a lossy compressed sound/audio-layer. Since iOS (i think) 3.0, one additional lossy compressed sound can be played but that will put substantial load onto the CPU as it is not hardware accelerated. AFAIK that is the limit already for MP3 and AAC.

As a personal favorite, I would suggest using OpenAL in connection with RAW (uncompressed) 16bit audio files. OpenAL is really straight forward, flexible and well documented (outside of Apple's references). You will however hit a limit there as well. From what I remember, OpenAL on the iOS device has a limit of 32 voices being played at the very same time.

like image 161
Till Avatar answered Nov 30 '25 14:11

Till



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!