libmsx
C library for MSX
|
The audio decoder interface. More...
#include <audio_dec.h>
Data Fields | |
bool(* | decode_update )(void) |
Function pointer to the decoder I/F decode_update() . | |
void(* | decode_final )(void) |
Function pointer to the decoder I/F decode_final() . | |
void(* | set_repeat )(bool repeat) |
Function pointer to the decoder I/F set_repeat() . | |
The audio decoder interface.
This object is used by libmsx audio replayer to decode music data.
The libmsx audio replayer can handle two dedicated audio decoders:
Decode music data then Store in the buffer
The decoder decodes the music data each time it is called and stores it in libmsx audio replayer's internal FIFO buffer by calling audio_buf_put()
.
To do this, each of the above audio decoders must implement the audio decoder interface of type AudioDecoder
.
Attach the decoder to the libmsx audio replayer
The decoder must be attached to the replayer when a music data is changed or set to the decoder by the decoder specific API.
A decoder for background music (BGM) shall be attached to the replayer by audio_cb_bgm_changed()
. So the audio_cb_bgm_changed()
should be called when the BGM is changed or set to the decoder by the decoder specific API.
A decoder for sound effects (SFX) shall be attached to the replayer by audio_cb_sfx_changed()
. So the audio_cb_sfx_changed()
should be called when the SFX is changed or set to the decoder by the decoder specific API.
Definition at line 89 of file audio_dec.h.
bool(* AudioDecoder::decode_update) (void) |
Function pointer to the decoder I/F decode_update()
.
This function is called by audio_play()
several times (depending on the frequency of the replayer and VSYNC) if the decoder has been attached to the replayer.
This function shall decodes the next sampled value of the music data.
Then, by calling the function audio_buf_put()
, the decoded value can be stored in the internal FIFO buffer of the libmsx audio replayer. (Or, it is done from the function decode_final()
.)
If a music data has been set to the decoder and it is not reached to the end of music, this shall return true
.
If no music data is set to the decoder or the music is already finished, this shall return false
.
true
if the music has not ended.Definition at line 117 of file audio_dec.h.
void(* AudioDecoder::decode_final) (void) |
Function pointer to the decoder I/F decode_final()
.
This function is called by audio_play()
after several iterations of decode_update()
if the decoder has been attached to the replayer.
If decode_update()
simply decodes but does not store in the libmsx audio replayer's internal FIFO buffer, the value decoded by decode_update()
should be stored by this function in the FIFO buffer.
Definition at line 135 of file audio_dec.h.
void(* AudioDecoder::set_repeat) (bool repeat) |
Function pointer to the decoder I/F set_repeat()
.
Turn on/off the auto-repeat of the music.
This function is called by audio_set_repeat()
or when the decoder is attached to replayer. If the decoder does not support the auto-repeat function, the function pointer set_repeat
may be set to NULL
.
repeat | true : turn on, false : turn off |
Definition at line 148 of file audio_dec.h.