Game Development Reference
In-Depth Information
One of the most common file formats for storing sound samples is the WAV file, so
wouldn't it be great if we could use this format to store our sound effects? Wouldn't
it also be great if we could load these files into memory using the same resource
manager code that we've used for textures and 3D models?
The answer to our prayers is the SoundEngine module, which is a layer that sits
on top of s3eSound and allows us to easily load and access sound effects using the
resource manager.
The SoundEngine module doesn't just stop there though. It also wraps up the
s3eSound calls we've learnt about in this chapter and it allows us to support a
further sound format that can be stored in WAV files—namely the compressed IMA
ADPCM type. This is particularly useful given that sound sample data can be quite
large in size; so this format helps us claw back some memory space at the expense of
a slight drop in sound quality.
The following sections give a brief introduction to using this module, but for full
details you should refer to the source and header files to see all the functionality
SoundEngine has to offer. The sound example project accompanying this chapter
also makes use of this module, so take a look at that to learn more.
Adding the SoundEngine module to a project
The SoundEngine module actually ships with the Marmalade SDK, but it lives,
awkwardly, in the examples directory. The easiest way to solve this is to just copy
the entire SoundEngine directory to the directory where your project resides and
then reference it by adding SoundEngine to your MKB files subprojects. This is the
same approach we used with the GUI and Localise modules that were introduced
in the sample code for the previous chapter.
The location of the SoundEngine module in the examples folder
means it isn't really considered part of the main Marmalade SDK.
In practice it is highly unlikely that the SoundEngine code will
suddenly disappear from the SDK, since the s3eSound API is unlikely
to change drastically from what it is now; so you shouldn't have any
concerns about using it directly in your own projects. If you prefer to
write your own code, SoundEngine does at least serve the purpose
of being a very good example of how to use the s3eSound API.
With the module added to our project, we can include the file IwSound.h in our code
to make use of it. A call to IwSoundInit is needed to set everything up and a call to
IwSoundTerminate cleans up at the end of our program.
 
Search WWH ::




Custom Search