# How the Sound Spooler Works

This section provides an overview of the sound spooler and describes how it works. See Music Library Calls in the 3DO Music and Audio Programmer's Reference for complete descriptions of the calls mentioned.

The sound spooler is part of the Music library that must be linked with your application. It provides function calls that can send blocks of audio data to the Audio folio for asynchronous playback. See How to Use the Sound Spooler for instructions on how to do this.

To create an instance of the sound spooler call `ssplCreateSoundSpooler()`. You can have multiple sound spoolers running at one time, but if they all get their data from the CD-ROM it could cause disc thrashing, which would affect performance.

The sound spooler has a list of buffer nodes, each created by a call to `ssplCreateSoundBufferNode()`, that manage sampled sound buffers through the spooler. These nodes are created for you automatically when you call `ssplCreateSoundSpooler()`. Each buffer node has a UserData field that the application can use to store a pointer to its own per-buffer-node information. The sampled sound buffers themselves are created, filled, reused, and deleted by the application. The application maintains a "free list" and a FIFO "active" playback queue of buffer nodes.

The application calls `ssplSetBufferAddressLength()` and then sspl`SendBuffer()` (or one of the convenience routines) to associate a block of sampled sound data with a buffer node and move it from the free list to the active queue. Buffers in the playback queue are called active.

When an active buffer finishes playing, the Audio folio sends its signal to the application. When the application notices one or more of these signals, it must call `ssplProcessSignals()` to recycle buffer nodes back to the spooler's free list. `ssplProcessSignals()` then calls an optional client call back procedure for each buffer that finished playing.