Implemented equalizer
authorNikolay Tischenko <niktischenko@gmail.com>
Mon, 27 Sep 2010 15:52:16 +0000 (22:52 +0700)
committerNikolay Tischenko <niktischenko@gmail.com>
Mon, 27 Sep 2010 15:52:16 +0000 (22:52 +0700)
Added missed license info
Removed debug output

28 files changed:
resources/deselect_all.png [new file with mode: 0644]
resources/resources.qrc
resources/select_all.png [new file with mode: 0644]
someplayer.pro
src/busywidget.cpp
src/config.cpp
src/config.h
src/dbstorage.cpp
src/equalizerdialog.cpp [new file with mode: 0644]
src/equalizerdialog.h [new file with mode: 0644]
src/filestorage.cpp
src/library.cpp
src/libraryform.cpp
src/libraryform.h
src/mainwindow.cpp
src/mainwindow.h
src/player/player.cpp
src/player/player.h
src/playerform.cpp
src/playerform.h
src/playlist.cpp
src/someplayer.h
src/tagresolver.cpp
src/timerdialog.cpp
src/timerdialog.h
src/ui/equalizerdialog.ui [new file with mode: 0644]
src/ui/libraryform.ui
src/ui/playerform.ui

diff --git a/resources/deselect_all.png b/resources/deselect_all.png
new file mode 100644 (file)
index 0000000..cd56d69
Binary files /dev/null and b/resources/deselect_all.png differ
index 984ba8d..65725d9 100644 (file)
@@ -26,5 +26,7 @@
         <file>window.png</file>
         <file>fullscreen.png</file>
         <file>volume.png</file>
+        <file>select_all.png</file>
+        <file>deselect_all.png</file>
     </qresource>
 </RCC>
diff --git a/resources/select_all.png b/resources/select_all.png
new file mode 100644 (file)
index 0000000..3d498d2
Binary files /dev/null and b/resources/select_all.png differ
index f7e5f1b..32a62e7 100644 (file)
@@ -117,7 +117,8 @@ SOURCES += src/main.cpp\
     src/taglib/wavpack/wavpackproperties.cpp \
     src/taglib/wavpack/wavpackfile.cpp \
     src/edittagsdialog.cpp \
-    src/timerdialog.cpp
+    src/timerdialog.cpp \
+    src/equalizerdialog.cpp
 
 HEADERS  += src/mainwindow.h \
                src/player/player.h \
@@ -212,7 +213,8 @@ HEADERS  += src/mainwindow.h \
     src/taglib/wavpack/wavpackproperties.h \
     src/taglib/wavpack/wavpackfile.h \
     src/edittagsdialog.h \
-    src/timerdialog.h
+    src/timerdialog.h \
+    src/equalizerdialog.h
 
 FORMS    += src/ui/mainwindow.ui \
     src/ui/playerform.ui \
@@ -220,7 +222,8 @@ FORMS    += src/ui/mainwindow.ui \
     src/ui/busywidget.ui \
     src/ui/playlistdialog.ui \
     src/ui/edittagsdialog.ui \
-    src/ui/timerdialog.ui
+    src/ui/timerdialog.ui \
+    src/ui/equalizerdialog.ui
 
 CONFIG += mobility
 MOBILITY = 
index c615376..cc05758 100644 (file)
@@ -19,7 +19,6 @@
 
 #include "busywidget.h"
 #include "ui_busywidget.h"
-#include <QDebug>
 
 BusyWidget::BusyWidget(QWidget *parent) :
     QWidget(parent),
