Game Development Reference
In-Depth Information
5
Cross-platform Audio
Streaming
Try turning off the sound in your favorite game.
— Viktor Latypov
In this chapter we will cover the following recipes:
F Initializing OpenAL and playing the .wav iles
F Abstracting basic audio components
F Streaming sounds
F Decoding Ogg Vorbis iles
F Decoding tracker music using ModPlug
Introduction
We are looking for a truly portable implementation of the sound playback for desktop PCs and
mobile devices. We propose using the OpenAL library, since it is a well-established library on a
desktop, and using it will make easier porting of existing games to Android. In this chapter we
organize a small multithreaded sound streaming library.
Audio playback is inherently an asynchronous process, so the decoding and control of sound
hardware should be done on a separate thread and controlled from other dedicated threads.
For example, when a player presses a ire button, or a character in an arcade game hits the
ground, we might just ask the system to start playback of an audio ile. The latency of this
operation in games usually does not matter so much.
Search WWH ::




Custom Search