Sounds 'resolution' in your game

Discussion in 'Public Game Developers Forum' started by sigLuca, May 30, 2011.

  1. sigLuca

    sigLuca Well-Known Member

    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
     
  2. Stroffolino

    Stroffolino Well-Known Member
    Patreon Silver

    Apr 28, 2009
    1,100
    8
    38
    Software Engineer
    Pennsylvania
    I've seen no evidence of "serious performance problems" mixing different sound formats.

     
  3. mobile1up

    mobile1up Well-Known Member

    Nov 6, 2008
    754
    0
    16
    Technical Director
    Munich, Germany
    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
     
  4. Stroffolino

    Stroffolino Well-Known Member
    Patreon Silver

    Apr 28, 2009
    1,100
    8
    38
    Software Engineer
    Pennsylvania
    Did you do a before and after test? Was the difference in latency actually perceptible?

     
  5. nyarla

    nyarla Well-Known Member

    #5 nyarla, May 31, 2011
    Last edited: May 31, 2011
    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]
     
  6. Vetasoft

    Vetasoft Well-Known Member

    Jul 27, 2010
    487
    0
    0
    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.
     
  7. GlennX

    GlennX Well-Known Member

    May 10, 2009
    761
    0
    0
    UK
    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.
     
  8. MoxyDave

    MoxyDave Active Member

    May 19, 2011
    34
    0
    0
    Make awesome games for mobile devices
    Colorado
    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!
     

Share This Page