Bug 96302

Summary: feature request for amarok (equalizer presets)
Product: [Applications] amarok Reporter: Tassilo Horn <tassilo>
Component: generalAssignee: Amarok Developers <amarok-bugs-dist>
Status: RESOLVED FIXED    
Severity: wishlist CC: dato, kde-bugs, lpradobr
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Gentoo Packages   
OS: Linux   
Latest Commit: Version Fixed In:

Description Tassilo Horn 2005-01-04 17:51:15 UTC
Version:           1.2.0-beta2 (using KDE KDE 3.3.2)
Installed from:    Gentoo Packages
OS:                Linux

Hi,

it would be nice to have presets for amarok's equalizer. These could be winamp-compatible or have their own format. 

One thing what could be really great and no music player has at the moment would be a context sensitive preset chooser which looks at the current tracks Genre-Tag and chooses the preset one defined for that genre.

For tracks which don't have such a tag, it's empty or there's nothing defined for the genre one should be able to choose a default preset.

Ok, hope you like this idea. Thanks for making the best audio player arround.

Tassilo (tassilo80@audioscrobbler)
Comment 1 Gleb Litvjak 2005-03-15 13:40:38 UTC
I agree that it would be a nice feature.
Comment 2 Alexandre Oliveira 2005-05-01 05:29:35 UTC
*** Bug 104883 has been marked as a duplicate of this bug. ***
Comment 3 Mario Galanti 2005-06-10 15:03:16 UTC
*** This bug has been confirmed by popular vote. ***
Comment 4 Seb Ruiz 2005-07-21 10:18:10 UTC
SVN commit 437197 by seb:

Feature: 17 Equalizer Presets!
BUG:96302


 M  +1 -0      ChangeLog  
 M  +1 -0      src/data/Makefile.am  
 A             src/data/equalizer_presets.xml  
 M  +70 -2     src/equalizersetup.cpp  
 M  +9 -1      src/equalizersetup.h  


--- trunk/extragear/multimedia/amarok/ChangeLog #437196:437197
@@ -5,6 +5,7 @@
 
 VERSION 1.3-beta3:
   FEATURES:
+    * 17 Equalizer presets. (BR 96302)
     * xine-engine supports crossfading. Note: Your audio device must support
       mixing. SBLive, dmix or ALSA 1.0.9 will do the trick.
     * Shuffle the queue list in the queue manager. (BR 108861)
--- trunk/extragear/multimedia/amarok/src/data/Makefile.am #437196:437197
@@ -5,6 +5,7 @@
     Cool-Streams.xml \
     ball.png \
     dot.png \
+    equalizer_presets.xml \
     grid.png \
     wirl1.png \
     wirl2.png
--- trunk/extragear/multimedia/amarok/src/equalizersetup.cpp #437196:437197
@@ -2,6 +2,7 @@
  Setup dialog for equalizer
 
  (c) 2004 Mark Kretschmann <markey@web.de>
