libdragon
Loading...
Searching...
No Matches
Data Structures | Macros | Functions
wav64.h File Reference

Support for WAV64 audio files. More...

Go to the source code of this file.

Data Structures

struct  wav64_t
 WAV64 structure. More...
 

Macros

#define wav64_init_compression(level)
 Enable a non-default compression level.
 

Functions

void wav64_open (wav64_t *wav, const char *fn)
 Open a WAV64 file for playback.
 
void wav64_set_loop (wav64_t *wav, bool loop)
 Configure a WAV64 file for looping playback.
 
void wav64_play (wav64_t *wav, int ch)
 Start playing a WAV64 file.
 
int wav64_get_bitrate (wav64_t *wav)
 Get the (possibly compressed) bitrate of the WAV64 file.
 
void wav64_close (wav64_t *wav)
 Close a WAV64 file.
 

Detailed Description

Support for WAV64 audio files.


Data Structure Documentation

◆ wav64_t

struct wav64_t

WAV64 structure.

This structure is initialized by wav64_open to refer to an opened WAV64 file. It is meant to be played back through the audio mixer, implementing the waveform_t interface. As such, samples are not preloaded in memory but rather loaded on request when needed for playback, streaming directly from ROM. See waveform_t for more details.

Use wav64_play to playback. For more advanced usage, call directly the mixer functions, accessing the wave structure field.

Data Fields
waveform_t wave waveform_t for this WAV64.

Access and use this field directly with the mixer, if needed.

int current_fd File descriptor to read WAV64.

File descriptor for the wav64 file

int base_offset Start of Wav64 data.
int format Internal format of the file.
void * ext Pointer to extended data (internal use)

Macro Definition Documentation

◆ wav64_init_compression

#define wav64_init_compression (   level)

Enable a non-default compression level.

This function must be called if any wav64 that will be loaded use a non-default compression level. The default compression level is 1 (VADPCM) for which no initialization is required. Level 0 (uncompressed) also requires no initialization.

Currently, only level 3 requires initialization (level 2 does not exist yet). If you have any wav64 compressed with level 3, you must call this function before opening them.

wav64_open(&jingle, "rom:/jingle.wav64");
void wav64_open(wav64_t *wav, const char *file_name)
Open a WAV64 file for playback.
Definition wav64.c:102
#define wav64_init_compression(level)
Enable a non-default compression level.
Definition wav64.h:69
Parameters
levelCompression level to initialize
See also
wav64_open

Function Documentation

◆ wav64_open()

void wav64_open ( wav64_t wav,
const char *  fn 
)

Open a WAV64 file for playback.

This function opens the file, parses the header, and initializes for playing back through the audio mixer.

Parameters
wavPointer to wav64_t structure
fnFilename of the wav64 (with filesystem prefix). Currently, only files on DFS ("rom:/") are supported.

◆ wav64_play()

void wav64_play ( wav64_t wav,
int  ch 
)

Start playing a WAV64 file.

This is just a simple wrapper that calls mixer_ch_play on the WAV64's waveform (wav64_t::wave). For advanced usages, please call directly the mixer functions.

It is possible to start the same waveform on multiple independent channels. Playback will automatically stop when the waveform is finished, unless it is looping. To stop playing a wav64 file before it is normally finished, call mixer_ch_stop on the channel used for playback.

Parameters
wavPointer to wav64_t structure
chChannel of the mixer to use for playback.

◆ wav64_get_bitrate()

int wav64_get_bitrate ( wav64_t wav)

Get the (possibly compressed) bitrate of the WAV64 file.

Parameters
wavPointer to wav64_t structure
Returns
int Bitrate in bits per second

◆ wav64_close()

void wav64_close ( wav64_t wav)

Close a WAV64 file.

This function closes the file and frees any resources associated with it. If the file is currently playing, playback will be stopped.

Parameters
wavPointer to wav64_t structure