audio.c File Reference


Detailed Description

This module provides audio support.

REVISION

Definition in file audio.c.

#include "../SYSTEM/sys_hardware.h"
#include "../SYSTEM/sys_hiddenfeature.h"
#include "../SYSTEM/sys_main.h"
#include "../SYSTEM/sys_clock.h"
#include "../MESSAGE/message.h"
#include "../codec/codec.h"
#include "../coder/coder.h"
#include "../DECODER/decoder.h"
#include "../encoder/encoder.h"
#include "../fat/fat.h"
#include "../FMXMIT/xmit_inc.h"
#include "../UI/ui.h"
#include "../UI/playQ.h"
#include "audio.h"

Include dependency graph for audio.c:

Include dependency graph

Go to the source code of this file.

Defines

#define EQ_VALUE_OFFSET   (15)
 LOCAL DEFINITIONS.

Functions

BOOL AUDIO_initInterface (AUDIO_MODE mode, AUDIO_FORMAT format, ULONG offset, ULONG duration)
 Function initializes the audio interface.
void AUDIO_setInterface (AUDIO_CONTROL ctl)
 Function sets to start the audio interface.
void AUDIO_setCurrentTrack (void)
 Function fetches the current playback file pointer.
void AUDIO_getCacheTrackFile (int setCacheFile)
 Function fetches the file pointer of that to be cached.
void AUDIO_speedInit (void)
 Function initializes the speed interface.
int AUDIO_speedIsOutputBufferFull (void)
 Function checks to see if speed output buffer is full.
BOOL AUDIO_config (void)
 Function configures the audio system.
void AUDIO_start (void)
 Function starts the audio interface.
void AUDIO_pause (void)
 Function pause the audio interface.
void AUDIO_unmute (void)
 Function unmute the audio interface.
void AUDIO_stop (void)
 Function shuts down active audio interface and releases all data objects used by active interface.
void AUDIO_myfiShutdown (void)
 Function shuts down MyFi broadcasting.
void AUDIO_shutdown (void)
 Function completely shuts down the audio interface and deletes all coder tasks and task level objects.
void AUDIO_energyInit (st_AUDIOENERGY *pEnergy, unsigned short blockSize)
 Function initializes the energy calculation module.
void AUDIO_setEQ (int *pEq)
 Function resets the EQ parameters.
ULONG AUDIO_getFilePtr (void)
 Function returns current audio file pointer offset.
void AUDIO_setFilePtr (ULONG fptr)
 Function sets audio file pointer to given offset.
void AUDIO_resetMyfiQuality (void)
 Function resets MyFi quality control.

Variables

st_AUDIO Audio
 GLOBAL DATA.


Define Documentation

#define EQ_VALUE_OFFSET   (15)
 

LOCAL DEFINITIONS.

TI interface EQ ranges from -15 to 15.

Definition at line 62 of file audio.c.


Function Documentation

BOOL AUDIO_config void   ) 
 

Function configures the audio system.

Returns:
TRUE if audio system is successfully configured, otherwise FALSE.

Definition at line 351 of file audio.c.

References AF_MP3, AF_OGG, AF_PCM, AF_WAV, AF_WMA, AM_MYFI, AM_PLAY, AM_RECFM, AM_RECLINE, AM_RECMIC, Audio, AUDIO_MODE, DECODER_config(), ENCODER_config(), st_CODER::flag, st_AUDIO::format, and st_AUDIO::mode.

Referenced by SYS_main().

00352 {
00353     AUDIO_MODE   mode   = Audio.mode;
00354     USHORT       amode; // 0: playback, 1: record, 2 other.
00355     
00356     if     ((AM_PLAY    == mode)||(AM_MYFI   == mode))                     amode = 0;
00357     else if((AM_RECLINE == mode)||(AM_RECMIC == mode)||(AM_RECFM == mode)) amode = 1;
00358     else                                                                   amode = 2;
00359     
00360     Coder.flag = SYS_isHDDpresent()? F_CODER_USE_CACHE:0;
00361     switch(Audio.format)
00362     {
00363         case AF_MP3:
00364         {
00365             if( 0 == amode )
00366             {
00367                 GEN_load(MP3_CODE);
00368                 GEN_load(MP3_CONST);
00369                 GEN_reinit(MP3_DECODER_OBJ);
00370                 DECODER_config(DECMP3);
00371                 _audioConfig(TRUE, AF_MP3);
00372             }
00373             else if( 1 == amode )
00374             {
00375                 GEN_load(MPR_CODE);
00376                 GEN_load(MPR_CONST);
00377                 GEN_reinit(MP3_ENCODER_OBJ);
00378                 ENCODER_config(ENCMP3);
00379                 _audioConfig(FALSE, AF_MP3);
00380             }
00381             break;
00382         }
00383         #ifdef WMA_SUPPORT
00384         case AF_WMA:
00385         {
00386             if( 0 == amode )
00387             {
00388                 GEN_load(WMA_CODE);
00389                 GEN_load(WMA_CONST);
00390                 GEN_reinit(WMA_DECODER_OBJ);
00391                 DECODER_config(DECWMA);
00392                 _audioConfig(TRUE, AF_WMA);
00393             }
00394             break;
00395         }
00396         #endif
00397         #ifdef WAV_SUPPORT
00398         case AF_WAV:
00399         {
00400             if( 0 == amode )
00401             {
00402                 GEN_load(WAV_CODE);
00403                 GEN_load(WAV_CONST);
00404                 GEN_reinit(WAV_DECODER_OBJ);
00405                 DECODER_config(DECWAV);
00406                 _audioConfig(TRUE, AF_WAV);
00407             }
00408             else if( 1 == amode )
00409             {
00410                 GEN_load(WAVR_CODE);
00411                 GEN_reinit(WAV_ENCODER_OBJ);
00412                 ENCODER_config(ENCWAV);
00413                 _audioConfig(FALSE, AF_WAV);
00414             }
00415             break;      
00416         }
00417         #endif
00418         #ifdef OGG_SUPPORT
00419         case AF_OGG:
00420         {
00421             if( 0 == amode )
00422             {
00423                 GEN_load(OGG_CODE);
00424                 GEN_load(OGG_CONST);
00425                 GEN_reinit(OGG_DECODER_OBJ);
00426                 DECODER_config(DECOGG);
00427                 _audioConfig(TRUE, AF_OGG);
00428             }
00429             break;      
00430         }
00431         #endif
00432         case AF_PCM:
00433         {       
00434             if(2 == amode) _audioConfig(-1, DONTCARE);
00435             break;
00436         }
00437     }
00438 
00439     AUDIO_setIdle();
00440     return TRUE;
00441 }

Here is the call graph for this function:

void AUDIO_energyInit st_AUDIOENERGY pEnergy,
unsigned short  blockSize
 

Function initializes the energy calculation module.

Parameters:
pEnergy Energy data structure.
blockSize Lenght of the block.

Definition at line 684 of file audio.c.

Referenced by CODEC_recordHdlReset().

00685 {
00686     pEnergy->ShortTermEnergy =
00687     pEnergy->AverageEnergy   = 0;
00688     
00689     pEnergy->FastPeak = 
00690     pEnergy->SlowPeak = 0;
00691     
00692     pEnergy->Index = 1;
00693     pEnergy->BlockSize = blockSize-1;
00694 }

void AUDIO_getCacheTrackFile int  setCacheFile  ) 
 

Function fetches the file pointer of that to be cached.

Parameters:
setCacheFile If non-zero, reset the cache file, otherwise seek next track only.

Definition at line 265 of file audio.c.

References Audio, st_AUDIO::cachefile, and UI_getNextAudioFileFromPlayQ().

Referenced by UI_PSF_play().

00266 {
00267     if(setCacheFile)
00268     {
00269         File * fp = UI_getNextAudioFileFromPlayQ(setCacheFile);
00270         if(fp) Audio.cachefile = *fp;
00271     }
00272     else
00273         UI_getNextAudioFileFromPlayQ(setCacheFile);
00274 }

