www.pudn.com > iMagic_2006_0428_v098r23.rar > AppAudio.h


/* 
**************************************************************** 
*                      Magic Pixel Inc. 
* 
*    Copyright 2004, Magic Pixel Inc., HsinChu, Taiwan 
*                    All rights reserved. 
* 
* 
* 
* Filename:    AppAudio.h 
* 
* Programmer:    Richard Lin 
*                MPX E120 division 
* 
* Created: 12/30/2004 
* 
* Description: Header file of audio related application functions 
* 
*         
* Change History (most recent first): 
*     <1>     12/30/2004    Richard Lin    first file 
*     <2>     07/04/2005    York Dai       Create Audio Control Structure 
************************************************************************* 
*/ 
#ifndef __APP_AUDIO_H 
#define __APP_AUDIO_H 
#include "Global.h" 
#include "File.h" 
#include "Main.h" 
#include "Video.h" 
 
#define AUDIO_SRAM_BUFFER_ADDRESS 0xB8000000 
 
// play status flag Definition 
#define PLAYER_READY		0 
#define PLAYER_PLAYING		1 
#define PLAYER_PAUSE 		2 
#define PLAYER_PROGRESS		3 
#define PLAYER_RECORDING	4 
#define PLAYER_FLUSHING		5 
#define PLAYER_PROMPT		6 
 
#define I2S_BUFFER_U16_SIZE 32768 
 
#define I2S_BUFFER_U16_SIZE_MASK 0x7fff 
 
#define OPEN_AUDIO_PARSER_ERROR -1 
#define NOT_SUPPORTED_FORMAT -2 
#define WMA_NOTSUPPORTED -3 
 
#define PROGRESS_COUNT_FRAME_PROFILE	0 
#define PROGRESS_FRAME_PROFILE		1 
#define PROGRESS_SAMPLING_PROFILE	2 
 
// the return code of the Progress Console  
#define BREAK_AUDIO_DECODER 0 
#define PROGRESS_AUDIO_DECODER 1 
#define CONTINUE_AUDIO_DECODER 2 
 
#define FLAG_POOL_MASK	0x00000001 
#define FLAG_POOL_SET	0x00000001 
 
// Audio Flag Pool Definition 
#define AUDIO_IS_DECODING_OFFSET		0 
#define AUDIO_RECORDING_PROFILE_OFFSTE		1 
#define AUDIO_WITH_SPECTRUM_OFFSET		2 
#define AUDIO_VBR_TYPE_OFFSET			3 
 
#define AUDIO_PARSER_TICKS_LIMIT	5000/4  // 5000 mini-seconds/4 mini-seconds(1 OS tick) 
 
//for mixer 
#define SAMPLES_PER_FRAME_AAC 1024 
#define SAMPLES_PER_FRAME_MP3 576 
#define SAMPLES_PER_FRAME_MP2 1152 
#define SAMPLES_PER_FRAME_AMR 160 
#define SAMPLES_PER_FRAME_WAV 160 
 
#define UNINSTALL_GETID3INFODATASYNC -1 
 
typedef struct { 
   STREAM *hFilebs_pt;    
   STREAM *hWTFile_pt; //kevin yang, for wave table 
   volatile DWORD progressSeconds;  		// the progress position in mini-second   
   volatile DWORD pausedProgressSeconds;	// the paused progress position in mini-second 
   volatile LONG playedFrameTime;		// the time of frame that has played    
   DWORD prevPlayTime;		// the PlayTime before SetAudioProgress, used for WMA now 
   BOOL AACFileType;	//ADIF or ADTS, used for AAC now 
   DWORD WAVEFormat;    //currently support PCM and IMA ADPCM format 
   DWORD ADPCMPacketLength; // unit: byte 
   DWORD SamplesPerFrame; // unit: byte 
   DWORD SkipSamples;   //for IMA ADPCM only     
// Start to AudioInformation that filled during Open Audio 
   DWORD audioSecondLength;		// the audio length in mini-second    
   DWORD firstStartFrame;		// the offset of the first frame in the audio 
   LONG frameMicroSeconds;		// one frame time in micro-second 
   DWORD bytePerSampling;               // the number of byte in a sampling 
   DWORD samplingRate;			// the sampling rate of the audio 
   DWORD bitRate;			// the bitrate of the audio 
   void (*clearAudioBuffer)(void);      // the function to clear the audio buffer in the decoder 
   BYTE channelNumber;   		// the number of channel in the audio     
// End to AudioInformation that filled during Open Audio 
   BYTE bAudioFileFormat;		// the fileformat of the audio 
   WORD maxVoiceLength; 
   volatile WORD play_status_flag;	// the Player status 
   volatile BOOL isCodecActive;	 	// the flag of the audio kernel status 
   BOOL recordingProfile;  
   BOOL withspectrum; 
   WORD intPeriod;			// the interrupt period during the audio recoding or playback  
   BOOL audioVbrType; 
   DWORD DriveFreeSizeForRecorder;    //only for music recorder 
   SWORD GetID3InfoDataSync;  // installed "GetID3Information" function of DataSyncFunc 
   BOOL boolCodecTaskIsBusy;    //avoid deadlock when start to play prompt and audio codec task is busy 
} AUDIOINFOCOMPONENT; 
 
