libgameaudio  0.1.0-rc1
All Files Functions Modules Pages
Macros | Functions
libgameaudio.h File Reference

Go to the source code of this file.

Macros

#define LGA_U_QT   0
 
#define LGA_E_QT   1
 
#define LGA_OPUS   0
 
#define LGA_BGM   0
 
#define LGA_BGS   1
 
#define LGA_ME   2
 
#define LGA_SE   3
 
#define LGA_BGM_LOOP_START   0
 Specifies the start of the loop section in the BGM track in samples.
 
#define LGA_GAIN   1
 Specifies the gain ("volume") with which a source should play.
 

Functions

void lgaInit (int nbgmt, int nbgst, int nmet, int nset, int nbgss, int nses)
 Initializes libgameaudio. More...
 
void lgaProc (void)
 Processes libgameaudio state. More...
 
void lgaTerminate (void)
 Terminates libgameaudio. More...
 
void lgaSetParami (int id, int value)
 Sets library parameters that modify how certain functions are performed. More...
 
void lgaSetParamf (int id, float value)
 Sets library parameters that modify how certain functions are performed. More...
 
void lgaLoad (int audio_type, int format, const char *file)
 Loads an audio track from an audio file. More...
 
void lgaPlay (int audio_type, int tid, int sid)
 Plays the the i-th track of an audio type. More...
 
void lgaStop (int qt, int audio_type, int id)
 Stops the playing BGM/ME track, if there is any. More...
 

Function Documentation

◆ lgaInit()

void lgaInit ( int  nbgmt,
int  nbgst,
int  nmet,
int  nset,
int  nbgss,
int  nses 
)

Initializes libgameaudio.

Allocates memory for the specified number of tracks of each audio type and sources for each sound audio type.

Parameters
nbgmtNumber of BGM tracks
nbgstNumber of BGS tracks
nmetNumber of ME tracks
nsetNumber of SE tracks
nbgssNumber of BGS sources
nsesNumber of SE sources

◆ lgaLoad()

void lgaLoad ( int  audio_type,
int  format,
const char *  file 
)

Loads an audio track from an audio file.

Parameters
audio_typePlay type of the audio file. See Audio types
formatFormat of the audio file. See Audio formats
filePath to audio file

◆ lgaPlay()

void lgaPlay ( int  audio_type,
int  tid,
int  sid 
)

Plays the the i-th track of an audio type.

Playing a BGM/BGS/ME track will stop the previously playing BGM/BGS/ME track, if there was any. Requests to play a SE will be ignored if there are no more available sources.

Parameters
audio_typePlay type of the audio file. See Audio types
tidTrack identifier. A track identifier is the order in which it was loaded with lgaLoad, e.g. if a track was loaded first its id is 0, if second 1 and so on.
sidSource identifier. Used to keep track on which source a BGS track is/should be played. Must be 0 in case of BGM/ME/SE

◆ lgaProc()

void lgaProc ( void  )

Processes libgameaudio state.

This function mainly performs resource management, for example, given the limited amount of sound effect sources it frees up those sources that have already played their sound effect to play the next sound effect requests. It also does state management, such as making sure that the intro section of a BGM track is not played again.

Attention
This function must be called periodically, preferably every frame.

◆ lgaSetParamf()

void lgaSetParamf ( int  id,
float  value 
)

Sets library parameters that modify how certain functions are performed.

Parameters
idParameter identifier. See Parameters
valueParameter value

◆ lgaSetParami()

void lgaSetParami ( int  id,
int  value 
)

Sets library parameters that modify how certain functions are performed.

Parameters
idParameter identifier. See Parameters
valueParameter value

◆ lgaStop()

void lgaStop ( int  qt,
int  audio_type,
int  id 
)

Stops the playing BGM/ME track, if there is any.

Parameters
qtFirst-order logic quantifier
audio_typePlay type of the audio file. See Audio types
idSource identifier. Must be 0 in case of BGM/ME/SE

◆ lgaTerminate()

void lgaTerminate ( void  )

Terminates libgameaudio.

Stops all audio playback and deallocates all tracks, sources, and buffers.