The advanced sound player contains a superset of the features of the original sound file player described in Chapter 5, "Playing Sound Files". In addition to the basic features offered by the original sound file player, playback of an AIFF file, the advanced sound player does the following:
permits sound files to be looped seamlessly (no audible pops or silent gaps)
allows multiple sound files to be linked together seamlessly
permits branching between markers in sound files
allows playback of in-memory samples as if they were sound files
Even though the advanced sound player completely supersedes the original sound file player, it does have slightly more code overhead than the original sound file player. This means that you may still wish to use the original sound file player if you simply want to play a single AIFF file once and have tight memory restrictions. Be aware, though, that the advanced sound player is more actively supported with regard to future enhancements than the original sound file player.
It is worth reading the discussion of spooling sound from disc in Chapter 5, as the same concepts apply to the advanced sound player.
Simple Advanced Sound Player Example
This annotated advanced sound player example demonstrates how to play an AIFF sound file through once. Error checking was eliminated for brevity. More complicated examples are built from this one later in this chapter.
Preparation. Note that this step makes a number of assumptions about the kinds of sounds that are going to be played and how to direct the output signal to the 3DO audio output. In this case, we are expecting to play a monophonic 16-bit 44KHz sample and are connecting it directly to the audio output. In practice, you may need to select a different sample player instrument or an alternate method of directing the output.
Set up branches. In this example, there are no branches to set up, so this step is simply a placeholder. Examples of looping and branching shows how to modify this example to do more interesting kinds of playback.
Start reading sound. This step prefills the spooler with sound data so that the next step can begin producing sound immediately.
Clean up. Note that spDeletePlayer() takes care of cleaning
up anything that was given to it (e.g. the sound file added in step 3).
This is more completely described in
spDeletePlayer
in Music Library Calls.