-Blog-

Texel’s Technical Tribulations Pt. 4



Following along with our discussion of sounds, I wanted to talk about the sound system. Currently, it supports Wav, Flac, and Ogg. We support wav since it's the most basic sound file to support. I wanted to support Flac files mainly because we develop on a remote subversion repository and I wanted to be able to commit lossless files while still conserving bandwidth. Ogg was chosen over Mp3 because of the licensing issues associated with Mp3 decoders. Now, the iPhone has its own decoder, but it is only supported on iOS devices (I plan on one day porting this over to the Android, and I wanted a cross platform solution). It may still be prudent to hook up the hardware Mp3 decoder for music (I'm playing this one by ear, hehe, right now).

Most of my codecs are using open source projects from Xiph.org (Their website has been very helpful). For future projects, I am very interested in there CELT codec (though it is still in heavy development).

Screenshot7


I don't have this fully setup, yet, but one of the things I'd like to support is letting the build system control the Ogg compression quality, sample rate, and maybe even the mono versus stereo. The idea is to have a config file that defines platform specific settings, and then during build, it converts it to those settings. This would be nice, because right now one of the limiting factors on the quality of music is package size (We're trying to be under the 20MB limit for OTA downloading). We have a lot of space consumed by the in-game textures, and I'm not sure exactly where we'll be at the end. So, it would be nice to very easily tweak a couple of settings until we find the right number (alas this may not happen for this project).

The next big thing I hooked up for the in-game effects is the notion of location-based sounds. This was a little tricky given the top down perspective. Make the sound listener from the players perspective was disorienting. In the end, we create the sound from the user's perspective (emitters on the left side of the screen play out of the left speaker). Also, the further the camera is from the sound, the quieter the sound will play.

The last thing I will definitely need to add is to move the audio streaming into a separate thread. I've noticed some hitching when I page textures in and out.