index 422e294..286cca1 100644 (file)
@@ -1,3 +1,22 @@
+/*
+ * SomePlayer - An alternate music player for Maemo 5
+ * Copyright (C) 2010 Nikolay (somebody) Tischenko <niktischenko@gmail.com>
+ *
+ * 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 the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+
 #include "config.h"
 #include <QString>
 #include <QDir>
index b1d98ed..3eeb279 100644 (file)
@@ -1,3 +1,22 @@
+/*
+ * SomePlayer - An alternate music player for Maemo 5
+ * Copyright (C) 2010 Nikolay (somebody) Tischenko <niktischenko@gmail.com>
+ *
+ * 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 the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+
 #ifndef CONFIG_H
 #define CONFIG_H
 
index 8b29483..aba866c 100644 (file)
@@ -20,7 +20,6 @@
 #include "dbstorage.h"
 #include <QSqlQuery>
 #include <QSqlResult>
-#include <QDebug>
 
 using namespace SomePlayer::Storage;
 using namespace SomePlayer::DataObjects;
@@ -323,7 +322,6 @@ void DbStorage::addTrack(Track track) {
        int artist_id = _check_add_artist(artist);
        int album_id = _check_add_album(album, artist_id);
        if (artist_id == -1 || album_id == -1) {
-               qDebug () << "one";
                //big bang
                return;
        }
@@ -331,7 +329,6 @@ void DbStorage::addTrack(Track track) {
        query->bindValue(":source", source);
        query->exec();
        if (query->next()) {
-               qDebug () << "two";
                // already in datebase, skip
                return;
        }
@@ -353,15 +350,12 @@ void DbStorage::addTrack(Track track) {
                        if (query->exec()) {
                                // ok
                        } else {
-                               qDebug () << "three";
                                // big bang
                        }
                } else {
-                       qDebug () << "four";
                        // big bang
                }
        } else {
-               qDebug () << "five";
                // big bang
        }
 }
@@ -388,25 +382,16 @@ void DbStorage::updateTrackCount(Track track) {
 Track DbStorage::updateTrack(Track track) {
        QSqlQuery *query = _remove_track_query;
        query->bindValue(":id", track.id());
-       if (!query->exec()) {
-               qDebug() << "Problem here";
-       }
        addTrack(track);
        query = _get_track_by_source_query;
        query->bindValue(":source", track.source());
        query->exec();
        if (query->next()) {
-               qDebug() << "enter";
                int id = query->value(0).toInt();
-               qDebug() << id;
                QString title = query->value(1).toString();
-               qDebug() << title;
                QString artist = query->value(2).toString();
-               qDebug() << artist;
                QString album = query->value(3).toString();
-               qDebug() << album;
                QString source = query->value(4).toString();
-               qDebug() << source;
                int count = query->value(5).toInt();
                int length = query->value(6).toInt();
                TrackMetadata meta(title, artist, album, length);
diff --git a/src/equalizerdialog.cpp b/src/equalizerdialog.cpp
new file mode 100644 (file)
index 0000000..847d408
--- /dev/null
@@ -0,0 +1,128 @@
+/*
+ * SomePlayer - An alternate music player for Maemo 5
+ * Copyright (C) 2010 Nikolay (somebody) Tischenko <niktischenko@gmail.com>
+ *
+ * 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 the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+
+#include "equalizerdialog.h"
+#include "ui_equalizerdialog.h"
+
+EqualizerDialog::EqualizerDialog(QWidget *parent) :
+               QDialog(parent),
+               ui(new Ui::EqualizerDialog)
+{
+       ui->setupUi(this);
+       ui->band0Slider->setMinimum(-240);
+       ui->band0Slider->setValue(0);
+       ui->band1Slider->setMinimum(-240);
+       ui->band1Slider->setValue(0);
+       ui->band2Slider->setMinimum(-240);
+       ui->band2Slider->setValue(0);
+       ui->band3Slider->setMinimum(-240);
+       ui->band3Slider->setValue(0);
+       ui->band4Slider->setMinimum(-240);
+       ui->band4Slider->setValue(0);
+       ui->band5Slider->setMinimum(-240);
+       ui->band5Slider->setValue(0);
+       ui->band6Slider->setMinimum(-240);
+       ui->band6Slider->setValue(0);
+       ui->band7Slider->setMinimum(-240);
+       ui->band7Slider->setValue(0);
+       ui->band8Slider->setMinimum(-240);
+       ui->band8Slider->setValue(0);
+       ui->band9Slider->setMinimum(-240);
+       ui->band9Slider->setValue(0);
+
+       ui->band0Slider->setMaximum(120);
+       ui->band1Slider->setMaximum(120);
+       ui->band2Slider->setMaximum(120);
+       ui->band3Slider->setMaximum(120);
+       ui->band4Slider->setMaximum(120);
+       ui->band5Slider->setMaximum(120);
+       ui->band6Slider->setMaximum(120);
+       ui->band7Slider->setMaximum(120);
+       ui->band8Slider->setMaximum(120);
+       ui->band9Slider->setMaximum(120);
+
+       connect(ui->band0Slider, SIGNAL(sliderMoved(int)), this, SLOT(_value0_changed(int)));
+       connect(ui->band1Slider, SIGNAL(sliderMoved(int)), this, SLOT(_value1_changed(int)));
+       connect(ui->band2Slider, SIGNAL(sliderMoved(int)), this, SLOT(_value2_changed(int)));
+       connect(ui->band3Slider, SIGNAL(sliderMoved(int)), this, SLOT(_value3_changed(int)));
+       connect(ui->band4Slider, SIGNAL(sliderMoved(int)), this, SLOT(_value4_changed(int)));
+       connect(ui->band5Slider, SIGNAL(sliderMoved(int)), this, SLOT(_value5_changed(int)));
+       connect(ui->band6Slider, SIGNAL(sliderMoved(int)), this, SLOT(_value6_changed(int)));
+       connect(ui->band7Slider, SIGNAL(sliderMoved(int)), this, SLOT(_value7_changed(int)));
+       connect(ui->band8Slider, SIGNAL(sliderMoved(int)), this, SLOT(_value8_changed(int)));
+       connect(ui->band9Slider, SIGNAL(sliderMoved(int)), this, SLOT(_value9_changed(int)));
+
+       connect(ui->enableToggleButton, SIGNAL(clicked()), this, SLOT(_state_changed()));
+
+}
+
+EqualizerDialog::~EqualizerDialog()
+{
+       delete ui;
+}
+
+void EqualizerDialog::setValue(int band, int val) {
+       switch (band) {
+       case 0:
+               ui->band0Slider->setValue(val); break;
+       case 1:
+               ui->band1Slider->setValue(val); break;
+       case 2:
+               ui->band2Slider->setValue(val); break;
+       case 3:
+               ui->band3Slider->setValue(val); break;
+       case 4:
+               ui->band4Slider->setValue(val); break;
+       case 5:
+               ui->band5Slider->setValue(val); break;
+       case 6:
+               ui->band6Slider->setValue(val); break;
+       case 7:
+               ui->band7Slider->setValue(val); break;
+       case 8:
+               ui->band8Slider->setValue(val); break;
+       case 9:
+               ui->band9Slider->setValue(val); break;
+       }
+
+}
+
+void EqualizerDialog::_state_changed() {
+       if (ui->enableToggleButton->isChecked()) {
+               setEqualizerEnabled(true);
+               emit equalizerEnabled();
+       } else {
+               setEqualizerEnabled(false);
+               emit equalizerDisabled();
+       }
+}
+
+void EqualizerDialog::setEqualizerEnabled(bool enabled) {
+       ui->band0Slider->setEnabled(enabled);
+       ui->band1Slider->setEnabled(enabled);
+       ui->band2Slider->setEnabled(enabled);
+       ui->band3Slider->setEnabled(enabled);
+       ui->band4Slider->setEnabled(enabled);
+       ui->band5Slider->setEnabled(enabled);
+       ui->band6Slider->setEnabled(enabled);
+       ui->band7Slider->setEnabled(enabled);
+       ui->band8Slider->setEnabled(enabled);
+       ui->band9Slider->setEnabled(enabled);
+       ui->enableToggleButton->setChecked(enabled);
+}
diff --git a/src/equalizerdialog.h b/src/equalizerdialog.h
new file mode 100644 (file)
index 0000000..8486677
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ * SomePlayer - An alternate music player for Maemo 5
+ * Copyright (C) 2010 Nikolay (somebody) Tischenko <niktischenko@gmail.com>
+ *
+ * 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 the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+
+#ifndef EQUALIZERDIALOG_H
+#define EQUALIZERDIALOG_H
+
+#include <QDialog>
+
+namespace Ui {
+       class EqualizerDialog;
+}
+
+class EqualizerDialog : public QDialog
+{
+       Q_OBJECT
+public:
+       explicit EqualizerDialog(QWidget *parent = 0);
+       ~EqualizerDialog();
+signals:
+       void valueChanged(int, int);
+       void equalizerDisabled();
+       void equalizerEnabled();
+
+public slots:
+       void setValue(int, int);
+       void setEqualizerEnabled(bool);
+
+private slots:
+       void _value0_changed(int v) { emit valueChanged(0, v);}
+       void _value1_changed(int v) { emit valueChanged(1, v);}
+       void _value2_changed(int v) { emit valueChanged(2, v);}
+       void _value3_changed(int v) { emit valueChanged(3, v);}
+       void _value4_changed(int v) { emit valueChanged(4, v);}
+       void _value5_changed(int v) { emit valueChanged(5, v);}
+       void _value6_changed(int v) { emit valueChanged(6, v);}
+       void _value7_changed(int v) { emit valueChanged(7, v);}
+       void _value8_changed(int v) { emit valueChanged(8, v);}
+       void _value9_changed(int v) { emit valueChanged(9, v);}
+
+       void _state_changed();
+private:
+       Ui::EqualizerDialog *ui;
+};
+
+#endif // EQUALIZERDIALOG_H
index a80b733..3dab290 100644 (file)
@@ -23,7 +23,6 @@
 #include <QFileInfo>
 #include <QTextStream>
 #include <QRegExp>
-#include <QDebug>
 
 using namespace SomePlayer::Storage;
 using namespace SomePlayer::DataObjects;
index 7f8165b..d175f5a 100644 (file)
@@ -18,7 +18,6 @@
  */
 
 #include "library.h"
