★ TouchArcade needs your help. Click here to support us on Patreon.

Sounds 'resolution' in your game

05-30-2011, 04:21 PM
#1
Joined: Apr 2011
Location: Italy
Posts: 81
Sounds 'resolution' in your game

Hi all,

thanks to yours useful directions, i've finally found sound effects for my game. Now i wonder which sound 'resolution' are you using for effects?

I mean, 16bit-44Khz-Stereo may be a bit too large... or not? I'd like my game to be enjoyable with earphone too.

Other question...

In a book i bought years ago (http://www.apress.com/9781430219682) i've read that mixing different resolution sound effect could create serious performance issues. I quote here:

"In OpenAL a sound effect is stored in a buffer and then played when needed. The format of the sound data in this buffer is critical because if you have 30 sound effects all going off simultaneously, then you don’t want the CPU to have to do any extra work converting the hundreds of thousands of samples every second from the buffer’s format to Core Audio’s native format. Therefore, all sound effects should be identically formatted and in Core Audio
File Format (CAFF) format. You should never have some of your sounds be 22 kHz and some 44.1 kHz. They must all be the exact same frequency, bit depth, and format, and they must be mono. Even having just one oddball effect can destroy the audio pipeline and cause serious performance issues. "

Is this still true with new iOS devices? The author here developed a game (Nanosaur) for iPhone 2G/3G.

Thanks again,

sigLuca
Game Artesan
05-30-2011, 10:45 PM
#2
Joined: Apr 2009
Location: Pennsylvania
Posts: 1,005
I've seen no evidence of "serious performance problems" mixing different sound formats.

Quote:
Originally Posted by sigLuca View Post
Hi all,

thanks to yours useful directions, i've finally found sound effects for my game. Now i wonder which sound 'resolution' are you using for effects?

I mean, 16bit-44Khz-Stereo may be a bit too large... or not? I'd like my game to be enjoyable with earphone too.

Other question...

In a book i bought years ago (http://www.apress.com/9781430219682) i've read that mixing different resolution sound effect could create serious performance issues. I quote here:

"In OpenAL a sound effect is stored in a buffer and then played when needed. The format of the sound data in this buffer is critical because if you have 30 sound effects all going off simultaneously, then you don’t want the CPU to have to do any extra work converting the hundreds of thousands of samples every second from the buffer’s format to Core Audio’s native format. Therefore, all sound effects should be identically formatted and in Core Audio
File Format (CAFF) format. You should never have some of your sounds be 22 kHz and some 44.1 kHz. They must all be the exact same frequency, bit depth, and format, and they must be mono. Even having just one oddball effect can destroy the audio pipeline and cause serious performance issues. "

Is this still true with new iOS devices? The author here developed a game (Nanosaur) for iPhone 2G/3G.

Thanks again,

sigLuca
Game Artesan

05-31-2011, 07:30 AM
#3
Joined: Nov 2008
Location: Munich, Germany
Posts: 754
Send a message via Skype™ to mobile1up
Quote:
Originally Posted by Stroffolino View Post
I've seen no evidence of "serious performance problems" mixing different sound formats.
typically; sounds libraries have a buffer for playback.
the higher your frequency; the more data gets pushed through the buffers; what this means is that 44khz processes the buffer 2x faster than a 22khz stream. the key question here; is pure latency.

buffer size: 1024 bytes
8khz: largest latency = 1024/8000 = 0.128 seconds
44khz: largest latency = 1024/44100 = 0.023 seconds

so; technically - you are better off with 44khz. in the lemmings preview we did; our audio samples were 8khz; but we dynamically extrapolated them to 22khz so we could reduce the latency. this is when programming gets fun; but you need to be hard core at the bit level

// Aaron Ardiri
Mobile 1UP is a proud indie developer - support us!
developer of Caveman / Caveman HD and GW Series
05-31-2011, 08:02 AM
#4
Joined: Apr 2009
Location: Pennsylvania
Posts: 1,005
Did you do a before and after test? Was the difference in latency actually perceptible?

Quote:
Originally Posted by mobile1up View Post
typically; sounds libraries have a buffer for playback.
the higher your frequency; the more data gets pushed through the buffers; what this means is that 44khz processes the buffer 2x faster than a 22khz stream. the key question here; is pure latency.

buffer size: 1024 bytes
8khz: largest latency = 1024/8000 = 0.128 seconds
44khz: largest latency = 1024/44100 = 0.023 seconds

so; technically - you are better off with 44khz. in the lemmings preview we did; our audio samples were 8khz; but we dynamically extrapolated them to 22khz so we could reduce the latency. this is when programming gets fun; but you need to be hard core at the bit level
05-31-2011, 08:10 AM
#5
Joined: Oct 2009
Location: Melbourne
Posts: 250
I don't know much about the technicalities of audio programming, but here's my experience:

Using OpenAL (via the finch framework), playing 44100hz 16-bit .wav files.. I can play lots and lots of sound effects, even triggering multiple .wavs every single frame, without any noticeable performance hit or latency, even on 2G iPod Touch (not sure about 1st gens, haven't seen one in action). I just keep piling on the sfx and haven't had any problems..

iPhone/iPod/iPad seem to have really good audio hardware, as you'd expect So yeah, I reckon you don't have to worry much about it!

[edit: although, my games are 2D using OpenGL, and most of my sound effects are quite small.. it may be a different story if you're making something like 3D environmental soundscapes with long, streaming samples, or something... dunno]

Last edited by nyarla; 05-31-2011 at 08:14 AM.
05-31-2011, 04:58 PM
#6
Joined: Jul 2010
Posts: 487
if your game use a lot of sound fx, than you should put some good fx at 44k stereo, choose mono if your game use a 3D/2D environment.

and if you're scary about the performance, try to FPS your game with and without the sound.

Developer Service: Need a Professional 720p Trailer ? : Vetasoft Animation Studio
05-31-2011, 05:14 PM
#7
Joined: May 2009
Location: UK
Posts: 741
It almost certainly depends how many sounds you plan to be playing at once and how you are going to position them. I suspect it's all a non issue unless your game is going to play 8+ of them at the same time, all positioned individually and played at different frequencies.

-=< Fat Owl With A Jetpack >=-
-=< Topia World Builder >=-
-=< Twitter >=-
-=< Blog >=-
05-31-2011, 08:43 PM
#8
IMA4 is your friend

You can play any non-compressed formats (PCM) and a few compressed (IMA4, ADPCM) at any frequency and bit depth without affecting performance or quality. The mixer is running full-speed all the time in software. It will take care of all the details. Apple recommends you use IMA/ADPCM audio (IMA4) format for playing multiple sounds simultaneously, but any PCM format is fine.

For MP3, AAC and other compressed formats the device uses the hardware mixer, which can only play back one sound at a time.

We did a lot of experimenting with formats in order to find the best compromise of quality vs. size. We chose IMA4 .caf as our final solution. It gives you 4:1 compression of 16-bit stereo PCM audio and it still sounds pretty good.

Download Lingua Free and listen for yourself. For a compressed format, it really is surprising how good it sounds. The key is to normalize all your sounds and use compression to bring up the levels without distortion.

I've read that OpenAL doesn't support IMA4 but we aren't using OpenAL so I can't say for sure.

Have a look here for more details:

Apple Coding How-To's on Audio

Aaaaaaaand this link tells you exactly how to extract IMA4 for use with OpenAL:

IMA4 with OpenAL

Good luck!

Regards,

MoxyDave
www.MoxyLava.com