Streaming Sound Files


Streaming And Spooling

Q: Playsoundfile.c and spoolsoundfile.c are "spooling" as opposed to "streaming". I have tried using them before, but they were choppy when all the other game stuff was going on. What do you feel is the difference between "spooling" and "streaming"?

A: The DataStreamer package from 3DO supports interwoven data such as audio and video. The SoundSpooler is only for audio.

The sound spooler in the Music library, or streamer, hiccups, or worse, if it is starved of data. This can occur if the application tries to read other files during the middle of playback, or if the spooling task is not given enough CPU access. You can reduce the chance of starvation by using larger buffers or more compressed data. Try mono, 22KHz, SQXD compressed sound. It sounds pretty good and is 1/8th the size of a "normal" audio track.

There have also been some improvements made in how the spooler recovers from data starvation. The old spooler could get confused and repeat segments. Try the new spooler in the 1.3 release or the advanced sound player.

Streaming Audio Sample Code

Q: Because everyone in the world seems to be streaming 44Khz 16-bit audio off the CD for their background music, I would like to see some sample code.

A: Check out the example programs playsoundfile.c or spoolsoundfile.c. They are basically the same but spoolsoundfile.c works in a thread. They are on the Portfolio CD.

The examples use the AIFF sound file playing routines in the Music library. The routines have been enhanced in V1.3 to use a new low level soundspooler library that could be used to write your own custom sound file player.

Many people find that using the 2:1 SQXD compression, and/or, using 22K also yields good fidelity and takes less disc space and bandwidth. You may want to use the advanced sound player. See Loading and Attaching Samples.

Playing Red Book Audio

Q: How can I play Red Book audio as part of my title?

A: You cannot interleave the proprietary 3DO format with Redbook Audio. Convert the sounds to an AIFF file and use the sound spooler of the 3DO Data Streamer. You can extract sound from a Redbook CD using commercially available programs such as Disc-to-Disk. If you have sound files in other formats, you can convert them using SoundHack.