-#include <QDebug>
 
 using namespace SomePlayer::DataObjects;
 using namespace SomePlayer::Storage;
index 5fd2177..0db0ebd 100644 (file)
@@ -26,9 +26,9 @@
 #include <QModelIndexList>
 #include "track.h"
 #include "playlist.h"
-#include <QDebug>
 #include <QTime>
 #include <QQueue>
+#include <QMessageBox>
 
 using namespace SomePlayer::DataObjects;
 
@@ -72,6 +72,7 @@ LibraryForm::LibraryForm(Library *lib, QWidget *parent) :
        connect(ui->dynamicButton, SIGNAL(clicked()), this, SLOT(_dynamic_button()));
        connect(ui->listView, SIGNAL(clicked(QModelIndex)), this, SLOT(_process_list_click(QModelIndex)));
        connect(ui->addButton, SIGNAL(clicked()), this, SLOT(_add_button()));
+       connect(ui->selectAllButton, SIGNAL(clicked()), this, SLOT(_toggle_select_all_button()));
        connect(ui->backButton, SIGNAL(clicked()), this, SLOT(_back_button()));
        connect(ui->deleteButton, SIGNAL(clicked()), this, SLOT(_delete_button()));
        connect(ui->useButton, SIGNAL(clicked()), this, SLOT(_use_button()));
