* all: added a new variable "equalizer.preamp" (self-explanatory ;) in skins
authorCyril Deguet <asmax@videolan.org>
Sun, 27 Nov 2005 16:01:53 +0000 (16:01 +0000)
committerCyril Deguet <asmax@videolan.org>
Sun, 27 Nov 2005 16:01:53 +0000 (16:01 +0000)
* winamp2.xml: added preamp slider and fixed offsets

modules/gui/skins2/commands/cmd_vars.cpp
modules/gui/skins2/commands/cmd_vars.hpp
modules/gui/skins2/src/vlcproc.cpp
modules/gui/skins2/src/vlcproc.hpp
modules/gui/skins2/vars/equalizer.cpp
modules/gui/skins2/vars/equalizer.hpp
modules/gui/skins2/vars/time.hpp
share/skins2/winamp2.xml

index 9c846f0..b64ede8 100644 (file)
@@ -65,3 +65,9 @@ void CmdSetEqBands::execute()
     m_rEqBands.set( m_value );
 }
 
+
+void CmdSetEqPreamp::execute()
+{
+    // Change the preamp variable
+    m_rPreamp.set( m_value, false );
+}
index de31378..a2445ed 100644 (file)
@@ -28,6 +28,7 @@
 #include "../utils/ustring.hpp"
 
 class EqualizerBands;
+class EqualizerPreamp;
 class VarText;
 
 /// Command to notify the playlist of a change
@@ -79,6 +80,29 @@ class CmdSetText: public CmdGeneric
 };
 
 
+/// Command to set the equalizer preamp
+class CmdSetEqPreamp: public CmdGeneric
+{
+    public:
+        CmdSetEqPreamp( intf_thread_t *pIntf, EqualizerPreamp &rPreamp,
+                       float value ):
+            CmdGeneric( pIntf ), m_rPreamp( rPreamp ), m_value( value ) {}
+        virtual ~CmdSetEqPreamp() {}
+
+        /// This method does the real job of the command
+        virtual void execute();
+
+        /// Return the type of the command
+        virtual string getType() const { return "set equalizer preamp"; }
+
+    private:
+        /// Preamp variable to set
+        EqualizerPreamp &m_rPreamp;
+        /// Value to set
+        float m_value;
+};
+
+
 /// Command to set the equalizerbands
 class CmdSetEqBands: public CmdGeneric
 {
index 5b25e97..d86436e 100644 (file)
@@ -5,7 +5,7 @@
  * $Id$
  *
  * Authors: Cyril Deguet     <asmax@via.ecp.fr>
- *          Olivier Teulière <ipkiss@via.ecp.fr>
+ *          Olivier Teulie <ipkiss@via.ecp.fr>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -98,6 +98,7 @@ VlcProc::VlcProc( intf_thread_t *pIntf ): SkinObject( pIntf ),
     REGISTER_VAR( m_cVarPaused, VarBoolImpl, "vlc.isPaused" )
     REGISTER_VAR( m_cVarSeekable, VarBoolImpl, "vlc.isSeekable" )
     REGISTER_VAR( m_cVarEqualizer, VarBoolImpl, "equalizer.isEnabled" )
+    REGISTER_VAR( m_cVarEqPreamp, EqualizerPreamp, "equalizer.preamp" )
 #undef REGISTER_VAR
     m_cVarStreamName = VariablePtr( new VarText( getIntf(), false ) );
     pVarManager->registerVar( m_cVarStreamName, "streamName" );
@@ -304,9 +305,11 @@ void VlcProc::refreshAudio()
     {
         if( pAout != m_pAout )
         {
-            // Register the equalizer callback
+            // Register the equalizer callbacks
             if( !var_AddCallback( pAout, "equalizer-bands",
-                                 onEqBandsChange, this ) )
+                                  onEqBandsChange, this ) &&
+                !var_AddCallback( pAout, "equalizer-preamp",
+                                  onEqPreampChange, this ) )
             {
                 m_pAout = pAout;
                 //char * psz_bands = var_GetString( p_aout, "equalizer-bands" );
@@ -567,3 +570,20 @@ int VlcProc::onEqBandsChange( vlc_object_t *pObj, const char *pVariable,
     return VLC_SUCCESS;
 }
 
+
+int VlcProc::onEqPreampChange( vlc_object_t *pObj, const char *pVariable,
+                               vlc_value_t oldVal, vlc_value_t newVal,
+                               void *pParam )
+{
+    VlcProc *pThis = (VlcProc*)pParam;
+    EqualizerPreamp *pVarPreamp = (EqualizerPreamp*)(pThis->m_cVarEqPreamp.get());
+
+    // Post a set preamp command
+    CmdSetEqPreamp *pCmd = new CmdSetEqPreamp( pThis->getIntf(), *pVarPreamp,
+                                              (newVal.f_float + 20.0) / 40.0 );
+    AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
+    pQueue->push( CmdGenericPtr( pCmd ) );
+
+    return VLC_SUCCESS;
+}
+
index 8d0113f..16e6580 100644 (file)
@@ -5,7 +5,7 @@
  * $Id$
  *
  * Authors: Cyril Deguet     <asmax@via.ecp.fr>
- *          Olivier Teulière <ipkiss@via.ecp.fr>
+ *          Olivier Teulie <ipkiss@via.ecp.fr>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -119,8 +119,9 @@ class VlcProc: public SkinObject
         VariablePtr m_cVarSeekable;
         /// Variable for the vout
         VarBox m_varVoutSize;
-        /// Equalizer variable
+        /// Equalizer variables
         EqualizerBands m_varEqBands;
+        VariablePtr m_cVarEqPreamp;
         VariablePtr m_cVarEqualizer;
 
         /// Set of handles of vout windows
@@ -194,6 +195,11 @@ class VlcProc: public SkinObject
         static int onEqBandsChange( vlc_object_t *pObj, const char *pVariable,
                                     vlc_value_t oldVal, vlc_value_t newVal,
                                     void *pParam );
+
+        /// Callback for equalizer-preamp variable
+        static int onEqPreampChange( vlc_object_t *pObj, const char *pVariable,
+                                     vlc_value_t oldVal, vlc_value_t newVal,
+                                     void *pParam );
 };
 
 
index 27b23b1..87fca34 100644 (file)
@@ -96,7 +96,7 @@ void EqualizerBands::onUpdate( Subject<VarPercent> &rBand )
             ss << " " << val;
         }
 
