如何单独针对AMR格式的音乐文件增大播放时Analog Gain

[DESCRIPTION]

客户录音下来的AMR格式的录音文件声音不够大,如果调整Digital Gain过大则失真严重。另外该AMR录音文件在电脑和

其他平台手机上播放声音不小,因此需要在播放时单独针对AMR格式的Analog Gain进行提升。

[SOLUTION]来自半导体社群

在开始播放AMR时置上一个标志位Is_Play_AMR,在AFE设置音量时判断这个标志位,如果被置上则音量增加相应单

位的dB。在播放AMR结束的时候清掉这个标志位。具体修改步骤如下:

Step1:在amr_drv.c这支文件中定义变量Is_Play_AMR,即添加如下行:

kal_bool Is_Play_AMR = 0;

Step2: 修改amr_drv.c这支文件的amrOpenDevice这个函数如下:

static void amrOpenDevice( amrMediaHdl *ihdl , kal_uint16 wCodecMode)

{

ihdl->end_status = MEDIA_NONE;

Is_Play_AMR = 1; //Add

mhdlDisallowSleep( (MHdl*)ihdl );

Step3:修改amr_drv.c这支文件的amrCloseDevice这个函数如下:

static void amrCloseDevice( amrMediaHdl *ihdl )

{

Is_Play_AMR = 0; //Add

#if defined(AMRWB_DECODE) && ( defined(MT6228) || defined(MT6225) || defined(MT6229) || defined(MT6230)

|| defined(MT6268T) || defined(MT6235) || defined(MT6238) || defined(MT6235B) || defined(MT6239) ||

defined(MT6268A) || defined(MT6268) || defined(MT6253T) || defined(MT6253) )

if(ihdl->amr.bWideBand)

amr_WBStopCtrl( ihdl, true );

#endif

Step4:在Afe2这支文件中添加如下行:

extern kal_bool Is_Play_AMR; //Add

Step5:在afe2.c这支文件中修改函数UpdateAGain这个函数如下:

static void UpdateAGain( kal_uint8 aud_func )

{

const kal_uint16 vol = afe.aud[aud_func].volume;

const kal_uint16 amp_gain = (vol>>4);

kal_uint16 amp_gain1 = amp_gain; //Add

/// Preserve the ADC_COUPLE bit (0x0400) and AVCM_MODE bit (0x0800)

if(Is_Play_AMR && (4 == aud_func)) //Add

{

amp_gain1+=3; //Add

if(amp_gain1>0xf)amp_gain1=0xf;

*AFE_AAG_CON = (*AFE_AAG_CON & 0x0C00) | (kal_uint16)((amp_gain1)|(amp_gain1<< 4)); //Add

}

Else //Add

*AFE_AAG_CON = (*AFE_AAG_CON & 0x0C00) | (kal_uint16)((amp_gain)|(amp_gain << 4));

if( aud_func == L1SP_SPEECH )

UpdateSidetone( (kal_int8)(vol >> 4) );

else

*DP_SIDETONE_VOL = 0;

}

Step6:Remake l1audio即可

你可能感兴趣的:(如何单独针对AMR格式的音乐文件增大播放时Analog Gain)