Here is the call graph for this function:

ULONG AUDIO_getFilePtr void   ) 
 

Function returns current audio file pointer offset.

It currently only supports decoder operation.

Returns:
File pointer offset in words.

Definition at line 738 of file audio.c.

References AF_MP3, AF_OGG, AF_WAV, AF_WMA, Audio, and st_AUDIO::format.

Referenced by MENU__djControl(), and UI_PSF_play().

00739 {
00740     ULONG fptr = 0L;
00741     
00742     switch(Audio.format)
00743     {
00744         case AF_MP3:    DECODER_mp3fptr(&fptr); break;
00745         #ifdef WAV_SUPPORT
00746         case AF_WAV:    DECODER_wavfptr(&fptr); break;
00747         #endif
00748         #ifdef OGG_SUPPORT
00749         case AF_OGG:    DECODER_oggfptr(&fptr); break;
00750         #endif
00751         #ifdef WMA_SUPPORT
00752         case AF_WMA:    DECODER_wmafptr(&fptr); break;
00753         #endif
00754     }
00755     return fptr;
00756 }

BOOL AUDIO_initInterface AUDIO_MODE  mode,
AUDIO_FORMAT  format,
ULONG  offset,
ULONG  duration
 

Function initializes the audio interface.

Function loads proper audio code into memory.

Parameters:
mode Target audio mode.
format Audio data format.
offset Audio data file offset.
duration Audio duration in seconds.
Returns:
TRUE if audio interface successfully initialized, otherwise FALSE.

Definition at line 147 of file audio.c.

References AF_NULL, AI_CONFIG, AM_MYFI, AM_PLAY, AM_RECFM, AM_RECLINE, AM_RECMIC, Audio, AUDIO_FORMAT, st_AUDIO::cachefile, st_AUDIO::duration, st_AUDIO::file, st_AUDIO::format, st_AUDIO::fptr, st_AUDIO::mode, st_AUDIO::offset, st_AUDIO::playtime, SAUDIOCTL, SCREATETASK, and UI_getCurrentAudioFileFromPlayQ().

Referenced by UI_PSF_hisi(), UI_PSF_play(), UI_PSF_radio(), and UI_PSF_record().

00151 {
00152     USHORT      amode; // 0: playback, 1: record, 2 other.
00153     
00154     if(AF_NULL == format) return FALSE;
00155     
00156     AUDIO_queryIdle();
00157 
00158     Audio.mode     = mode;
00159     Audio.format   = format;
00160     
00161     if     ((AM_PLAY    == mode)||(AM_MYFI   == mode))                     amode = 0;
00162     else if((AM_RECLINE == mode)||(AM_RECMIC == mode)||(AM_RECFM == mode)) amode = 1;
00163     else                                                                   amode = 2;
00164     
00165     if(0 == amode)
00166     {
00167         Audio.cachefile=
00168         Audio.file     = *UI_getCurrentAudioFileFromPlayQ();
00169         Audio.playtime = 0L; 
00170         Audio.fptr     = 0L;
00171         Audio.offset   = offset;        
00172         Audio.duration = duration;
00173     }
00174     else if(1 == amode) 
00175     {
00176         Audio.duration = 0L;
00177         Audio.fptr     = 0L;
00178     }
00179 
00180     // Config coder system.
00181     mMSG_send(sysMsgQ, SYS_MSG_ID, SAUDIOCTL, AI_CONFIG, SYS_FOREVER);
00182     
00183     if(0 == amode)
00184     {
00185         // Create decoder tasks if not created already.
00186         mMSG_send(sysMsgQ, SYS_MSG_ID, SCREATETASK, DECODER_TASKS, SYS_FOREVER);
00187     }
00188     else if(1 == amode)
00189     {
00190         // Create encoder tasks if not created already.
00191         mMSG_send(sysMsgQ, SYS_MSG_ID, SCREATETASK, ENCODER_TASKS, SYS_FOREVER);
00192     }
00193     
00194     AUDIO_waitIdle(SYS_FOREVER);
00195     return TRUE;
00196 }