@@ -283,7 +284,6 @@ void LibraryForm::_delete_button() {
                int count = to_delete.count();
                for (int i = count-1; i >= 0; i--) {
                        _current_playlist.removeTrackAt(to_delete.at(i));
-                       qDebug() << "Removing from" << _current_playlist.name() << to_delete.at(i);
                }
                _current_tracks = _current_playlist.tracks();
                _lib->savePlaylist(_current_playlist);
@@ -299,7 +299,6 @@ void LibraryForm::_delete_button() {
                for (int i = count-1; i >= 0; i--) {
                        QString name = _model->item(to_delete.at(i))->text();
                        if (name != _CURRENT_PLAYLIST_SUBST_) {
-                               qDebug() << "deleting " << name;
                                _lib->removePlaylist(name);
                                _model->removeRow(to_delete.at(i));
                        }
@@ -384,3 +383,14 @@ void LibraryForm::refresh() {
                break;
        }
 }
+
+void LibraryForm::_toggle_select_all_button() {
+       if (ui->listView->selectionModel()->selectedIndexes().count() == ui->listView->model()->rowCount()) {
+               ui->listView->selectionModel()->clearSelection();
+               ui->selectAllButton->setIcon(QIcon(":/icons/select_all.png"));
+       } else {
+               ui->listView->selectAll();
+               ui->selectAllButton->setIcon(QIcon(":/icons/deselect_all.png"));
+       }
+}
+
index 6672789..60a276f 100644 (file)
@@ -60,6 +60,7 @@ private slots:
        void _view_button();
        void _dynamic_button();
        void _playlists_button();
+       void _toggle_select_all_button();
        void _add_button();
        void _delete_button();
        void _back_button();
index e365dc1..2767608 100644 (file)
@@ -28,6 +28,7 @@
 
 #include "library.h"
 #include "timerdialog.h"
+#include "equalizerdialog.h"
 
 using namespace SomePlayer::DataObjects;
 using namespace SomePlayer::Storage;
@@ -46,6 +47,7 @@ MainWindow::MainWindow(QWidget *parent) :
        _library_form = new LibraryForm(_library, ui->stackedWidget);
        _busy_widget = new BusyWidget(ui->stackedWidget);
        _timer = new QTimer(this);
+       _equalizer_dialog = new EqualizerDialog(this);
        ui->stackedWidget->insertWidget(0, _player_form);
        ui->stackedWidget->insertWidget(1, _library_form);
        ui->stackedWidget->insertWidget(2, _busy_widget);
@@ -54,6 +56,7 @@ MainWindow::MainWindow(QWidget *parent) :
        QAction *clear_playlist = ui->menuLibrary->addAction("Clear current playlist");
        QAction *add_files = ui->menuLibrary->addAction("Add file to current playlist");
        QAction *set_timer = ui->menuBar->addAction("Set timer");
+       QAction *equalizer = ui->menuBar->addAction("Euqalizer");
        connect(_player_form, SIGNAL(library()), this, SLOT(library()));
        connect(_library_form, SIGNAL(player()), this, SLOT(player()));
        connect(add_directory, SIGNAL(triggered()), this, SLOT(_add_directory()));
@@ -61,6 +64,7 @@ MainWindow::MainWindow(QWidget *parent) :
        connect(clear_playlist, SIGNAL(triggered()), this, SLOT(_clear_current_playlist()));
        connect(add_files, SIGNAL(triggered()), this, SLOT(_add_files()));
        connect(set_timer, SIGNAL(triggered()), this, SLOT(_set_timer()));
+       connect(equalizer, SIGNAL(triggered()), this, SLOT(_equalizer()));
        connect(_library, SIGNAL(done()), this, SLOT(library()));
        connect(_library, SIGNAL(done()), _library_form, SLOT(refresh()));
        connect(_library, SIGNAL(addingTracks(int)), _busy_widget, SLOT(setMax(int)));
@@ -75,6 +79,9 @@ MainWindow::MainWindow(QWidget *parent) :
        connect(ui->prevButton, SIGNAL(clicked()), this, SLOT(_prevItem()));
        connect(ui->fscreenButton, SIGNAL(clicked()), this, SLOT(_toggle_full_screen()));
        connect(_timer, SIGNAL(timeout()), this, SLOT(_timeout()));
+       connect(_equalizer_dialog, SIGNAL(valueChanged(int,int)), this, SLOT(_equalizer_value_changed(int, int)));
+       connect(_equalizer_dialog, SIGNAL(equalizerEnabled()), _player_form, SLOT(enableEqualizer()));
+       connect(_equalizer_dialog, SIGNAL(equalizerDisabled()), _player_form, SLOT(disableEqualizer()));
        hideSearchPanel();
        library();
 }
@@ -261,3 +268,21 @@ void MainWindow::_timeout() {
        _player_form->stop();
        _timer->stop();
 }
+
+void MainWindow::_equalizer() {
+       if (_player_form->isEqualizerAvailable()) {
+               double val = 0;
+               for (int i = 0; i < 10; i++) {
+                       _player_form->equalizerValue(i, &val);
+                       _equalizer_dialog->setValue(i, (int)(val * 10 + 0.5));
+               }
+               _equalizer_dialog->setEqualizerEnabled(_player_form->isEqualizerEnabled());
+               _equalizer_dialog->exec();
+       } else {
+               QMessageBox::information(this, "Error", "No equalizer support. Please install gstreamer0.10-plugins-good-extra");
+       }
+}
+
+void MainWindow::_equalizer_value_changed(int band, int val) {
+       _player_form->setEqualizerValue(band, (val / 10.0));
+}
index 3a274a0..0239c59 100644 (file)
@@ -25,6 +25,7 @@
 #include "playerform.h"
 #include "libraryform.h"
 #include "busywidget.h"
+#include "equalizerdialog.h"
 #include "library.h"
 #include <QTimer>
 
@@ -66,12 +67,15 @@ private slots:
        void _toggle_full_screen();
        void _set_timer();
        void _timeout();
+       void _equalizer();
+       void _equalizer_value_changed(int, int);
 private:
        PlayerForm *_player_form;
        LibraryForm *_library_form;
        BusyWidget *_busy_widget;
        Library *_library;
        QTimer *_timer;
+       EqualizerDialog *_equalizer_dialog;
 };
 
 #endif // MAINWINDOW_H