-        aout_instance_t *pAout= (aout_instance_t *)vlc_object_find( getIntf(),
+        aout_instance_t *pAout = (aout_instance_t *)vlc_object_find( getIntf(),
                 VLC_OBJECT_AOUT, FIND_ANYWHERE );
         char *bands = (char*)ss.str().c_str();
         config_PutPsz( getIntf(), "equalizer-bands", bands );
@@ -109,3 +109,31 @@ void EqualizerBands::onUpdate( Subject<VarPercent> &rBand )
     }
 }
 
+
+EqualizerPreamp::EqualizerPreamp( intf_thread_t *pIntf ): VarPercent( pIntf )
+{
+    // Initial value
+    VarPercent::set( 0.8 );
+}
+
+
+void EqualizerPreamp::set( float percentage, bool updateVLC )
+{
+    VarPercent::set( percentage );
+
+    // Avoid infinite loop
+    if( updateVLC )
+    {
+        float val = 40 * percentage - 20;
+
+        aout_instance_t *pAout = (aout_instance_t *)vlc_object_find( getIntf(),
+                                VLC_OBJECT_AOUT, FIND_ANYWHERE );
+        config_PutFloat( getIntf(), "equalizer-preamp", val );
+        if( pAout )
+        {
+            // Update the audio output
+            var_SetFloat( pAout, "equalizer-preamp", val );
+            vlc_object_release( pAout );
+        }
+    }
+}
index 08f45bc..48bc031 100644 (file)
@@ -56,4 +56,17 @@ class EqualizerBands: public SkinObject, public Observer<VarPercent>
 };
 
 
+/// Variable for equalizer preamp
+class EqualizerPreamp: public VarPercent
+{
+    public:
+        EqualizerPreamp( intf_thread_t *pIntf );
+        virtual ~EqualizerPreamp() {}
+
+        virtual void set( float percentage, bool updateVLC );
+
+        void set( float percentage ) { set( percentage, true ); }
+};
+
+
 #endif
index 0292c43..5768587 100644 (file)
@@ -5,7 +5,7 @@
  * $Id$
  *
  * Authors: Cyril Deguet     <asmax@via.ecp.fr>
- *          Olivier Teulière <ipkiss@via.ecp.fr>
+ *          Olivier Teulie <ipkiss@via.ecp.fr>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -28,7 +28,7 @@
 #include "../utils/var_percent.hpp"
 #include <string>
 
