📄 extrapanel.cpp
字号:
filter_sizer->Add( normvol_check, 0, wxALL, 4 ); filter_sizer->Add( normvol_label, 0, wxALL, 4 ); filter_sizer->Add( normvol_slider, 0, wxALL, 4 ); panel_sizer->Add( filter_sizer, 1, wxTOP, 2 ); panel->SetSizerAndFit( panel_sizer ); panel_sizer->Layout(); panel_sizer->SetSizeHints( panel ); /* Write down initial values */ psz_filters = config_GetPsz( p_intf, "audio-filter" ); if( psz_filters ) { headphone_check->SetValue( strstr( psz_filters, "headphone" ) ); normvol_check->SetValue( strstr( psz_filters, "normvol" ) ); free( psz_filters ); } else { headphone_check->SetValue( 0 ); normvol_check->SetValue( 0 ); } return panel;}static const wxString band_frequencies[] ={ wxT(" 60 Hz"), wxT("170 Hz"), wxT("310 Hz"), wxT("600 Hz"), wxT(" 1 kHz"), wxT(" 3 kHz"), wxT(" 6 kHz"), wxT("12 kHz"), wxT("14 kHz"), wxT("16 kHz")};/* Equalizer Panel constructor */wxPanel *ExtraPanel::EqzPanel( wxWindow *parent ){ wxPanel *panel = new wxPanel( parent, -1 ); wxBoxSizer *panel_sizer = new wxBoxSizer( wxVERTICAL ); /* Create static box to surround the adjust controls */ wxBoxSizer *top_sizer = new wxBoxSizer( wxHORIZONTAL ); /* Create the enable button */ eq_chkbox = new wxCheckBox( panel, EqEnable_Event, wxU(_("Enable") ) ); eq_chkbox->SetToolTip( wxU(_("Enable the equalizer. You can either " "manually change the bands or use a preset (Audio Menu->Equalizer)." ) ) ); top_sizer->Add( eq_chkbox, 0, wxALL, 2 ); eq_2p_chkbox = new wxCheckBox( panel, Eq2Pass_Event, wxU(_("2 Pass") ) ); eq_2p_chkbox->SetToolTip( wxU(_("If you enable this settting, the " "equalizer filter will be applied twice. The effect will be sharper.") ) ); top_sizer->Add( eq_2p_chkbox, 0, wxALL, 2 ); top_sizer->Add( 0, 0, 1, wxALL, 2 ); eq_restoredefaults_button = new wxButton( panel, EqRestore_Event, wxU( _("Restore Defaults") ) ); top_sizer->Add( eq_restoredefaults_button, 0, wxALL, 2 ); top_sizer->Add( 0, 0, 1, wxALL, 2 ); smooth_text = new wxStaticText( panel, -1, wxU( "Smooth :" )); smooth_text->SetToolTip( wxU( SMOOTH_TIP ) ); top_sizer->Add( smooth_text, 0, wxALL, 2 ); smooth_slider =new wxSlider( panel, Smooth_Event, 0, 0, 10 , wxDefaultPosition, wxSize( 100, -1 ) ); smooth_slider->SetToolTip( wxU( SMOOTH_TIP ) ); top_sizer->Add( smooth_slider, 0, wxALL, 2 ); i_smooth = 0; /* Create flex grid */ wxFlexGridSizer *eq_gridsizer = new wxFlexGridSizer( 2, 12, 0, 0); eq_gridsizer->AddGrowableRow( 0 ); eq_gridsizer->AddGrowableCol( 1 ); preamp_slider = new wxSlider( panel, Preamp_Event, 80, 0, 400, wxDefaultPosition, wxSize( -1 , 90 ) , wxSL_VERTICAL ); eq_gridsizer->Add( preamp_slider, 1, wxEXPAND|wxALL, 2 ); eq_gridsizer->Add( 0, 0, 1, wxALL, 2 ); for( int i = 0 ; i < 10 ; i++ ) { band_sliders[i] = new wxSlider( panel, Band0_Event + i, 200, 0, 400, wxDefaultPosition, wxSize( -1 , 90 ) , wxSL_VERTICAL ); i_values[i] = 200; eq_gridsizer->Add( band_sliders[i], 1, wxEXPAND|wxALL, 2 ); } preamp_text = new wxStaticText( panel, -1, wxT( "Preamp\n12.0dB" ) ); wxFont font= preamp_text->GetFont(); font.SetPointSize(7); preamp_text->SetFont( font ); eq_gridsizer->Add( preamp_text, wxALL, 2 ); eq_gridsizer->Add( 0, 0, 1 ); for( int i = 0 ; i < 10 ; i++ ) { band_texts[i] = new wxStaticText( panel, -1, band_frequencies[i] + wxU("\n0.0dB" ) ) ; eq_gridsizer->Add( band_texts[i], 1, wxEXPAND|wxALL, 2 ); wxFont font= band_texts[i]->GetFont(); font.SetPointSize(7); band_texts[i]->SetFont( font ); } panel_sizer->Add( top_sizer , 0 , wxTOP | wxEXPAND, 5 ); panel_sizer->Add( eq_gridsizer , 0 , wxEXPAND, 0 ); panel->SetSizer( panel_sizer ); panel_sizer->Layout(); panel_sizer->SetSizeHints( panel ); CheckAout(); aout_instance_t *p_aout= (aout_instance_t *)vlc_object_find(p_intf, VLC_OBJECT_AOUT, FIND_ANYWHERE); char *psz_af = NULL; if( p_aout ) { psz_af = var_GetString( p_aout, "audio-filter" ); if( var_GetBool( p_aout, "equalizer-2pass" ) ) eq_2p_chkbox->SetValue( true ); } else { psz_af = config_GetPsz( p_intf, "audio-filter" ); if( config_GetInt( p_intf, "equalizer-2pass" ) ) eq_2p_chkbox->SetValue( true ); } if( psz_af != NULL ? strstr( psz_af, "equalizer" ) != NULL : VLC_FALSE ) { eq_chkbox->SetValue( true ); } else { eq_2p_chkbox->Disable(); eq_restoredefaults_button->Disable(); smooth_slider->Disable(); smooth_text->Disable(); preamp_slider->Disable(); preamp_text->Disable(); for( int i_index=0; i_index < 10; i_index++ ) { band_sliders[i_index]->Disable(); band_texts[i_index]->Disable(); } } free( psz_af ); return panel;}/******************************************************* * Event handlers *******************************************************//* Keep aout up to date and update the bands if needed */void ExtraPanel::OnIdle( wxIdleEvent &event ){ CheckAout(); if( b_update == VLC_TRUE ) { if( b_my_update == VLC_TRUE ) { b_update = b_my_update = VLC_FALSE; return; } char *p = psz_bands; for( int i = 0; i < 10; i++ ) { float f; char psz_val[5]; int i_val; /* Read dB -20/20*/ f = strtof( p, &p ); i_val= (int)( ( f + 20 ) * 10 ); band_sliders[i]->SetValue( 400 - i_val ); i_values[i] = 400 - i_val; sprintf( psz_val, "%.1f", f ); band_texts[i]->SetLabel( band_frequencies[i] + wxT("\n") + wxU( psz_val ) + wxT("dB") ); if( p == NULL ) { break; } p++; if( *p == 0 ) break; } char psz_val[5]; int i_val = (int)( ( f_preamp + 20 ) * 10 ); sprintf( psz_val, "%.1f", f_preamp ); preamp_slider->SetValue( 400 - i_val ); const wxString preamp = wxT("Preamp\n"); preamp_text->SetLabel( preamp + wxU( psz_val ) + wxT( "dB" ) ); eq_chkbox->SetValue( TRUE ); b_update = VLC_FALSE; }}/************************* * Equalizer Panel events *************************/void ExtraPanel::OnEnableEqualizer( wxCommandEvent &event ){ int i_index; aout_instance_t *p_aout= (aout_instance_t *)vlc_object_find(p_intf, VLC_OBJECT_AOUT, FIND_ANYWHERE); ChangeFiltersString( p_intf,p_aout, "equalizer", event.IsChecked() ? VLC_TRUE : VLC_FALSE ); if( event.IsChecked() ) { eq_2p_chkbox->Enable(); eq_restoredefaults_button->Enable(); smooth_slider->Enable(); smooth_text->Enable(); preamp_slider->Enable(); preamp_text->Enable(); for( i_index=0; i_index < 10; i_index++ ) { band_sliders[i_index]->Enable(); band_texts[i_index]->Enable(); } } else { eq_2p_chkbox->Disable(); eq_restoredefaults_button->Disable(); smooth_slider->Disable(); smooth_text->Disable(); preamp_slider->Disable(); preamp_text->Disable(); for( i_index=0; i_index < 10; i_index++ ) { band_sliders[i_index]->Disable(); band_texts[i_index]->Disable(); } } if( p_aout != NULL ) vlc_object_release( p_aout );}void ExtraPanel::OnEqRestore( wxCommandEvent &event ){ aout_instance_t *p_aout= (aout_instance_t *)vlc_object_find(p_intf, VLC_OBJECT_AOUT, FIND_ANYWHERE); if( p_aout == NULL ) { vlc_value_t val; vlc_bool_t b_previous = eq_chkbox->IsChecked(); val.f_float = 12.0; IntfPreampCallback( NULL, NULL, val,val, this ); config_PutFloat( p_intf, "equalizer-preamp", 12.0 ); val.psz_string = strdup( "0 0 0 0 0 0 0 0 0 0" ); IntfBandsCallback( NULL, NULL, val,val, this ); config_PutPsz( p_intf, "equalizer-bands", "0 0 0 0 0 0 0 0 0 0"); config_PutPsz( p_intf, "equalizer-preset","flat" ); eq_chkbox->SetValue( b_previous ); } else { var_SetFloat( p_aout, "equalizer-preamp", 12.0 ); config_PutFloat( p_intf, "equalizer-preamp", 12.0 ); var_SetString( p_aout, "equalizer-bands", "0 0 0 0 0 0 0 0 0 0"); config_PutPsz( p_intf, "equalizer-bands", "0 0 0 0 0 0 0 0 0 0"); var_SetString( p_aout , "equalizer-preset" , "flat" ); config_PutPsz( p_intf, "equalizer-preset","flat" ); vlc_object_release( p_aout ); }}void ExtraPanel::OnEq2Pass( wxCommandEvent &event ){ aout_instance_t *p_aout= (aout_instance_t *)vlc_object_find(p_intf, VLC_OBJECT_AOUT, FIND_ANYWHERE); vlc_bool_t b_2p = event.IsChecked() ? VLC_TRUE : VLC_FALSE; if( p_aout == NULL ) { config_PutInt( p_intf, "equalizer-2pass", b_2p ); } else { var_SetBool( p_aout, "equalizer-2pass", b_2p ); config_PutInt( p_intf, "equalizer-2pass", b_2p ); if( eq_chkbox->IsChecked() ) { for( int i = 0; i < p_aout->i_nb_inputs; i++ ) { p_aout->pp_inputs[i]->b_restart = VLC_TRUE; } } vlc_object_release( p_aout ); }}void ExtraPanel::OnEqSmooth( wxScrollEvent &event ){ /* Max smoothing : 70% */ i_smooth = event.GetPosition() * 7;}void ExtraPanel::OnPreamp( wxScrollEvent &event ){ float f= (float)( 400 - event.GetPosition() ) / 10 - 20 ; char psz_val[5]; aout_instance_t *p_aout= (aout_instance_t *)vlc_object_find(p_intf, VLC_OBJECT_AOUT, FIND_ANYWHERE); sprintf( psz_val, "%.1f", f ); const wxString preamp = wxT("Preamp\n"); preamp_text->SetLabel( preamp + wxU( psz_val ) + wxT( "dB" ) ); if( p_aout == NULL ) { config_PutFloat( p_intf, "equalizer-preamp", f ); } else { var_SetFloat( p_aout, "equalizer-preamp", f ); config_PutFloat( p_intf, "equalizer-preamp", f ); b_my_update = VLC_TRUE; vlc_object_release( p_aout ); }}void ExtraPanel::OnChangeEqualizer( wxScrollEvent &event ){ aout_instance_t *p_aout= (aout_instance_t *)vlc_object_find(p_intf, VLC_OBJECT_AOUT, FIND_ANYWHERE); char psz_values[102]; memset( psz_values, 0, 102 ); /* Smoothing */ int i_diff = event.GetPosition() - i_values[ event.GetId() - Band0_Event ]; i_values[ event.GetId() - Band0_Event] = event.GetPosition(); for( int i = event.GetId() + 1 ; i <= Band9_Event ; i++ ) { int i_new = band_sliders[ i-Band0_Event ]->GetValue() + (int)( i_diff * pow( (float)i_smooth / 100 , i- event.GetId() ) ) ; if( i_new < 0 ) i_new = 0; if( i_new > 400 ) i_new = 400; band_sliders[ i-Band0_Event ]->SetValue( i_new ); } for( int i = Band0_Event ; i < event.GetId() ; i++ ) { int i_new = band_sliders[ i-Band0_Event ]->GetValue() + (int)( i_diff * pow( (float)i_smooth / 100 , event.GetId() - i ) ); if( i_new < 0 ) i_new = 0; if( i_new > 400 ) i_new = 400; band_sliders[ i-Band0_Event ]->SetValue( i_new ); } /* Write the new bands values */ for( int i = 0 ; i < 10 ; i++ ) { char psz_val[5]; float f_val = (float)( 400 - band_sliders[i]->GetValue() ) / 10- 20 ; sprintf( psz_values, "%s %f", psz_values, f_val ); sprintf( psz_val, "%.1f", f_val ); band_texts[i]->SetLabel( band_frequencies[i] + wxT("\n") + wxU( psz_val ) + wxT("dB" ) ); } if( p_aout == NULL ) { config_PutPsz( p_intf, "equalizer-bands", psz_values ); } else { var_SetString( p_aout, "equalizer-bands", psz_values ); config_PutPsz( p_intf, "equalizer-bands", psz_values ); b_my_update = VLC_TRUE; vlc_object_release( p_aout ); }}/*********************** * Audio Panel events ***********************/void ExtraPanel::OnHeadphone( wxCommandEvent &event ){ aout_instance_t *p_aout= (aout_instance_t *)vlc_object_find(p_intf, VLC_OBJECT_AOUT, FIND_ANYWHERE); ChangeFiltersString( p_intf , p_aout, "headphone", event.IsChecked() ? VLC_TRUE : VLC_FALSE ); if( p_aout != NULL ) vlc_object_release( p_aout );}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -