next up previous contents
Next: Making Sounds for Peep Up: Developer's Guide Previous: The playback code   Contents

The Sound Module Interface

The sound modules are basically a set of function calls and constants that abstract the actual sound device underneath. The two types of sound modules currently implemented are /dev/audio support and ALSA support(for 0.9.x). Constants for those device drivers are abstracted via the definition of the constants in the sound.h header:

AU_SOUND_FORMAT
SIGNED_16_BIT
SOUND_WRONLY
SOUND_RDONLY
SOUND_RDWR

The sound.h header also defines other data structures capabable of describing the audio hardware. However, these structures cannot be filled out with /dev/audio support, which is the main thrust of support at the moment, and so are not really taken advantage of. The main functions to implement to create a sound modules are:

void *soundInit (void *snd_device, int mode);

int soundSetFormat (void *handle, unsigned int format_type,
                    unsigned int rate, unsigned int chans,
                    unsigned int port);

ssize_t soundPlayChunk (void *handle, char *buf, unsigned int len);

void soundClose (void *handle);

These have pretty obvious purposes. The current mixing scheme does everything in software. While this is portable across all hardware, it means that a lot of processing is CPU bound, rather than offloaded to the hardware. The two other functions defined in sound.h could be used to figure out what sort of capabilities the hardware offers and to take advantage of hardware directly in future versions.


next up previous contents
Next: Making Sounds for Peep Up: Developer's Guide Previous: The playback code   Contents
Collin Starkweather 2002-11-03