libmsx
C library for MSX
Loading...
Searching...
No Matches
The API of the libmsx audio replayer.

The API of the libmsx audio replayer. More...

+ Collaboration diagram for The API of the libmsx audio replayer.:

Functions

void audio_init (void)
 MSX Initialize the libmsx audio replayer.
 
void audio_start (void)
 MSX Start / Resume music.
 
void audio_pause (void)
 MSX Pause music.
 
bool audio_is_paused (void)
 MSX Return whether paused or not.
 
void audio_stop (void)
 MSX Stop music.
 
void audio_play (void)
 MSX Main routine of the libmsx audio replayer.
 
uint8_t audio_get_bgm_frequency (void)
 MSX Return replayer frequency of the background music.
 
void audio_set_bgm_frequency (uint8_t freq)
 MSX Force replayer frequency of the background music.
 
bool audio_is_playing (void)
 MSX Return whether BGM and/or SFX is playing or not.
 
bool audio_is_playing_bgm (void)
 MSX Return whether BGM is playing or not.
 
bool audio_is_playing_sfx (void)
 MSX Return whether SFX is playing or not.
 
void audio_set_repeat (bool repeat)
 MSX Turn on/off the auto-repeat of the BGM.
 

Detailed Description

The API of the libmsx audio replayer.

Features of The libmsx audio replayer :

Function Documentation

◆ audio_init()

void audio_init ( void  )

MSX Initialize the libmsx audio replayer.

This function must be called at least once. In particular, it must be called before the first call to audio_play().

◆ audio_start()

void audio_start ( void  )

MSX Start / Resume music.

◆ audio_pause()

void audio_pause ( void  )

MSX Pause music.

◆ audio_is_paused()

bool audio_is_paused ( void  )

MSX Return whether paused or not.

Returns
true if paused.

◆ audio_stop()

void audio_stop ( void  )

MSX Stop music.

◆ audio_play()

void audio_play ( void  )

MSX Main routine of the libmsx audio replayer.

To play back background music and sound effects, this function must be called at each VSYNC timing.

The easiest way is to set this function as the VSYNC interrupt handler by calling set_vsync_handler().

// At first, initialize the replayer.
// Then, register the replayer as the VSYNC interrupt handler.
// And then, calls other APIs to start, stop, etc.
// \note The replayer is already started in default.
// audio_start();
// Look up / load a music data and set it to the decoder by using decoder
// specific APIs.
// (Here, assume that any type or function prefixed with `l2a_` is such a
// decoder-specific API.)
l2a_File sf;
if (!l2a_open_resource(&sf, "songs.l2a") {
// Failed to open l2a file.
}
l2a_set_bgm(0, &sf);
void audio_init(void)
MSX Initialize the libmsx audio replayer.
void audio_play(void)
MSX Main routine of the libmsx audio replayer.
void set_vsync_handler(void(*handler)(void))
MSX Register user defined VSYNC interrupt handler.

◆ audio_get_bgm_frequency()

uint8_t audio_get_bgm_frequency ( void  )

MSX Return replayer frequency of the background music.

Returns
frequency in Hz.
See also
audio_set_bgm_frequency()

◆ audio_set_bgm_frequency()

void audio_set_bgm_frequency ( uint8_t  freq)

MSX Force replayer frequency of the background music.

Parameters
freqfrequency in Hz.
See also
audio_get_bgm_frequency()
Note
When a background music is set to the audio decoder, the replayer frequency is set (reset) to the default frequency of the music.

◆ audio_is_playing()

bool audio_is_playing ( void  )

MSX Return whether BGM and/or SFX is playing or not.

Returns
true if BGM and/or SFX is playing.

◆ audio_is_playing_bgm()

bool audio_is_playing_bgm ( void  )

MSX Return whether BGM is playing or not.

Returns
true if BGM is playing.

◆ audio_is_playing_sfx()

bool audio_is_playing_sfx ( void  )

MSX Return whether SFX is playing or not.

Returns
true if SFX is playing.

◆ audio_set_repeat()

void audio_set_repeat ( bool  repeat)

MSX Turn on/off the auto-repeat of the BGM.

Parameters
repeattrue: turn on, false: turn off
Note
Valid only if the BGM decoder supports this feature.