extern AUDIOINFOCOMPONENT insAudioInfo, *pAudioInfo; 
 
// I2S Flag Pool Definition 
#define I2S_CONSTANT_FREQUENCY_OFFSET		0 
#define I2S_EMBEDED_ADC_OFFSET			1 
#define I2S_ADC_DATA_TYPE_OFFSET		2 
#define I2S_EMBEDED_AGC_OFFSET			3 
 
typedef struct { 
   WORD configurationFlag;	// I2S Configuration Flag 
   WORD frameLength;		// I2S Frame Length of each channel 
   WORD codecACT;               // DAC_INIT or ADC_INIT 
   WORD mulSamplingRate;        // the multiplier of the Sampling Rate 
   BOOL constantFrequency;     
   BOOL MCLKout;			//0:enable GPIO 0  as MCLK clock output,  1:disable 
   BOOL SW_surrounding; 
   BOOL embededADC;		// use the embeded ADC or not 
   BOOL ADCDataType;		// the type of the channel output data of  the ADC  
   BOOL embededAGC;             // use the AGC of the embeded ADC or not 
   WORD eAGCGainLevel;		// the gain level of the embeded AGC in the embeded ADC 
} I2SCOMPONENT; 
 
extern I2SCOMPONENT insI2SInfo; 
 
typedef struct { 
   DWORD totalSize; 
   DWORD id3v2Size; 
   DWORD id3v1Size; 
   DWORD infoStart; 
   DWORD infoOffset; 
   DWORD remainderSize; 
   BOOL ID3v2andID3v1; 
} ID3INFOCOMPONENT; 
 
extern ID3INFOCOMPONENT insID3Info; 
 
#define AUDIO_STREAM_BLOCK_COUNT 2 
//#define AUDIO_STREAM_BBP_BLOCK_SIZE 1024*150 // 150K  
//#define AUDIO_STREAM_321_BLOCK_SIZE 1024*32 // 32K  
 
typedef struct { 
   STREAM **hFilebs_pt;     
   DWORD blockSize; 
   DWORD bufferSize; 
   BOOL fileEOF; 
   volatile BOOL fileReload;  
   DWORD dataRead; 
   volatile BOOL blockExchange;  
   volatile DWORD streamBlockID; 
   volatile DWORD streamBufLength[AUDIO_STREAM_BLOCK_COUNT]; 
   volatile DWORD bufferLength[AUDIO_STREAM_BLOCK_COUNT]; 
   volatile DWORD bufferPos[AUDIO_STREAM_BLOCK_COUNT]; 
   BYTE* streamBuffer[AUDIO_STREAM_BLOCK_COUNT];          
} AUDIOIOCOMPONENT; 
 
extern AUDIOIOCOMPONENT insAudioIo, *pAudioIo; 
 
 
 
#ifdef AUDIO_MIXER 
    #define CHANNEL_NUM 3 
    typedef struct  
    { 
        DWORD dwLength[CHANNEL_NUM]; 
        BYTE* bufAddress[CHANNEL_NUM];  
        DWORD repeat[CHANNEL_NUM]; 
        WORD  mono[CHANNEL_NUM]; 
        WORD  volume[CHANNEL_NUM]; 
         
    } 
    ST_MIXER_INFO; 
    //extern ST_MIXER_INFO stMixInfo; 
#endif 
 
 
extern DWORD I2SBufferAddress; 
//extern DWORD I2SBufferRow; 
extern volatile DWORD recordingCode; 
extern volatile DWORD outind;  
 
extern STVIDEOCLIPINFO *pstMp4AVInfo; 
 
DWORD MusicFileOpenApp(STREAM *handle, BYTE bFileFormat, DWORD *mediaSec); 
DWORD MusicFileCloseApp(void); 
DWORD MusicPlayStartApp(void); 
DWORD MusicPlayStopApp(void); 
DWORD GetAudioProgress(WORD *word, BYTE state); 
DWORD MusicVolumeAdjustApp(WORD params, WORD *resp); 
DWORD MicVolumeAdjustApp(WORD params, WORD *resp); 
DWORD VoiceStartRecordingApp(STREAM *hFile, BYTE bFileFormat, WORD maxLength); 
DWORD VoiceRecordStopApp(void); 
DWORD Mp4AudioStartDecodingApp(STREAM *, STVIDEOCLIPINFO *); 
DWORD Mp4AudioStopDecodingApp(void); 
void OverSamplingSetup(WORD n); 
void initProgressConsole(void); 
DWORD executeProgressConsole(DWORD firstTime, DWORD proFile); 
void endProgressConsole(void); 
void recodingDataDownmix(BOOL dwonmixing); 
void flushDecodingI2SBuffer(void); 
void EmbededADCInit(void); 
void EmbededADCPowerDown(void); 
void DACPowerDown(void); 
void GetID3InfSync(WORD* word); 
DWORD GetID3Information(DWORD* totalSize, DWORD* readLength, DWORD* blkAddr); 
void AudioPlayErrorExit(void); 
 
unsigned long calculateMIDFileLength(void); 
void BufferReset(SWORD *BuffAddr, DWORD BuffLen); 
//extern unsigned short (*MP3store)[16]; 
//WORD MP3Line[16]; 
 
#endif