form_FirCoeffCal.h
上传用户:gelin96
上传日期:2017-01-08
资源大小:20993k
文件大小:17k
- /*****************************************************************************
- * 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:
- * ---------
- * form_FirCoeffCal.h
- *
- * Project:
- * --------
- * Maui META APP
- *
- * Description:
- * ------------
- * FIR coefficient calibration form 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 _FORM_FIRCOEFFCAL_H_
- #define _FORM_FIRCOEFFCAL_H_
- //---------------------------------------------------------------------------
- #include <Classes.hpp>
- #include <Controls.hpp>
- #include <StdCtrls.hpp>
- #include <Forms.hpp>
- #include <ComCtrls.hpp>
- #include <Dialogs.hpp>
- #include <ExtCtrls.hpp>
- #include <Graphics.hpp>
- #include "sp_coef_cal.h"
- //------------------------------------------------------------------------------
- #define TOTAL_BOUNDARY_FREQ_NUM 17
- //------------------------------------------------------------------------------
- //------------------------------------------------------------------------------
- class TfrmFIRCoeffCal : public TForm
- {
- __published: // IDE-managed Components
- TLabel *lbl1xxHz;
- TEdit *edt1xxHzdB;
- TLabel *lbl2xxHz;
- TEdit *edt2xxHzdB;
- TLabel *lbl6xxHz;
- TLabel *lbl3xxHz;
- TEdit *edt3xxHzdB;
- TEdit *edt6xxHzdB;
- TEdit *edt7xxHzdB;
- TLabel *lbl7xxHz;
- TEdit *edt1xxxHzdB;
- TLabel *lbl1xxxHz;
- TEdit *edt2xxxHzdB;
- TLabel *lbl2xxxHz;
- TLabel *lbl3xxxHz;
- TEdit *edt3xxxHzdB;
- TLabel *lbl34xxHz;
- TEdit *edt34xxHzdB;
- TLabel *lbl39xxHz;
- TEdit *edt39xxHzdB;
- TLabel *Label11;
- TEdit *edtFIRTaps;
- TLabel *Label12;
- TEdit *edtExtraDB;
- TLabel *Label13;
- TComboBox *cbExtraFreq;
- TButton *btnIdealize;
- TGroupBox *GroupBox1;
- TRadioButton *rbTx;
- TRadioButton *rbRx;
- TStatusBar *sbAudioCal;
- TButton *btnLoad;
- TOpenDialog *dlgOpenUpl;
- TStaticText *stInputFileName;
- TImage *imAudioCal;
- TLabel *lblVertical0;
- TLabel *lblVertical1;
- TLabel *lblVertical2;
- TLabel *lblVertical3;
- TLabel *lblVertical4;
- TLabel *lblVertical5;
- TLabel *lblVertical6;
- TLabel *Label15;
- TLabel *lbl100Hz;
- TLabel *lbl1000Hz;
- TLabel *Label16;
- TLabel *Label17;
- TButton *btnRun;
- TStaticText *lblHint;
- TTimer *HintTimer;
- TLabel *lblVertical7;
- TLabel *lblVertical8;
- TEdit *edt5xxHzdB;
- TLabel *lbl5xxHz;
- TEdit *edt8xxHzdB;
- TLabel *lbl8xxHz;
- TEdit *edt13xxHzdB;
- TEdit *edt18xxHzdB;
- TLabel *lbl13xxHz;
- TLabel *lbl18xxHz;
- TEdit *edt25xxHzdB;
- TLabel *lbl25xxHz;
- TStaticText *stOutputTxFileName;
- TStaticText *stOutputRxFileName;
- TButton *btnSetupOutpuRxFile;
- TButton *btnSetupOutputTxFile;
- TLabel *Label1;
- TLabel *Label2;
- TLabel *Label3;
- TSaveDialog *SaveDialog;
- TLabel *Label4;
- TEdit *edtFirScale;
- TComboBox *cb1xxHz;
- TComboBox *cb2xxHz;
- TComboBox *cb3xxHz;
- TComboBox *cb5xxHz;
- TComboBox *cb6xxHz;
- TComboBox *cb7xxHz;
- TComboBox *cb8xxHz;
- TComboBox *cb1xxxHz;
- TComboBox *cb13xxHz;
- TComboBox *cb18xxHz;
- TComboBox *cb2xxxHz;
- TComboBox *cb25xxHz;
- TComboBox *cb3xxxHz;
- TComboBox *cb34xxHz;
- TComboBox *cb39xxHz;
- TGroupBox *gbEquipment;
- TRadioButton *rbUPL;
- TGroupBox *gbFileFormat;
- TRadioButton *rbLinear;
- TRadioButton *rbLogdB;
- TOpenDialog *dlgOpenAcqua;
- TRadioButton *rbMicrotronix;
- TComboBox *cbBoundary;
- TLabel *Label5;
- TOpenDialog *dlgOpenMicrotronix;
- TRadioButton *rbAcqua;
- TRadioButton *m_rbVita;
- TOpenDialog *m_dlgOpenVita;
- TRadioButton *m_rbUPV;
- TOpenDialog *m_dlgUPV;
- void __fastcall btnLoadClick(TObject *Sender);
- void __fastcall cbExtraFreqChange(TObject *Sender);
- void __fastcall rbTxClick(TObject *Sender);
- void __fastcall rbRxClick(TObject *Sender);
- void __fastcall btnIdealizeClick(TObject *Sender);
- void __fastcall btnRunClick(TObject *Sender);
- void __fastcall edt1xxHzdBExit(TObject *Sender);
- void __fastcall edt2xxHzdBExit(TObject *Sender);
- void __fastcall edt3xxHzdBExit(TObject *Sender);
- void __fastcall edt6xxHzdBExit(TObject *Sender);
- void __fastcall edt7xxHzdBExit(TObject *Sender);
- void __fastcall edt1xxxHzdBExit(TObject *Sender);
- void __fastcall edt2xxxHzdBExit(TObject *Sender);
- void __fastcall edt3xxxHzdBExit(TObject *Sender);
- void __fastcall edt34xxHzdBExit(TObject *Sender);
- void __fastcall edt39xxHzdBExit(TObject *Sender);
- void __fastcall FormCreate(TObject *Sender);
- void __fastcall edtFIRTapsExit(TObject *Sender);
- void __fastcall FormDragDrop(TObject *Sender, TObject *Source,
- int X, int Y);
- void __fastcall FormDockOver(TObject *Sender,
- TDragDockObject *Source, int X, int Y, TDragState State,
- bool &Accept);
- void __fastcall Image1DragDrop(TObject *Sender, TObject *Source,
- int X, int Y);
- void __fastcall FormMouseDown(TObject *Sender, TMouseButton Button,
- TShiftState Shift, int X, int Y);
- void __fastcall imAudioCalMouseDown(TObject *Sender,
- TMouseButton Button, TShiftState Shift, int X, int Y);
- void __fastcall edtExtraDBExit(TObject *Sender);
- void __fastcall imAudioCalDragOver(TObject *Sender,
- TObject *Source, int X, int Y, TDragState State, bool &Accept);
- void __fastcall imAudioCalEndDrag(TObject *Sender, TObject *Target,
- int X, int Y);
- void __fastcall edt5xxHzdBExit(TObject *Sender);
- void __fastcall edt8xxHzdBExit(TObject *Sender);
- void __fastcall edt13xxHzdBExit(TObject *Sender);
- void __fastcall edt18xxHzdBExit(TObject *Sender);
- void __fastcall edt25xxHzdBExit(TObject *Sender);
- void __fastcall btnSetupOutputTxFileClick(TObject *Sender);
- void __fastcall btnSetupOutpuRxFileClick(TObject *Sender);
- void __fastcall FormShow(TObject *Sender);
- void __fastcall FormClose(TObject *Sender, TCloseAction &Action);
- void __fastcall mTimerTimer(TObject *Sender);
- void __fastcall rbSpecClick(TObject *Sender);
- void __fastcall rbGoodSoundClick(TObject *Sender);
- void __fastcall edtFirScaleCheck(TObject *Sender);
- void __fastcall cb1xxHzChange(TObject *Sender);
- void __fastcall cb2xxHzChange(TObject *Sender);
- void __fastcall cb3xxHzChange(TObject *Sender);
- void __fastcall cb5xxHzChange(TObject *Sender);
- void __fastcall cb6xxHzChange(TObject *Sender);
- void __fastcall cb7xxHzChange(TObject *Sender);
- void __fastcall cb8xxHzChange(TObject *Sender);
- void __fastcall cb1xxxHzChange(TObject *Sender);
- void __fastcall cb13xxHzChange(TObject *Sender);
- void __fastcall cb18xxHzChange(TObject *Sender);
- void __fastcall cb2xxxHzChange(TObject *Sender);
- void __fastcall cb25xxHzChange(TObject *Sender);
- void __fastcall cb3xxxHzChange(TObject *Sender);
- void __fastcall cb34xxHzChange(TObject *Sender);
- void __fastcall cb39xxHzChange(TObject *Sender);
- void __fastcall HintTimerTimer(TObject *Sender);
- void __fastcall rbUPLClick(TObject *Sender);
- void __fastcall rbAcquaClick(TObject *Sender);
- void __fastcall cbBoundaryChange(TObject *Sender);
- void __fastcall FormActivate(TObject *Sender);
- void __fastcall rbMicrotronixClick(TObject *Sender);
- void __fastcall m_rbVitaClick(TObject *Sender);
- void __fastcall m_rbUPVClick(TObject *Sender);
-
- private: // User declarations
- // common
- bool m_b45TapSupport;
- bool m_bInit;
-
- // flag
- bool isTRCLoadOk;
- bool isOrgCurvePlot;
- bool isWantedCurvePlot;
- bool isCompensateCurvePlot;
- int max_y_grid, min_y_grid;
- TLabel *lblVertical[VERTICAL_LABEL_NUM], *lblHz[TOTAL_SEL_FREQ_NUM];
- TEdit *edtHzdB[TOTAL_SEL_FREQ_NUM];
- CSPCOEFCAL SP_COEF_CAL_Object;
- double LogFloor;
- double pi;
- double TrcScale;
- sSpCoefCalParameters OrgSpCoef, WantedSpCoef, IdealSpCoef, OldFirSpCoef;
- sSpCoefCalParameters m_sTargetSpCoef;
- sSpCoefCalParameters UIWantedSpCoef, NewFirSpCoef, ck_NewSpCoef;
- sSpCoefCalParameters ProcessSpCoef;
- sSelectedParameters SelectedSpCoef, UISelectedSpCoef;
- sFirCoefParameters old_FIR, Tx_FIR, Rx_FIR;
- sFirCoefParameters old_FIR_norm;
- sFirRespParameters FirResp_freqz_H, FirResp_freqz_F;
- int m_iTxLimitNum;
- int m_iRxLimitNum;
- double m_dTxUpLimit[TOTAL_BOUNDARY_FREQ_NUM];
- double m_dTxLowLimit[TOTAL_BOUNDARY_FREQ_NUM];
- double m_dRxUpLimit[TOTAL_BOUNDARY_FREQ_NUM];
- double m_dRxLowLimit[TOTAL_BOUNDARY_FREQ_NUM];
- double m_dLow_bound_dB[TOTAL_BOUNDARY_FREQ_NUM];
- double m_dUp_bound_dB[TOTAL_BOUNDARY_FREQ_NUM];
- // double m_dUITxUpLimit[8], m_dUITxLowLimit[8], m_dUIRxUpLimit[8], m_dUIRxLowLimit[8];
- double m_dLow_limit_dB;
- double m_dHz100_limit_dB;
- double m_dMean_bound_dB[TOTAL_BOUNDARY_FREQ_NUM];
- float FirScale;
- int m_iTxLimitFreq[TOTAL_BOUNDARY_FREQ_NUM];
- int m_iRxLimitFreq[TOTAL_BOUNDARY_FREQ_NUM];
- int m_iHz_bound[TOTAL_BOUNDARY_FREQ_NUM];
- // int UITxLimitFreq[8], UIRxLimitFreq[8];
- int m_iWantedTaps;
- int m_iWantedHz[TOTAL_SEL_FREQ_NUM];
- // UI
- int vStart, hStart, hStart2, vScale, hScale, vDistance, hDistance, Segments;
- int hInScale1, hOutScale1, hInScale2, hOutScale2;
- sAudioPoint WantedPoint;
- bool isWantedCircleOnDrag;
- int WantedCircleOnDragIndex;
- bool m_bFirstFormShow;
- public: // User declarations
- void _fastcall SubClassWndProc( Messages::TMessage &Message);
- __fastcall TfrmFIRCoeffCal(TComponent* Owner);
- void Init();
- // UI
- void DisplayDirection( void );
- void SaveDirection( void );
- void DisplayBoundary( void );
- void SaveBoundary( void );
- void DisplayEquipment( void );
- void SaveEquipment( void );
- void DisplayFileFormat( void );
- void SaveFileFormat( void );
- void Set_Boundary( void );
- bool edtdBCheck(TObject *Sender);
- void ClearImage( void );
- void GetMinMaxY( sSpCoefCalParameters *p_SpCoef, double *p_min_y, double *p_max_y );
- void IdealizeExcute( void );
- // plot curve
- void PlotCurve( int plot_mask );
- void PlotGrid(int min_x, int max_x, int min_y, int max_y);
- void PlotBoundaryCurve( void );
- void PlotWantedCurve( void );
- void PlotOrgCurve( void );
- void PlotCompensatedCurve( void );
- void PlotWantedCircle( void );
- // void DisplayEditor( void );
- // other UI
- void UpdateAllSelectParameters( void );
- void UpdateAllSelectEditor( void );
- void UpdateExtradBEditor( void );
- void UpdateEditor( void );
- void UpdateSelectedLabel( void );
- void UpdatecbExtraFreq( sSpCoefCalParameters* p_SpCoef );
- void Updatecb1xxHz( sSpCoefCalParameters* p_SpCoef, int idx );
- void Updatecb2xxHz( sSpCoefCalParameters* p_SpCoef, int idx );
- void Updatecb3xxHz( sSpCoefCalParameters* p_SpCoef, int idx );
- void Updatecb5xxHz( sSpCoefCalParameters* p_SpCoef, int idx );
- void Updatecb6xxHz( sSpCoefCalParameters* p_SpCoef, int idx );
- void Updatecb7xxHz( sSpCoefCalParameters* p_SpCoef, int idx );
- void Updatecb8xxHz( sSpCoefCalParameters* p_SpCoef, int idx );
- void Updatecb1xxxHz( sSpCoefCalParameters* p_SpCoef, int idx );
- void Updatecb15xxHz( sSpCoefCalParameters* p_SpCoef, int idx );
- void Updatecb18xxHz( sSpCoefCalParameters* p_SpCoef, int idx );
- void Updatecb2xxxHz( sSpCoefCalParameters* p_SpCoef, int idx );
- void Updatecb25xxHz( sSpCoefCalParameters* p_SpCoef, int idx );
- void Updatecb3xxxHz( sSpCoefCalParameters* p_SpCoef, int idx );
- void Updatecb34xxHz( sSpCoefCalParameters* p_SpCoef, int idx );
- void Updatecb39xxHz( sSpCoefCalParameters* p_SpCoef, int idx );
- void GetWantedIndex( sSpCoefCalParameters *p_SpCoefCal, sSelectedParameters *p_SpSelected );
- void GetIndexOfMostSimilar( int wanted_Hz, sSpCoefCalParameters *p_SpCoefCal, unsigned int* p_index );
- void Update_dB(sSelectedParameters *p_SelPar, int index, double dB, sSpCoefCalParameters *p_UPL_database);
- //void Update_dB(sSpCoefCalParameters *p_SpCoefCal, int index, double dB);
- // int getWantedSpCoefIndex(double Hz, sSpCoefCalParameters *p_SpCoefCal);
- int getSelectedSpCoefIndex(double Hz, sSelectedParameters *p_SelectedSpCoef);
- int getWantedSpCoefIndex(double Hz, sSpCoefCalParameters *p_WantedSpCoef);
- // bool getHzFromStr( AnsiString as_str, double &Hz);
- void Update_edtExtraDB( int select_idx, double dB );
- void ShowHintLabel( TControl *sender, char* hint );
- void PointTodB( int Wanted_idx );
- // file
- bool LoadTRCFile(char *filename);
- bool LoadAcquaFile(char *filename);
- bool LoadMicrotronixFile(char *i_filename);
- bool LoadUpvFile(char *i_filename);
- bool LoadVitaFile(char *i_filename);
- bool read_8k_Acoustic_FIR_setup(AnsiString asSetupFile, AnsiString asExeName);
- bool write_8k_Acoustic_FIR_setup(AnsiString asSetupFileName, AnsiString asExeName);
- // mfile
- void Req_freqz( void );
- };
- //---------------------------------------------------------------------------
- extern PACKAGE TfrmFIRCoeffCal *frmFIRCoeffCal;
- //---------------------------------------------------------------------------
- #endif