bx-lib : the Basic X11 Library tuned for C beginners  1.0
Data Structures | Typedefs | Functions
Audio (how to play sounds and music easily)

Data Structures

struct  bx_audio
 the type for an audio soundtrack More...

Typedefs

typedef struct bx_audio bx_audio
 the type for an audio soundtrack

Functions

void bx_init_audio (void)
bx_audio bx_load_audio (char const filename[])
bx_audio bx_load_audio_f (char const format[],...)
void bx_play_audio (bx_audio audio, double volume, unsigned long millisec, int ad_infinitum)

Detailed Description

Typedef Documentation

typedef struct bx_audio bx_audio

the type for an audio soundtrack

Function Documentation

void bx_init_audio ( void  )

Initializes the audio library. The function is available if the library was compiledwith audio support. No other audio function should be called before this one.

bx_audio bx_load_audio ( char const  filename[])

Loads an audio soundtrack in WAV format from a filename.

Parameters
filenamethe path to the filename of the WAV file to be loaded
Returns
the loaded soundtrack
bx_audio bx_load_audio_f ( char const  format[],
  ... 
)

Loads an audio soundtrack in WAV format from a printf()-like format yielding the filename of the sound file.

Parameters
formatthe printf()-like format ... the arguments of the format yielding the filename
Returns
the loaded soundtrack
void bx_play_audio ( bx_audio  audio,
double  volume,
unsigned long  millisec,
int  ad_infinitum 
)

Plays an audio soundtrack. The track is played in background mixed with other tracks still played, and the function returns immediately. You can specify the volume, a delay before the sound is played (that is, it will be played in the future) and whether it will be played only once or repeeatedly ad infinitum.

Parameters
audiothe soundtrack to play
volumea volume rate between 0.0 (mute) and 1.0 (max volume)
millisecthe delay in millesconds before the track starts
ad_infinitumboolean stating whether the sound repeats over and over