From: Nikolay Tischenko Date: Mon, 27 Sep 2010 15:52:16 +0000 (+0700) Subject: Implemented equalizer X-Git-Tag: 1.3.1~4 X-Git-Url: http://git.maemo.org/git/?p=someplayer;a=commitdiff_plain;h=1d213a9db9b725dc285e92021f35e2f83a813080 Implemented equalizer Added missed license info Removed debug output --- diff --git a/resources/deselect_all.png b/resources/deselect_all.png new file mode 100644 index 0000000..cd56d69 Binary files /dev/null and b/resources/deselect_all.png differ diff --git a/resources/resources.qrc b/resources/resources.qrc index 984ba8d..65725d9 100644 --- a/resources/resources.qrc +++ b/resources/resources.qrc @@ -26,5 +26,7 @@ window.png fullscreen.png volume.png + select_all.png + deselect_all.png diff --git a/resources/select_all.png b/resources/select_all.png new file mode 100644 index 0000000..3d498d2 Binary files /dev/null and b/resources/select_all.png differ diff --git a/someplayer.pro b/someplayer.pro index f7e5f1b..32a62e7 100644 --- a/someplayer.pro +++ b/someplayer.pro @@ -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 = diff --git a/src/busywidget.cpp b/src/busywidget.cpp index c615376..cc05758 100644 --- a/src/busywidget.cpp +++ b/src/busywidget.cpp @@ -19,7 +19,6 @@ #include "busywidget.h" #include "ui_busywidget.h" -#include BusyWidget::BusyWidget(QWidget *parent) : QWidget(parent), diff --git a/src/config.cpp b/src/config.cpp index 422e294..286cca1 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -1,3 +1,22 @@ +/* + * SomePlayer - An alternate music player for Maemo 5 + * Copyright (C) 2010 Nikolay (somebody) Tischenko + * + * 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 #include diff --git a/src/config.h b/src/config.h index b1d98ed..3eeb279 100644 --- a/src/config.h +++ b/src/config.h @@ -1,3 +1,22 @@ +/* + * SomePlayer - An alternate music player for Maemo 5 + * Copyright (C) 2010 Nikolay (somebody) Tischenko + * + * 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 diff --git a/src/dbstorage.cpp b/src/dbstorage.cpp index 8b29483..aba866c 100644 --- a/src/dbstorage.cpp +++ b/src/dbstorage.cpp @@ -20,7 +20,6 @@ #include "dbstorage.h" #include #include -#include 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 index 0000000..847d408 --- /dev/null +++ b/src/equalizerdialog.cpp @@ -0,0 +1,128 @@ +/* + * SomePlayer - An alternate music player for Maemo 5 + * Copyright (C) 2010 Nikolay (somebody) Tischenko + * + * 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 index 0000000..8486677 --- /dev/null +++ b/src/equalizerdialog.h @@ -0,0 +1,61 @@ +/* + * SomePlayer - An alternate music player for Maemo 5 + * Copyright (C) 2010 Nikolay (somebody) Tischenko + * + * 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 + +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 diff --git a/src/filestorage.cpp b/src/filestorage.cpp index a80b733..3dab290 100644 --- a/src/filestorage.cpp +++ b/src/filestorage.cpp @@ -23,7 +23,6 @@ #include #include #include -#include using namespace SomePlayer::Storage; using namespace SomePlayer::DataObjects; diff --git a/src/library.cpp b/src/library.cpp index 7f8165b..d175f5a 100644 --- a/src/library.cpp +++ b/src/library.cpp @@ -18,7 +18,6 @@ */ #include "library.h" -#include using namespace SomePlayer::DataObjects; using namespace SomePlayer::Storage; diff --git a/src/libraryform.cpp b/src/libraryform.cpp index 5fd2177..0db0ebd 100644 --- a/src/libraryform.cpp +++ b/src/libraryform.cpp @@ -26,9 +26,9 @@ #include #include "track.h" #include "playlist.h" -#include #include #include +#include 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")); + } +} + diff --git a/src/libraryform.h b/src/libraryform.h index 6672789..60a276f 100644 --- a/src/libraryform.h +++ b/src/libraryform.h @@ -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(); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index e365dc1..2767608 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -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)); +} diff --git a/src/mainwindow.h b/src/mainwindow.h index 3a274a0..0239c59 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -25,6 +25,7 @@ #include "playerform.h" #include "libraryform.h" #include "busywidget.h" +#include "equalizerdialog.h" #include "library.h" #include @@ -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 diff --git a/src/player/player.cpp b/src/player/player.cpp index 05d37cd..9395d8f 100644 --- a/src/player/player.cpp +++ b/src/player/player.cpp @@ -19,6 +19,11 @@ #include "player.h" #include +#include +#include +#include +#include "../config.h" +#include 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 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 (_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 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 plist = _equalizer->parameters(); + _equalizer->setParameterValue(plist[band], QVariant::fromValue(value)); + Config config; + config.setValue(QString("equalizer/band%1").arg(band), value); +} diff --git a/src/player/player.h b/src/player/player.h index 625aa63..50ab1f8 100644 --- a/src/player/player.h +++ b/src/player/player.h @@ -1,3 +1,22 @@ +/* + * SomePlayer - An alternate music player for Maemo 5 + * Copyright (C) 2010 Nikolay (somebody) Tischenko + * + * 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 #include #include +#include +#include #include #include @@ -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 _history; QQueue _queue; QStack _prev_history; Playlist _playlist; Phonon::MediaObject *_player; Phonon::AudioOutput *_output; + Phonon::Path _path; + Phonon::Effect *_equalizer; PlayerState _state; Config _config; diff --git a/src/playerform.cpp b/src/playerform.cpp index 4aa4e16..31352d0 100644 --- a/src/playerform.cpp +++ b/src/playerform.cpp @@ -21,7 +21,6 @@ #include "ui_playerform.h" #include "library.h" #include "player/player.h" -#include #include #include #include "trackrenderer.h" diff --git a/src/playerform.h b/src/playerform.h index 5f9f00d..b1093a4 100644 --- a/src/playerform.h +++ b/src/playerform.h @@ -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 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(); diff --git a/src/playlist.cpp b/src/playlist.cpp index 2233da3..957ee64 100644 --- a/src/playlist.cpp +++ b/src/playlist.cpp @@ -18,7 +18,6 @@ */ #include "playlist.h" -#include using namespace SomePlayer::DataObjects; diff --git a/src/someplayer.h b/src/someplayer.h index 8920e77..2b026d0 100644 --- a/src/someplayer.h +++ b/src/someplayer.h @@ -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 diff --git a/src/tagresolver.cpp b/src/tagresolver.cpp index 10bf0a6..a91c8e2 100644 --- a/src/tagresolver.cpp +++ b/src/tagresolver.cpp @@ -18,7 +18,6 @@ */ #include "tagresolver.h" -#include #include #include #include diff --git a/src/timerdialog.cpp b/src/timerdialog.cpp index e2856bc..431d6d7 100644 --- a/src/timerdialog.cpp +++ b/src/timerdialog.cpp @@ -1,6 +1,24 @@ +/* + * SomePlayer - An alternate music player for Maemo 5 + * Copyright (C) 2010 Nikolay (somebody) Tischenko + * + * 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 TimerDialog::TimerDialog(QWidget *parent) : QDialog(parent), diff --git a/src/timerdialog.h b/src/timerdialog.h index bc56b10..18513f3 100644 --- a/src/timerdialog.h +++ b/src/timerdialog.h @@ -1,3 +1,22 @@ +/* + * SomePlayer - An alternate music player for Maemo 5 + * Copyright (C) 2010 Nikolay (somebody) Tischenko + * + * 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 index 0000000..faa480d --- /dev/null +++ b/src/ui/equalizerdialog.ui @@ -0,0 +1,190 @@ + + + EqualizerDialog + + + + 0 + 0 + 800 + 480 + + + + Equalizer + + + + + + 0 + + + + + 0 + + + + + Qt::Vertical + + + + + + + Qt::Vertical + + + + + + + Qt::Vertical + + + + + + + Qt::Vertical + + + + + + + Qt::Vertical + + + + + + + Qt::Vertical + + + + + + + Qt::Vertical + + + + + + + Qt::Vertical + + + + + + + Qt::Vertical + + + + + + + Qt::Vertical + + + + + + + + + + + + + + 0 + 0 + + + + + 150 + 0 + + + + Enable + + + true + + + true + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + + + buttonBox + accepted() + EqualizerDialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + EqualizerDialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/src/ui/libraryform.ui b/src/ui/libraryform.ui index 6ba7458..0e91255 100644 --- a/src/ui/libraryform.ui +++ b/src/ui/libraryform.ui @@ -92,6 +92,38 @@ + + + + 0 + 0 + + + + + 70 + 70 + + + + + 70 + 70 + + + + + + + + :/icons/select_all.png:/icons/select_all.png + + + true + + + + diff --git a/src/ui/playerform.ui b/src/ui/playerform.ui index 2ebead7..97219a9 100644 --- a/src/ui/playerform.ui +++ b/src/ui/playerform.ui @@ -143,6 +143,12 @@ Qt::Vertical + + false + + + false +