aec_nm.cpp
上传用户:gelin96
上传日期:2017-01-08
资源大小:20993k
文件大小:22k
- /*****************************************************************************
- * Copyright Statement:
- * --------------------
- * This software is protected by Copyright and the information contained
- * herein is confidential. The software may not be copied and the information
- * contained herein may not be used or disclosed except with the written
- * permission of MediaTek Inc. (C) 2005
- *
- * BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
- * THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
- * RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
- * AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
- * NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
- * SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
- * SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
- * THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
- * NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
- * SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
- *
- * BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
- * LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
- * AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
- * OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
- * MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
- *
- * THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
- * WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
- * LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
- * RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
- * THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
- *
- *****************************************************************************/
- /*****************************************************************************
- *
- * Filename:
- * ---------
- * AEC_nm.cpp
- *
- * Project:
- * --------
- * Maui META APP
- *
- * Description:
- * ------------
- * Acoustic Echo Cancellation (AEC) calibration in normal mode source
- *
- * Author:
- * -------
- * Andy Ueng (mtk00490)
- *
- *============================================================================
- * HISTORY
- * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
- *------------------------------------------------------------------------------
- * $Revision$
- * $Modtime$
- * $Log$
- *
- *------------------------------------------------------------------------------
- * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
- *============================================================================
- ****************************************************************************/
- //---------------------------------------------------------------------------
- #include <IniFiles.hpp>
- #pragma hdrstop
- #ifndef _AEC_NM_H_
- #include "aec_nm.h"
- #endif
- #ifndef _MAN_ACTIVE_H_
- #include "man_active.h"
- #endif
- #ifndef _FT_UTILS_H_
- #include "ft_utils.h"
- #endif
- //---------------------------------------------------------------------------
- #pragma package(smart_init)
- //===========================================================================
- static CAECNM* g_aec_ptr;
- //============================= static function ==============================
- static void REQ_Read_FIR_From_NVRAM(void)
- {
- g_aec_ptr->REQ_Read_FIR_From_NVRAM();
- }
- //----------------------------------------------------------------------------
- static void CNF_ReadFirFromNVRAM(void)
- {
- g_aec_ptr->CNF_ReadFirFromNVRAM();
- }
- //----------------------------------------------------------------------------
- static void REQ_Write_FIR_To_NVRAM(void)
- {
- g_aec_ptr->REQ_Write_FIR_To_NVRAM();
- }
- //----------------------------------------------------------------------------
- static void CNF_WriteFirToNVRAM(void)
- {
- g_aec_ptr->CNF_WriteFirToNVRAM();
- }
- //----------------------------------------------------------------------------
- static void REQ_Read_Volume_Setting_From_NVRAM(void)
- {
- g_aec_ptr->REQ_Read_Volume_Setting_From_NVRAM();
- }
- //----------------------------------------------------------------------------
- static void CNF_ReadVolSettingFromNVRAM(void)
- {
- g_aec_ptr->CNF_ReadVolSettingFromNVRAM();
- }
- //----------------------------------------------------------------------------
- static void CNF_WriteVolSettingToNVRAM(void)
- {
- g_aec_ptr->CNF_WriteVolSettingToNVRAM();
- }
- //----------------------------------------------------------------------------
- static void REQ_Audio_Tone_Loop_Back_Rec(void)
- {
- //g_aec_ptr->REQ_Audio_Tone_Loop_Back_Rec();
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- void CAECNM::AllocateDynMemory(void)
- {
- m_cpBuf = new char[AEC_BUF_SIZE_2K*AEC_PLAY_FREQ_NUM];
- }
- //---------------------------------------------------------------------------
- void CAECNM::ReleaseDynMemory(void)
- {
- if (NULL != m_cpBuf)
- {
- delete [] m_cpBuf;
- m_cpBuf = NULL;
- }
- }
- //==============================================================================
- __fastcall CAECNM::CAECNM(bool CreateSuspended, S_AEC_NM_T *p_s_aec_nm): TThread(CreateSuspended)
- {
- g_aec_ptr = this;
- m_psAEC = p_s_aec_nm;
- }
- //----------------------------------------------------------------------------
- void __fastcall CAECNM::Execute(void)
- {
- AllocateDynMemory();
- // read FIR from NVRAM
- E_METAAPP_RESULT_T metaapp_result = REQ_Read_FIR_From_NVRAM();
- if (metaapp_result != METAAPP_SUCCESS)
- {
- return;
- }
- if (this->Terminated)
- {
- this->OnTerminate = m_psAEC->ne_onTermByUser;
- return;
- }
- // read MIC gain from NVRAM
- metaapp_result = REQ_Read_Volume_Setting_From_NVRAM();
- if (metaapp_result != METAAPP_SUCCESS)
- {
- return;
- }
- if (this->Terminated)
- {
- this->OnTerminate = m_psAEC->ne_onTermByUser;
- return;
- }
- // set MIC gain to DSP
- micresult s_mic_result;
- unsigned char uc_mic_vol_gain;
- unsigned char uc_max_speaker_gain;
- if (m_psAEC->b_cust_vol_16)
- {
- uc_mic_vol_gain = m_sCustVolEx.volume_gain[NORMAL_MODE][MICROPHONE_TYPE][0];
- uc_max_speaker_gain = m_sCustVolEx.volume_gain[NORMAL_MODE][SPEECH_TONE_TYPE][6];
- }
- else
- {
- uc_mic_vol_gain = m_sCustVol.volume_gain[NORMAL_MODE][MICROPHONE_TYPE][0];
- uc_max_speaker_gain = m_sCustVol.volume_gain[NORMAL_MODE][SPEECH_TONE_TYPE][6];
- }
- bool ok = load_mic(&s_mic_result, uc_mic_vol_gain);
- if (!ok)
- {
- return;
- }
- if (this->Terminated)
- {
- this->OnTerminate = m_psAEC->ne_onTermByUser;
- return;
- }
- // playback & record
- for (E_AEC_STEP_T step = AEC_STEP_1; step <= AEC_STEP_3; step++)
- {
- Audio_Tone_LoopBackRec_Req req;
- req.spkgain = uc_max_speaker_gain;
- req.micgain = uc_mic_vol_gain;
- req.ulgain = m_psAEC->s_ini.us_up_digital_gain;
- req.dlgain = m_psAEC->s_ini.us_dn_digital_gain;
- req.amp = m_psAEC->s_ini.us_kt_gain[step-1];
- E_METAAPP_RESULT_T metaapp_result = REQ_Audio_Tone_Loop_Back_Rec(req);
- if (metaapp_result != METAAPP_SUCCESS)
- {
- return;
- }
- if (this->Terminated)
- {
- this->OnTerminate = m_psAEC->ne_onTermByUser;
- return;
- }
- switch (step)
- {
- case AEC_STEP_1:
- {
- if (!calibrate_step_1_2k_normal(&s_mic_result, (short *)m_cpBuf, m_psAEC->b_debug))
- {
- return;
- }
- uc_mic_vol_gain = s_mic_result.volume;
- if (m_psAEC->b_cust_vol_16)
- {
- for (int i=0; i<MAX_VOL_LEVEL; i++)
- {
- m_sCustVolEx.volume_gain[NORMAL_MODE][MICROPHONE_TYPE][i] = uc_mic_vol_gain;
- }
- m_cVOL_SET_Obj.Set_CustVol16(m_sCustVolEx);
- }
- else
- {
- for (int i=0; i<MAX_VOL_LEVEL; i++)
- {
- m_sCustVol.volume_gain[NORMAL_MODE][MICROPHONE_TYPE][i] = uc_mic_vol_gain;
- }
- m_cVOL_SET_Obj.Set_CustVol(m_sCustVol);
- }
- metaapp_result = REQ_Write_Volume_Setting_To_NVRAM();
- if (metaapp_result != METAAPP_SUCCESS)
- {
- return;
- }
- }
- break;
- case AEC_STEP_2:
- {
- if (!calibrate_step_2_2k_normal(&s_mic_result, (short *)m_cpBuf, m_psAEC->b_debug))
- {
- return;
- }
- uc_mic_vol_gain = s_mic_result.volume;
- if (m_psAEC->b_cust_vol_16)
- {
- for (int i=0; i<MAX_VOL_LEVEL; i++)
- {
- m_sCustVolEx.volume_gain[NORMAL_MODE][MICROPHONE_TYPE][i] = uc_mic_vol_gain;
- }
- m_cVOL_SET_Obj.Set_CustVol16(m_sCustVolEx);
- }
- else
- {
- for (int i=0; i<MAX_VOL_LEVEL; i++)
- {
- m_sCustVol.volume_gain[NORMAL_MODE][MICROPHONE_TYPE][i] = uc_mic_vol_gain;
- }
- m_cVOL_SET_Obj.Set_CustVol(m_sCustVol);
- }
- metaapp_result = REQ_Write_Volume_Setting_To_NVRAM();
- if (metaapp_result != METAAPP_SUCCESS)
- {
- return;
- }
- // write volume gain to file
- bool ok = m_cVOL_SET_Obj.REQ_Write_To_File(m_psAEC->as_volume_gain_file.c_str(), true, m_psAEC->b_cust_vol_16);
- if (!ok)
- {
- return;
- }
- }
- break;
- case AEC_STEP_3:
- {
- speresult s_sp_result;
- if ((AUDIO_FIR_VER_W0547_45_TAP == m_psAEC->e_audio_param_type) ||
- (AUDIO_FIR_VER_W0712 == m_psAEC->e_audio_param_type) ||
- (AUDIO_FIR_VER_W0740 == m_psAEC->e_audio_param_type)
- )
- {
- if (!calibrate_step_3_2k_normal(&s_sp_result, (short *)m_cpBuf, &s_mic_result, m_psAEC->b_drc_support, m_psAEC->b_debug))
- {
- return;
- }
- }
- else
- {
- if (!calibrate_step_3_2k_normal_08A(&s_sp_result, (short *)m_cpBuf, &s_mic_result, m_psAEC->b_drc_support, m_psAEC->b_debug))
- {
- return;
- }
- }
- m_psAEC->e_result = (E_AEC_RESULT_T) s_sp_result.mechanism;
- // write normal mode FIR to NVRAM
- unsigned char uc_se_mode_para_num = m_cSP_COEF_Obj.Get_SpeechModeDependentParameterNum(m_psAEC->e_audio_param_type);
- if ((AUDIO_FIR_VER_W0547_45_TAP == m_psAEC->e_audio_param_type) ||
- (AUDIO_FIR_VER_W0712 == m_psAEC->e_audio_param_type) ||
- (AUDIO_FIR_VER_W0740 == m_psAEC->e_audio_param_type)
- )
- {
- for (int i=0; i<uc_se_mode_para_num; i++)
- {
- m_sFirCoeff.us_speech_mode_para[SPEECH_NORMAL_MODE][i] = s_sp_result.sp_enhace[i];
- }
- for (int i = uc_se_mode_para_num; i < SE_MODE_PARA_NUM_16; i++)
- {
- m_sFirCoeff.us_speech_mode_para[SPEECH_NORMAL_MODE][i] = 0;
- }
- }
- else
- {
- for (int i=0; i<uc_se_mode_para_num; i++)
- {
- m_sFirCoeff.us_speech_mode_para[SPEECH_NORMAL_MODE][i] = s_sp_result.sp_enhace_08A[i];
- }
- for (int i = uc_se_mode_para_num; i < SE_MODE_PARA_NUM_16; i++)
- {
- m_sFirCoeff.us_speech_mode_para[SPEECH_NORMAL_MODE][i] = 0;
- }
- }
- m_cSP_COEF_Obj.Set_FirCoef(m_sFirCoeff);
- metaapp_result = REQ_Write_FIR_To_NVRAM();
- if (metaapp_result != METAAPP_SUCCESS)
- {
- return;
- }
- // write to audcoeff_default.h
- if (!REQ_Write_To_Audcoeff_Default(m_psAEC->as_audcoeff_default_h.c_str(), m_psAEC->e_audio_param_type))
- {
- return;
- }
- }
- break;
- } // switch(step)
- } // for(step)
- this->OnTerminate = m_psAEC->ne_onTermSuccess;
- }
- //===========================================================================
- E_METAAPP_RESULT_T CAECNM::REQ_Read_FIR_From_NVRAM(void)
- {
- DWORD wait_result;
- m_hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
- ResetEvent(m_hEvent);
- m_cSP_COEF_Obj.ConfirmCallback = ::CNF_ReadFirFromNVRAM;
- m_cSP_COEF_Obj.REQ_Read_From_NVRAM(m_psAEC->e_audio_param_type);
- wait_result = WaitForSingleObject(m_hEvent, 5000);
- if (WAIT_TIMEOUT == wait_result)
- {
- return METAAPP_TIMEOUT;
- }
- else if (m_eConfirmState != METAAPP_SUCCESS)
- {
- return m_eConfirmState;
- }
- return METAAPP_SUCCESS;
- }
- //-------------------------------------
- void CAECNM::CNF_ReadFirFromNVRAM(void)
- {
- m_eConfirmState = m_cSP_COEF_Obj.Get_ConfirmState();
- if (METAAPP_SUCCESS == m_eConfirmState)
- {
- m_cSP_COEF_Obj.Get_FirCoef(m_sFirCoeff);
- }
- SetEvent(m_hEvent);
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- E_METAAPP_RESULT_T CAECNM::REQ_Write_FIR_To_NVRAM(void)
- {
- m_cSP_COEF_Obj.Set_FirCoef(m_sFirCoeff);
- DWORD wait_result;
- m_hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
- ResetEvent(m_hEvent);
- m_cSP_COEF_Obj.ConfirmCallback = ::CNF_WriteFirToNVRAM;
- m_cSP_COEF_Obj.REQ_Write_To_NVRAM(m_psAEC->e_audio_param_type, m_psAEC->b_fir_runtime_support);
- wait_result = WaitForSingleObject(m_hEvent, 5000);
- if (WAIT_TIMEOUT == wait_result)
- {
- return(METAAPP_TIMEOUT);
- }
- else if (m_eConfirmState != METAAPP_SUCCESS)
- {
- return m_eConfirmState;
- }
- return METAAPP_SUCCESS;
- }
- //-----------------------------------------
- void CAECNM::CNF_WriteFirToNVRAM(void)
- {
- m_eConfirmState = m_cSP_COEF_Obj.Get_ConfirmState();
- SetEvent(m_hEvent);
- //if (METAAPP_SUCCESS == m_eConfirmState)
- //{
- // ActiveMan->SetActiveFunction(::REQ_Read_Volume_Setting_From_NVRAM);
- //}
- //else
- // {
- // Confirm(state);
- // }
- }
- //===========================================================================
- E_METAAPP_RESULT_T CAECNM::REQ_Read_Volume_Setting_From_NVRAM(void)
- {
- DWORD wait_result;
- m_hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
- ResetEvent(m_hEvent);
- m_cVOL_SET_Obj.ConfirmCallback = ::CNF_ReadVolSettingFromNVRAM;
- m_cVOL_SET_Obj.REQ_Read_From_NVRAM(m_psAEC->b_cust_vol_16);
- wait_result = WaitForSingleObject(m_hEvent, 5000);
- if (WAIT_TIMEOUT == wait_result)
- {
- return(METAAPP_TIMEOUT);
- }
- else if (m_eConfirmState != METAAPP_SUCCESS)
- {
- return m_eConfirmState;
- }
- return METAAPP_SUCCESS;
- }
- //--------------------------------------------
- void CAECNM::CNF_ReadVolSettingFromNVRAM(void)
- {
- m_eConfirmState = m_cVOL_SET_Obj.Get_ConfirmState();
- if (m_eConfirmState == METAAPP_SUCCESS)
- {
- if (m_psAEC->b_cust_vol_16)
- {
- CustAcousticVol16lvl_T* p_cust_vol = m_cVOL_SET_Obj.Get_CustVol16();
- m_sCustVolEx = *p_cust_vol;
- #if 0
- for (int level=0; level<CUST_VOL_LEVEL_NUM; level++)
- {
- m_sCustVolEx.volume_gain[HANDSFREE_MODE][SPEECH_TONE_TYPE][level] = m_sSpkGain.volume[level];
- m_sCustVolEx.volume_gain[HANDSFREE_MODE][MICROPHONE_TYPE][level] = m_sMicGain.volume;
- }
- m_cVOL_SET_Obj.Set_CustVol16(m_sCustVolEx);
- #endif
- }
- else
- {
- CustAcousticVol_T* p_cust_vol = m_cVOL_SET_Obj.Get_CustVol();
- m_sCustVol = *p_cust_vol;
- #if 0
- for (int level=0; level<CUST_VOL_LEVEL_NUM; level++)
- {
- m_sCustVol.volume_gain[HANDSFREE_MODE][SPEECH_TONE_TYPE][level] = m_sSpkGain.volume[level];
- m_sCustVol.volume_gain[HANDSFREE_MODE][MICROPHONE_TYPE][level] = m_sMicGain.volume;
- }
- m_cVOL_SET_Obj.Set_CustVol(m_sCustVol);
- #endif
- }
- //REQ_Write_Volume_Setting_To_NVRAM();
- }
- SetEvent(m_hEvent);
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- E_METAAPP_RESULT_T CAECNM::REQ_Write_Volume_Setting_To_NVRAM(void)
- {
- DWORD wait_result;
- m_hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
- ResetEvent(m_hEvent);
- m_cVOL_SET_Obj.ConfirmCallback = ::CNF_WriteVolSettingToNVRAM;
- m_cVOL_SET_Obj.REQ_Write_To_NVRAM(m_psAEC->b_cust_vol_16, m_psAEC->b_cust_vol_runtime_support);
- wait_result = WaitForSingleObject(m_hEvent, 5000);
- if (WAIT_TIMEOUT == wait_result)
- {
- return(METAAPP_TIMEOUT);
- }
- else if (m_eConfirmState != METAAPP_SUCCESS)
- {
- return m_eConfirmState;
- }
- return METAAPP_SUCCESS;
- }
- //-------------------------------------------------
- void CAECNM::CNF_WriteVolSettingToNVRAM(void)
- {
- E_METAAPP_RESULT_T state = m_cVOL_SET_Obj.Get_ConfirmState();
- if (state != METAAPP_SUCCESS)
- {
- //Confirm(state);
- return;
- }
- SetEvent(m_hEvent);
- #if 0
- // write volume gain to file
- bool ok = m_cVOL_SET_Obj.REQ_Write_To_File(m_psAEC->as_volume_gain_file.c_str(), true, m_psAEC->b_cust_vol_16);
- if (!ok)
- {
- Confirm(METAAPP_FAIL);
- }
- else
- {
- Confirm(METAAPP_SUCCESS);
- }
- #endif
- }
- //---------------------------------------------------------------------------
- E_METAAPP_RESULT_T CAECNM::REQ_Audio_Tone_Loop_Back_Rec(Audio_Tone_LoopBackRec_Req req)
- {
- META_RESULT MetaResult;
- Audio_Tone_LoopBackRec_Cnf_2K cnf_2k;
- unsigned short us_freq[] = {500, 750, 1000, 1500, 2000, 2500, 3000, 3500};
- // if (!calibrate_mic(&m_sMicGain, m_psAEC->i_micgain, (int) m_psAEC->e_mic_device_type))
- // {
- // Confirm(METAAPP_FAIL);
- // return;
- // }
- // if (!calibrate_spk(&m_sSpkGain, m_psAEC->i_spkgain, (int) m_psAEC->e_speaker_dac_type))
- // {
- // Confirm(METAAPP_FAIL);
- // return;
- // }
- // req.spkgain = m_sSpkGain.cal_gain;
- // req.micgain = m_sMicGain.cal_gain;
- // req.ulgain = m_usUpDigiGain;
- // req.dlgain = m_usDnDigiGain;
- // req.amp = m_usKTGain[m_eStep-1];
- for (int freq_idx=0; freq_idx<AEC_PLAY_FREQ_NUM; freq_idx++)
- {
- req.fre = us_freq[freq_idx];
- MetaResult = META_Audio_Tone_Loop_Back_Rec_2K_Normal_r(m_META_HANDLE_Obj.Get_MainHandle(), 15000 , &req, &cnf_2k);
- if (MetaResult != META_SUCCESS)
- {
- if (MetaResult != META_TIMEOUT)
- {
- return METAAPP_FAIL;
- }
- else
- {
- return METAAPP_TIMEOUT;
- }
- }
- memcpy((void *)(m_cpBuf+freq_idx*AEC_BUF_SIZE_2K), (void *)cnf_2k.buffer, AEC_BUF_SIZE_2K);
- }
- return METAAPP_SUCCESS;
- }
- //===========================================================================
- ////////////////////////////// File ///////////////////////////
- //===========================================================================
- bool CAECNM::REQ_Write_To_Audcoeff_Default(char *filename, E_AUDIO_FIR_VER_T audio_param_type)
- {
- if ((AUDIO_FIR_VER_ORG == audio_param_type) || (AUDIO_FIR_VER_W0547 == audio_param_type))
- {
- return false;
- }
- FILE *fs;
- fs = fopen(filename, "w");
- if (NULL == fs)
- {
- return false;
- }
- // fprintf(fs, "#ifndef AUDCOEFF_COMMON_DOT_Hn");
- // fprintf(fs, "#define AUDCOEFF_COMMON_DOT_Hnn");
- fprintf(fs, "#define DEFAULT_SPEECH_NORMAL_MODE_PARA \");
- fprintf(fs, "n");
- fprintf(fs, "{ \");
- fprintf(fs, "n");
- unsigned char uc_se_mode_para_num = m_cSP_COEF_Obj.Get_SpeechModeDependentParameterNum(m_psAEC->e_audio_param_type);
- for (int i=0; i<uc_se_mode_para_num; i++)
- {
- fprintf(fs, "%6d", m_sFirCoeff.us_speech_mode_para[SPEECH_NORMAL_MODE][i]);
- if (i != uc_se_mode_para_num - 1)
- {
- fprintf(fs, ",");
- }
- else
- {
- fprintf(fs, " \");
- }
- }
- fprintf(fs, "n}nn");
- // fprintf(fs, "#endif // ... AUDCOEFF_COMMON_DOT_Hnn");
- fclose(fs);
- return true;
- }
- //---------------------------------------------------------------------------
- bool CAECNM::REQ_Write_Record_To_File(char *filename)
- {
- FILE *fs;
- fs = fopen(filename, "wb");
- if (NULL == fs)
- {
- return false;
- }
- if (AEC_TYPE_LOUD_SPEAKER_8K == m_psAEC->e_aec_type)
- {
- fwrite(m_cpBuf, AEC_BUF_SIZE_8K*AEC_PLAY_FREQ_NUM, 1, fs);
- }
- else
- {
- fwrite(m_cpBuf, AEC_BUF_SIZE_2K*AEC_PLAY_FREQ_NUM, 1, fs);
- }
- fclose(fs);
- return true;
- }