sp_coef.cpp
上传用户:gelin96
上传日期:2017-01-08
资源大小:20993k
文件大小:141k
- /*****************************************************************************
- * 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:
- * ---------
- * sp_coef.cpp
- *
- * Project:
- * --------
- * Maui META APP
- *
- * Description:
- * ------------
- * Acoustic FIR coefficient 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 _SP_COEF_H_
- #include "sp_coef.h"
- #endif
- #ifndef _MAN_ACTIVE_H_
- #include "man_active.h"
- #endif
- #ifndef _MISC_H_
- #include "misc.h"
- #endif
- #ifndef _FT_UTILS_H_
- #include "ft_utils.h"
- #endif
- #ifndef _NVRAM_VER_H_
- #include "nvram_ver.h"
- #endif
- //===========================================================================
- static const char Additional_8k_Output_Name[][32] =
- {
- "Additional 8k 1st Output",
- "Additional 8k 2nd Output",
- "Additional 8k 3rd Output",
- "Additional 8k 4th Output",
- "Additional 8k 5th Output",
- };
- static CSPCOEF* sp_coef_ptr;
- static bool g_bIsRunning;
- //===========================================================================
- static void CNF_ReadFromNVRAM(void)
- {
- sp_coef_ptr->CNF_ReadFromNVRAM();
- }
- //---------------------------------------------------------------------------
- static void CNF_WriteToNVRAM(void)
- {
- sp_coef_ptr->CNF_WriteToNVRAM();
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- static void REQ_Get_Runtime_Audio_Param_Settings(void)
- {
- sp_coef_ptr->REQ_Get_Runtime_Audio_Param_Settings();
- }
- //---------------------------------------------------------------------------
- static void REQ_Set_Runtime_Audio_Param_Settings(void)
- {
- sp_coef_ptr->REQ_Set_Runtime_Audio_Param_Settings();
- }
- //===========================================================================
- CSPCOEF::CSPCOEF( void )
- {
- g_bIsRunning = false;
- ConfirmCallback = 0;
- m_iCoefBufSize = 0;
- m_cpCoefBuf = 0;
- }
- //---------------------------------------------------------------------------
- CSPCOEF::~CSPCOEF( )
- {
- g_bIsRunning = false;
- ConfirmCallback = 0;
- if(m_cpCoefBuf)
- {
- delete [] m_cpCoefBuf;
- m_cpCoefBuf = NULL;
- }
- }
- //---------------------------------------------------------------------------
- void CSPCOEF::REQ_Stop( void )
- {
- if(!g_bIsRunning)
- {
- return;
- }
- META_Cancel_r( m_META_HANDLE_Obj.Get_MainHandle(), m_sSPID_COEF );
- Confirm(METAAPP_STOP);
- g_bIsRunning = false;
- }
- //---------------------------------------------------------------------------
- void CSPCOEF::Confirm(E_METAAPP_RESULT_T confirm_state)
- {
- if(!g_bIsRunning) return;
- g_bIsRunning = false;
- if(ConfirmCallback==0) return;
- m_eConfirmState = confirm_state;
- ActiveMan->SetActiveFunction( ConfirmCallback );
- }
- //===========================================================================
- /////////////////////////// Compose / decompse ////////////////////////////
- //===========================================================================
- void CSPCOEF::Compose_FirCoefOrg(S_FIR_COEFF_T fir, l1audio_param_T &fir_org)
- {
- fir_org.Speech_FIR[0] = fir.s_Speech_FIR[0];
- fir_org.Speech_FIR[1] = fir.s_Speech_FIR[1];
- fir_org.Melody_FIR[0] = fir.s_Melody_FIR[0];
- fir_org.Melody_FIR[1] = fir.s_Melody_FIR[0];
- fir_org.ES_TimeConst = fir.us_ES_TimeConst;
- fir_org.ES_VolConst = fir.us_ES_VolConst;
- fir_org.ES_TimeConst2 = fir.us_ES_TimeConst2;
- fir_org.ES_VolConst2 = fir.us_ES_VolConst2;
- fir_org.Media_Playback_Maximum_Swing = fir.us_Media_Playback_Maximum_Swing;
- }
- //---------------------------------------------------------------------------
- void CSPCOEF::DeCompose_FirCoefOrg(l1audio_param_T fir_org, S_FIR_COEFF_T& fir)
- {
- fir.s_Speech_FIR[0] = fir_org.Speech_FIR[0];
- fir.s_Speech_FIR[1] = fir_org.Speech_FIR[1];
- fir.s_Melody_FIR[0] = fir_org.Melody_FIR[0];
- fir.s_Melody_FIR[0] = fir_org.Melody_FIR[1];
- fir.us_ES_TimeConst = fir_org.ES_TimeConst;
- fir.us_ES_VolConst = fir_org.ES_VolConst;
- fir.us_ES_TimeConst2 = fir_org.ES_TimeConst2;
- fir.us_ES_VolConst2 = fir_org.ES_VolConst2;
- fir.us_Media_Playback_Maximum_Swing = fir_org.Media_Playback_Maximum_Swing;
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- void CSPCOEF::Compose_FirCoef0547(S_FIR_COEFF_T fir, l1audio_param_W0547_T &fir0547)
- {
- fir0547.Speech_FIR[0] = fir.s_Speech_FIR[0];
- fir0547.Speech_FIR[1] = fir.s_Speech_FIR[1];
- fir0547.Melody_FIR[0] = fir.s_Melody_FIR[0];
- fir0547.Melody_FIR[1] = fir.s_Melody_FIR[1];
- for (int i = 0; i < SE_SPEECH_COMMON_NUM_12; i++)
- {
- fir0547.Speech_Common_Para[i] = fir.us_speech_common_para[i];
- }
- for (int i = 0; i < SE_MODE_NUM; i++)
- {
- for (int j = 0; j < SE_MODE_PARA_NUM_8; j++)
- {
- fir0547.Speech_ModeDependent_Para[i][j] = fir.us_speech_mode_para[i][j];
- }
- }
- fir0547.Media_Playback_Maximum_Swing = fir.us_Media_Playback_Maximum_Swing;
- }
- //---------------------------------------------------------------------------
- void CSPCOEF::DeCompose_FirCoef0547(l1audio_param_W0547_T fir0547, S_FIR_COEFF_T& fir)
- {
- fir.s_Speech_FIR[0] = fir0547.Speech_FIR[0];
- fir.s_Speech_FIR[1] = fir0547.Speech_FIR[1];
- fir.s_Melody_FIR[0] = fir0547.Melody_FIR[0];
- fir.s_Melody_FIR[1] = fir0547.Melody_FIR[1];
- for (int i = 0; i < SE_SPEECH_COMMON_NUM_12; i++)
- {
- fir.us_speech_common_para[i] = fir0547.Speech_Common_Para[i];
- }
- for (int i = 0; i < SE_MODE_NUM; i++)
- {
- for (int j = 0; j < SE_MODE_PARA_NUM_8; j++)
- {
- fir.us_speech_mode_para[i][j]= fir0547.Speech_ModeDependent_Para[i][j];
- }
- }
- fir.us_Media_Playback_Maximum_Swing = fir0547.Media_Playback_Maximum_Swing;
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- void CSPCOEF::Compose_FirCoef0547_45Taps(S_FIR_COEFF_T fir, l1audio_param_W0547_45_T &fir0547_45tap)
- {
- for (int i = 0; i < SPEECH_INPUT_FIR_45_TAPS_GROUP_NUM; i++)
- {
- for (int j = 0; j < SPEECH_FIR_45_TAPS_NUM; j++)
- {
- fir0547_45tap.speech_input_FIR_coeffs[i][j] = fir.s_speech_input_FIR_coeffs[i][j];
- fir0547_45tap.speech_output_FIR_coeffs[i][j] = fir.s_speech_output_FIR_coeffs[i][j];
- }
- }
- fir0547_45tap.selected_FIR_output_index = fir.us_selected_FIR_output_index;
- for (int i = 0; i < SE_SPEECH_COMMON_NUM_12; i++)
- {
- fir0547_45tap.speech_common_para[i] = fir.us_speech_common_para[i];
- }
- for (int i = 0; i < SE_MODE_PARA_NUM_8; i++)
- {
- fir0547_45tap.speech_normal_mode_para[i] = fir.us_speech_mode_para[SPEECH_NORMAL_MODE][i];
- fir0547_45tap.speech_earphone_mode_para[i] = fir.us_speech_mode_para[SPEECH_EARPHONE_MODE][i];
- fir0547_45tap.speech_loudspk_mode_para[i] = fir.us_speech_mode_para[SPEECH_LOUDSPEAKER_MODE][i];
- fir0547_45tap.speech_bt_earphone_mode_para[i] = fir.us_speech_mode_para[SPEECH_BT_ERAPHONE_MODE][i];
- fir0547_45tap.speech_bt_cordless_mode_para[i] = fir.us_speech_mode_para[SPEECH_BT_CORDLESS_MODE][i];
- fir0547_45tap.speech_aux1_mode_para[i] = fir.us_speech_mode_para[SPEECH_AUX1_MODE][i];
- fir0547_45tap.speech_aux2_mode_para[i] = fir.us_speech_mode_para[SPEECH_AUX2_MODE][i];
- fir0547_45tap.speech_aux3_mode_para[i] = fir.us_speech_mode_para[SPEECH_AUX3_MODE][i];
- }
- fir0547_45tap.Media_Playback_Maximum_Swing = fir.us_Media_Playback_Maximum_Swing;
- for (int i = 0; i < SPEECH_FIR_45_TAPS_NUM; i++)
- {
- fir0547_45tap.Melody_FIR_Output_Coeff_32k_Tbl1[i] = fir.s_Melody_FIR[0].Melody_32k_Output_Coeff[i];
- }
- }
- //---------------------------------------------------------------------------
- void CSPCOEF::DeCompose_FirCoef0547_45Taps(l1audio_param_W0547_45_T fir0547_45tap, S_FIR_COEFF_T& fir)
- {
- for (int i = 0; i < SPEECH_INPUT_FIR_45_TAPS_GROUP_NUM; i++)
- {
- for (int j = 0; j < SPEECH_FIR_45_TAPS_NUM; j++)
- {
- fir.s_speech_input_FIR_coeffs[i][j] = fir0547_45tap.speech_input_FIR_coeffs[i][j];
- fir.s_speech_output_FIR_coeffs[i][j] = fir0547_45tap.speech_output_FIR_coeffs[i][j];
- }
- }
- fir.us_selected_FIR_output_index = fir0547_45tap.selected_FIR_output_index;
- for (int i = 0; i < SE_SPEECH_COMMON_NUM_12; i++)
- {
- fir.us_speech_common_para[i] = fir0547_45tap.speech_common_para[i];
- }
- for (int i = 0; i < SE_MODE_PARA_NUM_8; i++)
- {
- fir.us_speech_mode_para[SPEECH_NORMAL_MODE][i] = fir0547_45tap.speech_normal_mode_para[i];
- fir.us_speech_mode_para[SPEECH_EARPHONE_MODE][i] = fir0547_45tap.speech_earphone_mode_para[i];
- fir.us_speech_mode_para[SPEECH_LOUDSPEAKER_MODE][i] = fir0547_45tap.speech_loudspk_mode_para[i];
- fir.us_speech_mode_para[SPEECH_BT_ERAPHONE_MODE][i] = fir0547_45tap.speech_bt_earphone_mode_para[i];
- fir.us_speech_mode_para[SPEECH_BT_CORDLESS_MODE][i] = fir0547_45tap.speech_bt_cordless_mode_para[i] ;
- fir.us_speech_mode_para[SPEECH_AUX1_MODE][i] = fir0547_45tap.speech_aux1_mode_para[i];
- fir.us_speech_mode_para[SPEECH_AUX2_MODE][i] = fir0547_45tap.speech_aux2_mode_para[i];
- fir.us_speech_mode_para[SPEECH_AUX3_MODE][i] = fir0547_45tap.speech_aux3_mode_para[i];
- }
- fir.us_Media_Playback_Maximum_Swing = fir0547_45tap.Media_Playback_Maximum_Swing;
- for (int i = 0; i < SPEECH_FIR_45_TAPS_NUM; i++)
- {
- fir.s_Melody_FIR[0].Melody_32k_Output_Coeff[i] = fir0547_45tap.Melody_FIR_Output_Coeff_32k_Tbl1[i];
- }
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- void CSPCOEF::Compose_FirCoef0712(S_FIR_COEFF_T fir, l1audio_param_W0712_T &fir0712)
- {
- for (int i = 0; i < SPEECH_INPUT_FIR_45_TAPS_GROUP_NUM; i++)
- {
- for (int j = 0; j < SPEECH_FIR_45_TAPS_NUM; j++)
- {
- fir0712.speech_input_FIR_coeffs[i][j] = fir.s_speech_input_FIR_coeffs[i][j];
- fir0712.speech_output_FIR_coeffs[i][j] = fir.s_speech_output_FIR_coeffs[i][j];
- }
- }
- fir0712.selected_FIR_output_index = fir.us_selected_FIR_output_index;
- for (int i=0; i < SE_SPEECH_COMMON_NUM_12; i++)
- {
- fir0712.speech_common_para[i] = fir.us_speech_common_para[i];
- }
- for (int i = 0; i < SE_MODE_PARA_NUM_8; i++)
- {
- fir0712.speech_normal_mode_para[i] = fir.us_speech_mode_para[SPEECH_NORMAL_MODE][i];
- fir0712.speech_earphone_mode_para[i] = fir.us_speech_mode_para[SPEECH_EARPHONE_MODE][i];
- fir0712.speech_loudspk_mode_para[i] = fir.us_speech_mode_para[SPEECH_LOUDSPEAKER_MODE][i];
- fir0712.speech_bt_earphone_mode_para[i] = fir.us_speech_mode_para[SPEECH_BT_ERAPHONE_MODE][i];
- fir0712.speech_bt_cordless_mode_para[i] = fir.us_speech_mode_para[SPEECH_BT_CORDLESS_MODE][i];
- fir0712.speech_aux1_mode_para[i] = fir.us_speech_mode_para[SPEECH_AUX1_MODE][i];
- fir0712.speech_aux2_mode_para[i] = fir.us_speech_mode_para[SPEECH_AUX2_MODE][i];
- fir0712.speech_aux3_mode_para[i] = fir.us_speech_mode_para[SPEECH_AUX3_MODE][i];
- }
- fir0712.Media_Playback_Maximum_Swing = fir.us_Media_Playback_Maximum_Swing;
- for (int i = 0; i < MELODY_FIR_COEFF_25_TAPS_NUM; i++)
- {
- fir0712.Melody_FIR_Output_Coeff_32k_Tbl1[i] = fir.s_Melody_FIR[0].Melody_32k_Output_Coeff[i];
- }
- }
- //---------------------------------------------------------------------------
- void CSPCOEF::DeCompose_FirCoef0712(l1audio_param_W0712_T fir0712, S_FIR_COEFF_T& fir)
- {
- for (int i = 0; i < SPEECH_INPUT_FIR_45_TAPS_GROUP_NUM; i++)
- {
- for (int j = 0; j < SPEECH_FIR_45_TAPS_NUM; j++)
- {
- fir.s_speech_input_FIR_coeffs[i][j] = fir0712.speech_input_FIR_coeffs[i][j];
- fir.s_speech_output_FIR_coeffs[i][j] = fir0712.speech_output_FIR_coeffs[i][j];
- }
- }
- fir.us_selected_FIR_output_index = fir0712.selected_FIR_output_index;
- for (int i=0; i < SE_SPEECH_COMMON_NUM_12; i++)
- {
- fir.us_speech_common_para[i] = fir0712.speech_common_para[i];
- }
- for (int i = 0; i < SE_MODE_PARA_NUM_8; i++)
- {
- fir.us_speech_mode_para[SPEECH_NORMAL_MODE][i] = fir0712.speech_normal_mode_para[i];
- fir.us_speech_mode_para[SPEECH_EARPHONE_MODE][i] = fir0712.speech_earphone_mode_para[i];
- fir.us_speech_mode_para[SPEECH_LOUDSPEAKER_MODE][i] = fir0712.speech_loudspk_mode_para[i];
- fir.us_speech_mode_para[SPEECH_BT_ERAPHONE_MODE][i] = fir0712.speech_bt_earphone_mode_para[i];
- fir.us_speech_mode_para[SPEECH_BT_CORDLESS_MODE][i] = fir0712.speech_bt_cordless_mode_para[i];
- fir.us_speech_mode_para[SPEECH_AUX1_MODE][i] = fir0712.speech_aux1_mode_para[i];
- fir.us_speech_mode_para[SPEECH_AUX2_MODE][i] = fir0712.speech_aux2_mode_para[i];
- fir.us_speech_mode_para[SPEECH_AUX3_MODE][i] = fir0712.speech_aux3_mode_para[i];
- }
- fir.us_Media_Playback_Maximum_Swing = fir0712.Media_Playback_Maximum_Swing;
- for (int i = 0; i < MELODY_FIR_COEFF_25_TAPS_NUM; i++)
- {
- fir.s_Melody_FIR[0].Melody_32k_Output_Coeff[i] = fir0712.Melody_FIR_Output_Coeff_32k_Tbl1[i];
- }
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- void CSPCOEF::Compose_FirCoef0740(S_FIR_COEFF_T fir, l1audio_param_W0740_T &fir0740)
- {
- for (int i = 0; i < SPEECH_INPUT_FIR_45_TAPS_GROUP_NUM; i++)
- {
- for (int j = 0; j < SPEECH_FIR_45_TAPS_NUM; j++)
- {
- fir0740.speech_input_FIR_coeffs[i][j] = fir.s_speech_input_FIR_coeffs[i][j];
- fir0740.speech_output_FIR_coeffs[i][j] = fir.s_speech_output_FIR_coeffs[i][j];
- }
- }
- fir0740.selected_FIR_output_index = fir.us_selected_FIR_output_index;
- for (int i=0; i < SE_SPEECH_COMMON_NUM_12; i++)
- {
- fir0740.speech_common_para[i] = fir.us_speech_common_para[i];
- }
- for (int i = 0; i < SE_MODE_NUM; i++)
- {
- for (int j = 0; j < SE_MODE_PARA_NUM_8; j++)
- {
- fir0740.speech_mode_para[i][j] = fir.us_speech_mode_para[i][j];
- }
- }
- fir0740.Media_Playback_Maximum_Swing = fir.us_Media_Playback_Maximum_Swing;
- for (int i = 0; i < MELODY_FIR_COEFF_25_TAPS_NUM; i++)
- {
- fir0740.Melody_FIR_Coeff_Tbl[i] = fir.s_Melody_FIR[0].Melody_32k_Output_Coeff[i];
- }
- for (int i = 0; i < 2; i++)
- {
- for (int j = 0; j < SPEECH_FIR_45_TAPS_NUM; j++)
- {
- fir0740.audio_compensation_coeff[i][j] = fir.s_audio_compensation_coeff[i][j];
- }
- }
- }
- //----------------------------------------------------------------------------
- void CSPCOEF::DeCompose_FirCoef0740(l1audio_param_W0740_T fir0740, S_FIR_COEFF_T& fir)
- {
- for (int i = 0; i < SPEECH_INPUT_FIR_45_TAPS_GROUP_NUM; i++)
- {
- for (int j = 0; j < SPEECH_FIR_45_TAPS_NUM; j++)
- {
- fir.s_speech_input_FIR_coeffs[i][j] = fir0740.speech_input_FIR_coeffs[i][j];
- fir.s_speech_output_FIR_coeffs[i][j] = fir0740.speech_output_FIR_coeffs[i][j];
- }
- }
- fir0740.selected_FIR_output_index = fir.us_selected_FIR_output_index;
- for (int i=0; i < SE_SPEECH_COMMON_NUM_12; i++)
- {
- fir.us_speech_common_para[i] = fir0740.speech_common_para[i];
- }
- for (int i = 0; i < SE_MODE_NUM; i++)
- {
- for (int j = 0; j < SE_MODE_PARA_NUM_8; j++)
- {
- fir.us_speech_mode_para[i][j] = fir0740.speech_mode_para[i][j];
- }
- }
- fir.us_Media_Playback_Maximum_Swing = fir0740.Media_Playback_Maximum_Swing;
- for (int i = 0; i < MELODY_FIR_COEFF_25_TAPS_NUM; i++)
- {
- fir.s_Melody_FIR[0].Melody_32k_Output_Coeff[i] = fir0740.Melody_FIR_Coeff_Tbl[i];
- }
- for (int i = 0; i < 2; i++)
- {
- for (int j = 0; j < SPEECH_FIR_45_TAPS_NUM; j++)
- {
- fir.s_audio_compensation_coeff[i][j] = fir0740.audio_compensation_coeff[i][j];
- }
- }
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- void CSPCOEF::Compose_FirCoef0809(S_FIR_COEFF_T fir, l1audio_param_W0809_T &fir0809)
- {
- for (int i = 0; i < SPEECH_INPUT_FIR_45_TAPS_GROUP_NUM; i++)
- {
- for (int j = 0; j < SPEECH_FIR_45_TAPS_NUM; j++)
- {
- fir0809.speech_input_FIR_coeffs[i][j] = fir.s_speech_input_FIR_coeffs[i][j];
- fir0809.speech_output_FIR_coeffs[i][j] = fir.s_speech_output_FIR_coeffs[i][j];
- }
- }
- fir0809.selected_FIR_output_index = fir.us_selected_FIR_output_index;
- for (int i=0; i < SE_SPEECH_COMMON_NUM_12; i++)
- {
- fir0809.speech_common_para[i] = fir.us_speech_common_para[i];
- }
- for (int i = 0; i < SE_MODE_NUM; i++)
- {
- for (int j = 0; j < SE_MODE_PARA_NUM_16; j++)
- {
- fir0809.speech_mode_para[i][j] = fir.us_speech_mode_para[i][j];
- }
- }
- for (int i = 0; i < SE_VOLUME_MODE_NUM; i++)
- {
- for (int j = 0; j < SE_VOLUME_LEVEL_NUM; j++)
- {
- for (int k = 0; k < SE_VOLUME_LEVEL_NUM; k++)
- {
- fir0809.speech_volume_para[i][j][k] = fir.us_speech_volume_para[i][j][k];
- }
- }
- }
- fir0809.Media_Playback_Maximum_Swing = fir.us_Media_Playback_Maximum_Swing;
- for (int i = 0; i < MELODY_FIR_COEFF_25_TAPS_NUM; i++)
- {
- fir0809.Melody_FIR_Coeff_Tbl[i] = fir.s_Melody_FIR[0].Melody_32k_Output_Coeff[i];
- }
- for (int i = 0; i < 2; i++)
- {
- for (int j = 0; j < SPEECH_FIR_45_TAPS_NUM; j++)
- {
- fir0809.audio_compensation_coeff[i][j] = fir.s_audio_compensation_coeff[i][j];
- }
- }
- }
- //----------------------------------------------------------------------------
- void CSPCOEF::DeCompose_FirCoef0809(l1audio_param_W0809_T fir0809, S_FIR_COEFF_T& fir)
- {
- for (int i = 0; i < SPEECH_INPUT_FIR_45_TAPS_GROUP_NUM; i++)
- {
- for (int j = 0; j < SPEECH_FIR_45_TAPS_NUM; j++)
- {
- fir.s_speech_input_FIR_coeffs[i][j] = fir0809.speech_input_FIR_coeffs[i][j];
- fir.s_speech_output_FIR_coeffs[i][j] = fir0809.speech_output_FIR_coeffs[i][j];
- }
- }
- fir.us_selected_FIR_output_index = fir0809.selected_FIR_output_index;
- for (int i=0; i < SE_SPEECH_COMMON_NUM_12; i++)
- {
- fir.us_speech_common_para[i] = fir0809.speech_common_para[i];
- }
- for (int i = 0; i < SE_MODE_NUM; i++)
- {
- for (int j = 0; j < SE_MODE_PARA_NUM_16; j++)
- {
- fir.us_speech_mode_para[i][j] = fir0809.speech_mode_para[i][j];
- }
- }
- for (int i = 0; i < SE_VOLUME_MODE_NUM; i++)
- {
- for (int j = 0; j < SE_VOLUME_LEVEL_NUM; j++)
- {
- for (int k = 0; k < SE_VOLUME_LEVEL_NUM; k++)
- {
- fir.us_speech_volume_para[i][j][k] = fir0809.speech_volume_para[i][j][k];
- }
- }
- }
- fir.us_Media_Playback_Maximum_Swing = fir0809.Media_Playback_Maximum_Swing;
- for (int i = 0; i < MELODY_FIR_COEFF_25_TAPS_NUM; i++)
- {
- fir.s_Melody_FIR[0].Melody_32k_Output_Coeff[i] = fir0809.Melody_FIR_Coeff_Tbl[i];
- }
- for (int i = 0; i < 2; i++)
- {
- for (int j = 0; j < SPEECH_FIR_45_TAPS_NUM; j++)
- {
- fir.s_audio_compensation_coeff[i][j] = fir0809.audio_compensation_coeff[i][j];
- }
- }
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- bool CSPCOEF::Decompose_FirCoef(E_AUDIO_FIR_VER_T audio_para_type)
- {
- META_RESULT MetaResult;
- switch (audio_para_type)
- {
- case AUDIO_FIR_VER_ORG:
- {
- l1audio_param_T fir_org;
- MetaResult = META_NVRAM_Decompose_AudioParam(&fir_org, m_cpCoefBuf, m_iCoefBufSize);
- DeCompose_FirCoefOrg(fir_org, m_sFirCoeff);
- }
- break;
- case AUDIO_FIR_VER_W0547:
- {
- l1audio_param_W0547_T fir0547;
- MetaResult = META_NVRAM_Decompose_AudioParam_W0547(&fir0547, m_cpCoefBuf, m_iCoefBufSize);
- DeCompose_FirCoef0547(fir0547, m_sFirCoeff);
- }
- break;
- case AUDIO_FIR_VER_W0547_45_TAP:
- {
- l1audio_param_W0547_45_T fir0547_45tap;
- MetaResult = META_NVRAM_Decompose_AudioParam_W0547_45(&fir0547_45tap, m_cpCoefBuf, m_iCoefBufSize);
- DeCompose_FirCoef0547_45Taps(fir0547_45tap, m_sFirCoeff);
- }
- break;
- case AUDIO_FIR_VER_W0712:
- {
- l1audio_param_W0712_T fir0712;
- MetaResult = META_NVRAM_Decompose_AudioParam_W0712(&fir0712, m_cpCoefBuf, m_iCoefBufSize);
- DeCompose_FirCoef0712(fir0712, m_sFirCoeff);
- }
- break;
- case AUDIO_FIR_VER_W0740:
- {
- l1audio_param_W0740_T fir0740;
- MetaResult = META_NVRAM_Decompose_AudioParam_W0740(&fir0740, m_cpCoefBuf, m_iCoefBufSize);
- DeCompose_FirCoef0740(fir0740, m_sFirCoeff);
- }
- break;
- case AUDIO_FIR_VER_W0809:
- {
- l1audio_param_W0809_T fir0809;
- MetaResult = META_NVRAM_Decompose_AudioParam_W0809(&fir0809, m_cpCoefBuf, m_iCoefBufSize);
- DeCompose_FirCoef0809(fir0809, m_sFirCoeff);
- }
- break;
- default:
- {
- return false;
- }
- //break;
- }
- if (MetaResult != META_SUCCESS)
- {
- return false;
- }
- return true;
- }
- //---------------------------------------------------------------------------
- bool CSPCOEF::Compose_FirCoef(E_AUDIO_FIR_VER_T e_audio_para_type)
- {
- META_RESULT MetaResult;
- switch (e_audio_para_type)
- {
- case AUDIO_FIR_VER_ORG:
- {
- l1audio_param_T fir_org;
- Compose_FirCoefOrg(m_sFirCoeff, fir_org);
- MetaResult = META_NVRAM_Compose_AudioParam(&fir_org, m_cpCoefBuf, m_iCoefBufSize);
- }
- break;
- case AUDIO_FIR_VER_W0547:
- {
- l1audio_param_W0547_T fir0547;
- Compose_FirCoef0547(m_sFirCoeff, fir0547);
- MetaResult = META_NVRAM_Compose_AudioParam_W0547(&fir0547, m_cpCoefBuf, m_iCoefBufSize);
- }
- break;
- case AUDIO_FIR_VER_W0547_45_TAP:
- {
- l1audio_param_W0547_45_T fir0547_45tap;
- Compose_FirCoef0547_45Taps(m_sFirCoeff, fir0547_45tap);
- MetaResult = META_NVRAM_Compose_AudioParam_W0547_45(&fir0547_45tap, m_cpCoefBuf, m_iCoefBufSize);
- }
- break;
- case AUDIO_FIR_VER_W0712:
- {
- l1audio_param_W0712_T fir0712;
- Compose_FirCoef0712(m_sFirCoeff, fir0712);
- MetaResult = META_NVRAM_Compose_AudioParam_W0712(&fir0712, m_cpCoefBuf, m_iCoefBufSize);
- }
- break;
- case AUDIO_FIR_VER_W0740:
- {
- l1audio_param_W0740_T fir0740;
- Compose_FirCoef0740(m_sFirCoeff, fir0740);
- MetaResult = META_NVRAM_Compose_AudioParam_W0740(&fir0740, m_cpCoefBuf, m_iCoefBufSize);
- }
- break;
- case AUDIO_FIR_VER_W0809:
- {
- l1audio_param_W0809_T fir0809;
- Compose_FirCoef0809(m_sFirCoeff, fir0809);
- MetaResult = META_NVRAM_Compose_AudioParam_W0809(&fir0809, m_cpCoefBuf, m_iCoefBufSize);
- }
- break;
- default:
- {
- return false;
- }
-
- }
- if (MetaResult != META_SUCCESS)
- {
- return false;
- }
- return true;
- }
- //===========================================================================
- void CSPCOEF::REQ_Read_From_NVRAM(E_AUDIO_FIR_VER_T e_audio_para_type)
- {
- sp_coef_ptr = this;
- g_bIsRunning = true;
- m_eAudioParamType = e_audio_para_type;
- if (NULL == m_cpCoefBuf)
- {
- META_RESULT MetaResult = META_NVRAM_GetRecLen( "NVRAM_EF_AUDIO_PARAM_LID",
- &m_iCoefBufSize );
- if(MetaResult!=META_SUCCESS)
- { Confirm( METAAPP_FAIL ); return; }
- m_cpCoefBuf = new char[m_iCoefBufSize];
- }
- NVRAMMan->ConfirmCallback = ::CNF_ReadFromNVRAM;
- NVRAMMan->REQ_ReadNVRAM_Start( "NVRAM_EF_AUDIO_PARAM_LID",
- 1, // only 1 record
- m_iCoefBufSize,
- m_cpCoefBuf );
- }
- //-------------------------------------
- void CSPCOEF::CNF_ReadFromNVRAM(void)
- {
- if (!g_bIsRunning)
- {
- return;
- }
- E_METAAPP_RESULT_T state = NVRAMMan->Get_ConfirmState();
- switch (state)
- {
- case METAAPP_SUCCESS:
- {
- if (!Decompose_FirCoef(m_eAudioParamType))
- {
- Confirm(METAAPP_FAIL);
- return;
- }
- Confirm(METAAPP_SUCCESS);
- }
- break;
- default:
- {
- Confirm(state);
- }
- break;
- }
- }
- //===========================================================================
- void CSPCOEF::REQ_Write_To_NVRAM(E_AUDIO_FIR_VER_T e_audio_para_type, bool b_runtime_support)
- {
- sp_coef_ptr = this;
- g_bIsRunning = true;
- m_eAudioParamType = e_audio_para_type;
- m_bRuntimeSupport = b_runtime_support;
- unsigned short lid_ver;
- META_RESULT MetaResult;
- MetaResult = META_NVRAM_GetLIDVersion("NVRAM_EF_AUDIO_PARAM_LID", &lid_ver);
- if (lid_ver > NVRAM_EF_AUDIO_PARAM_LID_VERNO)
- {
- Confirm(METAAPP_NVRAM_LID_VER_NOT_SUPPORT);
- return;
- }
- if (NULL == m_cpCoefBuf)
- {
- MetaResult = META_NVRAM_GetRecLen("NVRAM_EF_AUDIO_PARAM_LID", &m_iCoefBufSize);
- if(MetaResult!=META_SUCCESS)
- { Confirm( METAAPP_FAIL ); return; }
- m_cpCoefBuf = new char[m_iCoefBufSize];
- }
- if (!Compose_FirCoef(m_eAudioParamType))
- {
- Confirm(METAAPP_FAIL);
- return;
- }
- NVRAMMan->ConfirmCallback = ::CNF_WriteToNVRAM;
- NVRAMMan->REQ_WriteNVRAM_Start("NVRAM_EF_AUDIO_PARAM_LID",
- 1,
- m_iCoefBufSize,
- m_cpCoefBuf );
- }
- //-------------------------------------
- void CSPCOEF::CNF_WriteToNVRAM(void)
- {
- if (!g_bIsRunning)
- {
- return;
- }
- E_METAAPP_RESULT_T state = NVRAMMan->Get_ConfirmState();
- if (METAAPP_SUCCESS == state)
- {
- if ((AUDIO_FIR_VER_ORG == m_eAudioParamType) ||
- (AUDIO_FIR_VER_W0547 == m_eAudioParamType) ||
- (AUDIO_FIR_VER_W0547_45_TAP == m_eAudioParamType) ||
- (AUDIO_FIR_VER_W0712 == m_eAudioParamType) ||
- (AUDIO_FIR_VER_W0740 == m_eAudioParamType)
- )
- {
- Confirm(state);
- return;
- }
- ActiveMan->SetActiveFunction(::REQ_Set_Runtime_Audio_Param_Settings);
- }
- else
- {
- Confirm(state);
- }
- }
- //===========================================================================
- ////////////////////////// Runtime setting //////////////////////////////
- //===========================================================================
- void CSPCOEF::REQ_Get_Runtime_Audio_Param_Settings_Start(E_AUDIO_FIR_VER_T e_audio_para_type)
- {
- m_eAudioParamType = e_audio_para_type;
- if ((AUDIO_FIR_VER_ORG == m_eAudioParamType) ||
- (AUDIO_FIR_VER_W0547 == m_eAudioParamType) ||
- (AUDIO_FIR_VER_W0547_45_TAP == m_eAudioParamType) ||
- (AUDIO_FIR_VER_W0712 == m_eAudioParamType) ||
- (AUDIO_FIR_VER_W0740 == m_eAudioParamType)
- )
- {
- return;
- }
- ActiveMan->SetActiveFunction(::REQ_Get_Runtime_Audio_Param_Settings);
- }
- //---------------------------------------------------------------------------
- void CSPCOEF::REQ_Get_Runtime_Audio_Param_Settings(void)
- {
- l1audio_param_W0809_T l1audio_param_W0809;
- META_RESULT MetaResult = META_Audio_Get_Audio_Param_Settings_0809_r(m_META_HANDLE_Obj.Get_MainHandle(), 5000, &l1audio_param_W0809);
- if (MetaResult != META_SUCCESS)
- {
- if (MetaResult != META_TIMEOUT)
- {
- Confirm(METAAPP_FAIL);
- return;
- }
- else
- {
- Confirm(METAAPP_TIMEOUT);
- return;
- }
- }
- DeCompose_FirCoef0809(l1audio_param_W0809, m_sFirCoeff);
- Confirm(METAAPP_SUCCESS);
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- void CSPCOEF::REQ_Set_Runtime_Audio_Param_Settings_Start(E_AUDIO_FIR_VER_T e_audio_para_type)
- {
- m_eAudioParamType = e_audio_para_type;
- if ((AUDIO_FIR_VER_ORG == m_eAudioParamType) ||
- (AUDIO_FIR_VER_W0547 == m_eAudioParamType) ||
- (AUDIO_FIR_VER_W0547_45_TAP == m_eAudioParamType) ||
- (AUDIO_FIR_VER_W0712 == m_eAudioParamType) ||
- (AUDIO_FIR_VER_W0740 == m_eAudioParamType)
- )
- {
- return;
- }
- ActiveMan->SetActiveFunction(::REQ_Set_Runtime_Audio_Param_Settings);
- }
- //---------------------------------------------------------------------------
- void CSPCOEF::REQ_Set_Runtime_Audio_Param_Settings(void)
- {
- l1audio_param_W0809_T l1audio_param_W0809;
- Audio_Set_Param_Cnf_T cnf;
- Compose_FirCoef0809(m_sFirCoeff, l1audio_param_W0809);
- META_RESULT MetaResult = META_Audio_Set_Audio_Param_Settings_0809_r(m_META_HANDLE_Obj.Get_MainHandle(), 5000, &l1audio_param_W0809, &cnf);
- if (MetaResult != META_SUCCESS)
- {
- if (MetaResult != META_TIMEOUT)
- {
- Confirm(METAAPP_FAIL);
- return;
- }
- else
- {
- Confirm(METAAPP_TIMEOUT);
- return;
- }
- }
- Confirm(METAAPP_SUCCESS);
- }
- //===========================================================================
- const AnsiString as_SECTION_NAME = "Acoustic FIR-Coefficient";
- const AnsiString as_KEY_NAME_SIFC = "Speech Input";
- const AnsiString as_KEY_NAME_SOFC = "Speech Output";
- const AnsiString as_KEY_NAME_ACT_OUTPUT_FIR_IDX = "active output FIR index";
- const AnsiString as_KEY_NAME_AC[2] = {"Audio compensation (loud speaker)", "Audio compensation (headset)"};
- const AnsiString as_KEY_NAME_VOL_MODE[3] = {"Loud speaker", "BT car-kit", "AUX2"};
- const AnsiString as_KEY_NAME_VOL_LEVEL = " volume level";
- //---------------------------------------------------------------------------
- bool CSPCOEF::REQ_Read_From_File(char *filename, E_AUDIO_FIR_VER_T e_audio_para_type)
- {
- TIniFile *ini_file;
- AnsiString as_data;
- char str[2048];
- ini_file = new TIniFile(filename);
- if (NULL == ini_file)
- {
- return false;
- }
- m_eAudioParamType = e_audio_para_type;
- // const
- switch (e_audio_para_type)
- {
- case AUDIO_FIR_VER_ORG:
- {
- m_sFirCoeff.us_ES_TimeConst = ini_file->ReadInteger(as_SECTION_NAME,
- "Time Constant",
- 0);
- m_sFirCoeff.us_ES_VolConst = ini_file->ReadInteger(as_SECTION_NAME,
- "Volume Constant",
- 0);
- m_sFirCoeff.us_ES_TimeConst2 = ini_file->ReadInteger(as_SECTION_NAME,
- "Time Constant 2",
- 0);
- m_sFirCoeff.us_ES_VolConst2 = ini_file->ReadInteger(as_SECTION_NAME,
- "Volume Constant 2",
- 0);
- m_sFirCoeff.us_Media_Playback_Maximum_Swing = ini_file->ReadInteger(as_SECTION_NAME,
- "Media Playback Max Swing",
- 0);
- }
- break;
- case AUDIO_FIR_VER_W0547:
- case AUDIO_FIR_VER_W0547_45_TAP:
- case AUDIO_FIR_VER_W0712:
- case AUDIO_FIR_VER_W0740:
- case AUDIO_FIR_VER_W0809:
- {
- m_sFirCoeff.us_Media_Playback_Maximum_Swing = ini_file->ReadInteger(as_SECTION_NAME,
- "Media Playback Max Swing",
- 0);
- }
- break;
- }
- ////////////////////////// 8k ////////////////////////////
- if ((AUDIO_FIR_VER_ORG == m_eAudioParamType) || (AUDIO_FIR_VER_W0547 == m_eAudioParamType))
- {
- short s_data_30tap[SPEECH_FIR_30_TAPS_NUM];
- //L1_SpeechCoeff_T *p_speech_coef;
- //if(AUDIO_FIR_VER_ORG == m_eAudioParamType)
- //{
- // p_speech_coef = m_sFirCoeff.Speech_FIR;
- //}
- //else // AUDIO_FIR_VER_W0547
- //{
- // p_speech_coef = m_sFirCoeff.Speech_FIR;
- //}
- // FIR1
- as_data = ini_file->ReadString(as_SECTION_NAME,
- "8k Input (mic)",
- "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0" );
- strcpy(str, as_data.c_str());
- String_To_Array_short(str, s_data_30tap, SPEECH_FIR_30_TAPS_NUM);
- for (int i=0; i<SPEECH_FIR_30_TAPS_NUM; i++)
- {
- m_sFirCoeff.s_Speech_FIR[AUDIO_NORMAL_MODE_INDEX].Speech_8k_Input_Coeff[i] = s_data_30tap[i];
- }
- as_data = ini_file->ReadString(as_SECTION_NAME,
- "8k Output (speaker)",
- "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0" );
- strcpy(str, as_data.c_str());
- String_To_Array_short( str, s_data_30tap, SPEECH_FIR_30_TAPS_NUM );
- for (int i=0; i<SPEECH_FIR_30_TAPS_NUM; i++)
- {
- m_sFirCoeff.s_Speech_FIR[AUDIO_NORMAL_MODE_INDEX].Speech_8k_Output_Coeff[i] = s_data_30tap[i];
- }
- // FIR2
- as_data = ini_file->ReadString(as_SECTION_NAME,
- "8k Input (earphone)",
- "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0" );
- strcpy(str, as_data.c_str());
- String_To_Array_short(str, s_data_30tap, SPEECH_FIR_30_TAPS_NUM);
- for (int i=0; i<SPEECH_FIR_30_TAPS_NUM; i++)
- {
- m_sFirCoeff.s_Speech_FIR[AUDIO_HEADSET_MODE_INDEX].Speech_8k_Input_Coeff[i] = s_data_30tap[i];
- }
- as_data = ini_file->ReadString(as_SECTION_NAME,
- "8k Output (earphone)",
- "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0" );
- strcpy(str, as_data.c_str());
- String_To_Array_short(str, s_data_30tap, SPEECH_FIR_30_TAPS_NUM);
- for (int i=0; i<SPEECH_FIR_30_TAPS_NUM; i++)
- {
- m_sFirCoeff.s_Speech_FIR[AUDIO_HEADSET_MODE_INDEX].Speech_8k_Output_Coeff[i] = s_data_30tap[i];
- }
- }
- //////////////////////////////// 8k additional /////////////////////////////////
- if ((AUDIO_FIR_VER_ORG == m_eAudioParamType) || (AUDIO_FIR_VER_W0547 == m_eAudioParamType))
- {
- short s_data_30tap[SPEECH_FIR_30_TAPS_NUM];
- // L1_SpeechCoeff_T *p_speech_coef;
- // if (AUDIO_FIR_VER_ORG == m_eAudioParamType)
- // {
- // p_speech_coef = m_sFirCoeff.Speech_FIR;
- // }
- // else // AUDIO_FIR_VER_W0547
- // {
- // p_speech_coef = m_sFirCoeff.Speech_FIR;
- // }
- // active output FIR index
- m_sFirCoeff.s_Speech_FIR[AUDIO_NORMAL_MODE_INDEX].Speech_8k_Output_Coeff_Index =
- ini_file->ReadInteger(as_SECTION_NAME,
- "active output FIR index",
- 0);
- for (int i=0; i<5; i++)
- {
- as_data = ini_file->ReadString(as_SECTION_NAME,
- Additional_8k_Output_Name[i],
- "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0" );
- strcpy(str, as_data.c_str());
- String_To_Array_short(str, s_data_30tap, SPEECH_FIR_30_TAPS_NUM);
- for (int j=0; j<SPEECH_FIR_30_TAPS_NUM; j++)
- {
- m_sFirCoeff.s_Speech_FIR[0].Additional_Speech_8k_Output_Coeff[i][j] = s_data_30tap[j];
- }
- }
- }
- //////////////////////////////// 16k /////////////////////////////////
- if ((AUDIO_FIR_VER_ORG == m_eAudioParamType) || (AUDIO_FIR_VER_W0547 == m_eAudioParamType))
- {
- short s_16kdata[ACOUSTIC_FIR_COEFF_16K_NUM];
- //L1_SpeechCoeff_T *p_speech_coef;
- //if (AUDIO_FIR_VER_ORG == m_eAudioParamType)
- //{
- // p_speech_coef = m_sFirCoeff.Speech_FIR;
- //}
- //else // AUDIO_FIR_VER_W0547
- //{
- // p_speech_coef = m_sFirCoeff.Speech_FIR;
- // }
- // FIR1
- as_data = ini_file->ReadString(as_SECTION_NAME,
- "AMR Input (mic)",
- "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0" );
- strcpy(str, as_data.c_str());
- String_To_Array_short(str, s_16kdata, ACOUSTIC_FIR_COEFF_16K_NUM);
- for (int i=0; i<ACOUSTIC_FIR_COEFF_16K_NUM; i++)
- {
- m_sFirCoeff.s_Speech_FIR[AUDIO_NORMAL_MODE_INDEX].Speech_16k_Input_Coeff[i] = s_16kdata[i];
- }
- as_data = ini_file->ReadString(as_SECTION_NAME,
- "AMR Output (speaker)",
- "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0" );
- strcpy(str, as_data.c_str());
- String_To_Array_short(str, s_16kdata, ACOUSTIC_FIR_COEFF_16K_NUM);
- for (int i=0; i<ACOUSTIC_FIR_COEFF_16K_NUM; i++)
- {
- m_sFirCoeff.s_Speech_FIR[AUDIO_NORMAL_MODE_INDEX].Speech_16k_Output_Coeff[i] = s_16kdata[i];
- }
- // FIR2
- as_data = ini_file->ReadString(as_SECTION_NAME,
- "AMR Input (earphone)",
- "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0" );
- strcpy(str, as_data.c_str());
- String_To_Array_short( str, s_16kdata, ACOUSTIC_FIR_COEFF_16K_NUM );
- for (int i=0; i<ACOUSTIC_FIR_COEFF_16K_NUM; i++)
- {
- m_sFirCoeff.s_Speech_FIR[AUDIO_HEADSET_MODE_INDEX].Speech_16k_Input_Coeff[i] = s_16kdata[i];
- }
- as_data = ini_file->ReadString(as_SECTION_NAME,
- "AMR Output (earphone)",
- "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0" );
- strcpy(str, as_data.c_str());
- String_To_Array_short(str, s_16kdata, ACOUSTIC_FIR_COEFF_16K_NUM);
- for (int i=0; i<ACOUSTIC_FIR_COEFF_16K_NUM; i++)
- {
- m_sFirCoeff.s_Speech_FIR[AUDIO_HEADSET_MODE_INDEX].Speech_16k_Output_Coeff[i] = s_16kdata[i];
- }
- }
- ////////////////////////// Speech input FIR coefficient ////////////////////////////
- if ((AUDIO_FIR_VER_W0547_45_TAP == m_eAudioParamType) ||
- (AUDIO_FIR_VER_W0712 == m_eAudioParamType) ||
- (AUDIO_FIR_VER_W0740 == m_eAudioParamType) ||
- (AUDIO_FIR_VER_W0809 == m_eAudioParamType)
- )
- {
- short speech_input_FIR_coeffs[SPEECH_INPUT_FIR_45_TAPS_GROUP_NUM][SPEECH_FIR_45_TAPS_NUM];
- for (int i=0; i<SPEECH_INPUT_FIR_45_TAPS_GROUP_NUM; i++)
- {
- as_data = ini_file->ReadString(as_SECTION_NAME,
- as_KEY_NAME_SIFC + IntToStr(i),
- "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0" );
- strcpy(str, as_data.c_str());
- String_To_Array_short(str, speech_input_FIR_coeffs[i], SPEECH_FIR_45_TAPS_NUM);
- switch (m_eAudioParamType)
- {
- case AUDIO_FIR_VER_W0547_45_TAP:
- case AUDIO_FIR_VER_W0712:
- case AUDIO_FIR_VER_W0740:
- case AUDIO_FIR_VER_W0809:
- {
- for (int j=0; j<SPEECH_FIR_45_TAPS_NUM; j++)
- {
- m_sFirCoeff.s_speech_input_FIR_coeffs[i][j] = speech_input_FIR_coeffs[i][j];
- }
- }
- break;
- }
- }
- }
- ////////////////////////// Speech output FIR coefficient ////////////////////////////
- if ((AUDIO_FIR_VER_W0547_45_TAP == m_eAudioParamType) ||
- (AUDIO_FIR_VER_W0712 == m_eAudioParamType) ||
- (AUDIO_FIR_VER_W0740 == m_eAudioParamType) ||
- (AUDIO_FIR_VER_W0809 == m_eAudioParamType)
- )
- {
- switch (m_eAudioParamType)
- {
- case AUDIO_FIR_VER_W0547_45_TAP:
- case AUDIO_FIR_VER_W0712:
- case AUDIO_FIR_VER_W0740:
- case AUDIO_FIR_VER_W0809:
- {
- m_sFirCoeff.us_selected_FIR_output_index = ini_file->ReadInteger(as_SECTION_NAME,
- as_KEY_NAME_ACT_OUTPUT_FIR_IDX,
- 0);
- }
- break;
- }
- short speech_output_FIR_coeffs[SPEECH_INPUT_FIR_45_TAPS_GROUP_NUM][SPEECH_FIR_45_TAPS_NUM];
- for (int i=0; i<SPEECH_INPUT_FIR_45_TAPS_GROUP_NUM; i++)
- {
- as_data = ini_file->ReadString(as_SECTION_NAME,
- as_KEY_NAME_SOFC + IntToStr(i),
- "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0" );
- strcpy(str, as_data.c_str());
- String_To_Array_short(str, speech_output_FIR_coeffs[i], SPEECH_FIR_45_TAPS_NUM);
- switch (m_eAudioParamType)
- {
- case AUDIO_FIR_VER_W0547_45_TAP:
- case AUDIO_FIR_VER_W0712:
- case AUDIO_FIR_VER_W0740:
- case AUDIO_FIR_VER_W0809:
- {
- for (int j=0; j<SPEECH_FIR_45_TAPS_NUM; j++)
- {
- m_sFirCoeff.s_speech_output_FIR_coeffs[i][j] = speech_output_FIR_coeffs[i][j];
- }
- }
- break;
- }
- }
- }
- /////////////////////////// Melody //////////////////////////////////
- short s_Melodydata[MELODY_FIR_COEFF_45_TAPS_NUM];
- if ((AUDIO_FIR_VER_ORG == m_eAudioParamType) || (AUDIO_FIR_VER_W0547 == m_eAudioParamType))
- {
- // L1_MelodyCoeff_T *p_melody_coef;
- // if (AUDIO_FIR_VER_ORG == m_eAudioParamType)
- // {
- // p_melody_coef = m_sFirCoeff.Melody_FIR;
- // }
- // else // AUDIO_FIR_VER_W0547
- // {
- // p_melody_coef = m_sFirCoeff.Melody_FIR;
- // }
- as_data = ini_file->ReadString(as_SECTION_NAME,
- "Melody Output (loud speaker)",
- "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0" );
- strcpy(str, as_data.c_str());
- String_To_Array_short(str, s_Melodydata, MELODY_FIR_COEFF_45_TAPS_NUM);
- for (int i=0; i<MELODY_FIR_COEFF_45_TAPS_NUM; i++)
- {
- m_sFirCoeff.s_Melody_FIR[FIR_COEFF_MELODY_LOUD_SPEAKER_MODE_INDEX].Melody_32k_Output_Coeff[i] = s_Melodydata[i];
- }
- as_data = ini_file->ReadString(as_SECTION_NAME,
- "Melody Output (stereo speaker)",
- "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0" );
- strcpy(str, as_data.c_str());
- String_To_Array_short(str, s_Melodydata, MELODY_FIR_COEFF_45_TAPS_NUM);
- for (int i=0; i<MELODY_FIR_COEFF_45_TAPS_NUM; i++)
- {
- m_sFirCoeff.s_Melody_FIR[FIR_COEFF_MELODY_STEREO_SPEAKER_MODE_INDEX].Melody_32k_Output_Coeff[i] = s_Melodydata[i];
- }
- }
- else // W0547_45_TAP, W0712, W0740, W0809
- {
- switch (m_eAudioParamType)
- {
- case AUDIO_FIR_VER_W0547_45_TAP:
- {
- as_data = ini_file->ReadString(as_SECTION_NAME,
- "Melody Output",
- "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0" );
- strcpy(str, as_data.c_str());
- String_To_Array_short(str, s_Melodydata, MELODY_FIR_COEFF_45_TAPS_NUM);
- for (int i=0; i<MELODY_FIR_COEFF_45_TAPS_NUM; i++)
- {
- m_sFirCoeff.s_Melody_FIR[FIR_COEFF_MELODY_LOUD_SPEAKER_MODE_INDEX].Melody_32k_Output_Coeff[i] = s_Melodydata[i];
- }
- }
- break;
- case AUDIO_FIR_VER_W0712:
- case AUDIO_FIR_VER_W0740:
- case AUDIO_FIR_VER_W0809:
- {
- as_data = ini_file->ReadString(as_SECTION_NAME,
- "Melody Output",
- "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0," );
- strcpy(str, as_data.c_str());
- String_To_Array_short(str, s_Melodydata, MELODY_FIR_COEFF_25_TAPS_NUM);
- for (int i=0; i<MELODY_FIR_COEFF_25_TAPS_NUM; i++)
- {
- m_sFirCoeff.s_Melody_FIR[FIR_COEFF_MELODY_LOUD_SPEAKER_MODE_INDEX].Melody_32k_Output_Coeff[i] = s_Melodydata[i];
- }
- }
- }
- }
- ////////////////////////// Speech enhancement ////////////////////////////
- if (m_eAudioParamType != AUDIO_FIR_VER_ORG)
- {
- //unsigned short usSpeechCommonPara[12];
- unsigned short usSpeechModeDependentPara[8][8];
- //unsigned short *p_Speech_ModeDependent_Para;
- //unsigned short *Speech_ModeDependent_Para_Array[8];
- const char SECTION_NAME[][64] =
- {
- "Normal Mode Parameter",
- "Earphone Mode Parameter",
- "Loud Speaker Mode Parameter",
- "BlueTooth Earphone Mode Parameter",
- "BlueTooth Cordless Mode Parameter",
- "AUX1 Mode Parameter",
- "AUX2 Mode Parameter",
- "AUX3 Mode Parameter"
- };
- switch (m_eAudioParamType)
- {
- case AUDIO_FIR_VER_W0547:
- case AUDIO_FIR_VER_W0547_45_TAP:
- case AUDIO_FIR_VER_W0712:
- case AUDIO_FIR_VER_W0740:
- {
- as_data = ini_file->ReadString(as_SECTION_NAME,
- "Speech Common Parameter",
- "0,0,0,0,0,0,0,0,0,0,0,0");
- strcpy(str, as_data.c_str());
- String_To_Array_UnsignedShort(str, m_sFirCoeff.us_speech_common_para, SE_SPEECH_COMMON_NUM_12);
- }
- break;
- case AUDIO_FIR_VER_W0809:
- {
- as_data = ini_file->ReadString(as_SECTION_NAME,
- "Speech Common Parameter",
- "0,0,0,0,0,0,0,0,");
- strcpy(str, as_data.c_str());
- String_To_Array_UnsignedShort(str, m_sFirCoeff.us_speech_common_para, SE_SPEECH_COMMON_NUM_12);
- }
- break;
- }
- switch (m_eAudioParamType)
- {
- case AUDIO_FIR_VER_W0547:
- case AUDIO_FIR_VER_W0547_45_TAP:
- case AUDIO_FIR_VER_W0712:
- case AUDIO_FIR_VER_W0740:
- {
- for (int i=0; i<SE_MODE_NUM; i++)
- {
- as_data = ini_file->ReadString(as_SECTION_NAME,
- SECTION_NAME[i],
- "0,0,0,0,0,0,0,0");
- strcpy(str, as_data.c_str());
- String_To_Array_UnsignedShort(str, usSpeechModeDependentPara[i], SE_MODE_PARA_NUM_8);
- for (int j=0; j<SE_MODE_PARA_NUM_8; j++)
- {
- m_sFirCoeff.us_speech_mode_para[i][j] = usSpeechModeDependentPara[i][SE_MODE_PARA_NUM_8-j-1];
- }
- }
- }
- break;
- case AUDIO_FIR_VER_W0809:
- {
- for (int i=0; i<SE_MODE_NUM; i++)
- {
- as_data = ini_file->ReadString(as_SECTION_NAME,
- SECTION_NAME[i],
- "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,");
- strcpy(str, as_data.c_str());
- String_To_Array_UnsignedShort(str, usSpeechModeDependentPara[i], SE_MODE_PARA_NUM_16);
- for (int j=0; j<SE_MODE_PARA_NUM_16; j++)
- {
- m_sFirCoeff.us_speech_mode_para[i][j] = usSpeechModeDependentPara[i][SE_MODE_PARA_NUM_16-j-1];
- }
- }
- }
- break;
- }
- }
- // audio compensation
- if ((AUDIO_FIR_VER_W0740 == m_eAudioParamType) ||
- (AUDIO_FIR_VER_W0809 == m_eAudioParamType)
- )
- {
- for (E_AUDIO_COMPENSATION_IDX_T type = AUDIO_COMPENSATION_LOUD_SPEAKER_IDX; type <= AUDIO_COMPENSATION_EARPHONE_IDX; type++)
- {
- as_data = ini_file->ReadString(as_SECTION_NAME,
- as_KEY_NAME_AC[type],
- "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0");
- String_To_Array_short(as_data.c_str(), m_sFirCoeff.s_audio_compensation_coeff[type], AUDIO_COMPENSATION_TAPS_NUM);
- }
- }
- // volume
- if (AUDIO_FIR_VER_W0809 == m_eAudioParamType)
- {
- for (int i = 0; i < SE_VOLUME_MODE_NUM; i++)
- {
- for (int j = 0; j < SE_VOLUME_LEVEL_NUM; j++)
- {
- AnsiString as_key_name = as_KEY_NAME_VOL_MODE[i] + as_KEY_NAME_VOL_LEVEL + IntToStr(j);
- as_data = ini_file->ReadString(as_SECTION_NAME,
- as_key_name,
- "0,0,0,0,"
- );
- String_To_Array_UnsignedShort(as_data.c_str(), m_sFirCoeff.us_speech_volume_para[i][j], SE_VOLUME_PARAM_NUM);
- }
- }
- }
- delete ini_file;
- return true;
- }
- //===========================================================================
- bool CSPCOEF::REQ_Write_To_File(char *filename, E_AUDIO_FIR_VER_T e_audio_para_type)
- {
- TIniFile *ini_file;
- AnsiString as_data;
- char str[2048];
- ini_file = new TIniFile(filename);
- if (NULL == ini_file)
- {
- return false;
- }
- m_eAudioParamType = e_audio_para_type;
- // const
- switch (e_audio_para_type)
- {
- case AUDIO_FIR_VER_ORG:
- {
- sprintf(str, "%d", m_sFirCoeff.us_ES_TimeConst);
- ini_file->WriteString(as_SECTION_NAME,
- "Time Constant",
- str);
- sprintf(str, "%d", m_sFirCoeff.us_ES_VolConst);
- ini_file->WriteString(as_SECTION_NAME,
- "Volume Constant",
- str);
- sprintf(str, "%d", m_sFirCoeff.us_ES_TimeConst2);
- ini_file->WriteString(as_SECTION_NAME,
- "Time Constant 2",
- str);
- sprintf(str, "%d", m_sFirCoeff.us_ES_VolConst2);
- ini_file->WriteString(as_SECTION_NAME,
- "Volume Constant 2",
- str);
- sprintf(str, "%d", m_sFirCoeff.us_Media_Playback_Maximum_Swing);
- }
- break;
- case AUDIO_FIR_VER_W0547:
- case AUDIO_FIR_VER_W0547_45_TAP:
- case AUDIO_FIR_VER_W0712:
- case AUDIO_FIR_VER_W0740:
- case AUDIO_FIR_VER_W0809:
- {
- sprintf(str, "%d", m_sFirCoeff.us_Media_Playback_Maximum_Swing);
- }
- break;
- default:
- {
- return false;
- }
- }
- ini_file->WriteString(as_SECTION_NAME,
- "Media Playback Max Swing",
- str);
- ///////////////////////// 8k /////////////////////////////////////
- if ((AUDIO_FIR_VER_ORG == m_eAudioParamType) ||
- (AUDIO_FIR_VER_W0547 == m_eAudioParamType)
- )
- {
- // 8k Input (mic)
- Array_To_String_short(str, m_sFirCoeff.s_Speech_FIR[AUDIO_NORMAL_MODE_INDEX].Speech_8k_Input_Coeff, SPEECH_FIR_30_TAPS_NUM, ',');
- ini_file->WriteString(as_SECTION_NAME,
- "8k Input (mic)",
- str);
- // 8k Output (speaker)
- Array_To_String_short(str, m_sFirCoeff.s_Speech_FIR[AUDIO_NORMAL_MODE_INDEX].Speech_8k_Output_Coeff, SPEECH_FIR_30_TAPS_NUM, ',');
- ini_file->WriteString(as_SECTION_NAME,
- "8k Output (speaker)",
- str);
- // 8k Input (earphone)
- Array_To_String_short(str, m_sFirCoeff.s_Speech_FIR[AUDIO_HEADSET_MODE_INDEX].Speech_8k_Input_Coeff, SPEECH_FIR_30_TAPS_NUM, ',');
- ini_file->WriteString(as_SECTION_NAME,
- "8k Input (earphone)",
- str);
- // 8k Output (earphone)
- Array_To_String_short(str, m_sFirCoeff.s_Speech_FIR[AUDIO_HEADSET_MODE_INDEX].Speech_8k_Output_Coeff, SPEECH_FIR_30_TAPS_NUM, ',');
- ini_file->WriteString(as_SECTION_NAME,
- "8k Output (earphone)",
- str );
- }
- /////////////////////// 8k additional ////////////////////////////////////
- if ((AUDIO_FIR_VER_ORG == m_eAudioParamType) ||
- (AUDIO_FIR_VER_W0547 == m_eAudioParamType)
- )
- {
- // active FIR index
- sprintf(str, "%d", m_sFirCoeff.s_Speech_FIR[AUDIO_NORMAL_MODE_INDEX].Speech_8k_Output_Coeff_Index);
- ini_file->WriteString(as_SECTION_NAME,
- "active output FIR index",
- str );
- for (int i=0; i<5; i++)
- {
- Array_To_String_short(str, m_sFirCoeff.s_Speech_FIR[AUDIO_NORMAL_MODE_INDEX].Additional_Speech_8k_Output_Coeff[i], SPEECH_FIR_30_TAPS_NUM, ',');
- ini_file->WriteString(as_SECTION_NAME,
- Additional_8k_Output_Name[i],
- str);
- }
- }
- /////////////////////// 16k ////////////////////////////////////
- if ((AUDIO_FIR_VER_ORG == m_eAudioParamType) ||
- (AUDIO_FIR_VER_W0547 == m_eAudioParamType)
- )
- {
- // FIR1
- Array_To_String_short(str, m_sFirCoeff.s_Speech_FIR[AUDIO_NORMAL_MODE_INDEX].Speech_16k_Input_Coeff, ACOUSTIC_FIR_COEFF_16K_NUM, ',');
- ini_file->WriteString(as_SECTION_NAME,
- "AMR Input (mic)",
- str);
- Array_To_String_short(str, m_sFirCoeff.s_Speech_FIR[AUDIO_NORMAL_MODE_INDEX].Speech_16k_Output_Coeff, ACOUSTIC_FIR_COEFF_16K_NUM, ',');
- ini_file->WriteString(as_SECTION_NAME,
- "AMR Output (speaker)",
- str);
- // FIR2
- Array_To_String_short(str, m_sFirCoeff.s_Speech_FIR[AUDIO_HEADSET_MODE_INDEX].Speech_16k_Input_Coeff, ACOUSTIC_FIR_COEFF_16K_NUM, ',');
- ini_file->WriteString(as_SECTION_NAME,
- "AMR Input (earphone)",
- str);
- Array_To_String_short(str, m_sFirCoeff.s_Speech_FIR[AUDIO_HEADSET_MODE_INDEX].Speech_16k_Output_Coeff, ACOUSTIC_FIR_COEFF_16K_NUM, ',');
- ini_file->WriteString(as_SECTION_NAME,
- "AMR Output (earphone)",
- str);
- }
- ////////////////////////// Speech input FIR coefficient ////////////////////////////
- if ((AUDIO_FIR_VER_W0547_45_TAP == m_eAudioParamType) ||
- (AUDIO_FIR_VER_W0712 == m_eAudioParamType) ||
- (AUDIO_FIR_VER_W0740 == m_eAudioParamType) ||
- (AUDIO_FIR_VER_W0809 == m_eAudioParamType)
- )
- {
- for (int i=0; i<SPEECH_INPUT_FIR_45_TAPS_GROUP_NUM; i++)
- {
- Array_To_String_short(str, m_sFirCoeff.s_speech_input_FIR_coeffs[i], SPEECH_FIR_45_TAPS_NUM, ',');
- ini_file->WriteString(as_SECTION_NAME,
- as_KEY_NAME_SIFC + IntToStr(i),
- str);
- }
- }
- ////////////////////////// Speech output FIR coefficient /////////////////
- if ((AUDIO_FIR_VER_W0547_45_TAP == m_eAudioParamType) ||
- (AUDIO_FIR_VER_W0712 == m_eAudioParamType) ||
- (AUDIO_FIR_VER_W0740 == m_eAudioParamType) ||
- (AUDIO_FIR_VER_W0809 == m_eAudioParamType)
- )
- {
- ini_file->WriteString(as_SECTION_NAME,
- as_KEY_NAME_ACT_OUTPUT_FIR_IDX,
- IntToStr(m_sFirCoeff.us_selected_FIR_output_index));
- for (int i=0; i<SPEECH_INPUT_FIR_45_TAPS_GROUP_NUM; i++)
- {
- Array_To_String_short(str, m_sFirCoeff.s_speech_output_FIR_coeffs[i], SPEECH_FIR_45_TAPS_NUM, ',');
- ini_file->WriteString(as_SECTION_NAME,
- as_KEY_NAME_SOFC + IntToStr(i),
- str);
- }
- }
- /////////////////////// Melody ////////////////////////////////////
- if ((AUDIO_FIR_VER_ORG == m_eAudioParamType) ||
- (AUDIO_FIR_VER_W0547 == m_eAudioParamType)
- )
- {
- // loud speaker
- Array_To_String_short(str, m_sFirCoeff.s_Melody_FIR[FIR_COEFF_MELODY_LOUD_SPEAKER_MODE_INDEX].Melody_32k_Output_Coeff, MELODY_FIR_COEFF_45_TAPS_NUM, ',');
- ini_file->WriteString(as_SECTION_NAME,
- "Melody Output (loud speaker)",
- str);
- // stereo speaker
- Array_To_String_short(str, m_sFirCoeff.s_Melody_FIR[FIR_COEFF_MELODY_STEREO_SPEAKER_MODE_INDEX].Melody_32k_Output_Coeff, MELODY_FIR_COEFF_45_TAPS_NUM, ',');
- ini_file->WriteString(as_SECTION_NAME,
- "Melody Output (stereo speaker)",
- str);
- }
- else // W0547_45_TAP, W0712, W0740, W0809
- {
- switch (m_eAudioParamType)
- {
- case AUDIO_FIR_VER_W0547_45_TAP:
- {
- Array_To_String_short(str, m_sFirCoeff.s_Melody_FIR[FIR_COEFF_MELODY_LOUD_SPEAKER_MODE_INDEX].Melody_32k_Output_Coeff, MELODY_FIR_COEFF_45_TAPS_NUM, ',');
- }
- break;
- case AUDIO_FIR_VER_W0712:
- case AUDIO_FIR_VER_W0740:
- case AUDIO_FIR_VER_W0809:
- {
- Array_To_String_short(str, m_sFirCoeff.s_Melody_FIR[FIR_COEFF_MELODY_LOUD_SPEAKER_MODE_INDEX].Melody_32k_Output_Coeff, MELODY_FIR_COEFF_25_TAPS_NUM, ',');
- }
- break;
- }
- ini_file->WriteString(as_SECTION_NAME,
- "Melody Output",
- str);
- }
- ////////////////////////// Speech enhancement ////////////////////////////
- if (m_eAudioParamType != AUDIO_FIR_VER_ORG)
- {
- unsigned short usSpeechCommonPara[12];
- unsigned short usSpeechModeDependentPara[8][8];
- unsigned short *p_Speech_ModeDependent_Para;
- unsigned short *Speech_ModeDependent_Para_Array[8];
- const char SECTION_NAME[][64] =
- {
- "Normal Mode Parameter",
- "Earphone Mode Parameter",
- "Loud Speaker Mode Parameter",
- "BlueTooth Earphone Mode Parameter",
- "BlueTooth Cordless Mode Parameter",
- "AUX1 Mode Parameter",
- "AUX2 Mode Parameter",
- "AUX3 Mode Parameter"
- };
- switch (m_eAudioParamType)
- {
- case AUDIO_FIR_VER_W0547:
- case AUDIO_FIR_VER_W0547_45_TAP:
- case AUDIO_FIR_VER_W0712:
- case AUDIO_FIR_VER_W0740:
- {
- Array_To_String_UnsignedShort(str, m_sFirCoeff.us_speech_common_para, SE_SPEECH_COMMON_NUM_12, ',');
- ini_file->WriteString(as_SECTION_NAME,
- "Speech Common Parameter",
- str);
- }
- break;
- case AUDIO_FIR_VER_W0809:
- {
- Array_To_String_UnsignedShort(str, m_sFirCoeff.us_speech_common_para, SE_SPEECH_COMMON_NUM_12, ',');
- ini_file->WriteString(as_SECTION_NAME,
- "Speech Common Parameter",
- str);
- }
- break;
- }
- switch (m_eAudioParamType)
- {
- case AUDIO_FIR_VER_W0547:
- case AUDIO_FIR_VER_W0547_45_TAP:
- case AUDIO_FIR_VER_W0712:
- case AUDIO_FIR_VER_W0740:
- {
- for (int i=0; i<SE_MODE_NUM; i++)
- {
- for (int j=0; j<SE_MODE_PARA_NUM_8; j++)
- {
- usSpeechModeDependentPara[i][SE_MODE_PARA_NUM_8-j-1] = m_sFirCoeff.us_speech_mode_para[i][j];
- }
- Array_To_String_UnsignedShort(str, usSpeechModeDependentPara[i], SE_MODE_PARA_NUM_8, ',');
- ini_file->WriteString(as_SECTION_NAME,
- SECTION_NAME[i],
- str
- );
- }
- }
- break;
- case AUDIO_FIR_VER_W0809:
- {
- for (int i=0; i<SE_MODE_NUM; i++)
- {
- for (int j=0; j<SE_MODE_PARA_NUM_16; j++)
- {
- usSpeechModeDependentPara[i][SE_MODE_PARA_NUM_16-j-1] = m_sFirCoeff.us_speech_mode_para[i][j];
- }
- Array_To_String_UnsignedShort(str, usSpeechModeDependentPara[i], SE_MODE_PARA_NUM_16, ',');
- ini_file->WriteString(as_SECTION_NAME,
- SECTION_NAME[i],
- str
- );
- }
- }
- break;
- }
- }
- // auido compensation
- if ((AUDIO_FIR_VER_W0740 == m_eAudioParamType) ||
- (AUDIO_FIR_VER_W0809 == m_eAudioParamType)
- )
- {
- for (E_AUDIO_COMPENSATION_IDX_T type = AUDIO_COMPENSATION_LOUD_SPEAKER_IDX; type <= AUDIO_COMPENSATION_EARPHONE_IDX; type++)
- {
- Array_To_String_short(str, m_sFirCoeff.s_audio_compensation_coeff[type], AUDIO_COMPENSATION_TAPS_NUM, ',');
- ini_file->WriteString(as_SECTION_NAME,
- as_KEY_NAME_AC[type],
- str);
- }
- }
- // volume
- if (AUDIO_FIR_VER_W0809 == m_eAudioParamType)
- {
- for (int i = 0; i < SE_VOLUME_MODE_NUM; i++)
- {
- for (int j = 0; j < SE_VOLUME_LEVEL_NUM; j++)
- {
- Array_To_String_UnsignedShort(str, m_sFirCoeff.us_speech_volume_para[i][j], SE_VOLUME_PARAM_NUM, ',');
- AnsiString as_key_name = as_KEY_NAME_VOL_MODE[i] + as_KEY_NAME_VOL_LEVEL + IntToStr(j);
- ini_file->WriteString(as_SECTION_NAME,
- as_key_name,
- str
- );
- }
- }
- }
- delete ini_file;
- return true;
- }
- //==============================================================================
- /////////////////////////////////////// FIR 1 //////////////////////////////////
- //==============================================================================
- bool CSPCOEF::REQ_Read_FIR1_Input_Coeff_From_File(char *filename, E_AUDIO_FIR_VER_T e_audio_para_type)
- {
- m_eAudioParamType = e_audio_para_type;
- if ((AUDIO_FIR_VER_W0547_45_TAP == m_eAudioParamType) ||
- (AUDIO_FIR_VER_W0712 == m_eAudioParamType) ||
- (AUDIO_FIR_VER_W0740 == m_eAudioParamType) ||
- (AUDIO_FIR_VER_W0809 == m_eAudioParamType)
- )
- {
- return false;
- }
- FILE *fp;
- bool IsEof;
- int i;
- fp = fopen(filename, "r");
- if (NULL == fp)
- {
- return false;
- }
- if (!feof(fp))
- {
- fscanf( fp, "%d", &m_iCoeffLen);
- }
- i=0; // initialize i
- int coeff;
- while(!feof(fp) && i< m_iCoeffLen && i<SPEECH_FIR_30_TAPS_NUM)
- {
- fscanf(fp, "%d", &coeff);
- m_sFirCoeff.s_Speech_FIR[AUDIO_NORMAL_MODE_INDEX].Speech_8k_Input_Coeff[i] = (short) coeff;
- i++;
- }
- for (i=m_iCoeffLen; i<SPEECH_FIR_30_TAPS_NUM; i++)
- {
- m_sFirCoeff.s_Speech_FIR[AUDIO_NORMAL_MODE_INDEX].Speech_8k_Input_Coeff[i]=0;
- }
- fclose(fp);
- return true;
- }
- //----------------------------------------------------------------------------
- bool CSPCOEF::REQ_Write_FIR1_Input_Coeff_To_File(char *filename, E_AUDIO_FIR_VER_T e_audio_para_type)
- {
- m_eAudioParamType = e_audio_para_type;
- if ((AUDIO_FIR_VER_W0547_45_TAP == m_eAudioParamType) ||
- (AUDIO_FIR_VER_W0712 == m_eAudioParamType) ||
- (AUDIO_FIR_VER_W0740 == m_eAudioParamType) ||
- (AUDIO_FIR_VER_W0809 == m_eAudioParamType)
- )
- {
- return false;
- }
- FILE *fp;
- int CoeffLength = SPEECH_FIR_30_TAPS_NUM;
- int i;
- fp = fopen(filename, "w");
- if (NULL == fp)
- {
- return false;
- }
- for (i=0; i<SPEECH_FIR_30_TAPS_NUM; i++)
- {
- if (0 == m_sFirCoeff.s_Speech_FIR[AUDIO_NORMAL_MODE_INDEX].Speech_8k_Input_Coeff[i])
- {
- CoeffLength = i;
- break;
- }
- }
- fprintf(fp, "%dn", CoeffLength);
- for (i=0; i<CoeffLength; i++)
- {
- fprintf(fp, "%dn", m_sFirCoeff.s_Speech_FIR[AUDIO_NORMAL_MODE_INDEX].Speech_8k_Input_Coeff[i]);
- }
- fclose(fp);
- return true;
- }
- //===========================================================================
- bool CSPCOEF::REQ_Read_FIR1_Output_Coeff_From_File(char *filename, E_AUDIO_FIR_VER_T e_audio_para_type)
- {
- m_eAudioParamType = e_audio_para_type;
- if ((AUDIO_FIR_VER_W0547_45_TAP == m_eAudioParamType) ||
- (AUDIO_FIR_VER_W0712 == m_eAudioParamType) ||
- (AUDIO_FIR_VER_W0740 == m_eAudioParamType) ||
- (AUDIO_FIR_VER_W0809 == m_eAudioParamType)
- )
- {
- return false;
- }
- FILE *fp;
- bool IsEof;
- int i=0;
- fp = fopen(filename, "r");
- if (NULL == fp)
- {
- return false;
- }
- if (!feof(fp))
- {
- fscanf(fp, "%d", &m_iCoeffLen);
- }
- i=0; // initialize i
- int coeff;
- while(!feof(fp) && i< m_iCoeffLen && i<SPEECH_FIR_30_TAPS_NUM)
- {
- fscanf( fp, "%d", &coeff);
- m_sFirCoeff.s_Speech_FIR[AUDIO_NORMAL_MODE_INDEX].Speech_8k_Output_Coeff[i] = (short) coeff;
- i++;
- }
- for (i=m_iCoeffLen; i<SPEECH_FIR_30_TAPS_NUM; i++)
- {
- m_sFirCoeff.s_Speech_FIR[AUDIO_NORMAL_MODE_INDEX].Speech_8k_Output_Coeff[i] = 0;
- }
- fclose(fp);
- return true;
- }
- //---------------------------------------------------------------------------
- bool CSPCOEF::REQ_Write_FIR1_Output_Coeff_To_File(char *filename, E_AUDIO_FIR_VER_T e_audio_para_type)
- {
- m_eAudioParamType = e_audio_para_type;
- if ((AUDIO_FIR_VER_W0547_45_TAP == m_eAudioParamType) ||
- (AUDIO_FIR_VER_W0712 == m_eAudioParamType) ||
- (AUDIO_FIR_VER_W0740 == m_eAudioParamType) ||
- (AUDIO_FIR_VER_W0809 == m_eAudioParamType)
- )
- {
- return false;
- }
- FILE *fp;
- int CoeffLength = SPEECH_FIR_30_TAPS_NUM;
- int i;
- fp = fopen(filename, "w");
- if(fp == NULL)
- return false;
- for (i=0; i<SPEECH_FIR_30_TAPS_NUM; i++)
- {
- if (0 == m_sFirCoeff.s_Speech_FIR[AUDIO_NORMAL_MODE_INDEX].Speech_8k_Output_Coeff[i])
- {
- CoeffLength = i;
- break;
- }
- }
- fprintf(fp, "%dn", CoeffLength);
- for (i=0; i<CoeffLength; i++)
- {
- fprintf(fp, "%dn", m_sFirCoeff.s_Speech_FIR[AUDIO_NORMAL_MODE_INDEX].Speech_8k_Output_Coeff[i]);
- }
- fclose(fp);
- return true;
- }
- //==============================================================================
- /////////////////////////////////////// FIR 2 //////////////////////////////////
- //==============================================================================
- bool CSPCOEF::REQ_Read_FIR2_Input_Coeff_From_File(char *filename, E_AUDIO_FIR_VER_T e_audio_para_type)
- {
- m_eAudioParamType = e_audio_para_type;
- if ((AUDIO_FIR_VER_W0547_45_TAP == m_eAudioParamType) ||
- (AUDIO_FIR_VER_W0712 == m_eAudioParamType) ||
- (AUDIO_FIR_VER_W0740 == m_eAudioParamType) ||
- (AUDIO_FIR_VER_W0809 == m_eAudioParamType)
- )
- {
- return false;
- }
- FILE *fp;
- bool IsEof;
- int i;
- fp = fopen(filename, "r");
- if (NULL == fp)
- {
- return false;
- }
- if (!feof(fp))
- {
- fscanf(fp, "%d", &m_iCoeffLen);
- }
- i=0; // initialize i
- int coeff;
- while(!feof(fp) && i< m_iCoeffLen && i<SPEECH_FIR_30_TAPS_NUM)
- {
- fscanf( fp, "%d", &coeff);
- m_sFirCoeff.s_Speech_FIR[AUDIO_HEADSET_MODE_INDEX].Speech_8k_Input_Coeff[i] = (short) coeff;
- i++;
- }
- for(i=m_iCoeffLen; i<SPEECH_FIR_30_TAPS_NUM; i++)
- {
- m_sFirCoeff.s_Speech_FIR[AUDIO_HEADSET_MODE_INDEX].Speech_8k_Input_Coeff[i]=0;
- }
- fclose(fp);
- return true;
- }
- //----------------------------------------------------------------------------
- bool CSPCOEF::REQ_Write_FIR2_Input_Coeff_To_File(char *filename, E_AUDIO_FIR_VER_T e_audio_para_type)
- {
- m_eAudioParamType = e_audio_para_type;
- if ((AUDIO_FIR_VER_W0547_45_TAP == m_eAudioParamType) ||
- (AUDIO_FIR_VER_W0712 == m_eAudioParamType) ||
- (AUDIO_FIR_VER_W0740 == m_eAudioParamType) ||
- (AUDIO_FIR_VER_W0809 == m_eAudioParamType)
- )
- {
- return false;
- }
- FILE *fp;
- int CoeffLength = SPEECH_FIR_30_TAPS_NUM;
- int i;
- fp = fopen(filename, "w");
- if(fp == NULL)
- return false;
- for (i=0; i<SPEECH_FIR_30_TAPS_NUM; i++)
- {
- if (0 == m_sFirCoeff.s_Speech_FIR[AUDIO_HEADSET_MODE_INDEX].Speech_8k_Input_Coeff[i])
- {
- CoeffLength = i;
- break;
- }
- }
- fprintf(fp, "%dn", CoeffLength);
- for (i=0; i<CoeffLength; i++)
- {
- fprintf(fp, "%dn", m_sFirCoeff.s_Speech_FIR[AUDIO_HEADSET_MODE_INDEX].Speech_8k_Input_Coeff[i]);
- }
- fclose(fp);
- return true;
- }
- //===========================================================================
- bool CSPCOEF::REQ_Read_FIR2_Output_Coeff_From_File(char *filename, E_AUDIO_FIR_VER_T e_audio_para_type)
- {
- m_eAudioParamType = e_audio_para_type;
- if ((AUDIO_FIR_VER_W0547_45_TAP == m_eAudioParamType) ||
- (AUDIO_FIR_VER_W0712 == m_eAudioParamType) ||
- (AUDIO_FIR_VER_W0740 == m_eAudioParamType) ||
- (AUDIO_FIR_VER_W0809 == m_eAudioParamType)
- )
- {
- return false;
- }
- FILE *fp;
- bool IsEof;
- int i=0;
- fp = fopen(filename, "r");
- if(fp == NULL)
- return false;
- if (!feof(fp))
- {
- fscanf( fp, "%d", &m_iCoeffLen);
- }
- i=0; // initialize i
- int coeff;
- while (!feof(fp) && i< m_iCoeffLen && i<SPEECH_FIR_30_TAPS_NUM)
- {
- fscanf(fp, "%d", &coeff);
- m_sFirCoeff.s_Speech_FIR[AUDIO_HEADSET_MODE_INDEX].Speech_8k_Output_Coeff[i] = (short) coeff;
- i++;
- }
- for (i=m_iCoeffLen; i<SPEECH_FIR_30_TAPS_NUM; i++)
- {
- m_sFirCoeff.s_Speech_FIR[AUDIO_HEADSET_MODE_INDEX].Speech_8k_Output_Coeff[i] = 0;
- }
- fclose(fp);
- return true;
- }
- //----------------------------------------------------------------------------
- bool CSPCOEF::REQ_Write_FIR2_Output_Coeff_To_File(char *filename, E_AUDIO_FIR_VER_T e_audio_para_type)
- {
- m_eAudioParamType = e_audio_para_type;
- if ((AUDIO_FIR_VER_W0547_45_TAP == m_eAudioParamType) ||
- (AUDIO_FIR_VER_W0712 == m_eAudioParamType) ||
- (AUDIO_FIR_VER_W0740 == m_eAudioParamType) ||
- (AUDIO_FIR_VER_W0809 == m_eAudioParamType)
- )
- {
- return false;
- }
- FILE *fp;
- int CoeffLength = SPEECH_FIR_30_TAPS_NUM;
- fp = fopen(filename, "w");
- if(fp == NULL)
- return false;
- for (int i=0; i<SPEECH_FIR_30_TAPS_NUM; i++)
- {
- if (0 == m_sFirCoeff.s_Speech_FIR[AUDIO_HEADSET_MODE_INDEX].Speech_8k_Output_Coeff[i])
- {
- CoeffLength = i;
- break;
- }
- }