⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 avccompressor.cpp

📁 Audacity是一款用於錄音和編輯聲音的、免費的開放源碼軟體。它可以執行於Mac OS X、Microsoft Windows、GNU/Linux和其它作業系統
💻 CPP
📖 第 1 页 / 共 2 页
字号:
void AvcCompressorDialog::OnOK(wxCommandEvent &event){	if ( Validate() && TransferDataFromWindow() ) {		// do our dialog specific validation		// Check Adjustment Settings        mstrAdjWin.ToLong(&mnAdjWin);		if ( LongRangeCheck( mctlAdjWin, mnAdjWin, ADJWIN_MIN, ADJWIN_MAX ) == false ) {			// value out of range			return;		}        mstrDelay.ToLong(&mnDelay);		if ( LongRangeCheck( mctlDelay, mnDelay, DELAY_MIN, DELAY_MAX ) == false ) {			// value out of range			return;		}        mstrChangeWin.ToLong(&mnChangeWin);		if ( LongRangeCheck( mctlChangeWin, mnChangeWin, CHANGE_MIN, CHANGE_MAX ) == false ) {			// value out of range			return;		}		if ( mnChangeWin > mnAdjWin ) {			wxMessageBox(_("Change window size must be less than or equal to Adjustment window size."),					 _("Validation error"), wxOK | wxICON_EXCLAMATION, GetParent() ); 			if ( mctlChangeWin )				mctlChangeWin->SetFocus();			return;		}        mstrMinPct.ToLong(&mnMinPct);		if ( LongRangeCheck( mctlMinPct, mnMinPct, MINPCT_MIN, MINPCT_MAX ) == false ) {			// value out of range			return;		}		// Check Amplification Settings		long iPrevPoint= 0;		// index to mnXAxis and mnYAxis		for ( int i = 0 ; i < NUM_CURVE_POINTS ; ++i ) {			mstrXAxis[i].ToLong(&mnXAxis[i]);			mstrYAxis[i].ToLong(&mnYAxis[i]);			// see if this is a checked point			if ( mctlCheckBoxes[i]->GetValue() == false)				continue;	// last box guaranteed to be checked			if ( i > 0 ) {				if ( mnXAxis[i] <= mnXAxis[iPrevPoint] ) {					wxMessageBox(_("Values in columns must be in ascending order."),								 _("Validation error"),								 wxOK | wxICON_EXCLAMATION, GetParent() );					mctlXAxis[(i==NUM_CURVE_POINTS-1) ? iPrevPoint : i]->SetFocus();					return;				}				if ( mnYAxis[i] <= mnYAxis[iPrevPoint] ) {					wxMessageBox(_("Values in columns must be in ascending order."),								 _("Validation error"),								 wxOK | wxICON_EXCLAMATION, GetParent() );					mctlYAxis[(i==NUM_CURVE_POINTS-1) ? iPrevPoint : i]->SetFocus();					return;				}			}			iPrevPoint = i;		}		// AOK, time to return		WritePrefs();			// save values user entered for next execution        if ( IsModal() )            EndModal(wxID_OK);        else {		    SetReturnCode(wxID_OK);		    this->Show(FALSE);        }	}}void AvcCompressorDialog::OnCancel(wxCommandEvent &event){   EndModal(false);}	static int* naSampleChoicesHoriz[5] = {iHoriz_1K_1K,iHoriz_1K_3HK,iHoriz_E75_5K,iHoriz_75_3500,iHoriz_AE75_3HK};	static int* naSampleChoicesVert[5]  = {iVert_1K_1K, iVert_1K_3HK, iVert_E75_5K, iVert_75_3500, iVert_AE75_3HK};void AvcCompressorDialog::OnRestoreDefaults(wxCommandEvent &event){	static int* naSampleChoicesHoriz[5] = {iHoriz_1K_1K,iHoriz_1K_3HK,iHoriz_E75_5K,iHoriz_75_3500,iHoriz_AE75_3HK};	static int* naSampleChoicesVert[5]  = {iVert_1K_1K, iVert_1K_3HK, iVert_E75_5K, iVert_75_3500, iVert_AE75_3HK};	mstrAdjWin.Printf("%d", ADJWIN_DEFAULT);	mstrDelay.Printf("%d", DELAY_DEFAULT);	mstrChangeWin.Printf("%d", CHANGE_DEFAULT);	mstrMinPct.Printf("%d", MINPCT_DEFAULT);	for ( int i = 0 ; i < NUM_CURVE_POINTS ; ++ i ) {		mctlCheckBoxes[i]->SetValue(true);		mctlXAxis[i]->Show ( true );		mctlYAxis[i]->Show ( true );		mstrXAxis[i].Printf( "%d", naSampleChoicesHoriz[4][i] );		mstrYAxis[i].Printf( "%d", naSampleChoicesVert[4][i] );	}	TransferDataToWindow();}void AvcCompressorDialog::ReadPrefs(){	int			nTemp;	bool		bTemp;	wxString	strTemp;	nTemp = gPrefs->Read ( PREF_ADJWIN, ADJWIN_DEFAULT );	mstrAdjWin.Printf("%d", nTemp);	nTemp = gPrefs->Read ( PREF_DELAY, DELAY_DEFAULT );	mstrDelay.Printf("%d", nTemp);	nTemp = gPrefs->Read ( PREF_CHANGE, CHANGE_DEFAULT );	mstrChangeWin.Printf("%d", nTemp);	nTemp = gPrefs->Read ( PREF_MINPCT, MINPCT_DEFAULT );	mstrMinPct.Printf("%d", nTemp);	for ( int i = 1 ; i < NUM_CURVE_POINTS - 1 ; ++ i ) {		strTemp.Printf(PREF_ENABLE,i);		bTemp = ( gPrefs->Read ( strTemp, true ) == 0 ) ? false : true;		mctlCheckBoxes[i]->SetValue(bTemp);		mctlXAxis[i]->Show ( bTemp );		mctlYAxis[i]->Show ( bTemp );		strTemp.Printf(PREF_HORIZ,i);		nTemp = gPrefs->Read ( strTemp, naSampleChoicesHoriz[4][i] );		mstrXAxis[i].Printf( "%d", nTemp );		strTemp.Printf(PREV_VERT,i);		nTemp = gPrefs->Read ( strTemp, naSampleChoicesVert[4][i] );		mstrYAxis[i].Printf( "%d", nTemp );	}	TransferDataToWindow();}void AvcCompressorDialog::WritePrefs(){	wxString	strTemp;	gPrefs->Write ( PREF_ADJWIN, mnAdjWin );	gPrefs->Write ( PREF_DELAY, mnDelay );	gPrefs->Write ( PREF_CHANGE, mnChangeWin );	gPrefs->Write ( PREF_MINPCT, mnMinPct );	for ( int i = 1 ; i < NUM_CURVE_POINTS - 1 ; ++ i ) {		strTemp.Printf(PREF_ENABLE,i);		gPrefs->Write ( strTemp, mctlCheckBoxes[i]->GetValue() );		strTemp.Printf(PREF_HORIZ,i);		gPrefs->Write ( strTemp, mnXAxis[i] );		strTemp.Printf(PREV_VERT,i);		gPrefs->Write ( strTemp, mnYAxis[i] );	}}void AvcCompressorDialog::OnCheckBox(wxCommandEvent & event){	bool bCheck = mctlCheckBoxes[event.m_id-ID_FIRST_CURVE_CHECK]->GetValue();    mctlXAxis[event.m_id-ID_FIRST_CURVE_CHECK]->Show ( bCheck );    mctlYAxis[event.m_id-ID_FIRST_CURVE_CHECK]->Show ( bCheck );}wxSizer *AvcCompressorDialog::MakeAvcCompressorDialog(wxWindow * parent, bool call_fit,														bool set_sizer){	wxBoxSizer *mainSizer = new wxBoxSizer(wxVERTICAL);	wxStaticBoxSizer *group;	wxBoxSizer *boxSizer;	wxStaticText *staticText;	//wxTextCtrl *textCtrl;	wxButton *button;	wxFlexGridSizer *flexGridSizer;	staticText =       new wxStaticText(parent, ID_TEXT,                        _("Automatic Volume Control by Vincent A. Busam"),                        wxDefaultPosition, wxDefaultSize, 0);	mainSizer->Add(staticText, 0, wxALIGN_CENTRE | wxALL, 5);	// 0.  Box Sizer for horizontal components	wxBoxSizer *horizontalSizer = new wxBoxSizer(wxHORIZONTAL);	// 1.  Box Sizer for leftmost group of controls	wxBoxSizer *leftSizer = new wxBoxSizer(wxVERTICAL);	// 1.1  Group Box for adjustment window settings	group = new wxStaticBoxSizer(new wxStaticBox(parent, -1,                                                _("Adjustment Settings")), wxVERTICAL);	flexGridSizer = new wxFlexGridSizer(2, 0, 0);	// 1.1.1  Adjustment Window	staticText =       new wxStaticText(parent, ID_TEXT, _("Adjustment Window:"),                        wxDefaultPosition, wxDefaultSize, 0 );	flexGridSizer->Add(staticText, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL | wxALL, 5);	mctlAdjWin =       new wxTextCtrl(parent, ID_ADJWINTEXT, "", wxDefaultPosition,                      wxSize(40, -1), 0,					  wxTextValidator(wxFILTER_NUMERIC, &mstrAdjWin ) );	flexGridSizer->Add(mctlAdjWin, 0, wxALIGN_CENTRE | wxALL, 5);	// 1.1.2  Adjustment Delay	staticText =       new wxStaticText(parent, ID_TEXT, _("Adjustment Delay:"),                        wxDefaultPosition, wxDefaultSize, 0);	flexGridSizer->Add(staticText, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL | wxALL, 5);	mctlDelay =       new wxTextCtrl(parent, ID_DELAYTEXT, "", wxDefaultPosition,                      wxSize(40, -1), 0,					  wxTextValidator(wxFILTER_NUMERIC, &mstrDelay ));	flexGridSizer->Add(mctlDelay, 0, wxALIGN_CENTRE | wxALL, 5);	// 1.1.3  Min Change Window   /* i18n-hint: the minimum size of the window that is changed */	staticText =       new wxStaticText(parent, ID_TEXT, _("Minimum Change Window:"),                        wxDefaultPosition, wxDefaultSize, 0);	flexGridSizer->Add(staticText, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL | wxALL, 5);	mctlChangeWin =       new wxTextCtrl(parent, ID_CHANGEWINTEXT, "", wxDefaultPosition,                      wxSize(40, -1), 0,					  wxTextValidator(wxFILTER_NUMERIC, &mstrChangeWin ));	flexGridSizer->Add(mctlChangeWin, 0, wxALIGN_CENTRE | wxALL, 5);	// 1.1.4  Min Change %	staticText =       new wxStaticText(parent, ID_TEXT, _("Minimum Change %:"),                        wxDefaultPosition, wxDefaultSize, 0);	flexGridSizer->Add(staticText, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL | wxALL, 5);	mctlMinPct =       new wxTextCtrl(parent, ID_MINPCTTEXT, "", wxDefaultPosition,                      wxSize(40, -1), 0,					  wxTextValidator(wxFILTER_NUMERIC, &mstrMinPct ));	 flexGridSizer->Add(mctlMinPct, 0, wxALIGN_CENTRE | wxALL, 5);	// 1.1.end  Add group	group->Add( flexGridSizer, 0,  wxALIGN_CENTRE|wxALL, 5 );	leftSizer->Add( group, 0, wxALIGN_TOP |wxALL, 5 );   // DMM: the following text box is too difficult to translate as-is.  Taken out of   // i18n for now.	// 1.2 area under group box	staticText =       new wxStaticText(parent, ID_TEXT,                        ("Above values are in samples.\n"						  "Adjustment Window defines number of \nsamples in moving average.\n"						  "Change window defines minimum time \nbetween volume changes.\n"						  "Minimum % change of volume adjustment \nbefore making a volume change.\n"						  "Grid at right determines how much to amplify \neach volume level.\n"						  "For more information see: \n"						  "http://www.busam.com/skyland/iavc\n"						  "7/21/02: WAV and MP3 files both work."						 ),                        wxDefaultPosition, wxDefaultSize, 0);	leftSizer->Add(staticText, 0, wxALIGN_CENTRE | wxALL, 5);	// 1.end	horizontalSizer->Add( leftSizer, 0, wxALIGN_TOP |wxALL, 5 );	// 2.  Group Box for volume settings	group = new wxStaticBoxSizer(new wxStaticBox(parent, -1,                                                _("Amplification Settings")), wxVERTICAL);	// 2.1  Add one row each time through loop	flexGridSizer = new wxFlexGridSizer(3, 0, 0);	staticText =       new wxStaticText(parent, ID_TEXT, _("Enabled"),                        wxDefaultPosition, wxDefaultSize, 0);	flexGridSizer->Add(staticText, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL | wxALL, 5);	staticText =       new wxStaticText(parent, ID_TEXT, _("Original Value"),                        wxDefaultPosition, wxDefaultSize, 0);	flexGridSizer->Add(staticText, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL | wxALL, 5);	staticText =       new wxStaticText(parent, ID_TEXT, _("New Value"),                        wxDefaultPosition, wxDefaultSize, 0);	flexGridSizer->Add(staticText, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL | wxALL, 5);	for ( int i = 0 ; i < NUM_CURVE_POINTS ; ++i )	{		mctlCheckBoxes[i] =		   new wxCheckBox(parent, ID_FIRST_CURVE_CHECK + i, "", wxDefaultPosition,						  wxSize(40, -1), 0);		flexGridSizer->Add(mctlCheckBoxes[i], 0, wxALIGN_CENTRE | wxALL, 5);		mctlCheckBoxes[i]->SetValue(true);		mctlXAxis[i] =		   new wxTextCtrl(parent, ID_FIRST_CURVE_X + i, "", wxDefaultPosition,						  wxSize(40, -1), 0,						  wxTextValidator(wxFILTER_NUMERIC, &mstrXAxis[i] ));		flexGridSizer->Add(mctlXAxis[i], 0, wxALIGN_CENTRE | wxALL, 5);		mctlYAxis[i] =		   new wxTextCtrl(parent, ID_FIRST_CURVE_Y + i, "", wxDefaultPosition,						  wxSize(40, -1), 0,						  wxTextValidator(wxFILTER_NUMERIC, &mstrYAxis[i] ));		flexGridSizer->Add(mctlYAxis[i], 0, wxALIGN_CENTRE | wxALL, 5);	}	mctlCheckBoxes[0]->Enable(false);	mctlXAxis[0]->Enable(false);	mctlYAxis[0]->Enable(false);	mctlCheckBoxes[NUM_CURVE_POINTS-1]->Enable(false);	mctlXAxis[NUM_CURVE_POINTS-1]->Enable(false);	mctlYAxis[NUM_CURVE_POINTS-1]->Enable(false);	// 2.end  Add group	group->Add( flexGridSizer, 0,  wxALIGN_CENTRE|wxALL, 5 );	horizontalSizer->Add( group, 0, wxALIGN_CENTRE|wxALL, 5 );	mainSizer->Add( horizontalSizer, 0,  wxALIGN_CENTRE|wxALL, 5 );	// Last:  Add buttons	boxSizer = new wxBoxSizer(wxHORIZONTAL);	// Add restore defaults button	button =       new wxButton(parent, ID_RESTORE_DEFAULTS, _("Restore Defaults"), wxDefaultPosition,                    wxDefaultSize, 0);	boxSizer->Add(button, 0, wxALIGN_CENTRE | wxALL, 5);	// Add Cancel button	button =       new wxButton(parent, wxID_CANCEL, _("Cancel"), wxDefaultPosition,                    wxDefaultSize, 0);	boxSizer->Add(button, 0, wxALIGN_CENTRE | wxALL, 5);	// Add OK button	button =       new wxButton(parent, wxID_OK, _("OK"), wxDefaultPosition,                    wxDefaultSize, 0);	button->SetDefault();	button->SetFocus();	boxSizer->Add(button, 0, wxALIGN_CENTRE | wxALL, 5);	mainSizer->Add(boxSizer, 0, wxALIGN_CENTRE | wxALL, 5);	if (set_sizer) {		parent->SetAutoLayout(TRUE);		parent->SetSizer(mainSizer);		if (call_fit) {			mainSizer->Fit(parent);			mainSizer->SetSizeHints(parent);		}	}	return mainSizer;}// Indentation settings for Vim and Emacs and unique identifier for Arch, a// version control system. Please do not modify past this point.//// Local Variables:// c-basic-offset: 3// indent-tabs-mode: nil// End://// vim: et sts=3 sw=3// arch-tag: 129a8b19-9efd-4b47-95cb-c5534840a0f0

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -