Sound Programming

This section explains compiling your code with a pre made sound blaster library (supplied). Only basic programming knowledge is assumed. We recommend users to go through the tutorial in sequence and check all the examples.

 All of the code snippets and downloadable examples are written in C

Reinventing the Wheel

There are plenty of sound libraries and code resources out there. For our games we linked to a pre-made sound blaster library for DJGPP. To add sound to your programs you need link them to 'libsb.a'.

Compile your code using this example command line for the compiler:

gcc -o myprog myprog.c libsb.a -lemu

and include this compiler directive at the top of your program:

#include "sb_lib.h"

The other header files in the example download must be in the same directory as sb_lib.h. This will give your prgram access to these functions in sblib.a:

sb_sample * //new data type
sb_load_sample(char *filename,filetype);//filetype _SB_WAV
sb_install_driver(int frequency)//should return SB_SUCCESS
sb_mix_sample(sb_sample*);//play a sound
sb_free_sample(sb_sample*);
sb_uninstall_driver();

There are probably more functions in the library, examine the header if you think you need more functionality.

  Download a working example including libsb
This library was written by Joel H. Hunter (1995)