-/// Variable for VLC strem time
+/// Variable for VLC stream time
 class StreamTime: public VarPercent
 {
     public:
index 58380a2..fdd88a0 100644 (file)
                 <Button x="254" y="3" up="eq_switch_up" down="eq_switch_down" over="eq_switch_up" action="equalizer_window.setLayout(eq_small_layout)" tooltiptext="Switch" />
                 <Button x="264" y="3" up="eq_close_up" down="eq_close_down" over="eq_close_up" action="equalizer_window.hide()" tooltiptext="Close the window" />
                 <Checkbox x="15" y="18" up1="eq_notok_up" down1="eq_notok_down" up2="eq_ok_up" down2="eq_ok_down" state="equalizer.isEnabled" action1="equalizer.enable()" action2="equalizer.disable()" tooltiptext1="Enable equalizer" tooltiptext2="Disable equalizer" />
-                <Slider value="equalizer.band(0)" x="78" y="37" up="eq_slider_up" down="eq_slider_down" points="(6,55),(6,7)" thickness="6" tooltiptext="">
+               <Slider value="equalizer.preamp" x="21" y="39" up="eq_slider_up" down="eq_slider_down" points="(6,55),(6,7)" thickness="6" tooltiptext="">
                     <SliderBackground image="eq_slider_bg" nbhoriz="14" nbvert="2" padhoriz="1" padvert="1" />
                 </Slider>
-                <Slider value="equalizer.band(1)" x="96" y="37" up="eq_slider_up" down="eq_slider_down" points="(6,55),(6,7)" thickness="6" tooltiptext="">
+                <Slider value="equalizer.band(0)" x="78" y="39" up="eq_slider_up" down="eq_slider_down" points="(6,55),(6,7)" thickness="6" tooltiptext="">
                     <SliderBackground image="eq_slider_bg" nbhoriz="14" nbvert="2" padhoriz="1" padvert="1" />
                 </Slider>
-                <Slider value="equalizer.band(2)" x="114" y="37" up="eq_slider_up" down="eq_slider_down" points="(6,55),(6,7)" thickness="6" tooltiptext="">
+                <Slider value="equalizer.band(1)" x="96" y="39" up="eq_slider_up" down="eq_slider_down" points="(6,55),(6,7)" thickness="6" tooltiptext="">
                     <SliderBackground image="eq_slider_bg" nbhoriz="14" nbvert="2" padhoriz="1" padvert="1" />
                 </Slider>
-                <Slider value="equalizer.band(3)" x="132" y="37" up="eq_slider_up" down="eq_slider_down" points="(6,55),(6,7)" thickness="6" tooltiptext="">
+                <Slider value="equalizer.band(2)" x="114" y="39" up="eq_slider_up" down="eq_slider_down" points="(6,55),(6,7)" thickness="6" tooltiptext="">
                     <SliderBackground image="eq_slider_bg" nbhoriz="14" nbvert="2" padhoriz="1" padvert="1" />
                 </Slider>
-                <Slider value="equalizer.band(4)" x="150" y="37" up="eq_slider_up" down="eq_slider_down" points="(6,55),(6,7)" thickness="6" tooltiptext="">
+                <Slider value="equalizer.band(3)" x="132" y="39" up="eq_slider_up" down="eq_slider_down" points="(6,55),(6,7)" thickness="6" tooltiptext="">
                     <SliderBackground image="eq_slider_bg" nbhoriz="14" nbvert="2" padhoriz="1" padvert="1" />
                 </Slider>
-                <Slider value="equalizer.band(5)" x="168" y="37" up="eq_slider_up" down="eq_slider_down" points="(6,55),(6,7)" thickness="6" tooltiptext="">
+                <Slider value="equalizer.band(4)" x="150" y="39" up="eq_slider_up" down="eq_slider_down" points="(6,55),(6,7)" thickness="6" tooltiptext="">
                     <SliderBackground image="eq_slider_bg" nbhoriz="14" nbvert="2" padhoriz="1" padvert="1" />
                 </Slider>
-                <Slider value="equalizer.band(6)" x="186" y="37" up="eq_slider_up" down="eq_slider_down" points="(6,55),(6,7)" thickness="6" tooltiptext="">
+                <Slider value="equalizer.band(5)" x="168" y="39" up="eq_slider_up" down="eq_slider_down" points="(6,55),(6,7)" thickness="6" tooltiptext="">
                     <SliderBackground image="eq_slider_bg" nbhoriz="14" nbvert="2" padhoriz="1" padvert="1" />
                 </Slider>
-                <Slider value="equalizer.band(7)" x="204" y="37" up="eq_slider_up" down="eq_slider_down" points="(6,55),(6,7)" thickness="6" tooltiptext="">
+                <Slider value="equalizer.band(6)" x="186" y="39" up="eq_slider_up" down="eq_slider_down" points="(6,55),(6,7)" thickness="6" tooltiptext="">
                     <SliderBackground image="eq_slider_bg" nbhoriz="14" nbvert="2" padhoriz="1" padvert="1" />
                 </Slider>
-                <Slider value="equalizer.band(8)" x="222" y="37" up="eq_slider_up" down="eq_slider_down" points="(6,55),(6,7)" thickness="6" tooltiptext="">
+                <Slider value="equalizer.band(7)" x="204" y="39" up="eq_slider_up" down="eq_slider_down" points="(6,55),(6,7)" thickness="6" tooltiptext="">
                     <SliderBackground image="eq_slider_bg" nbhoriz="14" nbvert="2" padhoriz="1" padvert="1" />
                 </Slider>
-                <Slider value="equalizer.band(9)" x="240" y="37" up="eq_slider_up" down="eq_slider_down" points="(6,55),(6,7)" thickness="6" tooltiptext="">
+                <Slider value="equalizer.band(8)" x="222" y="39" up="eq_slider_up" down="eq_slider_down" points="(6,55),(6,7)" thickness="6" tooltiptext="">
+                    <SliderBackground image="eq_slider_bg" nbhoriz="14" nbvert="2" padhoriz="1" padvert="1" />
+                </Slider>
+                <Slider value="equalizer.band(9)" x="240" y="39" up="eq_slider_up" down="eq_slider_down" points="(6,55),(6,7)" thickness="6" tooltiptext="">
                     <SliderBackground image="eq_slider_bg" nbhoriz="14" nbvert="2" padhoriz="1" padvert="1" />
                 </Slider>
             </Group>