All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
vexaudio.c File Reference

DAC port driver. More...

#include "ch.h"
#include "hal.h"
#include "vex.h"

Macros

#define WAVE_SAMPLES   32
 
#define AUDIO_WA_SIZE   THD_WA_SIZE(AUDIO_TASK_STACK_SIZE)
 

Functions

void vexAudioPlaySound (int freq, int amplitude, int timems)
 Play frequency at given amplitude. More...
 
void vexAudioPlaySoundWait (int freq, int amplitude, int timems)
 Play frequency at given amplitude and wait for completion. More...
 
void vexAudioStopSound ()
 Stop sound playing. More...
 
int vexAudioInitChipToneSong (int len)
 Initialize a chiptone song. More...
 
void vexAudioDeinitChipToneSong ()
 Free memory occupied by a song. More...
 
void vexAudioStartChipToneSong (int repeat)
 Start playback of the song. More...
 
void vexAudioStopChipToneSong ()
 Stop playback of the song. More...
 
void vexAudioSetNextChipTone (int freq, int amplitude, int timems)
 Add a tone to the array for the song. More...
 
void vexAudioDebugChipTone ()
 Print out the song data for debug. More...
 

Detailed Description

DAC port driver.

Macro Definition Documentation

#define WAVE_SAMPLES   32
#define AUDIO_WA_SIZE   THD_WA_SIZE(AUDIO_TASK_STACK_SIZE)

Function Documentation

void vexAudioPlaySound ( int  freq,
int  amplitude,
int  timems 
)

Play frequency at given amplitude.

Parameters
[in]freqdesired frequency in Hz
[in]amplitudedesired amplitude 0 = silence, 128 = max
[in]timemsduration of tone

This is the base function that all sound playback uses. The first time this is called all the DAC and DMA initialization is done, a thread is created to stop the sound after the requested playback time

void vexAudioPlaySoundWait ( int  freq,
int  amplitude,
int  timems 
)

Play frequency at given amplitude and wait for completion.

void vexAudioStopSound ( void  )

Stop sound playing.

This clears the counter used for tone duration and resets the semaphore the audio task is blocking on causing it to wake.

int vexAudioInitChipToneSong ( int  len)

Initialize a chiptone song.

Parameters
[in]lennumber of tones in the song

Initalize a chiptone song, allocate memory and clear all variables memory will be reused for subsequent songs if there is enough space to avoid multiple calls to malloc/free

void vexAudioDeinitChipToneSong ( void  )

Free memory occupied by a song.

void vexAudioStartChipToneSong ( int  repeat)

Start playback of the song.

void vexAudioStopChipToneSong ( void  )

Stop playback of the song.

void vexAudioSetNextChipTone ( int  freq,
int  amplitude,
int  timems 
)

Add a tone to the array for the song.

Parameters
[in]freqdesired frequency in Hz
[in]amplitudedesired amplitude 0 = silence, 128 = max
[in]timemsduration of tone
void vexAudioDebugChipTone ( void  )

Print out the song data for debug.