File indexing completed on 2024-05-05 04:48:36

0001 /****************************************************************************************
0002  * Copyright (c) 2004 Frederik Holljen <fh@ez.no>                                       *
0003  * Copyright (c) 2004,2005 Max Howell <max.howell@methylblue.com>                       *
0004  * Copyright (c) 2004-2013 Mark Kretschmann <kretschmann@kde.org>                       *
0005  * Copyright (c) 2008 Jason A. Donenfeld <Jason@zx2c4.com>                              *
0006  * Copyright (c) 2009 Artur Szymiec <artur.szymiec@gmail.com>                           *
0007  * Copyright (c) 2013 Anmol Ahuja <darthcodus@gmail.com>                                *
0008  *                                                                                      *
0009  * This program is free software; you can redistribute it and/or modify it under        *
0010  * the terms of the GNU General Public License as published by the Free Software        *
0011  * Foundation; either version 2 of the License, or (at your option) any later           *
0012  * version.                                                                             *
0013  *                                                                                      *
0014  * This program is distributed in the hope that it will be useful, but WITHOUT ANY      *
0015  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A      *
0016  * PARTICULAR PURPOSE. See the GNU General Public License for more details.             *
0017  *                                                                                      *
0018  * You should have received a copy of the GNU General Public License along with         *
0019  * this program.  If not, see <http://www.gnu.org/licenses/>.                           *
0020  ****************************************************************************************/
0021 
0022 #ifndef AMAROK_EQUALIZERCONTROLLER_H
0023 #define AMAROK_EQUALIZERCONTROLLER_H
0024 
0025 #include "amarok_export.h"
0026 
0027 #include <QPointer>
0028 
0029 #include <phonon/Path>
0030 #include <phonon/Effect>
0031 
0032 static const int s_equalizerBandsNum = 10; // Number of equalizer parameters excluding Preamp
0033 
0034 class AMAROK_EXPORT EqualizerController : public QObject
0035 {
0036     Q_OBJECT
0037 
0038 public:
0039 
0040     explicit EqualizerController( QObject *object );
0041     ~EqualizerController() override;
0042 
0043     void initialize( const Phonon::Path &path );
0044 
0045     /**
0046      * Phonon equalizer support is required for Amarok to enable equalizer
0047      * this method return whatever phonon support equalizer effect.
0048      *
0049      * @return @c true if the phonon support equalizer effect, @c false otherwise
0050      */
0051     bool isEqSupported() const;
0052 
0053     /**
0054      * Equalizer implementation for different backends may have different
0055      * gain scale. To properly display it we need to get a scale from effect
0056      *
0057      * @return maximum gain value for equalizer parameters.
0058      */
0059     double eqMaxGain() const;
0060 
0061     /**
0062      * Equalizer implementation for different backends may have different
0063      * frequency bands. For proper display this will try to extract frequency values
0064      * from effect parameters info.
0065      *
0066      * @return QStringList with band labels (form xxx Hz or xxx kHz).
0067      */
0068     QStringList eqBandsFreq() const;
0069 
0070     /**
0071      * @return the name of the equalizer preset being currently used.
0072      */
0073     QString equalizerPreset() const;
0074 
0075     /**
0076      * Changes equaliser preset to preset @param name if it exists.
0077      */
0078     void applyEqualizerPresetByName( const QString &name );
0079 
0080     QList<int> gains() const;
0081     void setGains( const QList<int> &gains );
0082     void savePreset( const QString &name, const QList<int> &gains );
0083     bool deletePreset( const QString &name );
0084     bool enabled();
0085 
0086 public Q_SLOTS:
0087 
0088     /**
0089      * Update equalizer status - enabled,disabled,set values
0090      */
0091     void eqUpdate();
0092 
0093     /**
0094      * Change equalizer to preset with index @param index in the global equalizer list.
0095      * Pass -1 to disable.
0096      */
0097     void applyEqualizerPresetByIndex( int index );
0098 
0099 Q_SIGNALS:
0100 
0101     /**
0102      * Emitted when preset with index @param index is applied or the equalizer is disabled.
0103      * index is \<0 when disabled.
0104      */
0105     void presetApplied( int index );
0106 
0107     /**
0108      * Emitted when the current gains are changed.
0109      */
0110     void gainsChanged( const QList<int> &gains );
0111 
0112     /**
0113      * Emitted when preset @param name is added, removed or modified.
0114      */
0115     void presetsChanged( const QString &name );
0116 
0117 private:
0118     QPointer<Phonon::Effect>            m_equalizer;
0119     Phonon::Path                            m_path;
0120 };
0121 
0122 #endif