Here is the call graph for this function:

void AUDIO_setEQ int *  pEq  ) 
 

Function resets the EQ parameters.

Parameters:
pEq New EQ parameters pointer.

Definition at line 705 of file audio.c.

Referenced by MENU__setEq(), and UI_MSF_eq().

00706 {
00707     USHORT  ii = EQBAR_MAXNUM;
00708     int     tmp;
00709     int     eq[EQBAR_MAXNUM] = {15,15,15,15,15};
00710     int *   p = &EQgain[0];
00711     
00712     if(NULL == pEq) pEq = eq;
00713     
00714     while(ii--)
00715     {
00716         tmp = *pEq - EQ_VALUE_OFFSET;
00717         if( (tmp < -15) || (tmp > 15) )
00718         {
00719             *pEq = 15;
00720             tmp = 0;
00721         }
00722         *p++ = tmp;
00723         pEq++;
00724     }
00725     
00726     EQ_setGains(&LeftEQ, EQgain);
00727     EQ_setGains(&RightEQ, EQgain);
00728 }

void AUDIO_setFilePtr ULONG  fptr  ) 
 

Function sets audio file pointer to given offset.

It currently only supports decoder operation.

Parameters:
fptr File pointer offset in words.

Definition at line 767 of file audio.c.

References Audio, Decoder, st_DECODER::flag, and st_AUDIO::offset.

Referenced by UI_PSF_play().

00768 {
00769     HWI_disable();
00770     Audio.offset = fptr;
00771     Decoder.flag |= DEC_MEDIASEEK;
00772     HWI_enable();
00773 }

int AUDIO_speedIsOutputBufferFull void   ) 
 

Function checks to see if speed output buffer is full.

Returns:
1 if full, otherwise 0.

Definition at line 317 of file audio.c.

Referenced by CODEC_playPcmPut().

00318 {
00319     unsigned int outRate;
00320     
00321     if(sampleCount >= 64) 
00322     {
00323         sampleCount -= 64;
00324         return 1;
00325     }
00326 
00327     // Check to reset SRC.
00328     outRate = (NORMAL_SPEED != speed)? USRATE: 44100;
00329     if(actvRate != outRate)
00330     {
00331         LeftSRC_params.outputRate       = 
00332         RightSRC_params.outputRate      = outRate;
00333         
00334         SRC_algInit(&LeftSRC, LeftSRC_memRec, NULL, &LeftSRC_params);
00335         SRC_algInit(&RightSRC, RightSRC_memRec, NULL, &RightSRC_params);
00336         actvRate = outRate;
00337     }
00338     
00339     return 0;       
00340 }


Variable Documentation

st_AUDIO Audio
 

GLOBAL DATA.

This global bridges the GUI and entir audio system. It has to sit in internal memory.

Definition at line 122 of file audio.c.

Referenced by AUDIO_config(), AUDIO_getCacheTrackFile(), AUDIO_getFilePtr(), AUDIO_initInterface(), AUDIO_setFilePtr(), AUDIO_shutdown(), AUDIO_start(), CODEC_recordHdlReset(), DECODER__mp3(), DECODER__mp3first(), DECODER__mp3media(), DECODER__oggfirst(), DECODER__oggRead(), DECODER__wav(), DECODER__wavfirst(), DECODER__wavmedia(), DECODER__wma(), DECODER__wmainit(), DECODER__wmamedia(), DECODER__wmatask(), DECODER_cache(), DECODER_getData(), DECODER_releaseObj(), DECODER_seek(), ENCODER__mp3(), ENCODER__wav(), ENCODER_cache(), ENCODER_putData(), ENCODER_releaseObj(), UI_PSF_hisi(), UI_PSF_play(), UI_PSF_record(), and UI_setupPlayQ().


Generated on Wed Jan 19 01:12:47 2005 for neuros-firmware by  doxygen 1.3.9.1