index 05d37cd..9395d8f 100644 (file)
 
 #include "player.h"
 #include <phonon/MediaSource>
+#include <phonon/Effect>
+#include <phonon/BackendCapabilities>
+#include <phonon/EffectParameter>
+#include "../config.h"
+#include <QTime>
 
 using namespace SomePlayer::Playback;
 using namespace SomePlayer::DataObjects;
@@ -30,10 +35,30 @@ Player::Player(QObject *parent) :
        _player = new Phonon::MediaObject(this);
        _output = new Phonon::AudioOutput(Phonon::MusicCategory, this);
        _player->setTickInterval(1000);
+       _equalizer == NULL;
+       _equalizer_enabled == false;
+       QList<Phonon::EffectDescription> effects = Phonon::BackendCapabilities::availableAudioEffects();
+       foreach (Phonon::EffectDescription desc, effects) {
+               if (desc.name() == "equalizer-10bands") {
+                       _equalizer = new Phonon::Effect(desc, this);
+                       Config config;
+                       if (config.getValue("equalizer/equalizer").toString() == "enabled") {
+                               for (int i = 0; i < 10; i++) {
+                                       QVariant var = config.getValue(QString("equalizer/band%1").arg(i));
+                                       setEqualizerValue(i, var.toDouble());
+                               }
+                               _equalizer_enabled = true;
+                       } else if (config.getValue("equalizer/equalizer") == "") {
+                               for (int i = 0; i < 10; i++) {
+                                       config.setValue(QString("equalizer/band%1").arg(i), 0);
+                               }
+                       }
+               }
+       }
        connect(_player, SIGNAL(stateChanged(Phonon::State,Phonon::State)), this, SLOT(_stateChanged(Phonon::State,Phonon::State)));
        connect(_player, SIGNAL(tick(qint64)), this, SLOT(_tick(qint64)));
