libdragon
Macros | Functions
audio.c File Reference

Audio Subsystem. More...

Macros

#define NUM_BUFFERS   4
 Number of buffers the audio subsytem allocates and manages.
 
#define BUFFERS_PER_SECOND   25
 How many different audio buffers we want to schedule in one second.
 
#define CALC_BUFFER(x)   ( ( ( ( x ) / BUFFERS_PER_SECOND ) >> 3 ) << 3 )
 Macro that calculates the size of a buffer based on frequency. More...
 
DAC rates for different regions
#define AI_NTSC_DACRATE   48681812
 NTSC DAC rate.
 
#define AI_PAL_DACRATE   49656530
 PAL DAC rate.
 
#define AI_MPAL_DACRATE   48628316
 MPAL DAC rate.
 
AI Status Register Values
#define AI_STATUS_BUSY   ( 1 << 30 )
 Bit representing that the AI is busy.
 
#define AI_STATUS_FULL   ( 1 << 31 )
 Bit representing that the AI is full.
 

Functions

void audio_init (const int frequency, int numbuffers)
 Initialize the audio subsystem. More...
 
void audio_set_buffer_callback (audio_fill_buffer_callback fill_buffer_callback)
 Install a audio callback to fill the audio buffer when required. More...
 
void audio_close ()
 Close the audio subsystem. More...
 
void audio_pause (bool pause)
 Pause or resume audio playback. More...
 
void audio_write (const short *const buffer)
 Write a chunk of audio data. More...
 
short * audio_write_begin (void)
 Start writing to the first free internal buffer. More...
 
void audio_write_end (void)
 Complete writing to an internal buffer. More...
 
void audio_write_silence ()
 Write a chunk of silence. More...
 
volatile int audio_can_write ()
 Return whether there is an empty buffer to write to. More...
 
int audio_get_frequency ()
 Return actual frequency of audio playback. More...
 
int audio_get_buffer_length ()
 Get the number of stereo samples that fit into an allocated buffer. More...
 

Detailed Description

Audio Subsystem.