ai.h File Reference

#include <types.h>
#include <broadway.h>

Go to the source code of this file.

Enumerations

enum  ai_sample_rate_t { AI_SAMPLE_RATE_48000 = 0, AI_SAMPLE_RATE_32000 }

Functions

int ai_initialize (void)
 Initialize the AI subsystem.
int ai_shutdown (void)
 Shut down the AI subsystem.
void ai_set_sample_rate (ai_sample_rate_t rate)
 Set the sample rate.
ai_sample_rate_t ai_get_sample_rate (void)
 Get the sample rate.
void ai_enable_irq (int on_sample, int(*exec)(u32 irq, void *data), void *data)
 Enable the sample-reached IRQ.
void ai_disable_irq (void)
 Disable the sample-reached IRQ.
void ai_set_volume (u8 left, u8 right)
 Sets the volume of the stereo output.
void ai_get_volume (u8 *left, u8 *right)
 Gets the volume of the stereo output.
u32 ai_samples_played (void)
 Gets how many samples have been played.
void ai_reset_sample_counter (void)
 Resets the sample played counter.
int ai_is_playing (void)
 Returns whether AI is playing audio or not.
int ai_play (int play)
 Starts or stops the AI from playing audio.

Detailed Description

An abstraction of the Audio Interface (AI). Controls various portions of the audio output (including volume and sample rate).


Enumeration Type Documentation

The sample rates supported by AI

Enumerator:
AI_SAMPLE_RATE_48000 

48kHz

AI_SAMPLE_RATE_32000 

32kHz


Function Documentation

void ai_disable_irq ( void   ) 

Disable the sample-reached IRQ.

Turns off the IRQ that fires when the AI plays a specific sample.

See also:
ai_enable_irq()
void ai_enable_irq ( int  on_sample,
int(*)(u32 irq, void *data)  exec,
void *  data 
)

Enable the sample-reached IRQ.

Turns on the IRQ that fires when the AI plays a specified sample.

Parameters:
on_sample the sample that the IRQ fires on.
exec the callback that is called when the IRQ fires.
data data provided to the callback when it fires.
See also:
ai_disable_irq()
ai_sample_rate_t ai_get_sample_rate ( void   ) 

Get the sample rate.

Returns:
The sample rate that AI was set to use. -1 if there was an error.
See also:
ai_set_sample_rate()
void ai_get_volume ( u8 *  left,
u8 *  right 
)

Gets the volume of the stereo output.

Parameters:
left a pointer to which the left volume is put. NULL if you don't want the output.
right a pointer to which the right volume is put. NULL if you don't want the output.
See also:
ai_set_volume()
int ai_initialize ( void   ) 

Initialize the AI subsystem.

Initializes the AI subsystem, registers the handler for the AI interrupt and performs all other required initialization tasks.

Returns:
If initialization was successful, returns 1. Otherwise 0.
See also:
ai_shutdown()
int ai_is_playing ( void   ) 

Returns whether AI is playing audio or not.

Returns:
Returns 1 if it was playing, 0 otherwise. -1 if an error occurred.
See also:
ai_play()
int ai_play ( int  play  ) 

Starts or stops the AI from playing audio.

Parameters:
play if 1 starts playing, or if 0 stops playing.
Returns:
Returns 1 if it was playing, 0 otherwise. -1 if an error occurred.
See also:
ai_is_playing()
u32 ai_samples_played ( void   ) 

Gets how many samples have been played.

Gets the number of stereo samples that have been played since the counter was last reset (either by a system reset or a manual reset.)

Returns:
How many samples were played. 0xFFFFFFFF if an error occurred.
See also:
ai_reset_sample_counter
void ai_set_sample_rate ( ai_sample_rate_t  rate  ) 

Set the sample rate.

Must only be called when the AI is not playing audio.

Parameters:
rate a value from ai_sample_rate_t specifying the sample rate to use.
See also:
ai_get_sample_rate()
void ai_set_volume ( u8  left,
u8  right 
)

Sets the volume of the stereo output.

Sets the volume of the output sound, with the left and right speakers being changable independantly

Parameters:
left the volume on the left speaker. 0 is mute, 0xFF is maximum.
right the volume on the right speaker. 0 is mute, 0xFF is maximum.
See also:
ai_get_volume()
int ai_shutdown ( void   ) 

Shut down the AI subsystem.

Shuts down the AI subsystem, unregisters the handler for the AI interrupt and performs all other required shut down tasks.

Returns:
If shut down was successful, returns 1. Otherwise 0.
See also:
ai_initialize()
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines
Generated by  doxygen 1.6.3