-       Phonon::createPath(_player, _output);
-       int seed = reinterpret_cast<int> (_player);
+       _path = Phonon::createPath(_player, _output);
+       int seed = QTime::currentTime().msec();
        qsrand(seed);
        _random = _config.getValue("playback/random").toBool();
        _repeat = _config.getValue("playback/repeat").toBool();
@@ -135,7 +160,6 @@ void Player::_stateChanged(Phonon::State newState, Phonon::State /*oldState*/) {
                break;
        case Phonon::ErrorState:
                _state = PLAYER_ERROR;
-               qDebug() << _player->errorString();
                break;
        }
 }
@@ -191,3 +215,39 @@ void Player::toggleRepeat() {
 void Player::setVolume(int v) {
        _output->setVolume(v*0.01);
 }
+
+void Player::equalizerValue(int band, double *val) {
+       if (band < 0 || band > 9) {
+               *val = -24;
+               return;
+       }
+       if (_equalizer_enabled) {
+               QList<Phonon::EffectParameter> plist = _equalizer->parameters();
+               QVariant var = _equalizer->parameterValue(plist[band]);
+               *val = var.toDouble();
+       }
+}
+
+void Player::enableEqualizer() {
+       _equalizer_enabled = true;
+       _path.insertEffect(_equalizer);
+       Config config;
+       config.setValue("equalizer/equalizer", "enabled");
+}
+
+void Player::disableEqualizer() {
+       _equalizer_enabled = false;
+       _path.removeEffect(_equalizer);
+       Config config;
+       config.setValue("equalizer/equalizer", "disabled");
+}
+
+void Player::setEqualizerValue(int band, double value) {
+       if (band < 0 || band > 9 || value < -24 || value > 12) {
+               return;
+       }
+       QList<Phonon::EffectParameter> plist = _equalizer->parameters();
+       _equalizer->setParameterValue(plist[band], QVariant::fromValue(value));
+       Config config;
+       config.setValue(QString("equalizer/band%1").arg(band), value);
+}
index 625aa63..50ab1f8 100644 (file)
@@ -1,3 +1,22 @@
+/*
+ * SomePlayer - An alternate music player for Maemo 5
+ * Copyright (C) 2010 Nikolay (somebody) Tischenko <niktischenko@gmail.com>
+ *
+ * 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 the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+
 #ifndef PLAYER_H
 #define PLAYER_H
 
@@ -9,6 +28,8 @@
 #include <phonon/MediaObject>
 #include <phonon/AudioOutput>
 #include <phonon/VolumeSlider>
+#include <phonon/Effect>
+#include <phonon/Path>
 #include <QStack>
 #include <QQueue>
 
@@ -34,6 +55,8 @@ namespace SomePlayer {
                        bool repeat() {return _repeat;}
                        int volume() {return (int)(_output->volume()*100 + 0.5);}
                        Phonon::MediaObject* mediaObject() {return _player;}
+                       bool equalizerEnabled() {return _equalizer_enabled;}
+                       bool equalizerAvailable() {return _equalizer != NULL;}
 
                signals:
                        void stateChanged (PlayerState);
@@ -54,6 +77,10 @@ namespace SomePlayer {
                        void toggleRepeat();
                        void seek(int);
                        void setVolume(int);
+                       void enableEqualizer();
+                       void disableEqualizer();
+                       void setEqualizerValue(int band, double value);
+                       void equalizerValue(int band, double *);
                private slots:
                        void _stateChanged(Phonon::State, Phonon::State);
                        void _tick(qint64);
@@ -62,12 +89,15 @@ namespace SomePlayer {
                        Track _track; // current track (workaround)
                        bool _random;
                        bool _repeat;
+                       bool _equalizer_enabled;
                        QStack<int> _history;
                        QQueue<int> _queue;
                        QStack<int> _prev_history;
                        Playlist _playlist;
                        Phonon::MediaObject *_player;
                        Phonon::AudioOutput *_output;
+                       Phonon::Path _path;
+                       Phonon::Effect *_equalizer;
                        PlayerState _state;
                        Config _config;
 
index 4aa4e16..31352d0 100644 (file)
@@ -21,7 +21,6 @@
 #include "ui_playerform.h"
 #include "library.h"
 #include "player/player.h"
-#include <QDebug>
 #include <QTime>
 #include <QSlider>
 #include "trackrenderer.h"
index 5f9f00d..b1093a4 100644 (file)
@@ -48,7 +48,10 @@ class PlayerForm : public QWidget
 
 public:
        explicit PlayerForm(Library *lib, QWidget *parent = 0);
-    ~PlayerForm();
+       ~PlayerForm();
+       bool isEqualizerEnabled() { return _player->equalizerEnabled(); }
+       bool isEqualizerAvailable() { return _player->equalizerAvailable(); }
+
 signals:
        void library();
        void showSearchPanel();
@@ -62,6 +65,10 @@ public slots:
        void cancelSearch();
        void addFiles(QList<QString> files);
        void stop();
+       void setEqualizerValue(int band, double value) { _player->setEqualizerValue(band, value); }
+       void equalizerValue(int band, double *value) { _player->equalizerValue(band, value); }
+       void enableEqualizer() { _player->enableEqualizer(); }
+       void disableEqualizer() { _player->disableEqualizer(); }
 
 private slots:
        void _library();
index 2233da3..957ee64 100644 (file)
@@ -18,7 +18,6 @@
  */
 
 #include "playlist.h"
-#include <QDebug>
 
 using namespace SomePlayer::DataObjects;
 
index 8920e77..2b026d0 100644 (file)
@@ -47,7 +47,7 @@ namespace SomePlayer {
 #include "config.h"
 
 #define _DYNAMIC_PLAYLIST_MAX_COUNT_ 50
-#define _SOMEPLAYER_VERSION_ "1.2.1"
+#define _SOMEPLAYER_VERSION_ "1.2.2"
 #define NDEBUG
 
 #endif
index 10bf0a6..a91c8e2 100644 (file)
@@ -18,7 +18,6 @@
  */
 
 #include "tagresolver.h"
-#include <QDebug>
 #include <QFile>
 #include <tag.h>
 #include <fileref.h>
index e2856bc..431d6d7 100644 (file)
@@ -1,6 +1,24 @@
+/*
+ * SomePlayer - An alternate music player for Maemo 5
+ * Copyright (C) 2010 Nikolay (somebody) Tischenko <niktischenko@gmail.com>
+ *
+ * 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 the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+
 #include "timerdialog.h"
 #include "ui_timerdialog.h"
-#include <QDebug>
 
 TimerDialog::TimerDialog(QWidget *parent) :
     QDialog(parent),
index bc56b10..18513f3 100644 (file)
@@ -1,3 +1,22 @@
+/*
+ * SomePlayer - An alternate music player for Maemo 5
+ * Copyright (C) 2010 Nikolay (somebody) Tischenko <niktischenko@gmail.com>
+ *
+ * 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 the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+
 #ifndef TIMERDIALOG_H
 #define TIMERDIALOG_H
 
diff --git a/src/ui/equalizerdialog.ui b/src/ui/equalizerdialog.ui
new file mode 100644 (file)
index 0000000..faa480d
--- /dev/null
@@ -0,0 +1,190 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>EqualizerDialog</class>
+ <widget class="QDialog" name="EqualizerDialog">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>800</width>
+    <height>480</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Equalizer</string>
+  </property>
+  <layout class="QVBoxLayout" name="verticalLayout">
+   <item>
+    <layout class="QHBoxLayout" name="horizontalLayout_2">
+     <property name="spacing">
+      <number>0</number>
+     </property>
+     <item>
+      <layout class="QHBoxLayout" name="horizontalLayout">
+       <property name="spacing">
+        <number>0</number>
+       </property>
+       <item>
+        <widget class="QSlider" name="band0Slider">
+         <property name="orientation">
+          <enum>Qt::Vertical</enum>
+         </property>
+        </widget>
+       </item>
+       <item>
+        <widget class="QSlider" name="band1Slider">
+         <property name="orientation">
+          <enum>Qt::Vertical</enum>
+         </property>
+        </widget>
+       </item>
+       <item>
+        <widget class="QSlider" name="band2Slider">
+         <property name="orientation">
+          <enum>Qt::Vertical</enum>
+         </property>
+        </widget>
+       </item>
+       <item>
+        <widget class="QSlider" name="band3Slider">
+         <property name="orientation">
+          <enum>Qt::Vertical</enum>
+         </property>
+        </widget>
+       </item>
+       <item>
+        <widget class="QSlider" name="band4Slider">
+         <property name="orientation">
+          <enum>Qt::Vertical</enum>
+         </property>
+        </widget>
+       </item>
+       <item>
+        <widget class="QSlider" name="band5Slider">
+         <property name="orientation">
+          <enum>Qt::Vertical</enum>
+         </property>
+        </widget>
+       </item>
+       <item>
+        <widget class="QSlider" name="band6Slider">
+         <property name="orientation">
+          <enum>Qt::Vertical</enum>
+         </property>
+        </widget>
+       </item>
+       <item>
+        <widget class="QSlider" name="band7Slider">
+         <property name="orientation">
+          <enum>Qt::Vertical</enum>
+         </property>
+        </widget>
+       </item>
+       <item>
+        <widget class="QSlider" name="band8Slider">
+         <property name="orientation">
+          <enum>Qt::Vertical</enum>
+         </property>
+        </widget>
+       </item>
+       <item>
+        <widget class="QSlider" name="band9Slider">
+         <property name="orientation">
+          <enum>Qt::Vertical</enum>
+         </property>
+        </widget>
+       </item>
+      </layout>
+     </item>
+    </layout>
+   </item>
+   <item>
+    <layout class="QHBoxLayout" name="horizontalLayout_3">
+     <item>
+      <widget class="QPushButton" name="enableToggleButton">
+       <property name="sizePolicy">
+        <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+         <horstretch>0</horstretch>
+         <verstretch>0</verstretch>
+        </sizepolicy>
+       </property>
+       <property name="minimumSize">
+        <size>
+         <width>150</width>
+         <height>0</height>
+        </size>
+       </property>
+       <property name="text">
+        <string>Enable</string>
+       </property>
+       <property name="checkable">
+        <bool>true</bool>
+       </property>
+       <property name="flat">
+        <bool>true</bool>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <spacer name="horizontalSpacer_2">
+       <property name="orientation">
+        <enum>Qt::Horizontal</enum>
+       </property>
+       <property name="sizeHint" stdset="0">
+        <size>
+         <width>40</width>
+         <height>20</height>
+        </size>
+       </property>
+      </spacer>
+     </item>
+     <item>
+      <widget class="QDialogButtonBox" name="buttonBox">
+       <property name="orientation">
+        <enum>Qt::Horizontal</enum>
+       </property>
+       <property name="standardButtons">
+        <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+       </property>
+      </widget>
+     </item>
+    </layout>
+   </item>
+  </layout>
+ </widget>
+ <resources/>
+ <connections>
+  <connection>
+   <sender>buttonBox</sender>
+   <signal>accepted()</signal>
+   <receiver>EqualizerDialog</receiver>
+   <slot>accept()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>248</x>
+     <y>254</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>157</x>
+     <y>274</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>buttonBox</sender>
+   <signal>rejected()</signal>
+   <receiver>EqualizerDialog</receiver>
+   <slot>reject()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>316</x>
+     <y>260</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>286</x>
+     <y>274</y>
+    </hint>
+   </hints>
+  </connection>
+ </connections>
+</ui>
index 6ba7458..0e91255 100644 (file)
       </widget>
      </item>
      <item>
+      <widget class="QPushButton" name="selectAllButton">
+       <property name="sizePolicy">
+        <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+         <horstretch>0</horstretch>
+         <verstretch>0</verstretch>
+        </sizepolicy>
+       </property>
+       <property name="minimumSize">
+        <size>
+         <width>70</width>
+         <height>70</height>
+        </size>
+       </property>
+       <property name="maximumSize">
+        <size>
+         <width>70</width>
+         <height>70</height>
+        </size>
+       </property>
+       <property name="text">
+        <string/>
+       </property>
+       <property name="icon">
+        <iconset resource="../../resources/resources.qrc">
+         <normaloff>:/icons/select_all.png</normaloff>:/icons/select_all.png</iconset>
+       </property>
+       <property name="flat">
+        <bool>true</bool>
+       </property>
+      </widget>
+     </item>
+     <item>
       <widget class="QPushButton" name="addButton">
        <property name="sizePolicy">
         <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
index 2ebead7..97219a9 100644 (file)
          <property name="orientation">
           <enum>Qt::Vertical</enum>
          </property>
+         <property name="invertedAppearance">
+          <bool>false</bool>
+         </property>
+         <property name="invertedControls">
+          <bool>false</bool>
+         </property>
         </widget>
        </item>
       </layout>