I’ve released tinysound.h, a C header implementing a an API over DirectSound for game sounds! Details found here :)
Demonstration code:
void LowLevelAPI( tsContext* ctx )
{
// load a couple sounds
tsLoadedSound airlock = tsLoadWAV( "airlock.wav" );
tsLoadedSound jump = tsLoadWAV( "jump.wav" );
// make playable instances
tsPlayingSound s0 = tsMakePlayingSound( &airlock );
tsPlayingSound s1 = tsMakePlayingSound( &jump );
// setup a loop and play it
tsLoopSound( &s0, 1 );
tsInsertSound( ctx, &s0 );
while ( 1 )
{
if ( GetAsyncKeyState( VK_ESCAPE ) )
break;
// play the sound
if ( GetAsyncKeyState( VK_SPACE ) )
tsInsertSound( ctx, &s1 );
tsMix( ctx );
}
}
int main( )
{
HWND hwnd = GetConsoleWindow( );
tsContext* ctx = tsMakeContext( hwnd, 48100, 15, 1, 0 );
LowLevelAPI( );
tsShutdownContext( ctx );
return 0;
}