form_FirCoeffCal.cpp
上传用户:gelin96
上传日期:2017-01-08
资源大小:20993k
文件大小:151k
- if( ! edtdBCheck(Sender) )
- {
- return;
- }
- dB = atof(edt39xxHzdB->Text.c_str());
-
- if( dB != UISelectedSpCoef.MagdB[14] )
- {
- UISelectedSpCoef.MagdB[14] = dB;
- Update_dB(&SelectedSpCoef, 14, dB, &WantedSpCoef);
- Update_edtExtraDB( 14, dB );
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmFIRCoeffCal::edtFIRTapsExit(TObject *Sender)
- {
- AnsiString text;
- short data;
- int band;
- TEdit *edit = (TEdit*)Sender;
- char hint[]= "value shall be 1 ~ 44";
- text = edit->Text;
- if (!IsValidFirTaps(text, data))
- {
- if( m_b45TapSupport )
- { edit->Text = SPEECH_FIR_44_TAPS_NUM;
- }
- else
- {
- edit->Text = SPEECH_FIR_30_TAPS_NUM;
- }
- m_iWantedTaps = (edit->Text).ToInt();
- ShowHintLabel( edit, hint );
- edit->SetFocus();
- return;
- }
- m_iWantedTaps = data;
- }
- //---------------------------------------------------------------------------
- void TfrmFIRCoeffCal::ShowHintLabel( TControl *sender, char* hint )
- {
- TPoint pt0 = this->ClientOrigin;
- TPoint pt1 = sender->ClientOrigin;
- lblHint->Left = (pt1.x-pt0.x-10);
- lblHint->Top = (pt1.y-pt0.y)+sender->Height+3;
- lblHint->Caption = hint;
- lblHint->Visible = true;
- HintTimer->Enabled = true;
- }
- void __fastcall TfrmFIRCoeffCal::FormDragDrop(TObject *Sender,
- TObject *Source, int X, int Y)
- {
- // Image1->Left = X;
- // Image1->Top = Y;
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmFIRCoeffCal::FormDockOver(TObject *Sender,
- TDragDockObject *Source, int X, int Y, TDragState State,
- bool &Accept)
- {
- //Accept = true;
- //Image1->Left = X;
- //Image1->Top = Y;
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmFIRCoeffCal::Image1DragDrop(TObject *Sender,
- TObject *Source, int X, int Y)
- {
- //Image1->Left = X;
- //Image1->Top = Y;
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmFIRCoeffCal::FormMouseDown(TObject *Sender,
- TMouseButton Button, TShiftState Shift, int X, int Y)
- {
- //char buf[20];
- //sprintf(buf, " (x=%d, y=%d) ", X, Y);
- //sbAudioCal->Panels->Items[0]->Text = (AnsiString) buf;
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmFIRCoeffCal::imAudioCalMouseDown(TObject *Sender,
- TMouseButton Button, TShiftState Shift, int X, int Y)
- {
- char buf[20];
- sprintf(buf, " (x=%d, y=%d) ", X, Y);
- sbAudioCal->Panels->Items[0]->Text = (AnsiString) buf;
- for(int i=0; i<WantedPoint.num; i++)
- {
- if( WantedPoint.x[i]-2<=X && X<=WantedPoint.x[i]+2 &&
- WantedPoint.y[i]-2<=Y && Y<=WantedPoint.y[i]+2 )
- {
- //Application->MessageBox( " Bingo ", "Fail", MB_OK );
- isWantedCircleOnDrag = true;
- break;
- }
- }
- }
- //---------------------------------------------------------------------------
- int TfrmFIRCoeffCal::getSelectedSpCoefIndex(double Hz, sSelectedParameters *p_SelectedSpCoef)
- {
- int index = NOT_FOUND;
- for(int i=0; i<TOTAL_SEL_FREQ_NUM; i++)
- {
- if(p_SelectedSpCoef->Hz[i] == Hz)
- {
- index = i;
- break;
- }
- }
- return index;
- }
- //---------------------------------------------------------------------------
- int TfrmFIRCoeffCal::getWantedSpCoefIndex(double Hz, sSpCoefCalParameters *p_SpCoefCal)
- {
- int index = NOT_FOUND;
- for (unsigned int i=0; i<p_SpCoefCal->num; i++)
- {
- if( (int) p_SpCoefCal->Hz[i] == Hz)
- {
- index = i;
- break;
- }
- }
- return index;
- }
- //------------------------------------------------------------------------------
- void __fastcall TfrmFIRCoeffCal::edtExtraDBExit(TObject *Sender)
- {
- int index;
- double MdB, Hz;
- MdB = atof(edtExtraDB->Text.c_str());
- // Mdata = pow( 10.0, MdB/20.0 );
- WantedSpCoef.MagdB[cbExtraFreq->ItemIndex] = MdB;
- WantedSpCoef.Mag[cbExtraFreq->ItemIndex] = pow(10.0, MdB/20.0);
- UIWantedSpCoef.MagdB[cbExtraFreq->ItemIndex] = MdB;
- // update edtxxxHzdB
- if( getHzFromStr( cbExtraFreq->Text, Hz ) )
- {
- index = getSelectedSpCoefIndex(Hz, &SelectedSpCoef);
- if( index == NOT_FOUND )
- {
- // plot curve
- PlotCurve( PLOT_GRID | PLOT_BOUNDARY_CURVE | PLOT_WANTED_CURVE | PLOT_ORG_CURVE );
- return;
- }
- edtHzdB[index]->Text = Double_To_AnsiString(MdB);
- if( MdB != UISelectedSpCoef.MagdB[index] )
- {
- UISelectedSpCoef.MagdB[index] = MdB;
- Update_dB(&SelectedSpCoef, index, MdB, &WantedSpCoef);
- }
- }
- //
- // if( index
- }
- //==============================================================================
- void TfrmFIRCoeffCal::Update_edtExtraDB( int select_idx, double dB )
- {
- double Hz;
- int wanted_idx;
- getHzFromStr( cbExtraFreq->Text, Hz);
- if( Hz == (int) SelectedSpCoef.Hz[select_idx] )
- {
- edtExtraDB->Text = Double_To_AnsiString( dB );
- wanted_idx = getWantedSpCoefIndex(Hz, &WantedSpCoef);
- if( wanted_idx != NOT_FOUND )
- {
- UIWantedSpCoef.MagdB[wanted_idx] = dB;
- }
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmFIRCoeffCal::imAudioCalDragOver(TObject *Sender,
- TObject *Source, int X, int Y, TDragState State, bool &Accept)
- {
- if( State == dsDragEnter )
- {
- char buf[20];
- sprintf(buf, " (x=%d, y=%d) ", X, Y);
- sbAudioCal->Panels->Items[0]->Text = (AnsiString) buf;
- for(int i=0; i<WantedPoint.num; i++)
- {
- if( WantedPoint.x[i]-2<=X && X<=WantedPoint.x[i]+2 &&
- WantedPoint.y[i]-2<=Y && Y<=WantedPoint.y[i]+2 )
- {
- isWantedCircleOnDrag = true;
- WantedCircleOnDragIndex = i;
- break;
- }
- }
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmFIRCoeffCal::imAudioCalEndDrag(TObject *Sender,
- TObject *Target, int X, int Y)
- {
- if( isWantedCircleOnDrag )
- {
- if( X == 0 && Y == 0 ) // outside image
- {
- Application->MessageBox( " Destination coordinates is outside image range", "Warning", MB_OK );
- return;
- }
- WantedPoint.y[WantedCircleOnDragIndex] = Y;
- PointTodB( WantedCircleOnDragIndex );
- PlotCurve( PLOT_GRID | PLOT_BOUNDARY_CURVE | PLOT_WANTED_CURVE | PLOT_ORG_CURVE );
- isWantedCircleOnDrag = false;
- UpdateEditor();
- }
- }
- //---------------------------------------------------------------------------
- void TfrmFIRCoeffCal::PointTodB( int Wanted_idx )
- {
- if( Wanted_idx >= 0 )
- {
- WantedSpCoef.MagdB[Wanted_idx] = (double) max_y_grid - (WantedPoint.y[Wanted_idx]-vStart)*vScale/vDistance;
- WantedSpCoef.Mag[Wanted_idx] = pow(10.0, WantedSpCoef.MagdB[Wanted_idx]/20.0);
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmFIRCoeffCal::btnSetupOutputTxFileClick(TObject *Sender)
- {
-
- bool ok = SaveDialog->Execute();
- if( !ok )
- {
- sbAudioCal->Panels->Items[0]->Text = (AnsiString) " Setup output TX file fail";
- Application->MessageBox( "Execution Failure : Setup output TX file", "FAILURE", MB_OK );
- return;
- }
- stOutputTxFileName->Caption = SaveDialog->FileName;
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmFIRCoeffCal::btnSetupOutpuRxFileClick(TObject *Sender)
- {
- bool ok = SaveDialog->Execute();
- if( !ok )
- {
- sbAudioCal->Panels->Items[0]->Text = (AnsiString) " Setup output RX file fail";
- Application->MessageBox( "Execution Failure : Setup output RX file", "FAILURE", MB_OK );
- return;
- }
- stOutputRxFileName->Caption = SaveDialog->FileName;
- }
- //---------------------------------------------------------------------------
- bool TfrmFIRCoeffCal::read_8k_Acoustic_FIR_setup(
- AnsiString asSetupFile,
- AnsiString asExeName
- )
- {
- AnsiString asPath;
- TIniFile *ini;
- if ( getPathFromStr(asExeName, asPath) &&
- withPath( asPath) &&
- !withPath( asSetupFile)
- )
- {
- asSetupFile = asPath + asSetupFile;
- }
- try
- {
- ini = new TIniFile( asSetupFile );
- if(ini == NULL) return false;
- DisplayDirection();
- DisplayBoundary();
- DisplayEquipment();
- DisplayFileFormat();
-
- stInputFileName->Caption = ini->ReadString("8k Acoustic FIR Tunning","Input file name", "");
- if (stInputFileName->Caption.AnsiCompareIC("") != 0 )
- {
- if (rbAcqua->Checked)
- {
- LoadAcquaFile(stInputFileName->Caption.c_str());
- }
- else if (rbMicrotronix->Checked)
- {
- LoadMicrotronixFile(stInputFileName->Caption.c_str());
- }
- if (rbUPL->Checked)
- {
- LoadTRCFile(stInputFileName->Caption.c_str());
- }
- else if (m_rbUPV->Checked)
- {
- LoadUpvFile(stInputFileName->Caption.c_str());
- }
- else
- {
- LoadVitaFile(stInputFileName->Caption.c_str());
- }
- }
- stOutputTxFileName->Caption = ini->ReadString("8k Acoustic FIR Tunning","Output TX file name", "");
- stOutputRxFileName->Caption = ini->ReadString("8k Acoustic FIR Tunning","Output RX file name", "");
- delete ini;
- ini = NULL;
- return true;
- }
- catch (...)
- {
- AnsiString as_warning_msg;
- as_warning_msg = " Acoustic FIR tunning : read setup file : " + asSetupFile + " error ";
- Application->MessageBox( as_warning_msg.c_str(), "Warning", MB_OK );
- return false;
- }
- }
- //---------------------------------------------------------------------------
- bool TfrmFIRCoeffCal::write_8k_Acoustic_FIR_setup(
- AnsiString asSetupFile,
- AnsiString asExeName
- )
- {
- AnsiString asPath;
- TIniFile *ini;
- if ( getPathFromStr(asExeName, asPath) &&
- withPath( asPath) &&
- !withPath( asSetupFile)
- )
- {
- asSetupFile = asPath + asSetupFile;
- }
- try
- {
- ini = new TIniFile( asSetupFile );
- if(ini == NULL) return false;
- ini->WriteString("8k Acoustic FIR Tunning","Input file name", stInputFileName->Caption );
- ini->WriteString("8k Acoustic FIR Tunning","Output TX file name", stOutputTxFileName->Caption );
- ini->WriteString("8k Acoustic FIR Tunning","Output RX file name", stOutputRxFileName->Caption );
- SaveDirection();
- SaveBoundary();
- SaveEquipment();
- SaveFileFormat();
- delete ini;
- ini = NULL;
- return true;
- }
- catch (...)
- {
- AnsiString as_warning_msg;
- as_warning_msg = " Acoustic FIR tunning : write setup file : " + asSetupFile + " error ";
- Application->MessageBox( as_warning_msg.c_str(), "Warning", MB_OK );
- return false;
- }
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- void TfrmFIRCoeffCal::DisplayDirection( void )
- {
- AnsiString as_direction = read_AcousticFirDirection( "MF_setup.txt", Application->ExeName );
- if( as_direction.AnsiCompareIC("TX") == 0 )
- {
- rbTx->Checked = true;
- }
- else
- {
- rbRx->Checked = true;
- }
- }
- //---------------------------------------------------------------------------
- void TfrmFIRCoeffCal::SaveDirection( void )
- {
- if( rbTx->Checked )
- {
- write_AcousticFirDirection( "MF_setup.txt", Application->ExeName, "Tx" );
- }
- else
- {
- write_AcousticFirDirection( "MF_setup.txt", Application->ExeName, "Rx" );
- }
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- void TfrmFIRCoeffCal::DisplayBoundary(void)
- {
- AnsiString as_boundary = read_AcousticFirBoundary("MF_setup.txt", Application->ExeName);
- if (as_boundary.AnsiCompareIC("Spec") == 0)
- {
- cbBoundary->ItemIndex = ITEMIDX_BOUNDARY_SPEC;
- }
- else if (as_boundary.AnsiCompareIC("Good sound") == 0)
- {
- cbBoundary->ItemIndex = ITEMIDX_BOUNDARY_GOOD_SOUND;
- }
- else if (as_boundary.AnsiCompareIC("3G handset and headset") == 0)
- {
- cbBoundary->ItemIndex = ITEMIDX_BOUNDARY_3G_HANDSET_AND_HEADSET;
- }
- else if (as_boundary.AnsiCompareIC("3G handsfree desktop and vehicle") == 0)
- {
- cbBoundary->ItemIndex = ITEMIDX_BOUNDARY_3G_HANDSFREE_DESKTOP_AND_VEHICLE;
- }
- else if (as_boundary.AnsiCompareIC("3G handsfree handheld") == 0)
- {
- cbBoundary->ItemIndex = ITEMIDX_BOUNDARY_3G_HANDSFREE_HANDHELD;
- }
- else if (as_boundary.AnsiCompareIC("VOIP handset") == 0)
- {
- cbBoundary->ItemIndex = ITEMIDX_BOUNDARY_VOIP_HANDSET;
- }
- else if (as_boundary.AnsiCompareIC("VOIP headset") == 0)
- {
- cbBoundary->ItemIndex = ITEMIDX_BOUNDARY_VOIP_HEADSET;
- }
- else if (as_boundary.AnsiCompareIC("VOIP handsfree") == 0)
- {
- cbBoundary->ItemIndex = ITEMIDX_BOUNDARY_VOIP_HANDSFREE;
- }
- else if (as_boundary.AnsiCompareIC("Type 3.3") == 0)
- {
- cbBoundary->ItemIndex = ITEMIDX_BOUNDARY_TYPE_3_3;
- }
- else
- {
- cbBoundary->ItemIndex = ITEMIDX_BOUNDARY_SPEC;
- }
- }
- //---------------------------------------------------------------------------
- void TfrmFIRCoeffCal::SaveBoundary(void)
- {
- if (ITEMIDX_BOUNDARY_SPEC == cbBoundary->ItemIndex)
- {
- write_AcousticFirBoundary("MF_setup.txt", Application->ExeName, "Spec");
- }
- else if (ITEMIDX_BOUNDARY_GOOD_SOUND == cbBoundary->ItemIndex)
- {
- write_AcousticFirBoundary("MF_setup.txt", Application->ExeName, "Good sound");
- }
- else if (ITEMIDX_BOUNDARY_3G_HANDSET_AND_HEADSET == cbBoundary->ItemIndex)
- {
- write_AcousticFirBoundary("MF_setup.txt", Application->ExeName, "3G handset and headset");
- }
- else if (ITEMIDX_BOUNDARY_3G_HANDSFREE_DESKTOP_AND_VEHICLE == cbBoundary->ItemIndex)
- {
- write_AcousticFirBoundary("MF_setup.txt", Application->ExeName, "3G handsfree desktop and vehicle");
- }
- else if (ITEMIDX_BOUNDARY_3G_HANDSFREE_HANDHELD == cbBoundary->ItemIndex)
- {
- write_AcousticFirBoundary("MF_setup.txt", Application->ExeName, "3G handsfree handheld");
- }
- else if (ITEMIDX_BOUNDARY_VOIP_HANDSET == cbBoundary->ItemIndex)
- {
- write_AcousticFirBoundary("MF_setup.txt", Application->ExeName, "VOIP handset");
- }
- else if (ITEMIDX_BOUNDARY_VOIP_HEADSET == cbBoundary->ItemIndex)
- {
- write_AcousticFirBoundary("MF_setup.txt", Application->ExeName, "VOIP headset");
- }
- else if( ITEMIDX_BOUNDARY_VOIP_HANDSFREE == cbBoundary->ItemIndex )
- {
- write_AcousticFirBoundary( "MF_setup.txt", Application->ExeName, "VOIP handsfree");
- }
- else if (ITEMIDX_BOUNDARY_TYPE_3_3 == cbBoundary->ItemIndex)
- {
- write_AcousticFirBoundary("MF_setup.txt", Application->ExeName, "Type 3.3");
- }
- else
- {
- write_AcousticFirBoundary( "MF_setup.txt", Application->ExeName, "Spec" );
- }
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- void TfrmFIRCoeffCal::DisplayEquipment(void)
- {
- AnsiString as_equ = read_AcousticFirEquipment("MF_setup.txt", Application->ExeName);
- if (as_equ.AnsiCompareIC("Acqua") == 0)
- {
- rbAcqua->Checked = true;
- rbAcquaClick(NULL);
- }
- else if (as_equ.AnsiCompareIC("Microtronix") == 0)
- {
- rbMicrotronix->Checked = true;
- rbMicrotronixClick(NULL);
- }
- else if (as_equ.AnsiCompareIC("UPL") == 0)
- {
- rbUPL->Checked = true;
- rbUPLClick(NULL);
- }
- else if (as_equ.AnsiCompareIC("UPV") == 0)
- {
- m_rbUPV->Checked = true;
- m_rbUPVClick(NULL);
- }
- else
- {
- m_rbVita->Checked = true;
- m_rbVitaClick(NULL);
- }
- }
- //---------------------------------------------------------------------------
- void TfrmFIRCoeffCal::SaveEquipment(void)
- {
- if (rbAcqua->Checked)
- {
- write_AcousticFirEquipment("MF_setup.txt", Application->ExeName, "Acqua");
- }
- else if (rbMicrotronix->Checked)
- {
- write_AcousticFirEquipment("MF_setup.txt", Application->ExeName, "Microtronix");
- }
- else if (rbUPL->Checked)
- {
- write_AcousticFirEquipment("MF_setup.txt", Application->ExeName, "UPL");
- }
- else if (m_rbUPV->Checked)
- {
- write_AcousticFirEquipment("MF_setup.txt", Application->ExeName, "UPV");
- }
- else
- {
- write_AcousticFirEquipment("MF_setup.txt", Application->ExeName, "Vita");
- }
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- void TfrmFIRCoeffCal::DisplayFileFormat( void )
- {
- AnsiString as_direction = read_AcousticFirFileFormat( "MF_setup.txt", Application->ExeName );
- if( as_direction.AnsiCompareIC("Linear") == 0 )
- {
- rbLinear->Checked = true;
- }
- else
- {
- rbLogdB->Checked = true;
- }
- if (rbUPL->Checked || m_rbUPV->Checked)
- {
- rbLinear->Enabled = false;
- rbLogdB->Enabled = false;
- }
- else
- {
- rbLinear->Enabled = true;
- rbLogdB->Enabled = true;
- }
- }
- //---------------------------------------------------------------------------
- void TfrmFIRCoeffCal::SaveFileFormat( void )
- {
- if( rbLinear->Checked )
- {
- write_AcousticFirFileFormat( "MF_setup.txt", Application->ExeName, "Linear" );
- }
- else
- {
- write_AcousticFirFileFormat( "MF_setup.txt", Application->ExeName, "Log dB" );
- }
- }
- //------------------------------------------------------------------------------
- bool TfrmFIRCoeffCal::LoadTRCFile(char *filename)
- {
- AnsiString as_FullFileName;
- double min_y, max_y;
- // read TRC file
- if( ! SP_COEF_CAL_Object.REQ_Read_TRC_File( filename, &TrcScale, &OrgSpCoef) )
- {
- isTRCLoadOk = false;
- }
- else
- {
- isTRCLoadOk = true;
- }
- for (unsigned int i=0; i<OrgSpCoef.num; i++)
- {
- if (OrgSpCoef.MagdB[i] < -25)
- {
- OrgSpCoef.MagdB[i] = -25;
- OrgSpCoef.Mag[i] = pow( 10.0, -25.0/20.0 );
- }
- }
- // set to wanted array & UI wanted array
- if( OrgSpCoef.num > TOTAL_TRC_FREQ_NUM )
- {
- return false;
- }
- WantedSpCoef.num = OrgSpCoef.num;
- for (unsigned int i=0; i<OrgSpCoef.num; i++)
- {
- WantedSpCoef.Hz[i] = OrgSpCoef.Hz[i];
- WantedSpCoef.Mag[i] = OrgSpCoef.Mag[i];
- WantedSpCoef.MagdB[i] = OrgSpCoef.MagdB[i];
- UIWantedSpCoef.MagdB[i] = OrgSpCoef.MagdB[i];
- }
- GetMinMaxY( &OrgSpCoef, &min_y, &max_y );
- if( min_y == max_y || isTRCLoadOk == false || OrgSpCoef.num>TOTAL_TRC_FREQ_NUM)
- {
- PlotGrid(100, 4000, -20, 15);
- }
- else
- {
- PlotGrid( 100, 4000, min_y, max_y);
- }
- PlotBoundaryCurve();
- // Plot original curve
- PlotOrgCurve();
- // update editor
- UpdateEditor();
- UpdateSelectedLabel();
- UpdatecbExtraFreq(&WantedSpCoef);
- #if 0
- Updatecb1xxHz( &WantedSpCoef, SelectedSpCoef.index[0] );
- Updatecb2xxHz( &WantedSpCoef, SelectedSpCoef.index[1] );
- Updatecb3xxHz( &WantedSpCoef, SelectedSpCoef.index[2] );
- Updatecb5xxHz( &WantedSpCoef, SelectedSpCoef.index[3] );
- Updatecb6xxHz( &WantedSpCoef, SelectedSpCoef.index[4] );
- Updatecb7xxHz( &WantedSpCoef, SelectedSpCoef.index[5] );
- Updatecb8xxHz( &WantedSpCoef, SelectedSpCoef.index[6] );
- Updatecb1xxxHz( &WantedSpCoef, SelectedSpCoef.index[7] );
- Updatecb15xxHz( &WantedSpCoef, SelectedSpCoef.index[8] );
- Updatecb18xxHz( &WantedSpCoef, SelectedSpCoef.index[9] );
- Updatecb2xxxHz( &WantedSpCoef, SelectedSpCoef.index[10] );
- Updatecb25xxHz( &WantedSpCoef, SelectedSpCoef.index[11] );
- Updatecb3xxxHz( &WantedSpCoef, SelectedSpCoef.index[12] );
- Updatecb34xxHz( &WantedSpCoef, SelectedSpCoef.index[13] );
- Updatecb39xxHz( &WantedSpCoef, SelectedSpCoef.index[14] );
- #endif
- Updatecb1xxHz( &WantedSpCoef, 0 );
- Updatecb2xxHz( &WantedSpCoef, 0 );
- Updatecb3xxHz( &WantedSpCoef, 0 );
- Updatecb5xxHz( &WantedSpCoef, 0 );
- Updatecb6xxHz( &WantedSpCoef, 0 );
- Updatecb7xxHz( &WantedSpCoef, 0 );
- Updatecb8xxHz( &WantedSpCoef, 0 );
- Updatecb1xxxHz( &WantedSpCoef, 0 );
- Updatecb15xxHz( &WantedSpCoef, 0 );
- Updatecb18xxHz( &WantedSpCoef, 0 );
- Updatecb2xxxHz( &WantedSpCoef, 0 );
- Updatecb25xxHz( &WantedSpCoef, 0 );
- Updatecb3xxxHz( &WantedSpCoef, 0 );
- Updatecb34xxHz( &WantedSpCoef, 0 );
- Updatecb39xxHz( &WantedSpCoef, 0 );
- // old FIR coefficient
- if( rbTx->Checked )
- {
- //SP_COEF_CAL_Object.REQ_Read_FIR_File( "Tx_old_FIR", &Tx_old_FIR );
- as_FullFileName = getFullPathFileName( (AnsiString) "Tx_old_FIR" );
- if( SP_COEF_CAL_Object.REQ_Read_FIR_File( as_FullFileName.c_str(), m_b45TapSupport, &old_FIR ) == false )
- {
- Application->MessageBox( " Read Tx_old_FIR file fail" , "Error", MB_OK );
- return false;
- }
- //SP_COEF_CAL_Object.ReorderFirCoef( &Tx_old_FIR );
- SP_COEF_CAL_Object.ReorderFirCoef( &old_FIR );
- }
- else
- {
- // SP_COEF_CAL_Object.REQ_Read_FIR_File( "Rx_old_FIR", &Rx_old_FIR );
- as_FullFileName = getFullPathFileName( (AnsiString) "Rx_old_FIR" );
- if( SP_COEF_CAL_Object.REQ_Read_FIR_File( as_FullFileName.c_str(), m_b45TapSupport, &old_FIR ) == false )
- {
- Application->MessageBox( " Read Rx_old_FIR file fail" , "Error", MB_OK );
- return false;
- }
- // SP_COEF_CAL_Object.ReorderFirCoef( &Rx_old_FIR );
- SP_COEF_CAL_Object.ReorderFirCoef( &old_FIR );
- }
- // show Hz and dB and store index of Hz to dB's UserData
- // Getting UPL database
- // UPL_database.num = OrgSpCoef.num;
- // for( i=0; i<UPL_database.num; i++ )
- // {
- // UPL_database.Hz[i] = OrgSpCoef.Hz[i];
- // UPL_database.Mag[i] = OrgSpCoef.Mag[i];
- // UPL_database.MagdB[i] = OrgSpCoef.MagdB[i];
- // }
-
- btnIdealize->Enabled = true;
- btnRun->Enabled = true;
- sbAudioCal->Panels->Items[0]->Text = (AnsiString) " Load TRC file successfully";
- if( rbUPL->Checked )
- {
- stInputFileName->Caption = (AnsiString) filename;
- }
- return true;
- }
- //------------------------------------------------------------------------------
- bool TfrmFIRCoeffCal::LoadAcquaFile(char *i_filename)
- {
- char o_filename[1024];
- if (!SP_COEF_CAL_Object.AcquaFile_To_UplFile(i_filename, rbRx->Checked, rbLinear->Checked, o_filename))
- {
- isTRCLoadOk = false;
- return false;
- }
- stInputFileName->Caption = i_filename;
- if (!LoadTRCFile(o_filename))
- {
- return false;
- }
- return true;
- }
- //------------------------------------------------------------------------------
- bool TfrmFIRCoeffCal::LoadMicrotronixFile(char *i_filename)
- {
- char o_filename[1024];
- if (!SP_COEF_CAL_Object.MicrotronixFile_To_UplFile(i_filename, rbRx->Checked, rbLinear->Checked, o_filename))
- {
- isTRCLoadOk = false;
- return false;
- }
- stInputFileName->Caption = i_filename;
- if (!LoadTRCFile(o_filename))
- {
- return false;
- }
- return true;
- }
- //------------------------------------------------------------------------------
- bool TfrmFIRCoeffCal::LoadUpvFile(char *i_filename)
- {
- //char o_filename[1024];
- AnsiString as_i_filename;
- as_i_filename = (AnsiString) i_filename;
- AnsiString as_o_filename = as_i_filename + ".trc";
- if (!SP_COEF_CAL_Object.UpvFile_To_UplFile(i_filename, as_o_filename.c_str()))
- {
- isTRCLoadOk = false;
- return false;
- }
- stInputFileName->Caption = i_filename;
- if (!LoadTRCFile(as_o_filename.c_str()))
- {
- return false;
- }
- return true;
- }
- //------------------------------------------------------------------------------
- bool TfrmFIRCoeffCal::LoadVitaFile(char *i_filename)
- {
- char o_filename[1024];
- if (!SP_COEF_CAL_Object.VitaFile_To_UplFile(i_filename, rbRx->Checked, rbLinear->Checked, o_filename))
- {
- isTRCLoadOk = false;
- return false;
- }
- stInputFileName->Caption = i_filename;
- if (!LoadTRCFile(o_filename))
- {
- return false;
- }
- return true;
- }
- //--------------------------------------------------------------------------
- void __fastcall TfrmFIRCoeffCal::FormShow(TObject *Sender)
- {
- if( m_bFirstFormShow )
- {
- m_bFirstFormShow = false;
- read_8k_Acoustic_FIR_setup( "MF_setup.txt", Application->ExeName );
- if( rbTx->Checked )
- {
- btnSetupOutputTxFile->Enabled = true;
- btnSetupOutpuRxFile->Enabled = false;
- stOutputTxFileName->Enabled = true;
- stOutputRxFileName->Enabled = false;
- }
- else
- {
- btnSetupOutputTxFile->Enabled = false;
- btnSetupOutpuRxFile->Enabled = true;
- stOutputTxFileName->Enabled = false;
- stOutputRxFileName->Enabled = true;
- }
- PlotCurve( PLOT_GRID | PLOT_BOUNDARY_CURVE );
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmFIRCoeffCal::FormClose(TObject *Sender,
- TCloseAction &Action)
- {
- write_8k_Acoustic_FIR_setup( "MF_setup.txt", Application->ExeName );
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmFIRCoeffCal::mTimerTimer(TObject *Sender)
- {
- sbAudioCal->Panels->Items[0]->Text = (AnsiString) " Connect MATLAB timeout";
- Application->MessageBox( "Connect MATLAB timeout" , "Timeout", MB_OK );
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmFIRCoeffCal::rbSpecClick(TObject *Sender)
- {
- double min_y, max_y;
-
- m_iTxLimitFreq[0] = 100;
- m_iTxLimitFreq[1] = 200;
- m_iTxLimitFreq[2] = 300;
- m_iTxLimitFreq[3] = 1000;
- m_iTxLimitFreq[4] = 2000;
- m_iTxLimitFreq[5] = 3000;
- m_iTxLimitFreq[6] = 3400;
- m_iTxLimitFreq[7] = 4000;
- m_dTxUpLimit[0] = -12; // 100 Hz
- m_dTxUpLimit[1] = 0; // 200 Hz
- m_dTxUpLimit[2] = 0; // 300 Hz
- m_dTxUpLimit[3] = 0; // 1000 Hz
- m_dTxUpLimit[4] = 4; // 2000 Hz
- m_dTxUpLimit[5] = 4; // 3000 Hz
- m_dTxUpLimit[6] = 4; // 3400 Hz
- m_dTxUpLimit[7] = 0; // 4000 Hz
- m_dTxLowLimit[0] = -100; // 100 Hz
- m_dTxLowLimit[1] = -100; // 200 Hz
- m_dTxLowLimit[2] = -12; // 300 Hz
- m_dTxLowLimit[3] = -6; // 1000 Hz
- m_dTxLowLimit[4] = -6; // 2000 Hz
- m_dTxLowLimit[5] = -6; // 3000 Hz
- m_dTxLowLimit[6] = -9; // 3400 Hz
- m_dTxLowLimit[7] = -100; // 4000 Hz
- m_iRxLimitFreq[0] = 100;
- m_iRxLimitFreq[1] = 200;
- m_iRxLimitFreq[2] = 300;
- m_iRxLimitFreq[3] = 500;
- m_iRxLimitFreq[4] = 1000;
- m_iRxLimitFreq[5] = 3000;
- m_iRxLimitFreq[6] = 3400;
- m_iRxLimitFreq[7] = 4000;
- m_dRxUpLimit[0] = -12; // 100 Hz
- m_dRxUpLimit[1] = 0; // 200 Hz
- m_dRxUpLimit[2] = 2; // 300 Hz
- m_dRxUpLimit[3] = 2+(20*log10(500)-20*log10(300))*(0-2)/(20*log10(1000)-20*log10(300)); // 500 Hz
- m_dRxUpLimit[4] = 0; // 1000 Hz
- m_dRxUpLimit[5] = 2; // 3000 Hz
- m_dRxUpLimit[6] = 2; // 3400 Hz
- m_dRxUpLimit[7] = 2; // 4000 Hz
- m_dRxLowLimit[0] = -100; // 100 Hz
- m_dRxLowLimit[1] = -100; // 200 Hz
- m_dRxLowLimit[2] = -7; // 300 Hz
- m_dRxLowLimit[3] = -5; // 500 Hz
- m_dRxLowLimit[4] = -5; // 1000 Hz
- m_dRxLowLimit[5] = -5; // 3000 Hz
- m_dRxLowLimit[6] = -10; // 3400 Hz
- m_dRxLowLimit[7] = -100; // 4000 Hz
- GetMinMaxY( &OrgSpCoef, &min_y, &max_y );
- if( min_y == max_y || isTRCLoadOk == false || OrgSpCoef.num>TOTAL_TRC_FREQ_NUM)
- {
- PlotGrid(100, 4000, -20, 15);
- }
- else
- {
- PlotGrid( 100, 4000, min_y, max_y);
- }
- PlotBoundaryCurve();
- if( isOrgCurvePlot )
- {
- PlotOrgCurve();
- }
-
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmFIRCoeffCal::rbGoodSoundClick(TObject *Sender)
- {
- double min_y, max_y;
- m_iTxLimitFreq[ 0] = 100;
- m_iTxLimitFreq[ 1] = 200;
- m_iTxLimitFreq[ 2] = 300;
- m_iTxLimitFreq[ 3] = 500;
- m_iTxLimitFreq[ 4] = 600;
- m_iTxLimitFreq[ 5] = 700;
- m_iTxLimitFreq[ 6] = 800;
- m_iTxLimitFreq[ 7] = 1000;
- m_iTxLimitFreq[ 8] = 1300;
- m_iTxLimitFreq[ 9] = 1800;
- m_iTxLimitFreq[10] = 2000;
- m_iTxLimitFreq[11] = 2500;
- m_iTxLimitFreq[12] = 3000;
- m_iTxLimitFreq[13] = 3400;
- m_iTxLimitFreq[14] = 3950;
- m_iRxLimitFreq[ 0] = 100;
- m_iRxLimitFreq[ 1] = 200;
- m_iRxLimitFreq[ 2] = 300;
- m_iRxLimitFreq[ 3] = 500;
- m_iRxLimitFreq[ 4] = 600;
- m_iRxLimitFreq[ 5] = 700;
- m_iRxLimitFreq[ 6] = 800;
- m_iRxLimitFreq[ 7] = 1000;
- m_iRxLimitFreq[ 8] = 1300;
- m_iRxLimitFreq[ 9] = 1800;
- m_iRxLimitFreq[10] = 2000;
- m_iRxLimitFreq[11] = 2500;
- m_iRxLimitFreq[12] = 3000;
- m_iRxLimitFreq[13] = 3400;
- m_iRxLimitFreq[14] = 3950;
- m_dTxUpLimit[0] = -19; // 100 Hz
- m_dTxUpLimit[1] = -2; // 200 Hz
- m_dTxUpLimit[2] = 11; // 300 Hz
- m_dTxUpLimit[3] = 5; // 500 Hz
- m_dTxUpLimit[4] = 4; // 600 Hz
- m_dTxUpLimit[5] = 4; // 700 Hz
- m_dTxUpLimit[6] = 3; // 800 Hz
- m_dTxUpLimit[7] = 1; // 1000 Hz
- m_dTxUpLimit[8] = -5; // 1300 Hz
- m_dTxUpLimit[9] = 2.8; // 1800 Hz
- m_dTxUpLimit[10] = 2.8; // 2000 Hz
- m_dTxUpLimit[11] = 5; // 2500 Hz
- m_dTxUpLimit[12] = 6; // 3000 Hz
- m_dTxUpLimit[13] = -1; // 3400 Hz
- m_dTxUpLimit[14] = -40.2; // 3950 Hz
- m_dTxLowLimit[0] = -25; // 100 Hz
- m_dTxLowLimit[1] = -8; // 200 Hz
- m_dTxLowLimit[2] = 5; // 300 Hz
- m_dTxLowLimit[3] = -1; // 500 Hz
- m_dTxLowLimit[4] = -2; // 600 Hz
- m_dTxLowLimit[5] = -2; // 700 Hz
- m_dTxLowLimit[6] = -3; // 800 Hz
- m_dTxLowLimit[7] = -5; // 1000 Hz
- m_dTxLowLimit[8] = -11; // 1300 Hz
- m_dTxLowLimit[9] = -3.2; // 1800 Hz
- m_dTxLowLimit[10] = -3.2; // 2000 Hz
- m_dTxLowLimit[11] = -1; // 2500 Hz
- m_dTxLowLimit[12] = 0; // 3000 Hz
- m_dTxLowLimit[13] = -7; // 3400 Hz
- m_dTxLowLimit[14] = -46.2; // 3950 Hz
- m_dRxUpLimit[0] = -19; // 100 Hz
- m_dRxUpLimit[1] = -2; // 200 Hz
- m_dRxUpLimit[2] = 11; // 300 Hz
- m_dRxUpLimit[3] = 5; // 500 Hz
- m_dRxUpLimit[4] = 4; // 600 Hz
- m_dRxUpLimit[5] = 4; // 700 Hz
- m_dRxUpLimit[6] = 3; // 800 Hz
- m_dRxUpLimit[7] = -2; // 1000 Hz
- m_dRxUpLimit[8] = -5; // 1300 Hz
- m_dRxUpLimit[9] = 2.8; // 1800 Hz
- m_dRxUpLimit[10] = 2.8; // 2000 Hz
- m_dRxUpLimit[11] = 5; // 2500 Hz
- m_dRxUpLimit[12] = 6; // 3000 Hz
- m_dRxUpLimit[13] = -1; // 3400 Hz
- m_dRxUpLimit[14] = -40.2; // 3950 Hz
- m_dRxLowLimit[0] = -25; // 100 Hz
- m_dRxLowLimit[1] = -8; // 200 Hz
- m_dRxLowLimit[2] = 5; // 300 Hz
- m_dRxLowLimit[3] = -1; // 500 Hz
- m_dRxLowLimit[4] = -2; // 600 Hz
- m_dRxLowLimit[5] = -2; // 700 Hz
- m_dRxLowLimit[6] = -3; // 800 Hz
- m_dRxLowLimit[7] = -5; // 1000 Hz
- m_dRxLowLimit[8] = -11; // 1300 Hz
- m_dRxLowLimit[9] = -3.2; // 1800 Hz
- m_dRxLowLimit[10] = -3.2; // 2000 Hz
- m_dRxLowLimit[11] = -1; // 2500 Hz
- m_dRxLowLimit[12] = 0; // 3000 Hz
- m_dRxLowLimit[13] = -7; // 3400 Hz
- m_dRxLowLimit[14] = -46.2; // 3950 Hz
- GetMinMaxY( &OrgSpCoef, &min_y, &max_y );
- if( min_y == max_y || isTRCLoadOk == false || OrgSpCoef.num>TOTAL_TRC_FREQ_NUM)
- {
- PlotGrid(100, 4000, -20, 15);
- }
- else
- {
- PlotGrid( 100, 4000, min_y, max_y);
- }
- PlotBoundaryCurve();
- if( isOrgCurvePlot )
- {
- PlotOrgCurve();
- }
-
- }
- //---------------------------------------------------------------------------
- void TfrmFIRCoeffCal::Req_freqz( void )
- {
- SP_COEF_CAL_Object.freqz( m_b45TapSupport, &old_FIR_norm, &ProcessSpCoef, 8000.0, &OldFirSpCoef );
- }
- //--------------------------------------------------------------------------
- void __fastcall TfrmFIRCoeffCal::edtFirScaleCheck(TObject *Sender)
- {
- AnsiString text;
- float data;
- int band;
- TEdit *edit = (TEdit*)Sender;
- char hint[] = "value shall be 0.5 ~ 1.0";
- text = edit->Text;
- if( !IsValidFirScale( text, data ) )
- {
- edit->Text = 0;
- ShowHintLabel( edit, hint );
- edit->SetFocus();
- return;
- }
- FirScale = data;
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmFIRCoeffCal::cb1xxHzChange(TObject *Sender)
- {
- char str[256];
- int index;
- double Hz;
- getHzFromStr( cb1xxHz->Text, Hz );
- index = getWantedSpCoefIndex(Hz, &WantedSpCoef);
- SelectedSpCoef.index[0] = index;
- SelectedSpCoef.Hz[0] = WantedSpCoef.Hz[ SelectedSpCoef.index[0] ];
- m_iWantedHz[0] = SelectedSpCoef.Hz[0];
- SelectedSpCoef.MagdB[0] = WantedSpCoef.MagdB[ SelectedSpCoef.index[0] ];
- sprintf(str, "%.3f", SelectedSpCoef.MagdB[0]);
- edt1xxHzdB->Text = (AnsiString ) str;
- edt1xxHzdBExit( this );
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmFIRCoeffCal::cb2xxHzChange(TObject *Sender)
- {
- char str[256];
- int index;
- double Hz;
- getHzFromStr( cb2xxHz->Text, Hz );
- index = getWantedSpCoefIndex(Hz, &WantedSpCoef);
- SelectedSpCoef.index[1] = index;
- SelectedSpCoef.Hz[1] = WantedSpCoef.Hz[ SelectedSpCoef.index[1] ];
- m_iWantedHz[1] = SelectedSpCoef.Hz[1];
- SelectedSpCoef.MagdB[1] = WantedSpCoef.MagdB[ SelectedSpCoef.index[1] ];
- sprintf(str, "%.3f", SelectedSpCoef.MagdB[1]);
- edt2xxHzdB->Text = (AnsiString ) str;
- edt2xxHzdBExit( this );
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmFIRCoeffCal::cb3xxHzChange(TObject *Sender)
- {
- char str[256];
- int index;
- double Hz;
- getHzFromStr( cb3xxHz->Text, Hz );
- index = getWantedSpCoefIndex(Hz, &WantedSpCoef);
- SelectedSpCoef.index[2] = index;
- SelectedSpCoef.Hz[2] = WantedSpCoef.Hz[ SelectedSpCoef.index[2] ];
- m_iWantedHz[2] = SelectedSpCoef.Hz[2];
- SelectedSpCoef.MagdB[2] = WantedSpCoef.MagdB[ SelectedSpCoef.index[2] ];
- sprintf(str, "%.3f", SelectedSpCoef.MagdB[2]);
- edt3xxHzdB->Text = (AnsiString ) str;
- edt3xxHzdBExit( this );
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmFIRCoeffCal::cb5xxHzChange(TObject *Sender)
- {
- char str[256];
- int index;
- double Hz;
- getHzFromStr( cb5xxHz->Text, Hz );
- index = getWantedSpCoefIndex(Hz, &WantedSpCoef);
- SelectedSpCoef.index[3] = index;
- SelectedSpCoef.Hz[3] = WantedSpCoef.Hz[ SelectedSpCoef.index[3] ];
- m_iWantedHz[3] = SelectedSpCoef.Hz[3];
- SelectedSpCoef.MagdB[3] = WantedSpCoef.MagdB[ SelectedSpCoef.index[3] ];
- sprintf(str, "%.3f", SelectedSpCoef.MagdB[3]);
- edt5xxHzdB->Text = (AnsiString ) str;
- edt5xxHzdBExit( this );
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmFIRCoeffCal::cb6xxHzChange(TObject *Sender)
- {
- char str[256];
- int index;
- double Hz;
- getHzFromStr( cb6xxHz->Text, Hz );
- index = getWantedSpCoefIndex(Hz, &WantedSpCoef);
- SelectedSpCoef.index[4] = index;
- SelectedSpCoef.Hz[4] = WantedSpCoef.Hz[ SelectedSpCoef.index[4] ];
- m_iWantedHz[4] = SelectedSpCoef.Hz[4];
- SelectedSpCoef.MagdB[4] = WantedSpCoef.MagdB[ SelectedSpCoef.index[4] ];
- sprintf(str, "%.3f", SelectedSpCoef.MagdB[4]);
- edt6xxHzdB->Text = (AnsiString ) str;
- edt6xxHzdBExit( this );
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmFIRCoeffCal::cb7xxHzChange(TObject *Sender)
- {
- char str[256];
- int index;
- double Hz;
- getHzFromStr( cb7xxHz->Text, Hz );
- index = getWantedSpCoefIndex(Hz, &WantedSpCoef);
- SelectedSpCoef.index[5] = index;
- SelectedSpCoef.Hz[5] = WantedSpCoef.Hz[ SelectedSpCoef.index[5] ];
- m_iWantedHz[5] = SelectedSpCoef.Hz[5];
- SelectedSpCoef.MagdB[5] = WantedSpCoef.MagdB[ SelectedSpCoef.index[5] ];
- sprintf(str, "%.3f", SelectedSpCoef.MagdB[5]);
- edt7xxHzdB->Text = (AnsiString ) str;
- edt7xxHzdBExit( this );
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmFIRCoeffCal::cb8xxHzChange(TObject *Sender)
- {
- char str[256];
- int index;
- double Hz;
- getHzFromStr( cb8xxHz->Text, Hz );
- index = getWantedSpCoefIndex(Hz, &WantedSpCoef);
- SelectedSpCoef.index[6] = index;
- SelectedSpCoef.Hz[6] = WantedSpCoef.Hz[ SelectedSpCoef.index[6] ];
- m_iWantedHz[6] = SelectedSpCoef.Hz[6];
- SelectedSpCoef.MagdB[6] = WantedSpCoef.MagdB[ SelectedSpCoef.index[6] ];
- sprintf(str, "%.3f", SelectedSpCoef.MagdB[6]);
- edt8xxHzdB->Text = (AnsiString ) str;
- edt8xxHzdBExit( this );
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmFIRCoeffCal::cb1xxxHzChange(TObject *Sender)
- {
- char str[256];
- int index;
- double Hz;
- getHzFromStr( cb1xxxHz->Text, Hz );
- index = getWantedSpCoefIndex(Hz, &WantedSpCoef);
- SelectedSpCoef.index[7] = index;
- SelectedSpCoef.Hz[7] = WantedSpCoef.Hz[ SelectedSpCoef.index[7] ];
- m_iWantedHz[7] = SelectedSpCoef.Hz[7];
- SelectedSpCoef.MagdB[7] = WantedSpCoef.MagdB[ SelectedSpCoef.index[7] ];
- sprintf(str, "%.3f", SelectedSpCoef.MagdB[7]);
- edt1xxxHzdB->Text = (AnsiString ) str;
- edt1xxxHzdBExit( this );
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmFIRCoeffCal::cb13xxHzChange(TObject *Sender)
- {
- char str[256];
- int index;
- double Hz;
- getHzFromStr( cb13xxHz->Text, Hz );
- index = getWantedSpCoefIndex(Hz, &WantedSpCoef);
- SelectedSpCoef.index[8] = index;
- SelectedSpCoef.Hz[8] = WantedSpCoef.Hz[ SelectedSpCoef.index[8] ];
- m_iWantedHz[8] = SelectedSpCoef.Hz[8];
- SelectedSpCoef.MagdB[8] = WantedSpCoef.MagdB[ SelectedSpCoef.index[8] ];
- sprintf(str, "%.3f", SelectedSpCoef.MagdB[8]);
- edt13xxHzdB->Text = (AnsiString ) str;
- edt13xxHzdBExit( this );
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmFIRCoeffCal::cb18xxHzChange(TObject *Sender)
- {
- char str[256];
- int index;
- double Hz;
- getHzFromStr( cb18xxHz->Text, Hz );
- index = getWantedSpCoefIndex(Hz, &WantedSpCoef);
- SelectedSpCoef.index[9] = index;
- SelectedSpCoef.Hz[9] = WantedSpCoef.Hz[ SelectedSpCoef.index[9] ];
- m_iWantedHz[9] = SelectedSpCoef.Hz[9];
- SelectedSpCoef.MagdB[9] = WantedSpCoef.MagdB[ SelectedSpCoef.index[9] ];
- sprintf(str, "%.3f", SelectedSpCoef.MagdB[9]);
- edt18xxHzdB->Text = (AnsiString ) str;
- edt18xxHzdBExit( this );
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmFIRCoeffCal::cb2xxxHzChange(TObject *Sender)
- {
- char str[256];
- int index;
- double Hz;
- getHzFromStr( cb2xxxHz->Text, Hz );
- index = getWantedSpCoefIndex(Hz, &WantedSpCoef);
- SelectedSpCoef.index[10] = index;
- SelectedSpCoef.Hz[10] = WantedSpCoef.Hz[ SelectedSpCoef.index[10] ];
- m_iWantedHz[10] = SelectedSpCoef.Hz[10];
- SelectedSpCoef.MagdB[10] = WantedSpCoef.MagdB[ SelectedSpCoef.index[10] ];
- sprintf(str, "%.3f", SelectedSpCoef.MagdB[10]);
- edt2xxxHzdB->Text = (AnsiString ) str;
- edt2xxxHzdBExit( this );
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmFIRCoeffCal::cb25xxHzChange(TObject *Sender)
- {
- char str[256];
- int index;
- double Hz;
- getHzFromStr( cb25xxHz->Text, Hz );
- index = getWantedSpCoefIndex(Hz, &WantedSpCoef);
- SelectedSpCoef.index[11] = index;
- SelectedSpCoef.Hz[11] = WantedSpCoef.Hz[ SelectedSpCoef.index[11] ];
- m_iWantedHz[11] = SelectedSpCoef.Hz[11];
- SelectedSpCoef.MagdB[11] = WantedSpCoef.MagdB[ SelectedSpCoef.index[11] ];
- sprintf(str, "%.3f", SelectedSpCoef.MagdB[11]);
- edt25xxHzdB->Text = (AnsiString ) str;
- edt25xxHzdBExit( this );
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmFIRCoeffCal::cb3xxxHzChange(TObject *Sender)
- {
- char str[256];
- int index;
- double Hz;
- getHzFromStr( cb3xxxHz->Text, Hz );
- index = getWantedSpCoefIndex(Hz, &WantedSpCoef);
- SelectedSpCoef.index[12] = index;
- SelectedSpCoef.Hz[12] = WantedSpCoef.Hz[ SelectedSpCoef.index[12] ];
- m_iWantedHz[12] = SelectedSpCoef.Hz[12];
- SelectedSpCoef.MagdB[12] = WantedSpCoef.MagdB[ SelectedSpCoef.index[12] ];
- sprintf(str, "%.3f", SelectedSpCoef.MagdB[12]);
- edt3xxxHzdB->Text = (AnsiString ) str;
- edt3xxxHzdBExit( this );
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmFIRCoeffCal::cb34xxHzChange(TObject *Sender)
- {
- char str[256];
- int index;
- double Hz;
- getHzFromStr( cb34xxHz->Text, Hz );
- index = getWantedSpCoefIndex(Hz, &WantedSpCoef);
- SelectedSpCoef.index[13] = index;
- SelectedSpCoef.Hz[13] = WantedSpCoef.Hz[ SelectedSpCoef.index[13] ];
- m_iWantedHz[13] = SelectedSpCoef.Hz[13];
- SelectedSpCoef.MagdB[13] = WantedSpCoef.MagdB[ SelectedSpCoef.index[13] ];
- sprintf(str, "%.3f", SelectedSpCoef.MagdB[13]);
- edt34xxHzdB->Text = (AnsiString ) str;
- edt34xxHzdBExit( this );
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmFIRCoeffCal::cb39xxHzChange(TObject *Sender)
- {
- char str[256];
- int index;
- double Hz;
- getHzFromStr( cb39xxHz->Text, Hz );
- index = getWantedSpCoefIndex(Hz, &WantedSpCoef);
- SelectedSpCoef.index[14] = index;
- SelectedSpCoef.Hz[14] = WantedSpCoef.Hz[ SelectedSpCoef.index[14] ];
- m_iWantedHz[14] = SelectedSpCoef.Hz[14];
- SelectedSpCoef.MagdB[14] = WantedSpCoef.MagdB[ SelectedSpCoef.index[14] ];
- sprintf(str, "%.3f", SelectedSpCoef.MagdB[14]);
- edt39xxHzdB->Text = (AnsiString ) str;
- edt39xxHzdBExit( this );
- }
- void __fastcall TfrmFIRCoeffCal::HintTimerTimer(TObject *Sender)
- {
- HintTimer->Enabled = false;
- lblHint->Visible = false;
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmFIRCoeffCal::rbUPLClick(TObject *Sender)
- {
- gbFileFormat->Visible = false;
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmFIRCoeffCal::m_rbUPVClick(TObject *Sender)
- {
- gbFileFormat->Visible = false;
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmFIRCoeffCal::rbAcquaClick(TObject *Sender)
- {
- gbFileFormat->Visible = true;
- rbLinear->Enabled = true;
- rbLogdB->Enabled = true;
- }
- //---------------------------------------------------------------------------
- void TfrmFIRCoeffCal::Set_Boundary(void)
- {
- switch (cbBoundary->ItemIndex)
- {
- case ITEMIDX_BOUNDARY_SPEC:
- {
- m_iTxLimitNum = 8;
- m_iRxLimitNum = 8;
- m_iTxLimitFreq[0] = 100;
- m_iTxLimitFreq[1] = 200;
- m_iTxLimitFreq[2] = 300;
- m_iTxLimitFreq[3] = 1000;
- m_iTxLimitFreq[4] = 2000;
- m_iTxLimitFreq[5] = 3000;
- m_iTxLimitFreq[6] = 3400;
- m_iTxLimitFreq[7] = 4000;
- m_dTxUpLimit[0] = -12; // 100 Hz
- m_dTxUpLimit[1] = 0; // 200 Hz
- m_dTxUpLimit[2] = 0; // 300 Hz
- m_dTxUpLimit[3] = 0; // 1000 Hz
- m_dTxUpLimit[4] = 4; // 2000 Hz
- m_dTxUpLimit[5] = 4; // 3000 Hz
- m_dTxUpLimit[6] = 4; // 3400 Hz
- m_dTxUpLimit[7] = 0; // 4000 Hz
- m_dTxLowLimit[0] = -100; // 100 Hz
- m_dTxLowLimit[1] = -100; // 200 Hz
- m_dTxLowLimit[2] = -12; // 300 Hz
- m_dTxLowLimit[3] = -6; // 1000 Hz
- m_dTxLowLimit[4] = -6; // 2000 Hz
- m_dTxLowLimit[5] = -6; // 3000 Hz
- m_dTxLowLimit[6] = -9; // 3400 Hz
- m_dTxLowLimit[7] = -100; // 4000 Hz
- m_iRxLimitFreq[0] = 100;
- m_iRxLimitFreq[1] = 200;
- m_iRxLimitFreq[2] = 300;
- m_iRxLimitFreq[3] = 500;
- m_iRxLimitFreq[4] = 1000;
- m_iRxLimitFreq[5] = 3000;
- m_iRxLimitFreq[6] = 3400;
- m_iRxLimitFreq[7] = 4000;
- m_dRxUpLimit[0] = -12; // 100 Hz
- m_dRxUpLimit[1] = 0; // 200 Hz
- m_dRxUpLimit[2] = 2; // 300 Hz
- m_dRxUpLimit[3] = 2+(20*log10(500)-20*log10(300))*(0-2)/(20*log10(1000)-20*log10(300)); // 500 Hz
- m_dRxUpLimit[4] = 0; // 1000 Hz
- m_dRxUpLimit[5] = 2; // 3000 Hz
- m_dRxUpLimit[6] = 2; // 3400 Hz
- m_dRxUpLimit[7] = 2; // 4000 Hz
- m_dRxLowLimit[0] = -100; // 100 Hz
- m_dRxLowLimit[1] = -100; // 200 Hz
- m_dRxLowLimit[2] = -7; // 300 Hz
- m_dRxLowLimit[3] = -5; // 500 Hz
- m_dRxLowLimit[4] = -5; // 1000 Hz
- m_dRxLowLimit[5] = -5; // 3000 Hz
- m_dRxLowLimit[6] = -10; // 3400 Hz
- m_dRxLowLimit[7] = -100; // 4000 Hz
- }
- break;
- case ITEMIDX_BOUNDARY_GOOD_SOUND:
- {
- m_iTxLimitNum = 15;
- m_iRxLimitNum = 15;
- m_iTxLimitFreq[ 0] = 100;
- m_iTxLimitFreq[ 1] = 200;
- m_iTxLimitFreq[ 2] = 300;
- m_iTxLimitFreq[ 3] = 500;
- m_iTxLimitFreq[ 4] = 600;
- m_iTxLimitFreq[ 5] = 700;
- m_iTxLimitFreq[ 6] = 800;
- m_iTxLimitFreq[ 7] = 1000;
- m_iTxLimitFreq[ 8] = 1300;
- m_iTxLimitFreq[ 9] = 1800;
- m_iTxLimitFreq[10] = 2000;
- m_iTxLimitFreq[11] = 2500;
- m_iTxLimitFreq[12] = 3000;
- m_iTxLimitFreq[13] = 3400;
- m_iTxLimitFreq[14] = 3950;
- m_iRxLimitFreq[ 0] = 100;
- m_iRxLimitFreq[ 1] = 200;
- m_iRxLimitFreq[ 2] = 300;
- m_iRxLimitFreq[ 3] = 500;
- m_iRxLimitFreq[ 4] = 600;
- m_iRxLimitFreq[ 5] = 700;
- m_iRxLimitFreq[ 6] = 800;
- m_iRxLimitFreq[ 7] = 1000;
- m_iRxLimitFreq[ 8] = 1300;
- m_iRxLimitFreq[ 9] = 1800;
- m_iRxLimitFreq[10] = 2000;
- m_iRxLimitFreq[11] = 2500;
- m_iRxLimitFreq[12] = 3000;
- m_iRxLimitFreq[13] = 3400;
- m_iRxLimitFreq[14] = 3950;
- m_dTxUpLimit[0] = -19; // 100 Hz
- m_dTxUpLimit[1] = -2; // 200 Hz
- m_dTxUpLimit[2] = 11; // 300 Hz
- m_dTxUpLimit[3] = 5; // 500 Hz
- m_dTxUpLimit[4] = 4; // 600 Hz
- m_dTxUpLimit[5] = 4; // 700 Hz
- m_dTxUpLimit[6] = 3; // 800 Hz
- m_dTxUpLimit[7] = 1; // 1000 Hz
- m_dTxUpLimit[8] = -5; // 1300 Hz
- m_dTxUpLimit[9] = 2.8; // 1800 Hz
- m_dTxUpLimit[10] = 2.8; // 2000 Hz
- m_dTxUpLimit[11] = 5; // 2500 Hz
- m_dTxUpLimit[12] = 6; // 3000 Hz
- m_dTxUpLimit[13] = -1; // 3400 Hz
- m_dTxUpLimit[14] = -40.2; // 3950 Hz
- m_dTxLowLimit[0] = -25; // 100 Hz
- m_dTxLowLimit[1] = -8; // 200 Hz
- m_dTxLowLimit[2] = 5; // 300 Hz
- m_dTxLowLimit[3] = -1; // 500 Hz
- m_dTxLowLimit[4] = -2; // 600 Hz
- m_dTxLowLimit[5] = -2; // 700 Hz
- m_dTxLowLimit[6] = -3; // 800 Hz
- m_dTxLowLimit[7] = -5; // 1000 Hz
- m_dTxLowLimit[8] = -11; // 1300 Hz
- m_dTxLowLimit[9] = -3.2; // 1800 Hz
- m_dTxLowLimit[10] = -3.2; // 2000 Hz
- m_dTxLowLimit[11] = -1; // 2500 Hz
- m_dTxLowLimit[12] = 0; // 3000 Hz
- m_dTxLowLimit[13] = -7; // 3400 Hz
- m_dTxLowLimit[14] = -46.2; // 3950 Hz
- m_dRxUpLimit[0] = -19; // 100 Hz
- m_dRxUpLimit[1] = -2; // 200 Hz
- m_dRxUpLimit[2] = 11; // 300 Hz
- m_dRxUpLimit[3] = 5; // 500 Hz
- m_dRxUpLimit[4] = 4; // 600 Hz
- m_dRxUpLimit[5] = 4; // 700 Hz
- m_dRxUpLimit[6] = 3; // 800 Hz
- m_dRxUpLimit[7] = -2; // 1000 Hz
- m_dRxUpLimit[8] = -5; // 1300 Hz
- m_dRxUpLimit[9] = 2.8; // 1800 Hz
- m_dRxUpLimit[10] = 2.8; // 2000 Hz
- m_dRxUpLimit[11] = 5; // 2500 Hz
- m_dRxUpLimit[12] = 6; // 3000 Hz
- m_dRxUpLimit[13] = -1; // 3400 Hz
- m_dRxUpLimit[14] = -40.2; // 3950 Hz
- m_dRxLowLimit[0] = -25; // 100 Hz
- m_dRxLowLimit[1] = -8; // 200 Hz
- m_dRxLowLimit[2] = 5; // 300 Hz
- m_dRxLowLimit[3] = -1; // 500 Hz
- m_dRxLowLimit[4] = -2; // 600 Hz
- m_dRxLowLimit[5] = -2; // 700 Hz
- m_dRxLowLimit[6] = -3; // 800 Hz
- m_dRxLowLimit[7] = -5; // 1000 Hz
- m_dRxLowLimit[8] = -11; // 1300 Hz
- m_dRxLowLimit[9] = -3.2; // 1800 Hz
- m_dRxLowLimit[10] = -3.2; // 2000 Hz
- m_dRxLowLimit[11] = -1; // 2500 Hz
- m_dRxLowLimit[12] = 0; // 3000 Hz
- m_dRxLowLimit[13] = -7; // 3400 Hz
- m_dRxLowLimit[14] = -46.2; // 3950 Hz
- }
- break;
- case ITEMIDX_BOUNDARY_3G_HANDSET_AND_HEADSET:
- {
- m_iTxLimitNum = 8;
- m_iRxLimitNum = 8;
- m_iTxLimitFreq[0] = 100;
- m_iTxLimitFreq[1] = 200;
- m_iTxLimitFreq[2] = 300;
- m_iTxLimitFreq[3] = 1000;
- m_iTxLimitFreq[4] = 2000;
- m_iTxLimitFreq[5] = 3000;
- m_iTxLimitFreq[6] = 3400;
- m_iTxLimitFreq[7] = 4000;
- m_dTxUpLimit[0] = -12; // 100 Hz
- m_dTxUpLimit[1] = 0; // 200 Hz
- m_dTxUpLimit[2] = 0; // 300 Hz
- m_dTxUpLimit[3] = 0; // 1000 Hz
- m_dTxUpLimit[4] = 4; // 2000 Hz
- m_dTxUpLimit[5] = 4; // 3000 Hz
- m_dTxUpLimit[6] = 4; // 3400 Hz
- m_dTxUpLimit[7] = 0; // 4000 Hz
- m_dTxLowLimit[0] = -100; // 100 Hz
- m_dTxLowLimit[1] = -100; // 200 Hz
- m_dTxLowLimit[2] = -12; // 300 Hz
- m_dTxLowLimit[3] = -6; // 1000 Hz
- m_dTxLowLimit[4] = -6; // 2000 Hz
- m_dTxLowLimit[5] = -6; // 3000 Hz
- m_dTxLowLimit[6] = -9; // 3400 Hz
- m_dTxLowLimit[7] = -100; // 4000 Hz
- m_iRxLimitFreq[0] = 70;
- m_iRxLimitFreq[1] = 200;
- m_iRxLimitFreq[2] = 300;
- m_iRxLimitFreq[3] = 500;
- m_iRxLimitFreq[4] = 1000;
- m_iRxLimitFreq[5] = 3000;
- m_iRxLimitFreq[6] = 3400;
- m_iRxLimitFreq[7] = 4000;
- m_dRxUpLimit[0] = -10; // 70 Hz
- m_dRxUpLimit[1] = 2; // 200 Hz
- m_dRxUpLimit[2] = 2; // 300 Hz
- m_dRxUpLimit[3] = 2; // 500 Hz
- m_dRxUpLimit[4] = 2; // 1000 Hz
- m_dRxUpLimit[5] = 2; // 3000 Hz
- m_dRxUpLimit[6] = 2; // 3400 Hz
- m_dRxUpLimit[7] = 2; // 4000 Hz
- m_dRxLowLimit[0] = -100; // 70 Hz
- m_dRxLowLimit[1] = -100; // 200 Hz
- m_dRxLowLimit[2] = -9; // 300 Hz
- m_dRxLowLimit[3] = -8.15; // 500 Hz
- m_dRxLowLimit[4] = -7; // 1000 Hz
- m_dRxLowLimit[5] = -11.49; // 3000 Hz
- m_dRxLowLimit[6] = -12; // 3400 Hz
- m_dRxLowLimit[7] = -100; // 4000 Hz
- }
- break;
- case ITEMIDX_BOUNDARY_3G_HANDSFREE_DESKTOP_AND_VEHICLE:
- {
- m_iTxLimitNum = 14;
- m_iRxLimitNum = 14;
- m_iTxLimitFreq[0] = 200;
- m_iTxLimitFreq[1] = 250;
- m_iTxLimitFreq[2] = 315;
- m_iTxLimitFreq[3] = 400;
- m_iTxLimitFreq[4] = 500;
- m_iTxLimitFreq[5] = 630;
- m_iTxLimitFreq[6] = 800;
- m_iTxLimitFreq[7] = 1000;
- m_iTxLimitFreq[8] = 1300;
- m_iTxLimitFreq[9] = 1600;
- m_iTxLimitFreq[10] = 2000;
- m_iTxLimitFreq[11] = 2500;
- m_iTxLimitFreq[12] = 3100;
- m_iTxLimitFreq[13] = 4000;
- m_dTxUpLimit[0] = 0; // 200 Hz
- m_dTxUpLimit[1] = 0; // 250 Hz
- m_dTxUpLimit[2] = 0; // 315 Hz
- m_dTxUpLimit[3] = 0; // 400 Hz
- m_dTxUpLimit[4] = 0; // 500 Hz
- m_dTxUpLimit[5] = 0; // 630 Hz
- m_dTxUpLimit[6] = 0; // 800 Hz
- m_dTxUpLimit[7] = 0; // 1000 Hz
- m_dTxUpLimit[8] = 2; // 1300 Hz
- m_dTxUpLimit[9] = 3; // 1600 Hz
- m_dTxUpLimit[10] = 4; // 2000 Hz
- m_dTxUpLimit[11] = 4; // 2500 Hz
- m_dTxUpLimit[12] = 4; // 3100 Hz
- m_dTxUpLimit[13] = 0; // 4000 Hz
- m_dTxLowLimit[0] = -100; // 200 Hz
- m_dTxLowLimit[1] = -100; // 250 Hz
- m_dTxLowLimit[2] = -14; // 315 Hz
- m_dTxLowLimit[3] = -13; // 400 Hz
- m_dTxLowLimit[4] = -12; // 500 Hz
- m_dTxLowLimit[5] = -11; // 630 Hz
- m_dTxLowLimit[6] = -10; // 800 Hz
- m_dTxLowLimit[7] = -8; // 1000 Hz
- m_dTxLowLimit[8] = -8; // 1300 Hz
- m_dTxLowLimit[9] = -8; // 1600 Hz
- m_dTxLowLimit[10] = -8; // 2000 Hz
- m_dTxLowLimit[11] = -8; // 2500 Hz
- m_dTxLowLimit[12] = -8; // 3100 Hz
- m_dTxLowLimit[13] = -100; // 4000 Hz
- m_iRxLimitFreq[0] = 200;
- m_iRxLimitFreq[1] = 250;
- m_iRxLimitFreq[2] = 315;
- m_iRxLimitFreq[3] = 400;
- m_iRxLimitFreq[4] = 500;
- m_iRxLimitFreq[5] = 630;
- m_iRxLimitFreq[6] = 800;
- m_iRxLimitFreq[7] = 1000;
- m_iRxLimitFreq[8] = 1300;
- m_iRxLimitFreq[9] = 1600;
- m_iRxLimitFreq[10] = 2000;
- m_iRxLimitFreq[11] = 2500;
- m_iRxLimitFreq[12] = 3100;
- m_iRxLimitFreq[13] = 4000;
- m_dRxUpLimit[0] = 0; // 200 Hz
- m_dRxUpLimit[1] = 0; // 250 Hz
- m_dRxUpLimit[2] = 0; // 315 Hz
- m_dRxUpLimit[3] = 0; // 400 Hz
- m_dRxUpLimit[4] = 0; // 500 Hz
- m_dRxUpLimit[5] = 0; // 630 Hz
- m_dRxUpLimit[6] = 0; // 800 Hz
- m_dRxUpLimit[7] = 0; // 1000 Hz
- m_dRxUpLimit[8] = 0; // 1300 Hz
- m_dRxUpLimit[9] = 0; // 1600 Hz
- m_dRxUpLimit[10] = 0; // 2000 Hz
- m_dRxUpLimit[11] = 0; // 2500 Hz
- m_dRxUpLimit[12] = 0; // 3100 Hz
- m_dRxUpLimit[13] = 0; // 4000 Hz
- m_dRxLowLimit[0] = -100; // 200 Hz
- m_dRxLowLimit[1] = -100; // 250 Hz
- m_dRxLowLimit[2] = -15; // 315 Hz
- m_dRxLowLimit[3] = -12; // 400 Hz
- m_dRxLowLimit[4] = -12; // 500 Hz
- m_dRxLowLimit[5] = -12; // 630 Hz
- m_dRxLowLimit[6] = -12; // 800 Hz
- m_dRxLowLimit[7] = -12; // 1000 Hz
- m_dRxLowLimit[8] = -12; // 1300 Hz
- m_dRxLowLimit[9] = -12; // 1600 Hz
- m_dRxLowLimit[10] = -12; // 2000 Hz
- m_dRxLowLimit[11] = -12; // 2500 Hz
- m_dRxLowLimit[12] = -12; // 3100 Hz
- m_dRxLowLimit[13] = -100; // 4000 Hz
- }
- break;
- case ITEMIDX_BOUNDARY_3G_HANDSFREE_HANDHELD:
- {
- m_iTxLimitNum = 14;
- m_iRxLimitNum = 14;
- m_iTxLimitFreq[0] = 200;
- m_iTxLimitFreq[1] = 250;
- m_iTxLimitFreq[2] = 315;
- m_iTxLimitFreq[3] = 400;
- m_iTxLimitFreq[4] = 500;
- m_iTxLimitFreq[5] = 630;
- m_iTxLimitFreq[6] = 800;
- m_iTxLimitFreq[7] = 1000;
- m_iTxLimitFreq[8] = 1300;
- m_iTxLimitFreq[9] = 1600;
- m_iTxLimitFreq[10] = 2000;
- m_iTxLimitFreq[11] = 2500;
- m_iTxLimitFreq[12] = 3100;
- m_iTxLimitFreq[13] = 4000;
- m_dTxUpLimit[0] = 0; // 200 Hz
- m_dTxUpLimit[1] = 0; // 250 Hz
- m_dTxUpLimit[2] = 0; // 315 Hz
- m_dTxUpLimit[3] = 0; // 400 Hz
- m_dTxUpLimit[4] = 0; // 500 Hz
- m_dTxUpLimit[5] = 0; // 630 Hz
- m_dTxUpLimit[6] = 0; // 800 Hz
- m_dTxUpLimit[7] = 0; // 1000 Hz
- m_dTxUpLimit[8] = 2; // 1300 Hz
- m_dTxUpLimit[9] = 3; // 1600 Hz
- m_dTxUpLimit[10] = 4; // 2000 Hz
- m_dTxUpLimit[11] = 4; // 2500 Hz
- m_dTxUpLimit[12] = 4; // 3100 Hz
- m_dTxUpLimit[13] = 0; // 4000 Hz
- m_dTxLowLimit[0] = -100; // 200 Hz
- m_dTxLowLimit[1] = -100; // 250 Hz
- m_dTxLowLimit[2] = -14; // 315 Hz
- m_dTxLowLimit[3] = -13; // 400 Hz
- m_dTxLowLimit[4] = -12; // 500 Hz
- m_dTxLowLimit[5] = -11; // 630 Hz
- m_dTxLowLimit[6] = -10; // 800 Hz
- m_dTxLowLimit[7] = -8; // 1000 Hz
- m_dTxLowLimit[8] = -8; // 1300 Hz
- m_dTxLowLimit[9] = -8; // 1600 Hz
- m_dTxLowLimit[10] = -8; // 2000 Hz
- m_dTxLowLimit[11] = -8; // 2500 Hz
- m_dTxLowLimit[12] = -8; // 3100 Hz
- m_dTxLowLimit[13] = -100; // 4000 Hz
- m_iRxLimitFreq[0] = 200;
- m_iRxLimitFreq[1] = 250;
- m_iRxLimitFreq[2] = 315;
- m_iRxLimitFreq[3] = 400;
- m_iRxLimitFreq[4] = 500;
- m_iRxLimitFreq[5] = 630;
- m_iRxLimitFreq[6] = 800;
- m_iRxLimitFreq[7] = 1000;
- m_iRxLimitFreq[8] = 1300;
- m_iRxLimitFreq[9] = 1600;
- m_iRxLimitFreq[10] = 2000;
- m_iRxLimitFreq[11] = 2500;
- m_iRxLimitFreq[12] = 3100;
- m_iRxLimitFreq[13] = 4000;
- m_dRxUpLimit[0] = 0; // 200 Hz
- m_dRxUpLimit[1] = 0; // 250 Hz
- m_dRxUpLimit[2] = 0; // 315 Hz
- m_dRxUpLimit[3] = 0; // 400 Hz
- m_dRxUpLimit[4] = 0; // 500 Hz
- m_dRxUpLimit[5] = 0; // 630 Hz
- m_dRxUpLimit[6] = 0; // 800 Hz
- m_dRxUpLimit[7] = 0; // 1000 Hz
- m_dRxUpLimit[8] = 0; // 1300 Hz
- m_dRxUpLimit[9] = 0; // 1600 Hz
- m_dRxUpLimit[10] = 0; // 2000 Hz
- m_dRxUpLimit[11] = 0; // 2500 Hz
- m_dRxUpLimit[12] = 0; // 3100 Hz
- m_dRxUpLimit[13] = 0; // 4000 Hz
- m_dRxLowLimit[0] = -100; // 200 Hz
- m_dRxLowLimit[1] = -100; // 250 Hz
- m_dRxLowLimit[2] = -100; // 315 Hz
- m_dRxLowLimit[3] = -100; // 400 Hz
- m_dRxLowLimit[4] = -100; // 500 Hz
- m_dRxLowLimit[5] = -100; // 630 Hz
- m_dRxLowLimit[6] = -12; // 800 Hz
- m_dRxLowLimit[7] = -12; // 1000 Hz
- m_dRxLowLimit[8] = -12; // 1300 Hz
- m_dRxLowLimit[9] = -12; // 1600 Hz
- m_dRxLowLimit[10] = -12; // 2000 Hz
- m_dRxLowLimit[11] = -12; // 2500 Hz
- m_dRxLowLimit[12] = -12; // 3100 Hz
- m_dRxLowLimit[13] = -100; // 4000 Hz
- }
- break;
- case ITEMIDX_BOUNDARY_VOIP_HANDSET:
- {
- m_iTxLimitNum = 9;
- m_iRxLimitNum = 9;
- m_iTxLimitFreq[0] = 100;
- m_iTxLimitFreq[1] = 150;
- m_iTxLimitFreq[2] = 300;
- m_iTxLimitFreq[3] = 500;
- m_iTxLimitFreq[4] = 1000;
- m_iTxLimitFreq[5] = 2000;
- m_iTxLimitFreq[6] = 3000;
- m_iTxLimitFreq[7] = 3400;
- m_iTxLimitFreq[8] = 4000;
- m_dTxUpLimit[0] = -7; // 100 Hz
- m_dTxUpLimit[1] = 0; // 150 Hz
- m_dTxUpLimit[2] = 0; // 300 Hz
- m_dTxUpLimit[3] = 0; // 500 Hz
- m_dTxUpLimit[4] = 0; // 1000 Hz
- m_dTxUpLimit[5] = 5; // 2000 Hz
- m_dTxUpLimit[6] = 5; // 3000 Hz
- m_dTxUpLimit[7] = 5; // 3400 Hz
- m_dTxUpLimit[8] = 0; // 4000 Hz
- m_dTxLowLimit[0] = -100; // 100 Hz
- m_dTxLowLimit[1] = -100; // 150 Hz
- m_dTxLowLimit[2] = -8; // 300 Hz
- m_dTxLowLimit[3] = -6; // 500 Hz
- m_dTxLowLimit[4] = -6; // 1000 Hz
- m_dTxLowLimit[5] = -6; // 2000 Hz
- m_dTxLowLimit[6] = -6; // 3000 Hz
- m_dTxLowLimit[7] = -9; // 3400 Hz
- m_dTxLowLimit[8] = -100; // 4000 Hz
- m_iRxLimitFreq[0] = 100;
- m_iRxLimitFreq[1] = 170;
- m_iRxLimitFreq[2] = 300;
- m_iRxLimitFreq[3] = 500;
- m_iRxLimitFreq[4] = 1000;
- m_iRxLimitFreq[5] = 3000;
- m_iRxLimitFreq[6] = 3400;
- m_iRxLimitFreq[7] = 4000;
- m_iRxLimitFreq[8] = 8000;
- m_dRxUpLimit[0] = -7; // 100 Hz
- m_dRxUpLimit[1] = 2; // 170 Hz
- m_dRxUpLimit[2] = 2; // 300 Hz
- m_dRxUpLimit[3] = 1.15; // 500 Hz
- m_dRxUpLimit[4] = 0; // 1000 Hz
- m_dRxUpLimit[5] = 2; // 3000 Hz
- m_dRxUpLimit[6] = 2; // 3400 Hz
- m_dRxUpLimit[7] = 2; // 4000 Hz
- m_dRxUpLimit[8] = -18; // 8000 Hz
- m_dRxLowLimit[0] = -100; // 100 Hz
- m_dRxLowLimit[1] = -100; // 170 Hz
- m_dRxLowLimit[2] = -7; // 300 Hz
- m_dRxLowLimit[3] = -5; // 500 Hz
- m_dRxLowLimit[4] = -5; // 1000 Hz
- m_dRxLowLimit[5] = -5; // 3000 Hz
- m_dRxLowLimit[6] = -8; // 3400 Hz
- m_dRxLowLimit[7] = -100; // 4000 Hz
- m_dRxLowLimit[8] = -100; // 8000 Hz
- }
- break;
- case ITEMIDX_BOUNDARY_VOIP_HEADSET:
- {
- m_iTxLimitNum = 9;
- m_iRxLimitNum = 10;
- m_iTxLimitFreq[0] = 100;
- m_iTxLimitFreq[1] = 150;
- m_iTxLimitFreq[2] = 300;
- m_iTxLimitFreq[3] = 500;
- m_iTxLimitFreq[4] = 1000;
- m_iTxLimitFreq[5] = 2000;
- m_iTxLimitFreq[6] = 3000;
- m_iTxLimitFreq[7] = 3400;
- m_iTxLimitFreq[8] = 4000;
- m_dTxUpLimit[0] = -7; // 100 Hz
- m_dTxUpLimit[1] = 0; // 150 Hz
- m_dTxUpLimit[2] = 0; // 300 Hz
- m_dTxUpLimit[3] = 0; // 500 Hz
- m_dTxUpLimit[4] = 0; // 1000 Hz
- m_dTxUpLimit[5] = 5; // 2000 Hz
- m_dTxUpLimit[6] = 5; // 3000 Hz
- m_dTxUpLimit[7] = 5; // 3400 Hz
- m_dTxUpLimit[8] = 0; // 4000 Hz
- m_dTxLowLimit[0] = -100; // 100 Hz
- m_dTxLowLimit[1] = -100; // 150 Hz
- m_dTxLowLimit[2] = -12; // 300 Hz
- m_dTxLowLimit[3] = -6; // 500 Hz
- m_dTxLowLimit[4] = -6; // 1000 Hz
- m_dTxLowLimit[5] = -6; // 2000 Hz
- m_dTxLowLimit[6] = -6; // 3000 Hz
- m_dTxLowLimit[7] = -9; // 3400 Hz
- m_dTxLowLimit[8] = -100; // 4000 Hz
- m_iRxLimitFreq[0] = 100;
- m_iRxLimitFreq[1] = 150;
- m_iRxLimitFreq[2] = 300;
- m_iRxLimitFreq[3] = 600;
- m_iRxLimitFreq[4] = 1000;
- m_iRxLimitFreq[5] = 2000;
- m_iRxLimitFreq[6] = 3000;
- m_iRxLimitFreq[7] = 3400;
- m_iRxLimitFreq[8] = 4000;
- m_iRxLimitFreq[9] = 8000;
- m_dRxUpLimit[0] = -7; // 100 Hz
- m_dRxUpLimit[1] = 0; // 150 Hz
- m_dRxUpLimit[2] = 0; // 300 Hz
- m_dRxUpLimit[3] = 0; // 600 Hz
- m_dRxUpLimit[4] = 0; // 1000 Hz
- m_dRxUpLimit[5] = 5; // 2000 Hz
- m_dRxUpLimit[6] = 5; // 3000 Hz
- m_dRxUpLimit[7] = 5; // 3400 Hz
- m_dRxUpLimit[8] = 0.63; // 4000 Hz
- m_dRxUpLimit[9] = -18; // 8000 Hz
- m_dRxLowLimit[0] = -100; // 100 Hz
- m_dRxLowLimit[1] = -100; // 150 Hz
- m_dRxLowLimit[2] = -11; // 300 Hz
- m_dRxLowLimit[3] = -8; // 600 Hz
- m_dRxLowLimit[4] = -8; // 1000 Hz
- m_dRxLowLimit[5] = -8; // 2000 Hz
- m_dRxLowLimit[6] = -8; // 3000 Hz
- m_dRxLowLimit[7] = -11; // 3400 Hz
- m_dRxLowLimit[8] = -100; // 4000 Hz
- m_dRxLowLimit[9] = -100; // 8000 Hz
- }
- break;
- case ITEMIDX_BOUNDARY_TYPE_3_3:
- {
- m_iTxLimitNum = 13;
- m_iRxLimitNum = 13;
- m_iTxLimitFreq[0] = 100;
- m_iTxLimitFreq[1] = 150;
- m_iTxLimitFreq[2] = 250;
- m_iTxLimitFreq[3] = 450;
- m_iTxLimitFreq[4] = 750;
- m_iTxLimitFreq[5] = 850;
- m_iTxLimitFreq[6] = 1000;
- m_iTxLimitFreq[7] = 1320;
- m_iTxLimitFreq[8] = 1500;
- m_iTxLimitFreq[9] = 2360;
- m_iTxLimitFreq[10] = 2800;
- m_iTxLimitFreq[11] = 3550;
- m_iTxLimitFreq[12] = 4000;
- m_dTxUpLimit[0] = -30.8; // 100 Hz
- m_dTxUpLimit[1] = -23.6; // 150 Hz
- m_dTxUpLimit[2] = -12.2; // 250 Hz
- m_dTxUpLimit[3] = -7.5; // 450 Hz
- m_dTxUpLimit[4] = -12.2; // 750 Hz
- m_dTxUpLimit[5] = -12.6; // 850 Hz
- m_dTxUpLimit[6] = -11; // 1000 Hz
- m_dTxUpLimit[7] = -1.5; // 1320 Hz
- m_dTxUpLimit[8] = 2.8; // 1500 Hz
- m_dTxUpLimit[9] = 7.1; // 2360 Hz
- m_dTxUpLimit[10] = 6.0; // 2800 Hz
- m_dTxUpLimit[11] = -1.1; // 3550 Hz
- m_dTxUpLimit[12] = -33.9; // 4000 Hz
- m_dTxLowLimit[0] = -33.8; // 100 Hz
- m_dTxLowLimit[1] = -26.6; // 150 Hz
- m_dTxLowLimit[2] = -15.2; // 250 Hz
- m_dTxLowLimit[3] = -10.5; // 450 Hz
- m_dTxLowLimit[4] = -15.2; // 750 Hz
- m_dTxLowLimit[5] = -15.6; // 850 Hz
- m_dTxLowLimit[6] = -14; // 1000 Hz
- m_dTxLowLimit[7] = -4.5; // 1320 Hz
- m_dTxLowLimit[8] = -0.2; // 1500 Hz
- m_dTxLowLimit[9] = 4.1; // 2360 Hz
- m_dTxLowLimit[10] = 3.0; // 2800 Hz
- m_dTxLowLimit[11] = -4.1; // 3550 Hz
- m_dTxLowLimit[12] = -36.9; // 4000 Hz
- // RX
- m_iRxLimitFreq[0] = 100;
- m_iRxLimitFreq[1] = 150;
- m_iRxLimitFreq[2] = 250;
- m_iRxLimitFreq[3] = 450;
- m_iRxLimitFreq[4] = 750;
- m_iRxLimitFreq[5] = 850;
- m_iRxLimitFreq[6] = 1000;
- m_iRxLimitFreq[7] = 1320;
- m_iRxLimitFreq[8] = 1500;
- m_iRxLimitFreq[9] = 2360;
- m_iRxLimitFreq[10] = 2800;
- m_iRxLimitFreq[11] = 3550;
- m_iRxLimitFreq[12] = 4000;
- m_dRxUpLimit[0] = -30.8; // 100 Hz
- m_dRxUpLimit[1] = -23.6; // 150 Hz
- m_dRxUpLimit[2] = -12.2; // 250 Hz
- m_dRxUpLimit[3] = -7.5; // 450 Hz
- m_dRxUpLimit[4] = -12.2; // 750 Hz
- m_dRxUpLimit[5] = -12.6; // 850 Hz
- m_dRxUpLimit[6] = -11; // 1000 Hz
- m_dRxUpLimit[7] = -1.5; // 1320 Hz
- m_dRxUpLimit[8] = 2.8; // 1500 Hz
- m_dRxUpLimit[9] = 7.1; // 2360 Hz
- m_dRxUpLimit[10] = 6.0; // 2800 Hz
- m_dRxUpLimit[11] = -1.1; // 3550 Hz
- m_dRxUpLimit[12] = -33.9; // 4000 Hz
- m_dRxLowLimit[0] = -33.8; // 100 Hz
- m_dRxLowLimit[1] = -26.6; // 150 Hz
- m_dRxLowLimit[2] = -15.2; // 250 Hz
- m_dRxLowLimit[3] = -10.5; // 450 Hz
- m_dRxLowLimit[4] = -15.2; // 750 Hz
- m_dRxLowLimit[5] = -15.6; // 850 Hz
- m_dRxLowLimit[6] = -14; // 1000 Hz
- m_dRxLowLimit[7] = -4.5; // 1320 Hz
- m_dRxLowLimit[8] = -0.2; // 1500 Hz
- m_dRxLowLimit[9] = 4.1; // 2360 Hz
- m_dRxLowLimit[10] = 3.0; // 2800 Hz
- m_dRxLowLimit[11] = -4.1; // 3550 Hz
- m_dRxLowLimit[12] = -36.9; // 4000 Hz
- }
- break;
- case ITEMIDX_BOUNDARY_VOIP_HANDSFREE:
- {
- m_iTxLimitNum = 17;
- m_iRxLimitNum = 14;
- m_iTxLimitFreq[0] = 100;
- m_iTxLimitFreq[1] = 125;
- m_iTxLimitFreq[2] = 160;
- m_iTxLimitFreq[3] = 200;
- m_iTxLimitFreq[4] = 250;
- m_iTxLimitFreq[5] = 315;
- m_iTxLimitFreq[6] = 400;
- m_iTxLimitFreq[7] = 500;
- m_iTxLimitFreq[8] = 630;
- m_iTxLimitFreq[9] = 800;
- m_iTxLimitFreq[10] = 1000;
- m_iTxLimitFreq[11] = 1250;
- m_iTxLimitFreq[12] = 1600;
- m_iTxLimitFreq[13] = 2000;
- m_iTxLimitFreq[14] = 2500;
- m_iTxLimitFreq[15] = 3150;
- m_iTxLimitFreq[16] = 4000;
- m_dTxUpLimit[0] = -7; // 100 Hz
- m_dTxUpLimit[1] = -3; // 125 Hz
- m_dTxUpLimit[2] = 0; // 160 Hz
- m_dTxUpLimit[3] = 0; // 200 Hz
- m_dTxUpLimit[4] = 0; // 250 Hz
- m_dTxUpLimit[5] = 0; // 315 Hz
- m_dTxUpLimit[6] = 0; // 400 Hz
- m_dTxUpLimit[7] = 0; // 500 Hz
- m_dTxUpLimit[8] = 0; // 630 Hz
- m_dTxUpLimit[9] = 0; // 800 Hz
- m_dTxUpLimit[10] = 0; // 1000 Hz
- m_dTxUpLimit[11] = 2; // 1250 Hz
- m_dTxUpLimit[12] = 4; // 1600 Hz
- m_dTxUpLimit[13] = 5; // 2000 Hz
- m_dTxUpLimit[14] = 5; // 2500 Hz
- m_dTxUpLimit[15] = 5; // 3150 Hz
- m_dTxUpLimit[16] = 0; // 4000 Hz
- m_dTxLowLimit[0] = -100; // 100 Hz
- m_dTxLowLimit[1] = -100; // 125 Hz
- m_dTxLowLimit[2] = -100; // 160 Hz
- m_dTxLowLimit[3] = -100; // 200 Hz
- m_dTxLowLimit[4] = -100; // 250 Hz
- m_dTxLowLimit[5] = -13; // 315 Hz
- m_dTxLowLimit[6] = -12; // 400 Hz
- m_dTxLowLimit[7] = -11; // 500 Hz
- m_dTxLowLimit[8] = -10; // 630 Hz
- m_dTxLowLimit[9] = -9; // 800 Hz
- m_dTxLowLimit[10] = -7; // 1000 Hz
- m_dTxLowLimit[11] = -7; // 12500 Hz
- m_dTxLowLimit[12] = -7; // 1600 Hz
- m_dTxLowLimit[13] = -7; // 2000 Hz
- m_dTxLowLimit[14] = -7; // 2500 Hz
- m_dTxLowLimit[15] = -10; // 3150 Hz
- m_dTxLowLimit[16] = -100; // 4000 Hz
- m_iRxLimitFreq[0] = 100;
- m_iRxLimitFreq[1] = 125;
- m_iRxLimitFreq[2] = 160;
- m_iRxLimitFreq[3] = 200;
- m_iRxLimitFreq[4] = 250;
- m_iRxLimitFreq[5] = 315;
- m_iRxLimitFreq[6] = 400;
- m_iRxLimitFreq[7] = 500;
- m_iRxLimitFreq[8] = 2500;
- m_iRxLimitFreq[9] = 3150;
- m_iRxLimitFreq[10] = 4000;
- m_iRxLimitFreq[11] = 5000;
- m_iRxLimitFreq[12] = 6300;
- m_iRxLimitFreq[13] = 8000;
- m_dRxUpLimit[0] = -9; // 100 Hz
- m_dRxUpLimit[1] = -6; // 125 Hz
- m_dRxUpLimit[2] = -3; // 160 Hz
- m_dRxUpLimit[3] = 0; // 200 Hz
- m_dRxUpLimit[4] = 0; // 250 Hz
- m_dRxUpLimit[5] = 0; // 315 Hz
- m_dRxUpLimit[6] = 0; // 400 Hz
- m_dRxUpLimit[7] = 0; // 500 Hz
- m_dRxUpLimit[8] = 0; // 2500 Hz
- m_dRxUpLimit[9] = 0; // 3150 Hz
- m_dRxUpLimit[10] = 0; // 4000 Hz
- m_dRxUpLimit[11] = -7; // 5000 Hz
- m_dRxUpLimit[12] = -14; // 6300 Hz
- m_dRxUpLimit[13] = -20; // 8000 Hz
- m_dRxLowLimit[0] = -100; // 100 Hz
- m_dRxLowLimit[1] = -100; // 125 Hz
- m_dRxLowLimit[2] = -100; // 160 Hz
- m_dRxLowLimit[3] = -100; // 200 Hz
- m_dRxLowLimit[4] = -100; // 250 Hz
- m_dRxLowLimit[5] = -12; // 315 Hz
- m_dRxLowLimit[6] = -11; // 400 Hz
- m_dRxLowLimit[7] = -10; // 500 Hz
- m_dRxLowLimit[8] = -10; // 2500 Hz
- m_dRxLowLimit[9] = -13; // 3150 Hz
- m_dRxLowLimit[10] = -100; // 4000 Hz
- m_dRxLowLimit[11] = -100; // 5000 Hz
- m_dRxLowLimit[12] = -100; // 6300 Hz
- m_dRxLowLimit[13] = -100; // 8000 Hz
- }
- break;
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmFIRCoeffCal::cbBoundaryChange(TObject *Sender)
- {
- Set_Boundary();
- double min_y, max_y;
- GetMinMaxY( &OrgSpCoef, &min_y, &max_y );
- if( min_y == max_y || isTRCLoadOk == false || OrgSpCoef.num>TOTAL_TRC_FREQ_NUM)
- {
- PlotGrid(100, 4000, -20, 15);
- }
- else
- {
- PlotGrid( 100, 4000, min_y, max_y);
- }
- PlotBoundaryCurve();
- if( isOrgCurvePlot )
- {
- PlotOrgCurve();
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmFIRCoeffCal::FormActivate(TObject *Sender)
- {
- if (m_bInit)
- {
- m_bInit = false;
- CSPCOEF SP_COEF_Obj;
- m_b45TapSupport = SP_COEF_Obj.Query_AudioParam45Tap_Start();
- if (m_b45TapSupport)
- {
- edtFIRTaps->Text = SPEECH_FIR_44_TAPS_NUM;
- }
- else
- {
- edtFIRTaps->Text = SPEECH_FIR_30_TAPS_NUM;
- }
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmFIRCoeffCal::rbMicrotronixClick(TObject *Sender)
- {
- gbFileFormat->Visible = true;
- rbLinear->Enabled = true;
- rbLogdB->Enabled = true;
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmFIRCoeffCal::m_rbVitaClick(TObject *Sender)
- {
- gbFileFormat->Visible = true;
- rbLinear->Enabled = true;
- rbLogdB->Enabled = true;
- }
- //---------------------------------------------------------------------------