Also, if you don't want to create sounds on your own, you can play any of the sound defined in General Midi (128 different instrument sounds including a few sound effects) with soundblaster 16 emulation using something like this:
#include <stdlib.h>
#include "dos.h"
int main(int argc, char *argv[]) {
setinstrument( 1, 14 );
setsoundbank( DEFAULT_SOUNDBANK_SB16 );
int exit = 0;
while( !exit ) {
noteon( 1, 52, 127 );
for( int i = 0; i < 40; ++i ) {
waitvbl();
if( keystate( KEY_ESCAPE ) || shuttingdown() ) {
exit = 1;
break;
}
}
noteoff( 1, 52 );
for( int i = 0; i < 80; ++i ) {
waitvbl();
if( keystate( KEY_ESCAPE ) || shuttingdown() ) {
exit = 1;
break;
}
}
}
return 0;
}