sp_coef_cal.h
上传用户:gelin96
上传日期:2017-01-08
资源大小:20993k
文件大小:7k
- /*****************************************************************************
- * 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_cal.h
- *
- * Project:
- * --------
- * Maui META APP
- *
- * Description:
- * ------------
- * Acoustic FIR coefficient calibration header
- *
- * 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!!
- *============================================================================
- ****************************************************************************/
- #ifndef _SP_COEF_CAL_H_
- #define _SP_COEF_CAL_H_
- /*---------------------------------------------------------------------------*/
- #include "meta.h"
- #include "Audio_common.h"
- #include "sp_coef.h"
- #include "aftdll.h"
- #ifndef _MAN_HANDLE_H_
- #include "man_handle.h"
- #endif
- #define STATE_COEF_CAL_OK 0
- #define STATE_COEF_CAL_FAIL 1
- #define STATE_COEF_CAL_TIMEOUT 2
- #define STATE_COEF_CAL_STOP 3
- #define TRC_FREQ_POSITION 5
- #define TOTAL_BOUND_FREQ_NUM 8
- #define MAX_WEIGHT_LEN 78
- #define TOTAL_SEL_FREQ_NUM 15
- #define SCALING_FACTOR_POSITION 17
- #define BUFFER_SIZE 4096
- #define FIR_COEFF_SCALE 32767.0
- #define MAX_FIR_RESPONSE_LEN 4096
- typedef struct
- {
- unsigned int num;
- double Hz[TOTAL_TRC_FREQ_NUM+2];
- double Mag[TOTAL_TRC_FREQ_NUM+2];
- double MagdB[TOTAL_TRC_FREQ_NUM+2];
- }sSpCoefCalParameters;
- typedef struct
- {
- double Hz[TOTAL_SEL_FREQ_NUM];
- int index[TOTAL_SEL_FREQ_NUM];
- double MagdB[TOTAL_SEL_FREQ_NUM];
- } sSelectedParameters;
- typedef struct
- {
- double Hz[TOTAL_TRC_FREQ_NUM+2];
- double Pyy[TOTAL_TRC_FREQ_NUM+2];
- double Pyf[TOTAL_TRC_FREQ_NUM+2];
- int num;
- } sModifiedParameters;
- typedef struct
- {
- int Anum;
- int Bnum;
- int Cnum;
- int num;
- double Hz[3];
- // int index[TOTAL_SEL_FREQ_NUM];
- double MagdB[3];
- int Start_data_idx;
- int End_data_idx;
- int distance;
- } sInterpolateParameters;
- typedef struct
- {
- unsigned int taps;
- double FirCoef[SPEECH_FIR_45_TAPS_NUM];
- }sFirCoefParameters;
- typedef struct
- {
- unsigned int dimension;
- double FirResp[MAX_FIR_RESPONSE_LEN];
- }sFirRespParameters;
- typedef struct
- {
- unsigned int num;
- double weight[MAX_WEIGHT_LEN];
- }sWeightParameters;
- /*---------------------------------------------------------------------------*/
- class CSPCOEFCAL
- {
- private:
- int ConfirmState;
- CMETAHANDLE m_META_HANDLE_Obj;
- protected:
- void Confirm( int confirm_state );
- public:
- short SPID_COEF_CAL;
- char *CoefCalBuf;
- int CoefCalBufSize;
- /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
- // Public member
- CSPCOEFCAL( void );
- ~CSPCOEFCAL( );
- void (*ConfirmCallback)( void );
- // Public interface
- void REQ_Finish( void );
- void REQ_TimeOut( void );
- void REQ_Stop( void );
- // file
- bool REQ_Read_TRC_File( char *filename, double* p_TrcScale, sSpCoefCalParameters *p_SpCoefCal );
- bool REQ_Read_FIR_File( char *filename, bool b_45TapSupport, sFirCoefParameters *p_FirCoef );
- bool REQ_Write_FIR_File( char *filename, sFirCoefParameters *p_FirCoef );
- bool CheckLicenseDat( void );
- void ReorderFirCoef( sFirCoefParameters *p_FirCoef );
- void getSelHzIndex(int *p_TplHz, int *p_SelHz, int* p_SelHzIndex);
- void getSeldB( double *p_TpldB, double *p_SeldB, int* p_SelHzIndex);
- bool CheckEngineExist( void );
- const char* Get_ErrorString(AFT_RESULT code);
- AFT_RESULT freqz( bool b_45TapSupport, sFirCoefParameters *p_old_FIR, sSpCoefCalParameters *p_ProcessSpCoef, double Fs, sSpCoefCalParameters *p_OldFirSpCoef);
- void freqz2out( sFirCoefParameters *p_new_fir_coeff_F_normalized_fixed_point, double N, double freqz_N, double Fs, sFirRespParameters *p_FirResp_freqz_H, sFirRespParameters *p_FirResp_freqz_F );
- AFT_RESULT firls( int wanted_ord, sSpCoefCalParameters *p_ProcessOddSpCoef, sSpCoefCalParameters *p_NewFirOddSpCoef, double Fs, sFirCoefParameters *p_NewFirCoeffF1);
- void firls4input( int wanted_ord, sSpCoefCalParameters *p_ProcessOddSpCoef, sSpCoefCalParameters *p_NewFirOddSpCoef, sWeightParameters *p_Weight, double Fs, sFirCoefParameters *p_NewFirCoeffF1);
- // file format transform
- bool AcquaFile_To_UplFile(char *i_filename, bool b_Rx, bool b_LinearFormat, char *o_filename);
- bool MicrotronixFile_To_UplFile(char *i_filename, bool b_Rx, bool b_LinearFormat, char *o_filename);
- bool UpvFile_To_UplFile(char *i_filename, char *o_filename);
- bool VitaFile_To_UplFile(char *i_filename, bool b_Rx, bool b_LinearFormat, char *o_filename);
- // Global information
- int Get_ConfirmState(void);
- };
- /*---------------------------------------------------------------------------*/
- #endif