+ (c) 2005 Seb Ruiz <me@sebruiz.net>
 ***************************************************************************/
 
 /***************************************************************************
@@ -22,16 +23,21 @@
 #include "sliderwidget.h"
 
 #include <qcheckbox.h>
+#include <qdom.h>
 #include <qgroupbox.h>
 #include <qhbox.h>
 #include <qlabel.h>
 #include <qlayout.h>
 #include <qstringlist.h>
+#include <qtextstream.h>   //presets
 #include <qvbox.h>
 
 #include <kapplication.h>
 #include <kdebug.h>
 #include <klocale.h>
+#include <kpopupmenu.h>
+#include <kstandarddirs.h> //locate()
+#include <ktoolbar.h>      //presets
 #include <kwin.h>
 
 EqualizerSetup* EqualizerSetup::s_instance = 0;
@@ -51,10 +57,24 @@
     setMargin( 8 );
     setSpacing( 8 );
 
+    QHBox *header = new QHBox( this );
     // BEGIN Equalizer Graph Widget
-    m_equalizerGraph = new EqualizerGraph( new QHBox( this ) );
-    //END
+    m_equalizerGraph = new EqualizerGraph( header );
+    // END Graph Widget
 
+    // BEGIN Presets
+    m_equalizerPresets = new KPopupMenu( header );
+    loadPresets();
+    connect( m_equalizerPresets, SIGNAL( activated(int) ), SLOT( presetChanged(int) ) );
+
+    KToolBar* toolBar = new KToolBar( header );
+    toolBar->setIconText( KToolBar::IconTextRight );
+    toolBar->setIconSize( 16 );
+    toolBar->setBarPos( KToolBar::Right );
+    toolBar->setFrameShape( QFrame::NoFrame );
+    toolBar->insertButton( "configure", 0, m_equalizerPresets, true, i18n( "Presets" ) );
+    // END Presets
+
     // BEGIN GroupBox
     QGroupBox* groupBox_sliders = new QGroupBox( 11, Qt::Horizontal, i18n("Enable Equalizer"), this );
     groupBox_sliders->setCheckable( true );
@@ -120,11 +140,59 @@
     m_equalizerGraph->update();
 }
 
+void
+EqualizerSetup::loadPresets()
+{
+    QFile file( locate( "data","amarok/data/equalizer_presets.xml" ) );
+    QTextStream stream( &file );
+    stream.setEncoding( QTextStream::UnicodeUTF8 );
+
+    QDomDocument d;
+
+    if( !file.open( IO_ReadOnly ) || !d.setContent( stream.read() ) )
+        return;
+
+    QDomNode n = d.namedItem( "equalizerpresets" ).namedItem("preset");
+
+    for( ; !n.isNull();  n = n.nextSibling(), m_totalPresets++ )
+    {
+        QDomElement e = n.toElement();
+        QString title = e.attribute( "name" );
+
+        QValueList<int> gains;
+        gains << e.namedItem( "preamp" ).toElement().text().toInt();
+        gains << e.namedItem( "b0" ).toElement().text().toInt();
+        gains << e.namedItem( "b1" ).toElement().text().toInt();
+        gains << e.namedItem( "b2" ).toElement().text().toInt();
+        gains << e.namedItem( "b3" ).toElement().text().toInt();
+        gains << e.namedItem( "b4" ).toElement().text().toInt();
+        gains << e.namedItem( "b5" ).toElement().text().toInt();
+        gains << e.namedItem( "b6" ).toElement().text().toInt();
+        gains << e.namedItem( "b7" ).toElement().text().toInt();
+        gains << e.namedItem( "b8" ).toElement().text().toInt();
+        gains << e.namedItem( "b9" ).toElement().text().toInt();
+
+        m_presets[ m_totalPresets ] = gains;
+        m_equalizerPresets->insertItem( title, m_totalPresets );
+    }
+}
+
+
 /////////////////////////////////////////////////////////////////////////////////////
 // PUBLIC SLOTS
 /////////////////////////////////////////////////////////////////////////////////////
 
 void
+EqualizerSetup::presetChanged( int id ) //SLOT
+{
+    QValueList<int> gains = m_presets[ id ];
+    int preamp = gains.first();
+    gains.pop_front();
+
+    updateSliders( preamp, gains );
+}
+
+void
 EqualizerSetup::setEqualizerEnabled( bool active ) //SLOT
 {
     EngineController::engine()->setEqualizerEnabled( active );
--- trunk/extragear/multimedia/amarok/src/equalizersetup.h #437196:437197
@@ -2,6 +2,7 @@
  Setup dialog for equalizer
 
  (c) 2004 Mark Kretschmann <markey@web.de>
+ (c) 2005 Seb Ruiz <me@sebruiz.net>
 ***************************************************************************/
 
 /***************************************************************************
@@ -21,6 +22,7 @@
 
 class EqualizerGraph;
 class QCheckBox;
+class KPopupMenu;
 
 namespace amaroK { class Slider; }
 
@@ -39,6 +41,7 @@
         void updateSliders(int, QValueList<int>);
 
     private slots:
+        void presetChanged( int id );
         void setEqualizerEnabled( bool );
         void setEqualizerParameters();
 
@@ -47,8 +50,13 @@
 
         amaroK::Slider* m_slider_preamp;
         EqualizerGraph* m_equalizerGraph;
+        QPtrList<amaroK::Slider> m_bandSliders;
 
-        QPtrList<amaroK::Slider> m_bandSliders;
+        void    loadPresets();
+        KPopupMenu*     m_equalizerPresets;
+        int             m_currentPreset;
+        uint            m_totalPresets;
+        QMap< int, QValueList<int> > m_presets;
 };
 
 
Comment 5 Ritesh Raj Sarraf 2008-02-09 13:23:13 UTC
I'm not sure if what feature request has been put here by the bug reported is implemented or not. At least I don't see it in my Amarok which is at version 1.4.8.

I had the same request and implemented the feature as an add-on script for Amarok,
autoEqualizer, available at:
http://www.kde-apps.org/content/show.php?content=70509

It is also available through KHNS. So just use Amarok and install the new script.