1 /*****************************************************************************
2 * extrapanel.cpp : wxWindows plugin for vlc
3 *****************************************************************************
4 * Copyright (C) 2000-2004, 2003 VideoLAN
7 * Authors: Clément Stenac <zorglub@videolan.org>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
22 *****************************************************************************/
24 /*****************************************************************************
26 *****************************************************************************/
29 #include <aout_internal.h>
35 #include "wxwindows.h"
37 /*****************************************************************************
38 * Local class declarations.
39 *****************************************************************************/
42 #define SMOOTH_TIP N_( "If this setting is not zero, the bands will move " \
43 "together when you move one. The higher the value is, the " \
44 "more correlated their movement will be." )
46 static int IntfBandsCallback( vlc_object_t *, char const *,
47 vlc_value_t, vlc_value_t, void * );
48 static int IntfPreampCallback( vlc_object_t *, char const *,
49 vlc_value_t, vlc_value_t, void * );
50 static void ChangeFiltersString( intf_thread_t *, aout_instance_t *,
52 static void ChangeVFiltersString( intf_thread_t *, char *, vlc_bool_t );
55 /* IDs for the controls and the menu commands */
61 RestoreDefaults_Event,
72 Filter0_Event, Filter1_Event, Filter2_Event, Filter3_Event, Filter4_Event,
73 Filter5_Event, Filter6_Event, Filter7_Event, Filter8_Event, Filter9_Event,
83 Band0_Event,Band1_Event,Band2_Event,Band3_Event,Band4_Event,
84 Band5_Event,Band6_Event,Band7_Event,Band8_Event,Band9_Event,
86 NormVol_Event, NVSlider_Event, HeadPhone_Event
89 BEGIN_EVENT_TABLE( ExtraPanel, wxPanel )
90 EVT_IDLE( ExtraPanel::OnIdle )
93 EVT_CHECKBOX( EqEnable_Event, ExtraPanel::OnEnableEqualizer )
94 EVT_CHECKBOX( Eq2Pass_Event, ExtraPanel::OnEq2Pass )
95 EVT_BUTTON( EqRestore_Event, ExtraPanel::OnEqRestore )
97 EVT_COMMAND_SCROLL( Preamp_Event, ExtraPanel::OnPreamp )
98 EVT_COMMAND_SCROLL( Smooth_Event, ExtraPanel::OnEqSmooth )
100 EVT_COMMAND_SCROLL(Band0_Event, ExtraPanel::OnChangeEqualizer)
101 EVT_COMMAND_SCROLL(Band1_Event, ExtraPanel::OnChangeEqualizer)
102 EVT_COMMAND_SCROLL(Band2_Event, ExtraPanel::OnChangeEqualizer)
103 EVT_COMMAND_SCROLL(Band3_Event, ExtraPanel::OnChangeEqualizer)
104 EVT_COMMAND_SCROLL(Band4_Event, ExtraPanel::OnChangeEqualizer)
105 EVT_COMMAND_SCROLL(Band5_Event, ExtraPanel::OnChangeEqualizer)
106 EVT_COMMAND_SCROLL(Band6_Event, ExtraPanel::OnChangeEqualizer)
107 EVT_COMMAND_SCROLL(Band7_Event, ExtraPanel::OnChangeEqualizer)
108 EVT_COMMAND_SCROLL(Band8_Event, ExtraPanel::OnChangeEqualizer)
109 EVT_COMMAND_SCROLL(Band9_Event, ExtraPanel::OnChangeEqualizer)
112 EVT_CHECKBOX( Adjust_Event, ExtraPanel::OnEnableAdjust )
113 EVT_BUTTON( RestoreDefaults_Event, ExtraPanel::OnRestoreDefaults )
115 EVT_COMMAND_SCROLL(Hue_Event, ExtraPanel::OnAdjustUpdate)
116 EVT_COMMAND_SCROLL(Contrast_Event, ExtraPanel::OnAdjustUpdate)
117 EVT_COMMAND_SCROLL(Brightness_Event, ExtraPanel::OnAdjustUpdate)
118 EVT_COMMAND_SCROLL(Saturation_Event, ExtraPanel::OnAdjustUpdate)
119 EVT_COMMAND_SCROLL(Gamma_Event, ExtraPanel::OnAdjustUpdate)
121 EVT_BUTTON( FiltersInfo_Event, ExtraPanel::OnFiltersInfo )
123 EVT_CHECKBOX( Filter0_Event, ExtraPanel::OnSelectFilter )
124 EVT_CHECKBOX( Filter1_Event, ExtraPanel::OnSelectFilter )
125 EVT_CHECKBOX( Filter2_Event, ExtraPanel::OnSelectFilter )
126 EVT_CHECKBOX( Filter3_Event, ExtraPanel::OnSelectFilter )
127 EVT_CHECKBOX( Filter4_Event, ExtraPanel::OnSelectFilter )
128 EVT_CHECKBOX( Filter5_Event, ExtraPanel::OnSelectFilter )
129 EVT_CHECKBOX( Filter6_Event, ExtraPanel::OnSelectFilter )
130 EVT_CHECKBOX( Filter7_Event, ExtraPanel::OnSelectFilter )
131 EVT_CHECKBOX( Filter8_Event, ExtraPanel::OnSelectFilter )
132 EVT_CHECKBOX( Filter9_Event, ExtraPanel::OnSelectFilter )
135 EVT_CHECKBOX( NormVol_Event, ExtraPanel::OnNormvol )
136 EVT_CHECKBOX( HeadPhone_Event, ExtraPanel::OnHeadphone )
138 EVT_COMMAND_SCROLL( NVSlider_Event, ExtraPanel::OnNormvolSlider )
148 static const struct filter vfilters[] =
150 { "clone", "Image clone", "Creates several clones of the image" },
151 { "distort", "Distortion", "Adds distorsion effects" },
152 { "invert", "Image inversion" , "Inverts the image colors" },
153 { "crop", "Image cropping", "Crops the image" },
154 { "motionblur", "Blurring", "Creates a motion blurring on the image" },
155 { "transform", "Transformation", "Rotates or flips the image" },
156 { NULL, NULL, NULL } /* Do not remove this line */
159 /*****************************************************************************
161 *****************************************************************************/
162 ExtraPanel::ExtraPanel( intf_thread_t *_p_intf, wxWindow *_p_parent ):
163 wxPanel( _p_parent , -1, wxDefaultPosition, wxDefaultSize )
167 p_parent = _p_parent;
168 SetAutoLayout( TRUE );
170 wxBoxSizer *extra_sizer = new wxBoxSizer( wxHORIZONTAL );
172 notebook = new wxNotebook( this, Notebook_Event );
174 wxNotebookSizer *notebook_sizer = new wxNotebookSizer( notebook );
176 notebook->AddPage( VideoPanel( notebook ), wxU(_("Video")) );
177 notebook->AddPage( EqzPanel( notebook ), wxU(_("Equalizer")) );
178 notebook->AddPage( AudioPanel( notebook ), wxU(_("Audio")) );
180 extra_sizer->Add( notebook_sizer, 1, wxEXPAND, 0 );
182 SetSizerAndFit( extra_sizer );
183 extra_sizer->Layout();
186 ExtraPanel::~ExtraPanel()
190 /* Video Panel constructor */
191 wxPanel *ExtraPanel::VideoPanel( wxWindow *parent )
195 wxPanel *panel = new wxPanel( parent, -1 );
196 wxBoxSizer *panel_sizer = new wxBoxSizer( wxHORIZONTAL );
198 /* Create static box to surround the adjust controls */
199 wxStaticBox *adjust_box =
200 new wxStaticBox( panel, -1, wxU(_("Adjust Image")) );
201 wxStaticBoxSizer *adjust_sizer =
202 new wxStaticBoxSizer( adjust_box, wxVERTICAL );
203 adjust_sizer->SetMinSize( -1, 50 );
205 /* Create flex grid */
206 wxFlexGridSizer *adjust_gridsizer =
207 new wxFlexGridSizer( 6, 2, 0, 0);
208 adjust_gridsizer->AddGrowableCol(1);
210 /* Create the adjust button */
211 wxCheckBox * adjust_check = new wxCheckBox( panel, Adjust_Event,
214 /* Create the restore to defaults button */
215 restoredefaults_button =
216 new wxButton( panel, RestoreDefaults_Event,
217 wxU(_("Restore Defaults")), wxDefaultPosition);
219 wxStaticText *hue_text = new wxStaticText( panel, -1,
221 hue_slider = new wxSlider ( panel, Hue_Event, 0, 0,
222 360, wxDefaultPosition, wxDefaultSize );
224 wxStaticText *contrast_text = new wxStaticText( panel, -1,
225 wxU(_("Contrast")) );
226 contrast_slider = new wxSlider ( panel, Contrast_Event, 0, 0,
227 200, wxDefaultPosition, wxDefaultSize);
229 wxStaticText *brightness_text = new wxStaticText( panel, -1,
230 wxU(_("Brightness")) );
231 brightness_slider = new wxSlider ( panel, Brightness_Event, 0, 0,
232 200, wxDefaultPosition, wxDefaultSize) ;
234 wxStaticText *saturation_text = new wxStaticText( panel, -1,
235 wxU(_("Saturation")) );
236 saturation_slider = new wxSlider ( panel, Saturation_Event, 0, 0,
237 300, wxDefaultPosition, wxDefaultSize );
239 wxStaticText *gamma_text = new wxStaticText( panel, -1,
241 gamma_slider = new wxSlider ( panel, Gamma_Event, 0, 0,
242 100, wxDefaultPosition, wxDefaultSize );
244 adjust_gridsizer->Add( adjust_check, 1, wxEXPAND|wxALL, 2 );
245 adjust_gridsizer->Add( restoredefaults_button, 1, wxEXPAND|wxALL, 2 );
246 adjust_gridsizer->Add( hue_text, 1, wxEXPAND|wxALL, 2 );
247 adjust_gridsizer->Add( hue_slider, 1, wxEXPAND|wxALL, 2 );
248 adjust_gridsizer->Add( contrast_text, 1, wxEXPAND|wxALL, 2 );
249 adjust_gridsizer->Add( contrast_slider, 1, wxEXPAND|wxALL, 2 );
250 adjust_gridsizer->Add( brightness_text, 1, wxEXPAND|wxALL, 2 );
251 adjust_gridsizer->Add( brightness_slider, 1, wxEXPAND|wxALL, 2 );
252 adjust_gridsizer->Add( saturation_text, 1, wxEXPAND|wxALL, 2 );
253 adjust_gridsizer->Add( saturation_slider, 1, wxEXPAND|wxALL, 2 );
254 adjust_gridsizer->Add( gamma_text, 1, wxEXPAND|wxALL, 2 );
255 adjust_gridsizer->Add( gamma_slider, 1, wxEXPAND|wxALL, 2 );
257 adjust_sizer->Add( adjust_gridsizer, 1, wxEXPAND|wxALL, 2);
259 panel_sizer->Add( adjust_sizer , 1, wxTOP, 2 );
262 /* Create sizer to surround the other controls */
263 wxBoxSizer *other_sizer = new wxBoxSizer( wxVERTICAL );
265 wxStaticBox *video_box =
266 new wxStaticBox( panel, -1, wxU(_("Video Options")) );
267 /* Create the sizer for the frame */
268 wxStaticBoxSizer *video_sizer =
269 new wxStaticBoxSizer( video_box, wxVERTICAL );
270 video_sizer->SetMinSize( -1, 50 );
272 static const wxString ratio_array[] =
278 wxBoxSizer *ratio_sizer = new wxBoxSizer( wxHORIZONTAL );
279 wxStaticText *ratio_text = new wxStaticText( panel, -1,
280 wxU(_("Aspect Ratio")) );
282 ratio_combo = new wxComboBox( panel, Ratio_Event, wxT(""),
283 wxDefaultPosition, wxSize( 80 , -1),
284 WXSIZEOF(ratio_array), ratio_array,
287 ratio_sizer->Add( ratio_text, 0, wxALL, 2 );
288 ratio_sizer->Add( ratio_combo, 0, wxALL, 2 );
289 ratio_sizer->Layout();
291 video_sizer->Add( ratio_sizer , 0 , wxALL , 2 );
292 video_sizer->Layout();
295 wxStaticBox *filter_box =
296 new wxStaticBox( panel, -1, wxU(_("Video Filters")) );
297 wxStaticBoxSizer *filter_sizer =
298 new wxStaticBoxSizer( filter_box, wxHORIZONTAL );
300 wxBoxSizer *t_col_sizer = new wxBoxSizer( wxVERTICAL );
303 for( int i = 0 ; vfilters[i].psz_filter != NULL ; i++ )
305 wxCheckBox *box = new wxCheckBox( panel, Filter0_Event + i,
306 wxU( _( vfilters[i].psz_name ) ) );
307 t_col_sizer->Add( box, 0, wxALL, 4 );
308 box->SetToolTip( wxU( _( vfilters[i].psz_help ) ) );
311 filter_sizer->Add( t_col_sizer );
312 filter_sizer->Add( new wxButton( panel, FiltersInfo_Event,
313 wxU(_("More info" ) ) ), 0, wxALL, 4 );
315 other_sizer->Add( video_sizer, 0, wxALL | wxEXPAND , 0);
316 other_sizer->Add( filter_sizer, 0, wxALL | wxEXPAND , 0);
317 other_sizer->Layout();
318 panel_sizer->Add(other_sizer , 1 );
321 panel_sizer->Add( filter_sizer, 1, wxTOP|wxLEFT, 2 );
323 panel->SetSizerAndFit( panel_sizer );
325 /* Layout the whole panel */
326 panel_sizer->Layout();
328 panel_sizer->SetSizeHints( panel );
330 /* Write down initial values */
331 psz_filters = config_GetPsz( p_intf, "filter" );
332 if( psz_filters && strstr( psz_filters, "adjust" ) )
334 adjust_check->SetValue( 1 );
335 restoredefaults_button->Enable();
336 saturation_slider->Enable();
337 contrast_slider->Enable();
338 brightness_slider->Enable();
339 hue_slider->Enable();
340 gamma_slider->Enable();
344 adjust_check->SetValue( 0 );
345 restoredefaults_button->Disable();
346 saturation_slider->Disable();
347 contrast_slider->Disable();
348 brightness_slider->Disable();
349 hue_slider->Disable();
350 gamma_slider->Disable();
352 if( psz_filters ) free( psz_filters );
354 int i_value = config_GetInt( p_intf, "hue" );
355 if( i_value > 0 && i_value < 360 )
356 hue_slider->SetValue( i_value );
358 f_value = config_GetFloat( p_intf, "saturation" );
359 if( f_value > 0 && f_value < 5 )
360 saturation_slider->SetValue( (int)(100 * f_value) );
361 f_value = config_GetFloat( p_intf, "contrast" );
362 if( f_value > 0 && f_value < 4 )
363 contrast_slider->SetValue( (int)(100 * f_value) );
364 f_value = config_GetFloat( p_intf, "brightness" );
365 if( f_value > 0 && f_value < 2 )
366 brightness_slider->SetValue( (int)(100 * f_value) );
367 f_value = config_GetFloat( p_intf, "gamma" );
368 if( f_value > 0 && f_value < 10 )
369 gamma_slider->SetValue( (int)(10 * f_value) );
374 /* Audio panel constructor */
375 wxPanel *ExtraPanel::AudioPanel( wxWindow *parent )
379 wxPanel *panel = new wxPanel( parent, -1 );
380 wxBoxSizer *panel_sizer = new wxBoxSizer( wxHORIZONTAL );
382 /* Create static box to surround the adjust controls */
383 wxStaticBox *filter_box =
384 new wxStaticBox( panel, -1, wxU(_("Audio filters")) );
385 wxStaticBoxSizer *filter_sizer =
386 new wxStaticBoxSizer( filter_box, wxVERTICAL );
387 filter_sizer->SetMinSize( -1, 50 );
389 wxCheckBox * headphone_check = new wxCheckBox( panel, HeadPhone_Event,
390 wxU(_("Headphone virtualization")));
391 headphone_check->SetToolTip( wxU(_("This filter gives the feeling of a "
392 "5.1 speaker set when using a headphone." ) ) );
394 wxCheckBox * normvol_check = new wxCheckBox( panel, NormVol_Event,
395 wxU(_("Volume normalization")));
396 normvol_check->SetToolTip( wxU(_("This filter prevents the audio output "
397 "power from going over a defined value." ) ) );
399 wxStaticText *normvol_label = new wxStaticText( panel, -1,
400 wxU( _("Maximum level") ) );
402 wxSlider *normvol_slider = new wxSlider ( panel, NVSlider_Event, 20, 5,
403 100, wxDefaultPosition, wxSize( 100, -1 ) );
405 filter_sizer->Add( headphone_check, 0, wxALL, 4 );
406 filter_sizer->Add( normvol_check, 0, wxALL, 4 );
407 filter_sizer->Add( normvol_label, 0, wxALL, 4 );
408 filter_sizer->Add( normvol_slider, 0, wxALL, 4 );
410 panel_sizer->Add( filter_sizer, 1, wxTOP, 2 );
411 panel->SetSizerAndFit( panel_sizer );
412 panel_sizer->Layout();
413 panel_sizer->SetSizeHints( panel );
415 /* Write down initial values */
416 psz_filters = config_GetPsz( p_intf, "audio-filter" );
419 headphone_check->SetValue( strstr( psz_filters, "headphone" ) );
420 normvol_check->SetValue( strstr( psz_filters, "normvol" ) );
425 headphone_check->SetValue( 0 );
426 normvol_check->SetValue( 0 );
433 static const wxString band_frequencies[] =
447 /* Equalizer Panel constructor */
448 wxPanel *ExtraPanel::EqzPanel( wxWindow *parent )
450 wxPanel *panel = new wxPanel( parent, -1 );
451 wxBoxSizer *panel_sizer = new wxBoxSizer( wxVERTICAL );
453 /* Create static box to surround the adjust controls */
454 wxBoxSizer *top_sizer =
455 new wxBoxSizer( wxHORIZONTAL );
457 /* Create the enable button */
458 eq_chkbox = new wxCheckBox( panel, EqEnable_Event,
460 eq_chkbox->SetToolTip( wxU(_("Enable the equalizer. You can either "
461 "manually change the bands or use a preset (Audio Menu->Equalizer)." ) ) );
462 top_sizer->Add( eq_chkbox, 0, wxALL, 2 );
464 eq_2p_chkbox = new wxCheckBox( panel, Eq2Pass_Event,
467 eq_2p_chkbox->SetToolTip( wxU(_("If you enable this settting, the "
468 "equalizer filter will be applied twice. The effect will be sharper.") ) );
470 top_sizer->Add( eq_2p_chkbox, 0, wxALL, 2 );
472 top_sizer->Add( 0, 0, 1, wxALL, 2 );
474 top_sizer->Add( new wxButton( panel, EqRestore_Event,
475 wxU( _("Restore Defaults") ) ),
477 top_sizer->Add( 0, 0, 1, wxALL, 2 );
479 wxStaticText *smooth_text = new wxStaticText( panel, -1, wxU( "Smooth :" ));
480 smooth_text->SetToolTip( wxU( SMOOTH_TIP ) );
481 top_sizer->Add( smooth_text, 0, wxALL, 2 );
483 smooth_slider =new wxSlider( panel, Smooth_Event, 0, 0, 10 ,
484 wxDefaultPosition, wxSize( 100, -1 ) );
485 smooth_slider->SetToolTip( wxU( SMOOTH_TIP ) );
486 top_sizer->Add( smooth_slider, 0, wxALL, 2 );
488 /* Create flex grid */
489 wxFlexGridSizer *eq_gridsizer =
490 new wxFlexGridSizer( 2, 12, 0, 0);
491 eq_gridsizer->AddGrowableRow( 0 );
492 eq_gridsizer->AddGrowableCol( 1 );
494 preamp_slider = new wxSlider( panel, Preamp_Event, 200, 0, 400,
495 wxDefaultPosition, wxSize( -1 , 90 ) , wxSL_VERTICAL );
496 eq_gridsizer->Add( preamp_slider, 1, wxEXPAND|wxALL, 2 );
498 eq_gridsizer->Add( 0, 0, 1, wxALL, 2 );
500 for( int i = 0 ; i < 10 ; i++ )
502 band_sliders[i] = new wxSlider( panel, Band0_Event + i, 200, 0, 400,
503 wxDefaultPosition, wxSize( -1 , 90 ) , wxSL_VERTICAL );
506 eq_gridsizer->Add( band_sliders[i], 1, wxEXPAND|wxALL, 2 );
509 preamp_text = new wxStaticText( panel, -1, wxT( "Preamp\n0.0dB" ) );
510 wxFont font= preamp_text->GetFont();
511 font.SetPointSize(7);
512 preamp_text->SetFont( font );
513 eq_gridsizer->Add( preamp_text, wxALL, 2 );
515 eq_gridsizer->Add( 0, 0, 1 );
517 for( int i = 0 ; i < 10 ; i++ )
519 band_texts[i] = new wxStaticText( panel, -1,
520 band_frequencies[i] + wxU("\n0.0dB" ) ) ;
521 eq_gridsizer->Add( band_texts[i], 1, wxEXPAND|wxALL, 2 );
522 wxFont font= band_texts[i]->GetFont();
523 font.SetPointSize(7);
524 band_texts[i]->SetFont( font );
527 panel_sizer->Add( top_sizer , 0 , wxTOP | wxEXPAND, 5 );
528 panel_sizer->Add( eq_gridsizer , 0 , wxEXPAND, 0 );
530 panel->SetSizer( panel_sizer );
532 panel_sizer->Layout();
534 panel_sizer->SetSizeHints( panel );
540 /*******************************************************
542 *******************************************************/
544 /* Keep aout up to date and update the bands if needed */
545 void ExtraPanel::OnIdle( wxIdleEvent &event )
548 if( b_update == VLC_TRUE )
550 if( b_my_update == VLC_TRUE )
552 b_update = b_my_update = VLC_FALSE;
556 for( int i = 0; i < 10; i++ )
563 i_val= (int)( ( f + 20 ) * 10 );
564 band_sliders[i]->SetValue( 400 - i_val );
565 i_values[i] = 400 - i_val;
566 sprintf( psz_val, "%.1f", f );
567 band_texts[i]->SetLabel( band_frequencies[i] + wxT("\n") +
568 wxU( psz_val ) + wxT("dB") );
578 int i_val = (int)( ( f_preamp + 20 ) * 10 );
579 sprintf( psz_val, "%.1f", f_preamp );
580 preamp_slider->SetValue( 400 - i_val );
581 const wxString preamp = wxT("Preamp\n");
582 preamp_text->SetLabel( preamp + wxU( psz_val ) + wxT( "dB" ) );
583 eq_chkbox->SetValue( TRUE );
584 b_update = VLC_FALSE;
588 /*************************
589 * Equalizer Panel events
590 *************************/
591 void ExtraPanel::OnEnableEqualizer( wxCommandEvent &event )
593 aout_instance_t *p_aout= (aout_instance_t *)vlc_object_find(p_intf,
594 VLC_OBJECT_AOUT, FIND_ANYWHERE);
595 ChangeFiltersString( p_intf,p_aout, "equalizer",
596 event.IsChecked() ? VLC_TRUE : VLC_FALSE );
598 vlc_object_release( p_aout );
601 void ExtraPanel::OnEqRestore( wxCommandEvent &event )
603 aout_instance_t *p_aout= (aout_instance_t *)vlc_object_find(p_intf,
604 VLC_OBJECT_AOUT, FIND_ANYWHERE);
608 vlc_bool_t b_previous = eq_chkbox->IsChecked();
610 IntfPreampCallback( NULL, NULL, val,val, this );
611 config_PutFloat( p_intf, "equalizer-preamp", 12.0 );
612 val.psz_string = strdup( "0 0 0 0 0 0 0 0 0 0" );
613 IntfBandsCallback( NULL, NULL, val,val, this );
614 config_PutPsz( p_intf, "equalizer-bands",
615 "0 0 0 0 0 0 0 0 0 0");
616 config_PutPsz( p_intf, "equalizer-preset","flat" );
617 eq_chkbox->SetValue( b_previous );
621 var_SetFloat( p_aout, "equalizer-preamp", 0.0 );
622 var_SetString( p_aout, "equalizer-bands",
623 "0 0 0 0 0 0 0 0 0 0");
624 var_SetString( p_aout , "equalizer-preset" , "flat" );
625 vlc_object_release( p_aout );
629 void ExtraPanel::OnEq2Pass( wxCommandEvent &event )
631 aout_instance_t *p_aout= (aout_instance_t *)vlc_object_find(p_intf,
632 VLC_OBJECT_AOUT, FIND_ANYWHERE);
634 vlc_bool_t b_2p = event.IsChecked() ? VLC_TRUE : VLC_FALSE;
638 config_PutInt( p_intf, "equalizer-2pass", b_2p );
642 var_SetBool( p_aout, "equalizer-2pass", b_2p );
643 if( eq_chkbox->IsChecked() )
645 for( int i = 0; i < p_aout->i_nb_inputs; i++ )
647 p_aout->pp_inputs[i]->b_restart = VLC_TRUE;
650 vlc_object_release( p_aout );
654 void ExtraPanel::OnEqSmooth( wxScrollEvent &event )
656 /* Max smoothing : 70% */
657 i_smooth = event.GetPosition() * 7;
660 void ExtraPanel::OnPreamp( wxScrollEvent &event )
662 float f= (float)( 400 - event.GetPosition() ) / 10 - 20 ;
665 aout_instance_t *p_aout= (aout_instance_t *)vlc_object_find(p_intf,
666 VLC_OBJECT_AOUT, FIND_ANYWHERE);
668 sprintf( psz_val, "%.1f", f );
669 const wxString preamp = wxT("Preamp\n");
670 preamp_text->SetLabel( preamp + wxU( psz_val ) + wxT( "dB" ) );
674 config_PutFloat( p_intf, "equalizer-preamp", f );
678 var_SetFloat( p_aout, "equalizer-preamp", f );
679 b_my_update = VLC_TRUE;
680 vlc_object_release( p_aout );
684 void ExtraPanel::OnChangeEqualizer( wxScrollEvent &event )
686 aout_instance_t *p_aout= (aout_instance_t *)vlc_object_find(p_intf,
687 VLC_OBJECT_AOUT, FIND_ANYWHERE);
688 char psz_values[102];
689 memset( psz_values, 0, 102 );
692 int i_diff = event.GetPosition() - i_values[ event.GetId() - Band0_Event ];
693 i_values[ event.GetId() - Band0_Event] = event.GetPosition();
695 for( int i = event.GetId() + 1 ; i <= Band9_Event ; i++ )
697 int i_new = band_sliders[ i-Band0_Event ]->GetValue() +
698 (int)( i_diff * pow( (float)i_smooth / 100 , i- event.GetId() ) ) ;
699 if( i_new < 0 ) i_new = 0;
700 if( i_new > 400 ) i_new = 400;
701 band_sliders[ i-Band0_Event ]->SetValue( i_new );
703 for( int i = Band0_Event ; i < event.GetId() ; i++ )
705 int i_new = band_sliders[ i-Band0_Event ]->GetValue() +
706 (int)( i_diff * pow( (float)i_smooth / 100 , event.GetId() - i ) );
707 if( i_new < 0 ) i_new = 0;
708 if( i_new > 400 ) i_new = 400;
709 band_sliders[ i-Band0_Event ]->SetValue( i_new );
712 /* Write the new bands values */
713 for( int i = 0 ; i < 10 ; i++ )
716 float f_val = (float)( 400 - band_sliders[i]->GetValue() ) / 10- 20 ;
717 sprintf( psz_values, "%s %f", psz_values, f_val );
718 sprintf( psz_val, "%.1f", f_val );
719 band_texts[i]->SetLabel( band_frequencies[i] + wxT("\n") +
720 wxU( psz_val ) + wxT("dB" ) );
724 config_PutPsz( p_intf, "equalizer-bands", psz_values );
728 var_SetString( p_aout, "equalizer-bands", psz_values );
729 b_my_update = VLC_TRUE;
730 vlc_object_release( p_aout );
734 /***********************
736 ***********************/
737 void ExtraPanel::OnHeadphone( wxCommandEvent &event )
739 aout_instance_t *p_aout= (aout_instance_t *)vlc_object_find(p_intf,
740 VLC_OBJECT_AOUT, FIND_ANYWHERE);
741 ChangeFiltersString( p_intf , p_aout, "headphone",
742 event.IsChecked() ? VLC_TRUE : VLC_FALSE );
744 vlc_object_release( p_aout );
747 void ExtraPanel::OnNormvol( wxCommandEvent &event )
749 aout_instance_t *p_aout= (aout_instance_t *)vlc_object_find(p_intf,
750 VLC_OBJECT_AOUT, FIND_ANYWHERE);
751 ChangeFiltersString( p_intf , p_aout, "normvol",
752 event.IsChecked() ? VLC_TRUE : VLC_FALSE );
754 vlc_object_release( p_aout );
757 void ExtraPanel::OnNormvolSlider( wxScrollEvent &event )
759 aout_instance_t *p_aout= (aout_instance_t *)vlc_object_find(p_intf,
760 VLC_OBJECT_AOUT, FIND_ANYWHERE);
763 var_SetFloat( p_aout, "norm-max-level", (float)event.GetPosition()/10 );
764 vlc_object_release( p_aout );
768 config_PutFloat( p_intf, "norm-max-level",
769 (float)event.GetPosition()/10 );
772 /***********************
774 ***********************/
775 void ExtraPanel::OnEnableAdjust(wxCommandEvent& event)
777 ChangeVFiltersString( p_intf, "adjust",
778 event.IsChecked() ? VLC_TRUE : VLC_FALSE );
780 if( event.IsChecked() )
782 restoredefaults_button->Enable();
783 brightness_slider->Enable();
784 saturation_slider->Enable();
785 contrast_slider->Enable();
786 hue_slider->Enable();
787 gamma_slider->Enable();
791 restoredefaults_button->Disable();
792 brightness_slider->Disable();
793 saturation_slider->Disable();
794 contrast_slider->Disable();
795 hue_slider->Disable();
796 gamma_slider->Disable();
800 void ExtraPanel::OnRestoreDefaults( wxCommandEvent &event)
802 hue_slider->SetValue(0);
803 saturation_slider->SetValue(100);
804 brightness_slider->SetValue(100);
805 contrast_slider->SetValue(100),
806 gamma_slider->SetValue(10);
808 wxScrollEvent *hscroll_event = new wxScrollEvent(0, Hue_Event, 0);
809 OnAdjustUpdate(*hscroll_event);
811 wxScrollEvent *sscroll_event = new wxScrollEvent(0, Saturation_Event, 100);
812 OnAdjustUpdate(*sscroll_event);
814 wxScrollEvent *bscroll_event = new wxScrollEvent(0, Brightness_Event, 100);
815 OnAdjustUpdate(*bscroll_event);
817 wxScrollEvent *cscroll_event = new wxScrollEvent(0, Contrast_Event, 100);
818 OnAdjustUpdate(*cscroll_event);
820 wxScrollEvent *gscroll_event = new wxScrollEvent(0, Gamma_Event, 10);
821 OnAdjustUpdate(*gscroll_event);
825 void ExtraPanel::OnAdjustUpdate( wxScrollEvent &event)
827 vout_thread_t *p_vout = (vout_thread_t *)vlc_object_find(p_intf,
828 VLC_OBJECT_VOUT, FIND_ANYWHERE);
831 switch( event.GetId() )
834 config_PutInt( p_intf , "hue" , event.GetPosition() );
837 case Saturation_Event:
838 config_PutFloat( p_intf , "saturation" ,
839 (float)event.GetPosition()/100 );
842 case Brightness_Event:
843 config_PutFloat( p_intf , "brightness" ,
844 (float)event.GetPosition()/100 );
848 config_PutFloat( p_intf , "contrast" ,
849 (float)event.GetPosition()/100 );
853 config_PutFloat( p_intf , "gamma" ,
854 (float)event.GetPosition()/10 );
861 switch( event.GetId() )
864 val.i_int = event.GetPosition();
865 var_Set( p_vout, "hue", val );
868 case Saturation_Event:
869 val.f_float = (float)event.GetPosition() / 100;
870 var_Set( p_vout, "saturation", val );
873 case Brightness_Event:
874 val.f_float = (float)event.GetPosition() / 100;
875 var_Set( p_vout, "brightness", val );
879 val.f_float = (float)event.GetPosition() / 100;
880 var_Set( p_vout, "contrast", val );
884 val.f_float = (float)event.GetPosition() / 10;
885 var_Set( p_vout, "gamma", val );
888 vlc_object_release(p_vout);
893 void ExtraPanel::OnRatio( wxCommandEvent& event )
895 config_PutPsz( p_intf, "aspect-ratio", ratio_combo->GetValue().mb_str() );
899 void ExtraPanel::OnSelectFilter(wxCommandEvent& event)
901 int i_filter = event.GetId() - Filter0_Event ;
902 if( vfilters[i_filter].psz_filter )
904 ChangeVFiltersString( p_intf, vfilters[i_filter].psz_filter ,
905 event.IsChecked() ? VLC_TRUE : VLC_FALSE );
909 void ExtraPanel::OnFiltersInfo(wxCommandEvent& event)
911 wxMessageBox( wxU( _("Select the video effects filters to apply. "
912 "You must restart the stream for these settings to "
914 "To configure the filters, go to the Preferences, "
915 "and go to Modules/Video Filters. "
916 "You can then configure each filter.\n"
917 "If you want fine control over the filters ( to choose "
918 "the order in which they are applied ), you need to enter "
919 "manually a filters string (Preferences / General / Video)."
921 wxU( _("More information" ) ), wxOK | wxICON_INFORMATION,
924 /**********************************
926 **********************************/
927 void ExtraPanel::CheckAout()
929 aout_instance_t *p_aout= (aout_instance_t *)vlc_object_find(p_intf,
930 VLC_OBJECT_AOUT, FIND_ANYWHERE);
933 if( p_aout != p_intf->p_sys->p_aout )
935 /* We want to know if someone changes the bands */
936 if( var_AddCallback( p_aout, "equalizer-bands",
937 IntfBandsCallback, this ) )
939 /* The variable does not exist yet, wait */
940 vlc_object_release( p_aout );
943 if( var_AddCallback( p_aout, "equalizer-preamp",
944 IntfPreampCallback, this ) )
946 vlc_object_release( p_aout );
949 /* Ok, we have our variables, make a first update round */
950 p_intf->p_sys->p_aout = p_aout;
952 f_preamp = var_GetFloat( p_aout, "equalizer-preamp" );
953 psz_bands = var_GetString( p_aout, "equalizer-bands" );
956 vlc_object_release( p_aout );
961 static void ChangeVFiltersString( intf_thread_t *p_intf,
962 char *psz_name, vlc_bool_t b_add )
964 vout_thread_t *p_vout;
965 char *psz_parser, *psz_string;
967 psz_string = config_GetPsz( p_intf, "filter" );
969 if( !psz_string ) psz_string = strdup("");
971 psz_parser = strstr( psz_string, psz_name );
977 psz_parser = psz_string;
978 asprintf( &psz_string, (*psz_string) ? "%s:%s" : "%s%s",
979 psz_string, psz_name );
991 memmove( psz_parser, psz_parser + strlen(psz_name) +
992 (*(psz_parser + strlen(psz_name)) == ':' ? 1 : 0 ),
993 strlen(psz_parser + strlen(psz_name)) + 1 );
995 /* Remove trailing : : */
996 if( *(psz_string+strlen(psz_string ) -1 ) == ':' )
998 *(psz_string+strlen(psz_string ) -1 ) = '\0';
1007 /* Vout is not kept, so put that in the config */
1008 config_PutPsz( p_intf, "filter", psz_string );
1010 /* Try to set on the fly */
1011 p_vout = (vout_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_VOUT,
1015 var_SetString( p_vout, "filter", psz_string );
1016 vlc_object_release( p_vout );
1023 static void ChangeFiltersString( intf_thread_t *p_intf,
1024 aout_instance_t * p_aout,
1025 char *psz_name, vlc_bool_t b_add )
1027 char *psz_parser, *psz_string;
1031 psz_string = var_GetString( p_aout, "audio-filter" );
1035 psz_string = config_GetPsz( p_intf, "audio-filter" );
1038 if( !psz_string ) psz_string = strdup("");
1040 psz_parser = strstr( psz_string, psz_name );
1046 psz_parser = psz_string;
1047 asprintf( &psz_string, (*psz_string) ? "%s,%s" : "%s%s",
1048 psz_string, psz_name );
1060 memmove( psz_parser, psz_parser + strlen(psz_name) +
1061 (*(psz_parser + strlen(psz_name)) == ',' ? 1 : 0 ),
1062 strlen(psz_parser + strlen(psz_name)) + 1 );
1064 if( *(psz_string+strlen(psz_string ) -1 ) == ',' )
1066 *(psz_string+strlen(psz_string ) -1 ) = '\0';
1076 if( p_aout == NULL )
1078 config_PutPsz( p_intf, "audio-filter", psz_string );
1082 var_SetString( p_aout, "audio-filter", psz_string );
1083 for( int i = 0; i < p_aout->i_nb_inputs; i++ )
1085 p_aout->pp_inputs[i]->b_restart = VLC_TRUE;
1092 static int IntfBandsCallback( vlc_object_t *p_this, char const *psz_cmd,
1093 vlc_value_t oldval, vlc_value_t newval, void *param )
1095 ExtraPanel *p_panel = (ExtraPanel *)param;
1097 p_panel->psz_bands = strdup( newval.psz_string );
1098 p_panel->b_update = VLC_TRUE;
1103 static int IntfPreampCallback( vlc_object_t *p_this, char const *psz_cmd,
1104 vlc_value_t oldval, vlc_value_t newval, void *param )
1106 ExtraPanel *p_panel = (ExtraPanel *)param;
1108 p_panel->f_preamp = newval.f_float;
1109 p_panel->b_update = VLC_TRUE;
1115 /**********************************************************************
1116 * A small window to contain the extrapanel in its undocked state
1117 **********************************************************************/
1118 BEGIN_EVENT_TABLE(ExtraWindow, wxFrame)
1122 ExtraWindow::ExtraWindow( intf_thread_t *_p_intf, wxWindow *p_parent,
1123 wxPanel *_extra_panel ):
1124 wxFrame( p_parent, -1, wxU(_("Extended controls")), wxDefaultPosition,
1125 wxDefaultSize, wxDEFAULT_FRAME_STYLE )
1127 fprintf(stderr,"Creating extrawindow\n");
1129 SetIcon( *p_intf->p_sys->p_icon );
1131 wxBoxSizer *window_sizer = new wxBoxSizer( wxVERTICAL );
1132 SetSizer( window_sizer );
1133 // panel = new ExtraPanel( p_intf, this );//_extra_panel;
1135 panel = _extra_panel;
1136 window_sizer->Add( panel );
1138 window_sizer->Layout();
1139 window_sizer->Fit( this );
1144 ExtraWindow::~ExtraWindow()