[vlc-commits] Qt: display equalizer bands depending on the core

Jean-Baptiste Kempf git at videolan.org
Sun Apr 15 17:19:35 CEST 2012


vlc | branch: master | Jean-Baptiste Kempf <jb at videolan.org> | Fri Apr 13 18:28:17 2012 +0200| [b8bdfbdb024806c355de729046a4e694d295325f] | committer: Jean-Baptiste Kempf

Qt: display equalizer bands depending on the core

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=b8bdfbdb024806c355de729046a4e694d295325f
---

 modules/gui/qt4/components/extended_panels.cpp |   39 ++++++++++++++++++++++--
 modules/gui/qt4/components/extended_panels.hpp |    2 +
 2 files changed, 38 insertions(+), 3 deletions(-)

diff --git a/modules/gui/qt4/components/extended_panels.cpp b/modules/gui/qt4/components/extended_panels.cpp
index 52e55b2..ec1f12a 100644
--- a/modules/gui/qt4/components/extended_panels.cpp
+++ b/modules/gui/qt4/components/extended_panels.cpp
@@ -893,12 +893,18 @@ void ExtV4l2::ValueChange( int value )
  * Equalizer
  **********************************************************************/
 
-static const QString band_frequencies[] =
+static const QString vlc_band_frequencies[] =
 {
     "  60 Hz  ", " 170 Hz ", " 310 Hz ", " 600 Hz ", "  1 kHz ",
     "  3 kHz  ", "  6 kHz ", " 12 kHz ", " 14 kHz ", " 16 kHz "
 };
 
+static const QString iso_band_frequencies[] =
+{
+    " 31.25 Hz ", " 62.5 Hz ", " 125 Hz ", " 250 Hz ", " 500 Hz ",
+    "    1 kHz ", "   2 kHz ", "  4 kHz ", "  8 kHz ", " 16 kHz "
+};
+
 Equalizer::Equalizer( intf_thread_t *_p_intf, QWidget *_parent ) :
                             QWidget( _parent ) , p_intf( _p_intf )
 {
@@ -912,6 +918,8 @@ Equalizer::Equalizer( intf_thread_t *_p_intf, QWidget *_parent ) :
     presetsComboBox = ui.presetsCombo;
     CONNECT( presetsComboBox, activated( int ), this, setCorePreset( int ) );
 
+    b_vlcBands = var_InheritBool( p_intf, "equalizer-vlcfreqs" );
+
     /* Add the sliders for the Bands */
     QGridLayout *grid = new QGridLayout( ui.frame );
     grid->setMargin( 0 );
@@ -923,7 +931,8 @@ Equalizer::Equalizer( intf_thread_t *_p_intf, QWidget *_parent ) :
         bands[i]->setMinimumWidth(34);
         CONNECT( bands[i], valueChanged( int ), this, setCoreBands() );
 
-        band_texts[i] = new QLabel( band_frequencies[i] + "\n00.0dB" );
+        band_texts[i] = new QLabel( b_vlcBands ? vlc_band_frequencies[i]
+                                               : iso_band_frequencies[i] + "\n00.0dB" );
         band_texts[i]->setFont( smallFont );
 
         grid->addWidget( bands[i], 0, i );
@@ -1002,7 +1011,23 @@ void Equalizer::updateUIFromCore()
     free( psz_pres );
 }
 
-/* Functin called when enableButton is toggled */
+void Equalizer::changeFreqLabels( bool b_useVlcBands )
+{
+    b_vlcBands = b_useVlcBands;
+
+    const QString *band_frequencies = b_vlcBands
+                                    ? vlc_band_frequencies
+                                    : iso_band_frequencies;
+
+    for( int i = 0; i < BANDS; i++ )
+    {
+        const float f_val = (float)( bands[i]->value() ) / 10 - 20;
+        QString val = QString("%1").arg( f_val, 5, 'f', 1 );
+        band_texts[i]->setText( band_frequencies[i] + "\n" + val + "dB" );
+    }
+}
+
+/* Function called when enableButton is toggled */
 void Equalizer::enable()
 {
     bool en = ui.enableCheck->isChecked();
@@ -1065,6 +1090,10 @@ void Equalizer::setCoreBands()
 {
     /**\todo smoothing */
 
+    const QString *band_frequencies = b_vlcBands
+                                    ? vlc_band_frequencies
+                                    : iso_band_frequencies;
+
     QString values;
     for( int i = 0; i < BANDS; i++ )
     {
@@ -1111,6 +1140,10 @@ void Equalizer::setCorePreset( int i_preset )
     char *psz_values = createValuesFromPreset( i_preset );
     if( !psz_values ) return ;
 
+    const QString *band_frequencies = b_vlcBands
+                                    ? vlc_band_frequencies
+                                    : iso_band_frequencies;
+
     char *p = psz_values;
     for( int i = 0; i < BANDS && *p; i++ )
     {
diff --git a/modules/gui/qt4/components/extended_panels.hpp b/modules/gui/qt4/components/extended_panels.hpp
index 9964aef..84950b5 100644
--- a/modules/gui/qt4/components/extended_panels.hpp
+++ b/modules/gui/qt4/components/extended_panels.hpp
@@ -93,10 +93,12 @@ public:
 
     char * createValuesFromPreset( int i_preset );
     void updateUIFromCore();
+    void changeFreqLabels( bool );
 private:
     Ui::EqualizerWidget ui;
     QSlider *bands[BANDS];
     QLabel *band_texts[BANDS];
+    bool b_vlcBands;
 
     void delCallbacks( vlc_object_t * );
     void addCallbacks( vlc_object_t * );



More information about the vlc-commits mailing list