⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 audio.c

📁 dz3000_51.0.0.4.rar
💻 C
字号:
/*++

Copyright (c) 2001 Sunplus Technology Co., Ltd.

Module Name:

        audio.c

Abstract:

        Module related to AC'97 audio CODEC

Environment:

        Keil C51 Compiler

Revision History:

        08/28/2001      Chi-Yeh Tsai    created                 

--*/

//=============================================================================
//Header file
//=============================================================================
#include "general.h"

#if (AUDIO_OPTION == 1)

#include "audio.h"
#include "main.h"
#include "cardlink.h"	// @WYEO, 1008
#include "asicreg.h"
#include "audfmt.h"

//=============================================================================
//Symbol
//=============================================================================
//-----------------------------------------------------------------------------
//Constant
//-----------------------------------------------------------------------------

//-----------------------------------------------------------------------------
//Variable
//-----------------------------------------------------------------------------
xdata   ULONG   G_AUDIO_RateScale;
xdata   ULONG   G_AUDIO_Rate;
xdata   UCHAR   G_AUDIO_Bits;
xdata   UCHAR   G_AUDIO_nChannel;
xdata   UCHAR   G_AUDIO_nSampleSize;

// these variables use in avi file with audio
idata   UCHAR    G_File_AudioByteLo;
idata   UCHAR    G_File_AudioByteHi;
idata   UCHAR    G_File_AudioSampleCount;
data   	UCHAR    G_File_SubSampleFactor = K_AUDIO_SubSampleFactor;
xdata   ULONG    G_File_SDRAM_AudioBufSize;

//=============================================================================
//Program
//=============================================================================
//-----------------------------------------------------------------------------
//AUDIO_Initialize
//-----------------------------------------------------------------------------
void AUDIO_Initialize(void) USING_0
/*++

Routine Description:

        initialize audio function

Arguments:

        none

Return Value:

        none

--*/
{
        ULONG i = 0;
        USHORT temp;

        G_AUDIO_RateScale = 1;
        G_AUDIO_Rate = K_AC_SampleRate0;
        G_AUDIO_Bits = 8;
        G_AUDIO_nChannel = 1;
        G_AUDIO_nSampleSize = 1;

        L2_WrAC97Reg(K_AC_Index_MicVolume, K_AC_MicVolume);
        L2_WrAC97Reg(K_AC_Index_RecordSelect, K_AC_RecordSelect);
        L2_WrAC97Reg(K_AC_Index_RecordGain, K_AC_RecordGain);
        L2_WrAC97Reg(K_AC_Index_GeneralPurpose, K_AC_GeneralPurpose);
        L2_WrAC97Reg(K_AC_Index_MiscCtrlBits, K_AC_MiscCtrlBits);
        L2_WrAC97Reg(K_AC_Index_SampleRate0, K_AC_SampleRate0);

        L2_RdAC97Reg(K_AC_Index_MicVolume, &temp);
        L2_RdAC97Reg(K_AC_Index_RecordSelect, &temp);
        L2_RdAC97Reg(K_AC_Index_RecordGain, &temp);
        L2_RdAC97Reg(K_AC_Index_GeneralPurpose, &temp);
        L2_RdAC97Reg(K_AC_Index_MiscCtrlBits, &temp);
        L2_RdAC97Reg(K_AC_Index_SampleRate0, &temp);
}

//-----------------------------------------------------------------------------
//File_AudioSetMode
//-----------------------------------------------------------------------------
/*++

Routine Description:
	these function use in avi file with audio
	
Arguments:
	none
	
Return Value:

        none

--*/
void File_AudioSetMode(void) USING_0
{
	G_AUDIO_RateScale = 1;
	G_AUDIO_Rate = K_AC_SampleRate0;
	G_AUDIO_Bits = 8;
	G_AUDIO_nChannel = 1;
	G_AUDIO_nSampleSize = 1;
	G_File_SubSampleFactor = K_AUDIO_SubSampleFactor;

        //enable audio capture
        //G_File_AudioEnable = 1; // WWWW0409

        //initialize audio size (unit: WORD)
        G_File_AudioSize = 4;

        //initialize sample count
        G_File_AudioSampleCount = G_File_SubSampleFactor - 1;
}

//-----------------------------------------------------------------------------
//File_AudioGetSample
//-----------------------------------------------------------------------------
/*++

Routine Description:
	these function use in avi file with audio

Arguments:
	none
	
Return Value:

        none

--*/
void File_AudioGetSample(void) USING_2
{
}

#if ( PLAYBACK_OPTION )
// @WYEO, 102501
BYTE File_PlayWaveStream(ULONG ramAddr, ULONG audioSize, ULONG *pAudsValue)
{
        ULONG ulTemp0 = ramAddr;
        ULONG ulTemp1 = audioSize;
        *pAudsValue = 0;

	return TRUE;
}
#endif

ULONG File_RecordAudioStream(ULONG ramAddr, ULONG ramSize, ULONG *pAudsValue) USING_0
{
        ULONG ulTemp0 = ramAddr;  
        ULONG ulTemp1 = ramSize;  
        ULONG audioSize = 0;

	pAudsValue[0] = 2;		// K_File_Wave_wFormatTag_Value
	pAudsValue[1] = 1;		// K_File_Wave_nChannels_Value
	pAudsValue[2] = 0x1f40;		// K_File_Wave_nSamplesPerSec_Value
	pAudsValue[3] = 0x1f40;		// K_File_Wave_nAvgBytesPerSec_Value
	pAudsValue[4] = 1;		// K_File_Wave_blockAlign_Value
	pAudsValue[5] = 8;		// K_File_Wave_wBitsPerSample_Value

	return audioSize;
}

#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -