orcus
Functions
audio.h File Reference

Audio. More...

#include <stdint.h>

Functions

uint16_t ac97GetReg (uint8_t reg)
 Read register value from AC97 codec. More...
 
void ac97SetReg (uint8_t reg, uint16_t value)
 Set register value in AC97 codec. More...
 
void ac97Start ()
 Start AC97 codec. More...
 
void ac97Stop ()
 Stop AC97 codec. More...
 
bool audioHeadphonesConnected ()
 Check if headphones are connected (F100 only). More...
 
void audioInit (int dmaChannel)
 Initialise audio subsystem. More...
 
void audioMuteHeadphones ()
 Mute headphones. More...
 
void audioMuteSpeakers ()
 Mute speakers. More...
 
void audioPlaySample (uint16_t bytes, void *data)
 Play a PCM sample. More...
 
bool audioSamplePlaying ()
 Check if a sample is currently playing. More...
 
void audioSetSampleRate (uint16_t khz)
 Set sample rate for AC97 codec. More...
 
void audioSetVolume (uint8_t left, uint8_t right)
 Set volume. More...
 
void audioUnmuteHeadphones ()
 Unmute headphones. More...
 
void audioUnmuteSpeakers ()
 Unmute speakers. More...
 

Function Documentation

◆ ac97GetReg()

uint16_t ac97GetReg ( uint8_t  reg)

Read register value from AC97 codec

Note
Must have called ac97Start() or audioInit() before using this.
Parameters
regRegister to read
Returns
Register value
See also
ac97Start
audioInit

◆ ac97SetReg()

void ac97SetReg ( uint8_t  reg,
uint16_t  value 
)

Set register value in AC97 codec.

Note
Must have called ac97Start() or audioInit() before using this.
Parameters
regRegister to set
valueValue to set
See also
ac97Start
audioInit

◆ ac97Start()

void ac97Start ( )

Start AC97 codec, will restart codec if it was previously started.

Note
DMA channels must have been set up before calling this.

◆ ac97Stop()

void ac97Stop ( )

Stop AC97 codec.

◆ audioHeadphonesConnected()

bool audioHeadphonesConnected ( )

Check if headphones are connected. This works on the F100 only, the F200 physically switches the DAC output between the speakers and headphones when you insert the jack.

Note
F100 only
Returns
true if headphones are connected, false otherwise

◆ audioInit()

void audioInit ( int  dmaChannel)

Initialise auto subsystem.

Parameters
dmaChannelDMA channel to use for audio (0 - 15, recommend 0 - 3)

◆ audioMuteHeadphones()

void audioMuteHeadphones ( )

Mute headphones.

◆ audioMuteSpeakers()

void audioMuteSpeakers ( )

Mute speakers.

◆ audioPlaySample()

void audioPlaySample ( uint16_t  bytes,
void *  data 
)

Play a PCM sample. Non-blocking, see if the sample has finished playing with audioSamplePlaying().

Parameters
bytesNumber of bytes in sample (max 0xFFFF)
dataPointer to sample data
See also
audioSamplePlaying

◆ audioSamplePlaying()

bool audioSamplePlaying ( )

Check if a sample is currently playing.

Returns
true if a sample is currently playing, false otherwise

◆ audioSetSampleRate()

void audioSetSampleRate ( uint16_t  khz)

Set sample rate for AC97 codec.

Note
Must have called audioInit() before using this.
Parameters
khzSample rate to set
See also
ac97Start
audioInit

◆ audioSetVolume()

void audioSetVolume ( uint8_t  left,
uint8_t  right 
)

Set volume.

@warn You may not wish to allow the volume to reach 31, with headphones connected this could do damage to somebody's hearing!

Parameters
leftVolume level for left channel (0 [lowest] - 31 [highest])
rightVolume level for right channel (0 [lowest] - 31 [highest])

◆ audioUnmuteHeadphones()

void audioUnmuteHeadphones ( )

Unmute headphones.

◆ audioUnmuteSpeakers()

void audioUnmuteSpeakers ( )

Unmute speakers.