VLSI Solution Oy / MegaLib Documentation

audio.h File Reference

#include "vs1000.h"

Include dependency graph for audio.h:

Go to the source code of this file.

Data Structures

struct  AUDIOPTR
struct  EARSPEAKER

Defines

#define WITH_EARSPEAKER
#define DIRECT_VORBIS_BLOCKSIZE
#define USE_TIMER
#define TIMER_TICKS   100
#define DEFAULT_AUDIO_BUFFER_SAMPLES   2048
#define DAC_DEFAULT_SAMPLERATE   8000
#define DAC_DRIVER_ON_DELAY   (DAC_DEFAULT_SAMPLERATE/10)
#define APPL_RESET   0
#define APPL_AUDIO   1
#define APPL_BITSTREAM   10

Functions

u_int32 ReadTimeCount (void)
void InitAudio (void)
auto void StereoCopy (register __i2 s_int16 *s, register __a0 u_int16 n)
s_int16 AudioBufFill (void)
s_int16 AudioBufFree (void)
auto void SetRate (register __c1 u_int16 rate)
auto void RealSetRate (register __c1 u_int16 rate)
auto void SetVolume (void)
auto void RealSetVolume (void)
auto void AudioOutputSamples (s_int16 *p, s_int16 samples)
u_int16 UartDiv (void)

Variables

__y volatile u_int32 timeCount
s_int16(* applAddr )(s_int16 register __i0 **d, s_int16 register __a1 mode, s_int16 register __a0 n)
__y s_int16 audioBuffer [2 *DEFAULT_AUDIO_BUFFER_SAMPLES]
__y struct AUDIOPTR audioPtr
u_int16 earSpeakerReg
__y u_int16 earSpeakerDisable
u_int16 volumeReg
u_int16 bassReg
__y u_int16 extClock4KHz
__y u_int16 clockX
u_int32 __y curFctl
__y u_int16 hwSampleRate
__y u_int16 uiTime
__y u_int16 uiTrigger
s_int16 __y timeToRemovePDown2
u_int32 __y haltTime
__y u_int16 uartByteSpeed
__y struct EARSPEAKER earSpeaker


Detailed Description

Routines related to audio.

Definition in file audio.h.


Define Documentation

#define APPL_AUDIO   1
 

Definition at line 30 of file audio.h.

#define APPL_BITSTREAM   10
 

Definition at line 31 of file audio.h.

#define APPL_RESET   0
 

Definition at line 29 of file audio.h.

#define DAC_DEFAULT_SAMPLERATE   8000
 

Definition at line 26 of file audio.h.

#define DAC_DRIVER_ON_DELAY   (DAC_DEFAULT_SAMPLERATE/10)
 

Definition at line 27 of file audio.h.

#define DEFAULT_AUDIO_BUFFER_SAMPLES   2048
 

Definition at line 25 of file audio.h.

#define DIRECT_VORBIS_BLOCKSIZE
 

Definition at line 10 of file audio.h.

#define TIMER_TICKS   100
 

Definition at line 14 of file audio.h.

#define USE_TIMER
 

Definition at line 12 of file audio.h.

#define WITH_EARSPEAKER
 

Definition at line 9 of file audio.h.


Function Documentation

s_int16 AudioBufFill void   ) 
 

Tells the fill state of audio buffer in stereo samples.

s_int16 AudioBufFree void   ) 
 

Tells how many stereo samples still fits into the audio buffer without waiting. Note: the buffer should never be completely filled because the same state means empty.

auto void AudioOutputSamples s_int16 p,
s_int16  samples
 

High-level audio output routine. If the samples do not fit into the audio buffer, this routine automatically waits for some room (calls Sleep()).

Parameters:
p Pointer to interleaved stereo samples.
samples The number of stereo samples.

void InitAudio void   ) 
 

Initializes audio structures and configures the PLL.

u_int32 ReadTimeCount void   ) 
 

ReadTimeCount Reads the timecount variable safely, no interrupt disable is needed.

auto void RealSetRate register __c1 u_int16  rate  ) 
 

Sets new samplerate and/or new PLL setting (according to clockX variable).

Parameters:
rate New samplerate.

auto void RealSetVolume void   ) 
 

Sets the hardware volume according to volumeReg.

auto void SetRate register __c1 u_int16  rate  ) 
 

Hook: Sets new samplerate and/or new PLL setting. Default: RealSetRate.

Parameters:
rate New samplerate.

auto void SetVolume void   ) 
 

Hook: Sets the hardware volume according to volumeReg. Default: RealSetVolume

auto void StereoCopy register __i2 s_int16 s,
register __a0 u_int16  n
 

Internal low-level audio output routine that puts samples into the audio buffer. Applies audioPtr.leftVol and audioPtr.rightVol to the data. Setting audioPtr.rightVol to -audioPtr.leftVol after InitAudio() has been called activates differential output mode, where the phase of right channel is inverted compared to the left channel. This routine does not check the buffer fullness.

Parameters:
s Pointer to interleaved stereo samples
n The number of stereo samples

u_int16 UartDiv void   ) 
 

Calculates UART divider from clockX and uartByteSpeed. When SetRate() changes PLL settings, the uart divider is automatically changed.

Returns:
UART divider for the current clockX and uartByteSpeed.


Variable Documentation

s_int16(* applAddr)(s_int16 register __i0 **d, s_int16 register __a1 mode, s_int16 register __a0 n)
 

applAddr A hook function to process samples before they are put into the audio buffer.

Parameters:
d A pointer to pointer to interleaved stereo samples
mode If APPL_AUDIO, samples available
n Number of stereo samples
Returns:
For APPL_AUDIO the number of output stereo samples, return n otherwise.

__y s_int16 audioBuffer[2 *DEFAULT_AUDIO_BUFFER_SAMPLES]
 

Audio FIFO. The length of the area used for audio can change depending on the state of the earSpeaker setting. Earspeaker can not be active when long vorbis frames are used.

__y struct AUDIOPTR audioPtr
 

Audio structure containing the audio FIFO read and write pointers, FIFO size, software volume settings, and the FIFO underflow flag. By negating the other volume field you can get mono differential drive from the DAC for connecting a speaker between LEFT and RIGHT outputs.

u_int16 bassReg
 

Bass and treble controls, not used by rom firmware. See VS10xx datasheets for details.

__y u_int16 clockX
 

Current clock multiplier in 0.5x steps. Is used to program the PLL at the next SetRate().

u_int32 __y curFctl
 

Current DAC adder value.

__y struct EARSPEAKER earSpeaker
 

__y u_int16 earSpeakerDisable
 

Long vorbis frames disable EarSpeaker automatically.

u_int16 earSpeakerReg
 

Current EarSpeaker setting.

__y u_int16 extClock4KHz
 

Crystal/4000. Normally 3000 (for 12MHz).

u_int32 __y haltTime
 

The number of cycles spent in HALT since last check. Used for automatic clock management.

__y u_int16 hwSampleRate
 

Current samplerate.

__y volatile u_int32 timeCount
 

timeCount counts TIMER_TICKS regardless of clockX.

s_int16 __y timeToRemovePDown2
 

Delay until analog drivers are enabled.

__y u_int16 uartByteSpeed
 

UART speed in bps / 10. UART divider is automatically updated when PLL value is changed.

__y u_int16 uiTime
 

Free-running counter for UI.

__y u_int16 uiTrigger
 

Is non-zero 16 times per second when audio is played.

u_int16 volumeReg
 

Left and right volume 0x00(loudest)..0xff (off).


All software copyright 2005-2006 VLSI Solution OY. Redistribution of this software is strictly forbidden.