├── screenshot.png ├── GraphicEQWidget ├── icons │ ├── go-up.ico │ ├── edit-copy.ico │ ├── edit-cut.ico │ ├── power_off.ico │ ├── power_on.ico │ ├── arrow_right.ico │ ├── document-new.ico │ ├── edit-delete.ico │ ├── edit-paste.ico │ ├── document-open.ico │ ├── document-save.ico │ ├── list-add-green.ico │ ├── reset_response.ico │ ├── resize_corner.ico │ ├── document-save-as.ico │ ├── edit-select-all.ico │ ├── invert_response.ico │ ├── list-remove-red.ico │ ├── normalize_response.ico │ ├── accessories-text-editor.ico │ ├── format-justify-fill-rotated.ico │ ├── applications-graphics-rotated.ico │ ├── arrow_right.svg │ ├── invert_response.svg │ ├── power_off.svg │ ├── power_on.svg │ ├── reset_response.svg │ ├── normalize_response.svg │ ├── resize_corner.svg │ └── resize_corner_20.svg ├── helpers │ ├── ColorHelper.h │ ├── ColorHelper.cpp │ ├── DPIHelper.h │ ├── GainIterator.h │ ├── DPIHelper.cpp │ └── GainIterator.cpp ├── GraphicEQWidget.qrc ├── GraphicEQWidget.pri ├── GraphicEQFilterGUIView.h ├── widgets │ ├── FrequencyPlotHRuler.h │ ├── FrequencyPlotVRuler.h │ ├── FrequencyPlotItem.h │ ├── FrequencyPlotItem.cpp │ ├── FrequencyPlotScene.h │ ├── FrequencyPlotView.h │ ├── FrequencyPlotScene.cpp │ ├── FrequencyPlotVRuler.cpp │ ├── FrequencyPlotHRuler.cpp │ └── FrequencyPlotView.cpp ├── GraphicEQFilterGUIItem.h ├── GraphicEQFilterGUIView.cpp ├── GraphicEQFilterGUIScene.h ├── GraphicEQFilterGUI.h ├── GraphicEQFilterGUIItem.cpp ├── GraphicEQFilterGUIScene.cpp ├── GraphicEQFilterGUI.ui ├── LICENSE └── GraphicEQFilterGUI.cpp ├── main.cpp ├── demo.pro ├── README.md ├── LICENSE └── demo.pro.user /screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timschneeb/GraphicEQWidget/HEAD/screenshot.png -------------------------------------------------------------------------------- /GraphicEQWidget/icons/go-up.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timschneeb/GraphicEQWidget/HEAD/GraphicEQWidget/icons/go-up.ico -------------------------------------------------------------------------------- /GraphicEQWidget/icons/edit-copy.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timschneeb/GraphicEQWidget/HEAD/GraphicEQWidget/icons/edit-copy.ico -------------------------------------------------------------------------------- /GraphicEQWidget/icons/edit-cut.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timschneeb/GraphicEQWidget/HEAD/GraphicEQWidget/icons/edit-cut.ico -------------------------------------------------------------------------------- /GraphicEQWidget/icons/power_off.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timschneeb/GraphicEQWidget/HEAD/GraphicEQWidget/icons/power_off.ico -------------------------------------------------------------------------------- /GraphicEQWidget/icons/power_on.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timschneeb/GraphicEQWidget/HEAD/GraphicEQWidget/icons/power_on.ico -------------------------------------------------------------------------------- /GraphicEQWidget/icons/arrow_right.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timschneeb/GraphicEQWidget/HEAD/GraphicEQWidget/icons/arrow_right.ico -------------------------------------------------------------------------------- /GraphicEQWidget/icons/document-new.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timschneeb/GraphicEQWidget/HEAD/GraphicEQWidget/icons/document-new.ico -------------------------------------------------------------------------------- /GraphicEQWidget/icons/edit-delete.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timschneeb/GraphicEQWidget/HEAD/GraphicEQWidget/icons/edit-delete.ico -------------------------------------------------------------------------------- /GraphicEQWidget/icons/edit-paste.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timschneeb/GraphicEQWidget/HEAD/GraphicEQWidget/icons/edit-paste.ico -------------------------------------------------------------------------------- /GraphicEQWidget/icons/document-open.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timschneeb/GraphicEQWidget/HEAD/GraphicEQWidget/icons/document-open.ico -------------------------------------------------------------------------------- /GraphicEQWidget/icons/document-save.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timschneeb/GraphicEQWidget/HEAD/GraphicEQWidget/icons/document-save.ico -------------------------------------------------------------------------------- /GraphicEQWidget/icons/list-add-green.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timschneeb/GraphicEQWidget/HEAD/GraphicEQWidget/icons/list-add-green.ico -------------------------------------------------------------------------------- /GraphicEQWidget/icons/reset_response.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timschneeb/GraphicEQWidget/HEAD/GraphicEQWidget/icons/reset_response.ico -------------------------------------------------------------------------------- /GraphicEQWidget/icons/resize_corner.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timschneeb/GraphicEQWidget/HEAD/GraphicEQWidget/icons/resize_corner.ico -------------------------------------------------------------------------------- /GraphicEQWidget/icons/document-save-as.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timschneeb/GraphicEQWidget/HEAD/GraphicEQWidget/icons/document-save-as.ico -------------------------------------------------------------------------------- /GraphicEQWidget/icons/edit-select-all.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timschneeb/GraphicEQWidget/HEAD/GraphicEQWidget/icons/edit-select-all.ico -------------------------------------------------------------------------------- /GraphicEQWidget/icons/invert_response.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timschneeb/GraphicEQWidget/HEAD/GraphicEQWidget/icons/invert_response.ico -------------------------------------------------------------------------------- /GraphicEQWidget/icons/list-remove-red.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timschneeb/GraphicEQWidget/HEAD/GraphicEQWidget/icons/list-remove-red.ico -------------------------------------------------------------------------------- /GraphicEQWidget/icons/normalize_response.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timschneeb/GraphicEQWidget/HEAD/GraphicEQWidget/icons/normalize_response.ico -------------------------------------------------------------------------------- /GraphicEQWidget/icons/accessories-text-editor.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timschneeb/GraphicEQWidget/HEAD/GraphicEQWidget/icons/accessories-text-editor.ico -------------------------------------------------------------------------------- /GraphicEQWidget/icons/format-justify-fill-rotated.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timschneeb/GraphicEQWidget/HEAD/GraphicEQWidget/icons/format-justify-fill-rotated.ico -------------------------------------------------------------------------------- /GraphicEQWidget/icons/applications-graphics-rotated.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timschneeb/GraphicEQWidget/HEAD/GraphicEQWidget/icons/applications-graphics-rotated.ico -------------------------------------------------------------------------------- /GraphicEQWidget/helpers/ColorHelper.h: -------------------------------------------------------------------------------- 1 | #ifndef COLORHELPER_H 2 | #define COLORHELPER_H 3 | 4 | #include 5 | 6 | class ColorHelper 7 | { 8 | public: 9 | static bool isLightPalette(const QPalette& pal); 10 | }; 11 | 12 | #endif // COLORHELPER_H 13 | -------------------------------------------------------------------------------- /GraphicEQWidget/helpers/ColorHelper.cpp: -------------------------------------------------------------------------------- 1 | #include "ColorHelper.h" 2 | 3 | bool ColorHelper::isLightPalette(const QPalette &pal) 4 | { 5 | auto lightnessText = pal.color(QPalette::WindowText).toHsl().lightness(); 6 | auto lightnessWindow = pal.color(QPalette::Window).toHsl().lightness(); 7 | return lightnessText < lightnessWindow; 8 | } 9 | -------------------------------------------------------------------------------- /GraphicEQWidget/GraphicEQWidget.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | icons/document-open.ico 4 | icons/document-save.ico 5 | icons/invert_response.ico 6 | icons/normalize_response.ico 7 | icons/reset_response.ico 8 | 9 | 10 | -------------------------------------------------------------------------------- /main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int main(int argc, char *argv[]) 6 | { 7 | QApplication a(argc, argv); 8 | qApp->setStyle("Fusion"); 9 | qApp->setPalette(qApp->style()->standardPalette()); 10 | 11 | GraphicEQFilterGUI* g = new GraphicEQFilterGUI(); 12 | g->load("GraphicEQ: 25 24.18; 40 34.28; 63 -10.78; 100 39.69; 160 23.66; 250 12.77; 400 3.19; 630 48.33; 1000 35.76; 1600 22.98; 2500 8.84; 4000 1.64; 6300 9.71; 10000 17.91; 16000 26.25"); 13 | g->show(); 14 | 15 | return a.exec(); 16 | } 17 | -------------------------------------------------------------------------------- /demo.pro: -------------------------------------------------------------------------------- 1 | QT += core gui 2 | 3 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets 4 | 5 | CONFIG += c++11 6 | 7 | # The following define makes your compiler emit warnings if you use 8 | # any Qt feature that has been marked deprecated (the exact warnings 9 | # depend on your compiler). Please consult the documentation of the 10 | # deprecated API in order to know how to port your code away from it. 11 | DEFINES += QT_DEPRECATED_WARNINGS 12 | 13 | # You can also make your code fail to compile if it uses deprecated APIs. 14 | # In order to do so, uncomment the following line. 15 | # You can also select to disable deprecated APIs only up to a certain version of Qt. 16 | #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 17 | 18 | include(GraphicEQWidget/GraphicEQWidget.pri) 19 | 20 | SOURCES += main.cpp 21 | 22 | # Default rules for deployment. 23 | qnx: target.path = /tmp/$${TARGET}/bin 24 | else: unix:!android: target.path = /opt/$${TARGET}/bin 25 | !isEmpty(target.path): INSTALLS += target 26 | -------------------------------------------------------------------------------- /GraphicEQWidget/GraphicEQWidget.pri: -------------------------------------------------------------------------------- 1 | SOURCES += \ 2 | $$PWD/GraphicEQFilterGUI.cpp \ 3 | $$PWD/GraphicEQFilterGUIItem.cpp \ 4 | $$PWD/GraphicEQFilterGUIScene.cpp \ 5 | $$PWD/GraphicEQFilterGUIView.cpp \ 6 | $$PWD/helpers/ColorHelper.cpp \ 7 | $$PWD/helpers/DPIHelper.cpp \ 8 | $$PWD/helpers/GainIterator.cpp \ 9 | $$PWD/widgets/FrequencyPlotHRuler.cpp \ 10 | $$PWD/widgets/FrequencyPlotItem.cpp \ 11 | $$PWD/widgets/FrequencyPlotScene.cpp \ 12 | $$PWD/widgets/FrequencyPlotVRuler.cpp \ 13 | $$PWD/widgets/FrequencyPlotView.cpp 14 | 15 | HEADERS += \ 16 | $$PWD/GraphicEQFilterGUI.h \ 17 | $$PWD/GraphicEQFilterGUIItem.h \ 18 | $$PWD/GraphicEQFilterGUIScene.h \ 19 | $$PWD/GraphicEQFilterGUIView.h \ 20 | $$PWD/helpers/ColorHelper.h \ 21 | $$PWD/helpers/DPIHelper.h \ 22 | $$PWD/helpers/GainIterator.h \ 23 | $$PWD/widgets/FrequencyPlotHRuler.h \ 24 | $$PWD/widgets/FrequencyPlotItem.h \ 25 | $$PWD/widgets/FrequencyPlotScene.h \ 26 | $$PWD/widgets/FrequencyPlotVRuler.h \ 27 | $$PWD/widgets/FrequencyPlotView.h 28 | 29 | FORMS += \ 30 | $$PWD/GraphicEQFilterGUI.ui 31 | 32 | RESOURCES += \ 33 | $$PWD/GraphicEQWidget.qrc 34 | 35 | INCLUDEPATH += $$PWD 36 | -------------------------------------------------------------------------------- /GraphicEQWidget/helpers/DPIHelper.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of EqualizerAPO, a system-wide equalizer. 3 | Copyright (C) 2016 Jonas Thedering 4 | 5 | This program is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 2 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License along 16 | with this program; if not, write to the Free Software Foundation, Inc., 17 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 | */ 19 | 20 | #include 21 | 22 | #pragma once 23 | 24 | class DPIHelper 25 | { 26 | public: 27 | static QSize scale(QSize size); 28 | static int scale(double pixel); 29 | static double scaleZoom(double zoom); 30 | static double invScale(int pixel); 31 | static double invScaleZoom(double zoom); 32 | }; 33 | -------------------------------------------------------------------------------- /GraphicEQWidget/GraphicEQFilterGUIView.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of EqualizerAPO, a system-wide equalizer. 3 | Copyright (C) 2015 Jonas Thedering 4 | 5 | This program is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 2 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License along 16 | with this program; if not, write to the Free Software Foundation, Inc., 17 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 | */ 19 | 20 | #pragma once 21 | 22 | #include "widgets/FrequencyPlotView.h" 23 | 24 | class GraphicEQFilterGUIView : public FrequencyPlotView 25 | { 26 | Q_OBJECT 27 | 28 | public: 29 | explicit GraphicEQFilterGUIView(QWidget* parent = 0); 30 | 31 | protected: 32 | void drawBackground(QPainter* painter, const QRectF& rect) override; 33 | }; 34 | -------------------------------------------------------------------------------- /GraphicEQWidget/widgets/FrequencyPlotHRuler.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of EqualizerAPO, a system-wide equalizer. 3 | Copyright (C) 2015 Jonas Thedering 4 | 5 | This program is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 2 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License along 16 | with this program; if not, write to the Free Software Foundation, Inc., 17 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 | */ 19 | 20 | #pragma once 21 | 22 | #include 23 | 24 | class FrequencyPlotHRuler : public QWidget 25 | { 26 | Q_OBJECT 27 | public: 28 | explicit FrequencyPlotHRuler(QWidget* parent = 0); 29 | 30 | protected: 31 | void paintEvent(QPaintEvent*) override; 32 | void wheelEvent(QWheelEvent* event) override; 33 | void mouseMoveEvent(QMouseEvent* event) override; 34 | }; 35 | -------------------------------------------------------------------------------- /GraphicEQWidget/widgets/FrequencyPlotVRuler.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of EqualizerAPO, a system-wide equalizer. 3 | Copyright (C) 2015 Jonas Thedering 4 | 5 | This program is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 2 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License along 16 | with this program; if not, write to the Free Software Foundation, Inc., 17 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 | */ 19 | 20 | #pragma once 21 | 22 | #include 23 | 24 | class FrequencyPlotVRuler : public QWidget 25 | { 26 | Q_OBJECT 27 | public: 28 | explicit FrequencyPlotVRuler(QWidget* parent = 0); 29 | 30 | protected: 31 | void paintEvent(QPaintEvent*) override; 32 | void wheelEvent(QWheelEvent* event) override; 33 | void mouseMoveEvent(QMouseEvent* event) override; 34 | }; 35 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # GraphicEQWidget 2 | 3 | This is a graphical equalizer widget for Qt. Most code chunks originated from [EqualizerAPO](https://sourceforge.net/projects/equalizerapo/) which is licensed under GPLv2. This widget has been extracted from their project and has been modified to run on any operating system, completely independent of any Win32 calls. Additionally, the layout has been designed to be much more compact, a method to parse Graphic-EQ data has been implemented, and the widget can now properly be themed using QPalettes. 4 | 5 | *All credits go to the original EqualizerAPO developer* 6 | 7 | ### Usage 8 | 9 | #### Include it in your project 10 | 11 | Copy the `GraphicEQWidget` subdirectory from this repository into your project folder and add this to your qmake project file: 12 | 13 | ```cmake 14 | include(GraphicEQWidget/GraphicEQWidget.pri) 15 | ``` 16 | 17 | #### Load points 18 | 19 | ```c++ 20 | GraphicEQFilterGUI* eq = new GraphicEQFilterGUI(); 21 | eq->load("GraphicEQ: 25 24.18; 40 34.28; 63 -10.78; 100 39.69; 160 23.66; 250 12.77; 400 3.19; 630 48.33; 1000 35.76; 1600 22.98; 2500 8.84; 4000 1.64; 6300 9.71; 10000 17.91; 16000 26.25"); 22 | eq->show(); 23 | ``` 24 | 25 | #### Store points 26 | 27 | ```c++ 28 | QString points = ""; 29 | eq->store(points); 30 | //'points' contains now the graphic-eq data 31 | ``` 32 | 33 | ### Screenshot 34 | 35 | ![screenshot](screenshot.png) 36 | -------------------------------------------------------------------------------- /GraphicEQWidget/widgets/FrequencyPlotItem.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of EqualizerAPO, a system-wide equalizer. 3 | Copyright (C) 2015 Jonas Thedering 4 | 5 | This program is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 2 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License along 16 | with this program; if not, write to the Free Software Foundation, Inc., 17 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 | */ 19 | 20 | #pragma once 21 | 22 | #include 23 | 24 | class FrequencyPlotItem : public QGraphicsItem 25 | { 26 | public: 27 | FrequencyPlotItem(double hz, double db); 28 | 29 | enum {Type = UserType + 1}; 30 | virtual int type() const 31 | { 32 | return Type; 33 | } 34 | 35 | void updatePos(); 36 | 37 | double getHz() const; 38 | void setHz(double value); 39 | 40 | double getDb() const; 41 | void setDb(double value); 42 | 43 | private: 44 | double hz; 45 | double db; 46 | }; 47 | -------------------------------------------------------------------------------- /GraphicEQWidget/helpers/GainIterator.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of EqualizerAPO, a system-wide equalizer. 3 | Copyright (C) 2015 Jonas Thedering 4 | 5 | This program is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 2 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License along 16 | with this program; if not, write to the Free Software Foundation, Inc., 17 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 | */ 19 | 20 | #pragma once 21 | 22 | #include 23 | 24 | struct FilterNode 25 | { 26 | double freq; 27 | double dbGain; 28 | 29 | FilterNode(double freq, double dbGain) 30 | { 31 | this->freq = freq; 32 | this->dbGain = dbGain; 33 | } 34 | 35 | bool operator<(FilterNode other) const 36 | { 37 | return freq < other.freq; 38 | } 39 | }; 40 | 41 | class GainIterator 42 | { 43 | public: 44 | GainIterator(const std::vector& nodes); 45 | double gainAt(double freq); 46 | 47 | private: 48 | std::vector nodes; 49 | FilterNode* nodeLeft; 50 | FilterNode* nodeRight; 51 | double logLeft; 52 | double logRightMinusLeft; 53 | }; 54 | -------------------------------------------------------------------------------- /GraphicEQWidget/GraphicEQFilterGUIItem.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of EqualizerAPO, a system-wide equalizer. 3 | Copyright (C) 2015 Jonas Thedering 4 | 5 | This program is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 2 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License along 16 | with this program; if not, write to the Free Software Foundation, Inc., 17 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 | */ 19 | 20 | #pragma once 21 | 22 | #include "widgets/FrequencyPlotItem.h" 23 | 24 | class GraphicEQFilterGUIItem : public FrequencyPlotItem 25 | { 26 | public: 27 | GraphicEQFilterGUIItem(int index, double hz, double db); 28 | 29 | enum {Type = UserType + 2}; 30 | virtual int type() const 31 | { 32 | return Type; 33 | } 34 | 35 | void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override; 36 | QRectF boundingRect() const override; 37 | QPainterPath shape() const override; 38 | void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) override; 39 | 40 | int getIndex() const; 41 | void setIndex(int value); 42 | 43 | protected: 44 | QVariant itemChange(GraphicsItemChange change, const QVariant& value) override; 45 | 46 | private: 47 | int index; 48 | }; 49 | -------------------------------------------------------------------------------- /GraphicEQWidget/widgets/FrequencyPlotItem.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of EqualizerAPO, a system-wide equalizer. 3 | Copyright (C) 2015 Jonas Thedering 4 | 5 | This program is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 2 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License along 16 | with this program; if not, write to the Free Software Foundation, Inc., 17 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 | */ 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | 26 | #include "FrequencyPlotScene.h" 27 | #include "FrequencyPlotItem.h" 28 | 29 | FrequencyPlotItem::FrequencyPlotItem(double hz, double db) 30 | : hz(hz), db(db) 31 | { 32 | setFlag(ItemSendsScenePositionChanges); 33 | } 34 | 35 | void FrequencyPlotItem::updatePos() 36 | { 37 | setFlag(ItemSendsScenePositionChanges, false); 38 | FrequencyPlotScene* s = qobject_cast(scene()); 39 | setPos(floor(s->hzToX(hz)) + 0.5, floor(s->dbToY(db)) + 0.5); 40 | setFlag(ItemSendsScenePositionChanges, true); 41 | } 42 | 43 | double FrequencyPlotItem::getHz() const 44 | { 45 | return hz; 46 | } 47 | 48 | void FrequencyPlotItem::setHz(double value) 49 | { 50 | hz = value; 51 | } 52 | 53 | double FrequencyPlotItem::getDb() const 54 | { 55 | return db; 56 | } 57 | 58 | void FrequencyPlotItem::setDb(double value) 59 | { 60 | db = value; 61 | } 62 | -------------------------------------------------------------------------------- /GraphicEQWidget/widgets/FrequencyPlotScene.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of EqualizerAPO, a system-wide equalizer. 3 | Copyright (C) 2015 Jonas Thedering 4 | 5 | This program is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 2 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License along 16 | with this program; if not, write to the Free Software Foundation, Inc., 17 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 | */ 19 | 20 | #pragma once 21 | 22 | #include 23 | #include 24 | 25 | #include "FrequencyPlotItem.h" 26 | 27 | class FrequencyPlotScene : public QGraphicsScene 28 | { 29 | Q_OBJECT 30 | public: 31 | explicit FrequencyPlotScene(QObject* parent = 0); 32 | 33 | void addItem(FrequencyPlotItem* item); 34 | 35 | double xToHz(double x); 36 | double hzToX(double hz); 37 | double yToDb(double y); 38 | double dbToY(double db); 39 | 40 | double getZoomX() const; 41 | double getZoomY() const; 42 | void setZoom(double zoomX, double zoomY); 43 | 44 | int getBandCount() const; 45 | virtual void setBandCount(int value); 46 | 47 | const std::vector& getBands(); 48 | const std::vector& getBands(int count); 49 | 50 | protected: 51 | static std::vector bands15; 52 | static std::vector bands31; 53 | static std::vector bandsVar; 54 | 55 | private: 56 | void updateSceneRect(); 57 | 58 | double zoomX; 59 | double zoomY; 60 | int bandCount = -1; 61 | }; 62 | -------------------------------------------------------------------------------- /GraphicEQWidget/widgets/FrequencyPlotView.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of EqualizerAPO, a system-wide equalizer. 3 | Copyright (C) 2015 Jonas Thedering 4 | 5 | This program is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 2 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License along 16 | with this program; if not, write to the Free Software Foundation, Inc., 17 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 | */ 19 | 20 | #pragma once 21 | 22 | #include 23 | 24 | #include "FrequencyPlotScene.h" 25 | #include "FrequencyPlotHRuler.h" 26 | #include "FrequencyPlotVRuler.h" 27 | 28 | class FrequencyPlotView : public QGraphicsView 29 | { 30 | Q_OBJECT 31 | public: 32 | explicit FrequencyPlotView(QWidget* parent = 0); 33 | 34 | FrequencyPlotScene* scene() const; 35 | void setScene(FrequencyPlotScene* scene); 36 | 37 | void drawBackground(QPainter* painter, const QRectF& drawRect) override; 38 | 39 | void updateHRuler(); 40 | 41 | QPoint getLastMousePos() const; 42 | void setLastMousePos(QPoint pos); 43 | using QGraphicsView::viewportMargins; 44 | 45 | void zoom(int deltaX, int deltaY, int mouseX, int mouseY); 46 | void setScrollOffsets(int x, int y); 47 | 48 | protected: 49 | void wheelEvent(QWheelEvent* event) override; 50 | void scrollContentsBy(int dx, int dy) override; 51 | void resizeEvent(QResizeEvent* event) override; 52 | void mousePressEvent(QMouseEvent* event) override; 53 | void mouseMoveEvent(QMouseEvent* event) override; 54 | void leaveEvent(QEvent*) override; 55 | void showEvent(QShowEvent* event) override; 56 | 57 | private: 58 | FrequencyPlotHRuler* hRuler; 59 | FrequencyPlotVRuler* vRuler; 60 | QPoint lastMousePos; 61 | int presetScrollX = -1; 62 | int presetScrollY = -1; 63 | }; 64 | -------------------------------------------------------------------------------- /GraphicEQWidget/helpers/DPIHelper.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of EqualizerAPO, a system-wide equalizer. 3 | Copyright (C) 2016 Jonas Thedering 4 | 5 | This program is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 2 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License along 16 | with this program; if not, write to the Free Software Foundation, Inc., 17 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 | */ 19 | 20 | #include "DPIHelper.h" 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | QSize DPIHelper::scale(QSize size) 28 | { 29 | if (qApp->testAttribute(Qt::AA_Use96Dpi)) 30 | return size; 31 | 32 | qreal dpi = QGuiApplication::primaryScreen()->logicalDotsPerInchX(); 33 | return QSize(qRound(size.width() * dpi / 96), qRound(size.height() * dpi / 96)); 34 | } 35 | 36 | int DPIHelper::scale(double pixel) 37 | { 38 | if (qApp->testAttribute(Qt::AA_Use96Dpi)) 39 | return qRound(pixel); 40 | 41 | qreal dpi = QGuiApplication::primaryScreen()->logicalDotsPerInchX(); 42 | return qRound(pixel * dpi / 96); 43 | } 44 | 45 | double DPIHelper::scaleZoom(double zoom) 46 | { 47 | if (qApp->testAttribute(Qt::AA_Use96Dpi)) 48 | return zoom; 49 | 50 | qreal dpi = QGuiApplication::primaryScreen()->logicalDotsPerInchX(); 51 | return zoom * dpi / 96; 52 | } 53 | 54 | double DPIHelper::invScale(int pixel) 55 | { 56 | if (qApp->testAttribute(Qt::AA_Use96Dpi)) 57 | return pixel; 58 | 59 | qreal dpi = QGuiApplication::primaryScreen()->logicalDotsPerInchX(); 60 | return pixel * 96 / dpi; 61 | } 62 | 63 | double DPIHelper::invScaleZoom(double zoom) 64 | { 65 | if (qApp->testAttribute(Qt::AA_Use96Dpi)) 66 | return zoom; 67 | 68 | qreal dpi = QGuiApplication::primaryScreen()->logicalDotsPerInchX(); 69 | return zoom * 96 / dpi; 70 | } 71 | -------------------------------------------------------------------------------- /GraphicEQWidget/GraphicEQFilterGUIView.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of EqualizerAPO, a system-wide equalizer. 3 | Copyright (C) 2015 Jonas Thedering 4 | 5 | This program is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 2 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License along 16 | with this program; if not, write to the Free Software Foundation, Inc., 17 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 | */ 19 | 20 | #include "GraphicEQFilterGUIScene.h" 21 | #include "GraphicEQFilterGUIView.h" 22 | 23 | #include "helpers/ColorHelper.h" 24 | #include 25 | 26 | GraphicEQFilterGUIView::GraphicEQFilterGUIView(QWidget* parent) 27 | : FrequencyPlotView(parent) 28 | { 29 | } 30 | 31 | void GraphicEQFilterGUIView::drawBackground(QPainter* painter, const QRectF& rect) 32 | { 33 | FrequencyPlotView::drawBackground(painter, rect); 34 | 35 | painter->setRenderHint(QPainter::Antialiasing, true); 36 | GraphicEQFilterGUIScene* s = qobject_cast(scene()); 37 | std::vector& nodes = s->getNodes(); 38 | GainIterator gainIterator(nodes); 39 | QPainterPath path; 40 | bool first = true; 41 | double lastDb = -1000; 42 | for (int x = rect.left() - 1; x <= rect.right() + 1; x++) 43 | { 44 | double hz = s->xToHz(x); 45 | double db = gainIterator.gainAt(hz); 46 | double y = s->dbToY(db); 47 | if (db == lastDb) 48 | y = floor(y) + 0.5; 49 | lastDb = db; 50 | if (first) 51 | { 52 | path.moveTo(x, y); 53 | first = false; 54 | } 55 | else 56 | { 57 | path.lineTo(x, y); 58 | } 59 | } 60 | painter->setPen(ColorHelper::isLightPalette(palette()) ? palette().color(QPalette::Disabled,QPalette::WindowText).darker() : 61 | palette().color(QPalette::Disabled,QPalette::WindowText).lighter()); 62 | painter->drawPath(path); 63 | } 64 | -------------------------------------------------------------------------------- /GraphicEQWidget/icons/arrow_right.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 22 | 24 | 43 | 45 | 46 | 48 | image/svg+xml 49 | 51 | 52 | 53 | 54 | 55 | 60 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /GraphicEQWidget/GraphicEQFilterGUIScene.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of EqualizerAPO, a system-wide equalizer. 3 | Copyright (C) 2015 Jonas Thedering 4 | 5 | This program is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 2 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License along 16 | with this program; if not, write to the Free Software Foundation, Inc., 17 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 | */ 19 | 20 | #pragma once 21 | 22 | #include 23 | 24 | #include "widgets/FrequencyPlotScene.h" 25 | #include "helpers/GainIterator.h" 26 | #include "GraphicEQFilterGUIItem.h" 27 | 28 | class GraphicEQFilterGUIScene : public FrequencyPlotScene 29 | { 30 | Q_OBJECT 31 | public: 32 | explicit GraphicEQFilterGUIScene(QObject* parent = 0); 33 | void setNodes(const std::vector& nodes); 34 | void addNode(double hz, double db); 35 | void removeNode(int index); 36 | void setNode(int index, double hz, double db); 37 | void setSelectedNodes(QSet indices); 38 | QSet getSelectedIndices(); 39 | void itemMoved(int index); 40 | void itemSelectionChanged(int index, bool selected); 41 | 42 | std::vector& getNodes(); 43 | int verifyBands(const std::vector& nodes); 44 | void setBandCount(int value) override; 45 | 46 | void set15BandFreeMode(bool e); 47 | bool get15BandFreeMode(); 48 | signals: 49 | void nodeInserted(int index, double hz, double db); 50 | void nodeRemoved(int index); 51 | void nodeUpdated(int index, double hz, double db); 52 | void nodeMoved(int fromIndex, int toIndex); 53 | void nodeSelectionChanged(int index, bool selected); 54 | void updateModel(bool isMoving); 55 | void nodeMouseUp(int index); 56 | 57 | protected: 58 | void mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event) override; 59 | void keyPressEvent(QKeyEvent* event) override; 60 | 61 | private: 62 | std::vector nodes; 63 | QList items; 64 | bool freeMode15 = false; 65 | bool noUpdateModel = false; 66 | }; 67 | -------------------------------------------------------------------------------- /GraphicEQWidget/helpers/GainIterator.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of EqualizerAPO, a system-wide equalizer. 3 | Copyright (C) 2015 Jonas Thedering 4 | 5 | This program is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 2 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License along 16 | with this program; if not, write to the Free Software Foundation, Inc., 17 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 | */ 19 | 20 | #include 21 | #include 22 | 23 | #include "GainIterator.h" 24 | 25 | using namespace std; 26 | 27 | GainIterator::GainIterator(const vector& nodes) 28 | { 29 | this->nodes = nodes; 30 | nodeLeft = NULL; 31 | nodeRight = NULL; 32 | } 33 | 34 | double GainIterator::gainAt(double freq) 35 | { 36 | if ((nodeLeft == NULL && nodeRight == NULL) || (nodeLeft != NULL && freq < nodeLeft->freq)) 37 | { 38 | FilterNode findNode(freq, 0); 39 | vector::iterator it = lower_bound(nodes.begin(), nodes.end(), findNode); 40 | if (it != nodes.begin()) 41 | nodeLeft = &*(it - 1); 42 | if (it != nodes.end()) 43 | nodeRight = &*it; 44 | 45 | if (nodeLeft != NULL && nodeRight != NULL) 46 | { 47 | logLeft = log(nodeLeft->freq); 48 | logRightMinusLeft = log(nodeRight->freq) - logLeft; 49 | } 50 | } 51 | else if (nodeRight != NULL && freq > nodeRight->freq) 52 | { 53 | vector::iterator it = nodes.begin() + (nodeRight - &*nodes.begin()); 54 | while (it != nodes.end() && freq > it->freq) 55 | { 56 | it++; 57 | } 58 | if (it == nodes.end()) 59 | nodeRight = NULL; 60 | else 61 | nodeRight = &*it; 62 | 63 | if (it != nodes.begin()) 64 | nodeLeft = &*(it - 1); 65 | 66 | if (nodeLeft != NULL && nodeRight != NULL) 67 | { 68 | logLeft = log(nodeLeft->freq); 69 | logRightMinusLeft = log(nodeRight->freq) - logLeft; 70 | } 71 | } 72 | 73 | double dbGain; 74 | if (nodeLeft == NULL) 75 | { 76 | if (nodeRight == NULL) 77 | dbGain = 0.0; 78 | else 79 | dbGain = nodeRight->dbGain; 80 | } 81 | else if (nodeRight == NULL) 82 | { 83 | dbGain = nodeLeft->dbGain; 84 | } 85 | else 86 | { 87 | double t = (log(freq) - logLeft) / logRightMinusLeft; 88 | // to support dbGain == -INF for both nodes 89 | if (nodeLeft->dbGain == nodeRight->dbGain) 90 | dbGain = nodeLeft->dbGain; 91 | else 92 | dbGain = nodeLeft->dbGain + t * (nodeRight->dbGain - nodeLeft->dbGain); 93 | } 94 | 95 | return dbGain; 96 | } 97 | -------------------------------------------------------------------------------- /GraphicEQWidget/icons/invert_response.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 22 | 24 | 43 | 45 | 46 | 48 | image/svg+xml 49 | 51 | 52 | 53 | 54 | 55 | 59 | 65 | 71 | 77 | 78 | 79 | -------------------------------------------------------------------------------- /GraphicEQWidget/GraphicEQFilterGUI.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of EqualizerAPO, a system-wide equalizer. 3 | Copyright (C) 2015 Jonas Thedering 4 | 5 | This program is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 2 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License along 16 | with this program; if not, write to the Free Software Foundation, Inc., 17 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 | */ 19 | 20 | #pragma once 21 | 22 | #include 23 | #include 24 | #include 25 | #include "GraphicEQFilterGUIScene.h" 26 | 27 | namespace Ui { 28 | class GraphicEQFilterGUI; 29 | } 30 | 31 | class GraphicEQFilterGUI : public QWidget 32 | { 33 | Q_OBJECT 34 | 35 | public: 36 | explicit GraphicEQFilterGUI(QWidget* parent = nullptr); 37 | ~GraphicEQFilterGUI(); 38 | 39 | void store(QString& parameters); 40 | void storeCsv(QString ¶meters); 41 | void load(const QString ¶meters); 42 | 43 | void loadPreferences(const QVariantMap& prefs); 44 | void storePreferences(QVariantMap& prefs); 45 | 46 | QCheckBox* chk_enable; 47 | 48 | void setSidebarHidden(bool hidden); 49 | void set15BandFreeMode(bool e); 50 | void setAutoEqAvailable(bool visible); 51 | void setEnableSwitchVisible(bool visible); 52 | void loadMap(const QMap ¶meters); 53 | 54 | private slots: 55 | void insertRow(int index, double hz, double db); 56 | void removeRow(int index); 57 | void updateRow(int index, double hz, double db); 58 | void moveRow(int fromIndex, int toIndex); 59 | void selectRow(int index, bool select); 60 | 61 | void on_tableWidget_cellChanged(int row, int column); 62 | void on_tableWidget_itemSelectionChanged(); 63 | 64 | void on_radioButton15_toggled(bool checked); 65 | void on_radioButton31_toggled(bool checked); 66 | void on_radioButtonVar_toggled(bool checked); 67 | 68 | void on_actionImport_triggered(); 69 | void on_actionExport_triggered(); 70 | void on_actionInvertResponse_triggered(); 71 | void on_actionNormalizeResponse_triggered(); 72 | void on_actionResetResponse_triggered(); 73 | 74 | void on_actionImport_AutoEQ_result_triggered(); 75 | signals: 76 | void updateModel(bool isMoving); 77 | void updateModelEnd(); 78 | void mouseUp(); 79 | void updateChannels(); 80 | void autoeqClicked(); 81 | 82 | private: 83 | void setFreqEditable(bool editable); 84 | 85 | Ui::GraphicEQFilterGUI* ui; 86 | GraphicEQFilterGUIScene* scene; 87 | QString configPath; 88 | bool freeMode15 = false; 89 | static QRegularExpression numberRegEx; 90 | }; 91 | -------------------------------------------------------------------------------- /GraphicEQWidget/widgets/FrequencyPlotScene.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of EqualizerAPO, a system-wide equalizer. 3 | Copyright (C) 2015 Jonas Thedering 4 | 5 | This program is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 2 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License along 16 | with this program; if not, write to the Free Software Foundation, Inc., 17 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 | */ 19 | 20 | #include "helpers/DPIHelper.h" 21 | #include "FrequencyPlotView.h" 22 | #include "FrequencyPlotScene.h" 23 | #include 24 | #include 25 | 26 | using namespace std; 27 | 28 | static double maxX = 1000; 29 | static double maxY = 500; 30 | static double minHz = 1; 31 | static double maxHz = 30000; 32 | static double minDb = -70; 33 | static double maxDb = 70; 34 | 35 | vector FrequencyPlotScene::bands15 = {25, 40, 63, 100, 160, 250, 400, 630, 1000, 1600, 2500, 4000, 6300, 10000, 16000}; 36 | vector FrequencyPlotScene::bands31 = {20, 25, 31.5, 40, 50, 63, 80, 100, 125, 160, 200, 250, 315, 400, 500, 630, 800, 37 | 1000, 1250, 1600, 2000, 2500, 3150, 4000, 5000, 6300, 8000, 10000, 12500, 16000, 20000}; 38 | vector FrequencyPlotScene::bandsVar; 39 | 40 | FrequencyPlotScene::FrequencyPlotScene(QObject* parent) 41 | : QGraphicsScene(parent) 42 | { 43 | zoomX = DPIHelper::scaleZoom(1.0); 44 | zoomY = DPIHelper::scaleZoom(1.0); 45 | 46 | updateSceneRect(); 47 | } 48 | 49 | void FrequencyPlotScene::addItem(FrequencyPlotItem* item) 50 | { 51 | QGraphicsScene::addItem(item); 52 | } 53 | 54 | double FrequencyPlotScene::xToHz(double x) 55 | { 56 | return pow(maxHz / minHz, x / zoomX / maxX) * minHz; 57 | } 58 | 59 | double FrequencyPlotScene::hzToX(double hz) 60 | { 61 | if (hz < minHz || hz > maxHz) 62 | return -1; 63 | 64 | return log(hz / minHz) / log(maxHz / minHz) * maxX * zoomX; 65 | } 66 | 67 | double FrequencyPlotScene::yToDb(double y) 68 | { 69 | return(minDb + (1 - y / zoomY / maxY) * (maxDb - minDb)); 70 | } 71 | 72 | double FrequencyPlotScene::dbToY(double db) 73 | { 74 | if (db < minDb || db > maxDb) 75 | return -1; 76 | 77 | return (1 - (db - minDb) / (maxDb - minDb)) * maxY * zoomY; 78 | } 79 | 80 | double FrequencyPlotScene::getZoomX() const 81 | { 82 | return zoomX; 83 | } 84 | 85 | double FrequencyPlotScene::getZoomY() const 86 | { 87 | return zoomY; 88 | } 89 | 90 | void FrequencyPlotScene::setZoom(double zoomX, double zoomY) 91 | { 92 | if (zoomX != this->zoomX || zoomY != this->zoomY) 93 | { 94 | this->zoomX = zoomX; 95 | this->zoomY = zoomY; 96 | updateSceneRect(); 97 | 98 | for (QGraphicsItem* item : items()) 99 | { 100 | FrequencyPlotItem* plotItem = (FrequencyPlotItem*)item; 101 | plotItem->updatePos(); 102 | } 103 | } 104 | } 105 | 106 | void FrequencyPlotScene::updateSceneRect() 107 | { 108 | setSceneRect(0, 0, maxX * zoomX, maxY * zoomY); 109 | } 110 | 111 | int FrequencyPlotScene::getBandCount() const 112 | { 113 | return bandCount; 114 | } 115 | 116 | void FrequencyPlotScene::setBandCount(int value) 117 | { 118 | if (value != bandCount) 119 | { 120 | bandCount = value; 121 | update(); 122 | FrequencyPlotView* view = qobject_cast(views()[0]); 123 | view->updateHRuler(); 124 | } 125 | } 126 | 127 | const vector& FrequencyPlotScene::getBands() 128 | { 129 | return getBands(bandCount); 130 | } 131 | 132 | const std::vector& FrequencyPlotScene::getBands(int count) 133 | { 134 | switch (count) 135 | { 136 | case 15: 137 | return bands15; 138 | case 31: 139 | return bands31; 140 | default: 141 | return bandsVar; 142 | } 143 | } 144 | -------------------------------------------------------------------------------- /GraphicEQWidget/widgets/FrequencyPlotVRuler.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of EqualizerAPO, a system-wide equalizer. 3 | Copyright (C) 2015 Jonas Thedering 4 | 5 | This program is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 2 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License along 16 | with this program; if not, write to the Free Software Foundation, Inc., 17 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 | */ 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | 26 | #include "helpers/DPIHelper.h" 27 | #include "FrequencyPlotView.h" 28 | #include "FrequencyPlotScene.h" 29 | #include "FrequencyPlotVRuler.h" 30 | 31 | FrequencyPlotVRuler::FrequencyPlotVRuler(QWidget* parent) 32 | : QWidget(parent) 33 | { 34 | } 35 | 36 | void FrequencyPlotVRuler::paintEvent(QPaintEvent*) 37 | { 38 | QPainter painter(this); 39 | painter.setRenderHint(QPainter::Antialiasing); 40 | FrequencyPlotView* view = qobject_cast(parentWidget()); 41 | FrequencyPlotScene* s = view->scene(); 42 | 43 | QPointF topLeft = view->mapToScene(0, 0); 44 | QPointF bottomRight = view->mapToScene(view->viewport()->width(), view->viewport()->height()); 45 | double dbStep = abs(s->yToDb(0) - s->yToDb(DPIHelper::scale(30))); 46 | 47 | double dbBase = pow(10, floor(log10(dbStep))); 48 | if (dbStep >= 5 * dbBase) 49 | dbStep = 5 * dbBase; 50 | else if (dbStep >= 2 * dbBase) 51 | dbStep = 2 * dbBase; 52 | else 53 | dbStep = dbBase; 54 | 55 | double fromDb = floor(s->yToDb(topLeft.y()) / dbStep) * dbStep; 56 | double toDb = ceil(s->yToDb(bottomRight.y()) / dbStep) * dbStep; 57 | 58 | painter.setPen(qApp->palette().text().color()); 59 | for (double db = toDb; db <= fromDb; db += dbStep) 60 | { 61 | if (abs(db) < 1e-6) 62 | db = 0; 63 | double y = s->dbToY(db); 64 | if (y != -1) 65 | painter.drawText(0, y - topLeft.y() - 1, width(), 0, Qt::TextDontClip | Qt::AlignCenter, QString("%0").arg(db)); 66 | } 67 | 68 | QPoint mousePos = view->getLastMousePos(); 69 | if (!mousePos.isNull()) 70 | { 71 | QPointF mouseScenePos = view->mapToScene(mousePos); 72 | 73 | double db = s->yToDb(mouseScenePos.y()); 74 | double y = s->dbToY(db); 75 | if (y != -1) 76 | { 77 | QString text = QString("%0").arg(db, 0, 'f', 1); 78 | QFontMetrics metrics = painter.fontMetrics(); 79 | QRectF rect = metrics.boundingRect(text); 80 | float center = y - topLeft.y() - 1; 81 | rect = QRectF(ceil(width() / 2) - ceil(rect.width() / 2) - 2.5, center - rect.height() / 2 + 1, rect.width() + 3, rect.height()); 82 | QPainterPath path; 83 | path.addRect(rect); 84 | QPainterPath rightTriangle; 85 | rightTriangle.moveTo(QPoint(rect.right(), center - 2)); 86 | rightTriangle.lineTo(QPoint(rect.right(), center + 4)); 87 | rightTriangle.lineTo(QPoint(rect.right() + 4, center + 1)); 88 | path = path.united(rightTriangle); 89 | 90 | painter.setPen(Qt::black); 91 | painter.setBrush(Qt::white); 92 | painter.drawPath(path); 93 | painter.setPen(Qt::blue); 94 | painter.drawText(0, center, width() - 2, 0, Qt::TextDontClip | Qt::AlignCenter, text); 95 | } 96 | } 97 | } 98 | 99 | void FrequencyPlotVRuler::wheelEvent(QWheelEvent* event) 100 | { 101 | FrequencyPlotView* view = qobject_cast(parentWidget()); 102 | #if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) 103 | view->zoom(0, event->angleDelta().y(), 0, event->y()); 104 | #else 105 | view->zoom(0, event->angleDelta().y(), 0, event->position().y()); 106 | #endif 107 | } 108 | 109 | void FrequencyPlotVRuler::mouseMoveEvent(QMouseEvent* event) 110 | { 111 | FrequencyPlotView* view = qobject_cast(parentWidget()); 112 | #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) 113 | view->setLastMousePos(QPoint(0, std::min(event->y(), view->viewport()->height() - 1))); 114 | #else 115 | view->setLastMousePos(QPoint(0, std::min(event->position().y(), (double)view->viewport()->height() - 1))); 116 | #endif 117 | } 118 | -------------------------------------------------------------------------------- /GraphicEQWidget/GraphicEQFilterGUIItem.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of EqualizerAPO, a system-wide equalizer. 3 | Copyright (C) 2015 Jonas Thedering 4 | 5 | This program is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 2 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License along 16 | with this program; if not, write to the Free Software Foundation, Inc., 17 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 | */ 19 | 20 | #include 21 | #include 22 | #include 23 | #include "helpers/ColorHelper.h" 24 | #include "helpers/DPIHelper.h" 25 | #include "GraphicEQFilterGUIScene.h" 26 | #include "GraphicEQFilterGUIItem.h" 27 | 28 | static double size = 10; 29 | 30 | GraphicEQFilterGUIItem::GraphicEQFilterGUIItem(int index, double hz, double db) 31 | : FrequencyPlotItem(hz, db), index(index) 32 | { 33 | setFlag(ItemIsMovable); 34 | setFlag(ItemIsSelectable); 35 | } 36 | 37 | void GraphicEQFilterGUIItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) 38 | { 39 | GraphicEQFilterGUIScene* s = qobject_cast(scene()); 40 | s->nodeMouseUp(index); 41 | QGraphicsItem::mouseReleaseEvent(event); 42 | } 43 | 44 | QRectF GraphicEQFilterGUIItem::boundingRect() const 45 | { 46 | int s = DPIHelper::scale(size); 47 | return QRectF(-s / 2, -s / 2, s, s); 48 | } 49 | 50 | QPainterPath GraphicEQFilterGUIItem::shape() const 51 | { 52 | QPainterPath path; 53 | path.addEllipse(boundingRect()); 54 | return path; 55 | } 56 | 57 | void GraphicEQFilterGUIItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) 58 | { 59 | Q_UNUSED(option) 60 | Q_UNUSED(widget) 61 | 62 | auto pal = qApp->palette(); 63 | auto shape_border_light = pal.color(QPalette::Disabled,QPalette::WindowText).darker(150); 64 | auto shape_border_dark = pal.color(QPalette::Disabled,QPalette::Window).lighter(150); 65 | auto text_light = pal.color(QPalette::Active,QPalette::WindowText).darker(120); 66 | auto text_dark = pal.color(QPalette::Active,QPalette::WindowText).lighter(120); 67 | 68 | painter->setBrush(qApp->palette().window()); 69 | painter->setPen(ColorHelper::isLightPalette(pal) ? shape_border_light : shape_border_dark); 70 | if (isSelected()) 71 | painter->setBrush(QColor(38, 147, 255)); 72 | painter->drawPath(shape()); 73 | if (index < 99) 74 | { 75 | if (isSelected()) 76 | painter->setPen(qApp->palette().window().color()); 77 | else 78 | painter->setPen(ColorHelper::isLightPalette(pal) ? text_light : text_dark); 79 | 80 | QFont font; 81 | font.setPixelSize(DPIHelper::scale(9)); 82 | font.setLetterSpacing(QFont::AbsoluteSpacing, -1); 83 | QFontMetrics metrics(font); 84 | painter->setFont(font); 85 | QString text = QString::number(index + 1); 86 | painter->drawText(-metrics.horizontalAdvance(text) / 2, metrics.boundingRect('0').height() / 2, text); 87 | } 88 | } 89 | 90 | QVariant GraphicEQFilterGUIItem::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant& value) 91 | { 92 | QVariant result = QGraphicsItem::itemChange(change, value); 93 | 94 | if (change == ItemScenePositionHasChanged) 95 | { 96 | GraphicEQFilterGUIScene* s = qobject_cast(scene()); 97 | s->itemMoved(index); 98 | } 99 | else if (change == ItemSelectedHasChanged) 100 | { 101 | GraphicEQFilterGUIScene* s = qobject_cast(scene()); 102 | s->itemSelectionChanged(index, value.toBool()); 103 | } 104 | else if (change == ItemPositionChange) 105 | { 106 | GraphicEQFilterGUIScene* s = qobject_cast(scene()); 107 | if (s->getBandCount() != -1 && !s->get15BandFreeMode()) 108 | { 109 | QPointF newPos = value.toPointF(); 110 | newPos.setX(s->hzToX(getHz())); 111 | result = newPos; 112 | } 113 | } 114 | 115 | return result; 116 | } 117 | int GraphicEQFilterGUIItem::getIndex() const 118 | { 119 | return index; 120 | } 121 | 122 | void GraphicEQFilterGUIItem::setIndex(int value) 123 | { 124 | index = value; 125 | } 126 | -------------------------------------------------------------------------------- /GraphicEQWidget/icons/power_off.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 22 | 24 | 43 | 45 | 46 | 48 | image/svg+xml 49 | 51 | 52 | 53 | 54 | 55 | 59 | 64 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /GraphicEQWidget/icons/power_on.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 22 | 24 | 43 | 45 | 46 | 48 | image/svg+xml 49 | 51 | 52 | 53 | 54 | 55 | 59 | 64 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /GraphicEQWidget/widgets/FrequencyPlotHRuler.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of EqualizerAPO, a system-wide equalizer. 3 | Copyright (C) 2015 Jonas Thedering 4 | 5 | This program is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 2 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License along 16 | with this program; if not, write to the Free Software Foundation, Inc., 17 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 | */ 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | #include "FrequencyPlotView.h" 26 | #include "FrequencyPlotHRuler.h" 27 | #include 28 | #include 29 | 30 | using namespace std; 31 | 32 | FrequencyPlotHRuler::FrequencyPlotHRuler(QWidget* parent) 33 | : QWidget(parent) 34 | { 35 | } 36 | 37 | void FrequencyPlotHRuler::paintEvent(QPaintEvent*) 38 | { 39 | QPainter painter(this); 40 | painter.setRenderHint(QPainter::Antialiasing); 41 | FrequencyPlotView* view = qobject_cast(parentWidget()); 42 | FrequencyPlotScene* s = view->scene(); 43 | QFontMetrics metrics = painter.fontMetrics(); 44 | painter.setPen(qApp->palette().text().color()); 45 | 46 | QPointF topLeft = view->mapToScene(0, 0); 47 | QPointF bottomRight = view->mapToScene(view->viewport()->width(), view->viewport()->height()); 48 | int offsetLeft = view->viewportMargins().left(); 49 | double fromHz = s->xToHz(topLeft.x()); 50 | double toHz = s->xToHz(bottomRight.x()); 51 | const vector& bands = s->getBands(); 52 | if (bands.empty()) 53 | { 54 | double hzBase = pow(10, floor(log10(fromHz))); 55 | fromHz = floor(fromHz / hzBase) * hzBase; 56 | fromHz += hzBase; 57 | if (round(fromHz / hzBase) >= 10) 58 | hzBase *= 10; 59 | for (double hz = fromHz; hz <= toHz;) 60 | { 61 | double x = s->hzToX(hz); 62 | if (x != -1) 63 | { 64 | QString text; 65 | if (hz < 1000) 66 | text = QString("%0").arg(hz); 67 | else 68 | text = QString("%0k").arg(hz / 1000); 69 | if (metrics.horizontalAdvance(text) + 2 < s->hzToX(hz + hzBase) - x) 70 | painter.drawText(x - topLeft.x() + offsetLeft + 1, 0, 0, height(), Qt::TextDontClip | Qt::AlignCenter, text); 71 | } 72 | 73 | hz += hzBase; 74 | if (round(hz / hzBase) >= 10) 75 | hzBase *= 10; 76 | } 77 | } 78 | else 79 | { 80 | vector::const_iterator it = lower_bound(bands.cbegin(), bands.cend(), fromHz); 81 | for (; it != bands.cend() && *it < toHz; it++) 82 | { 83 | double hz = *it; 84 | double x = s->hzToX(hz); 85 | if (x != -1) 86 | { 87 | QString text; 88 | if (hz < 1000) 89 | text = QString("%0").arg(hz); 90 | else 91 | text = QString("%0k").arg(hz / 1000); 92 | painter.drawText(x - topLeft.x() + offsetLeft + 1, 0, 0, height(), Qt::TextDontClip | Qt::AlignCenter, text); 93 | } 94 | } 95 | } 96 | 97 | QPoint mousePos = view->getLastMousePos(); 98 | if (!mousePos.isNull()) 99 | { 100 | QPointF mouseScenePos = view->mapToScene(mousePos); 101 | 102 | double hz = s->xToHz(mouseScenePos.x()); 103 | double x = s->hzToX(hz); 104 | if (x != -1) 105 | { 106 | QString text = QString("%0").arg(hz, 0, 'f', 1); 107 | QFontMetrics metrics = painter.fontMetrics(); 108 | QRectF rect = metrics.boundingRect(text); 109 | float center = x - topLeft.x() + offsetLeft + 1; 110 | rect = QRectF(center - ceil(rect.width() / 2) - 2 + 0.5, ceil(height() / 2) - ceil(rect.height() / 2) + 1.5, rect.width() + 3, rect.height()); 111 | QPainterPath path; 112 | path.addRect(rect); 113 | QPainterPath topTriangle; 114 | topTriangle.moveTo(QPoint(center - 3, rect.top() + 1)); 115 | topTriangle.lineTo(QPoint(center + 3, rect.top() + 1)); 116 | topTriangle.lineTo(QPoint(center, rect.top() - 3)); 117 | path = path.united(topTriangle); 118 | 119 | painter.setPen(Qt::black); 120 | painter.setBrush(Qt::white); 121 | painter.drawPath(path); 122 | painter.setPen(Qt::blue); 123 | painter.drawText(center, 0, 0, height(), Qt::TextDontClip | Qt::AlignCenter, text); 124 | } 125 | } 126 | } 127 | 128 | void FrequencyPlotHRuler::wheelEvent(QWheelEvent* event) 129 | { 130 | FrequencyPlotView* view = qobject_cast(parentWidget()); 131 | #if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) 132 | view->zoom(event->angleDelta().y(), 0, event->x() - view->viewportMargins().left(), 0); 133 | #else 134 | view->zoom(event->angleDelta().y(), 0, event->position().x() - view->viewportMargins().left(), 0); 135 | #endif 136 | } 137 | 138 | void FrequencyPlotHRuler::mouseMoveEvent(QMouseEvent* event) 139 | { 140 | FrequencyPlotView* view = qobject_cast(parentWidget()); 141 | #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) 142 | view->setLastMousePos(QPoint(event->x() - view->viewportMargins().left(), view->viewport()->height() - 1)); 143 | #else 144 | view->setLastMousePos(QPoint(event->position().x() - view->viewportMargins().left(), view->viewport()->height() - 1)); 145 | #endif 146 | } 147 | -------------------------------------------------------------------------------- /GraphicEQWidget/icons/reset_response.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 22 | 24 | 32 | 37 | 38 | 46 | 51 | 52 | 60 | 65 | 66 | 74 | 79 | 80 | 88 | 93 | 94 | 102 | 107 | 108 | 116 | 121 | 122 | 123 | 142 | 144 | 145 | 147 | image/svg+xml 148 | 150 | 151 | 152 | 153 | 154 | 158 | 164 | 170 | 176 | 177 | 178 | -------------------------------------------------------------------------------- /GraphicEQWidget/icons/normalize_response.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 22 | 24 | 32 | 37 | 38 | 46 | 51 | 52 | 60 | 65 | 66 | 74 | 79 | 80 | 88 | 93 | 94 | 102 | 107 | 108 | 116 | 121 | 122 | 123 | 142 | 144 | 145 | 147 | image/svg+xml 148 | 150 | 151 | 152 | 153 | 154 | 158 | 164 | 170 | 176 | 182 | 183 | 184 | -------------------------------------------------------------------------------- /GraphicEQWidget/widgets/FrequencyPlotView.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of EqualizerAPO, a system-wide equalizer. 3 | Copyright (C) 2015 Jonas Thedering 4 | 5 | This program is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 2 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License along 16 | with this program; if not, write to the Free Software Foundation, Inc., 17 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 | */ 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | #include "helpers/DPIHelper.h" 26 | #include "FrequencyPlotItem.h" 27 | #include "FrequencyPlotView.h" 28 | 29 | using namespace std; 30 | 31 | FrequencyPlotView::FrequencyPlotView(QWidget* parent) 32 | : QGraphicsView(parent) 33 | { 34 | setViewportMargins(DPIHelper::scale(32), 0, 0, DPIHelper::scale(20)); 35 | hRuler = new FrequencyPlotHRuler(this); 36 | vRuler = new FrequencyPlotVRuler(this); 37 | hRuler->setMouseTracking(true); 38 | vRuler->setMouseTracking(true); 39 | } 40 | 41 | FrequencyPlotScene* FrequencyPlotView::scene() const 42 | { 43 | return qobject_cast(QGraphicsView::scene()); 44 | } 45 | 46 | void FrequencyPlotView::setScene(FrequencyPlotScene* scene) 47 | { 48 | QGraphicsView::setScene(scene); 49 | } 50 | 51 | void FrequencyPlotView::drawBackground(QPainter* painter, const QRectF& drawRect) 52 | { 53 | painter->setRenderHint(QPainter::Antialiasing, false); 54 | 55 | QRectF rect = drawRect; 56 | if (!sceneRect().contains(rect)) 57 | { 58 | rect = rect.intersected(sceneRect()); 59 | painter->setClipRect(rect); 60 | } 61 | 62 | FrequencyPlotScene* s = scene(); 63 | QPointF topLeft = mapToScene(0, 0); 64 | QPointF bottomRight = mapToScene(viewport()->width(), viewport()->height()); 65 | double dbStep = abs(s->yToDb(0) - s->yToDb(DPIHelper::scale(30))); 66 | 67 | double dbBase = pow(10, floor(log10(dbStep))); 68 | if (dbStep >= 5 * dbBase) 69 | dbStep = 5 * dbBase; 70 | else if (dbStep >= 2 * dbBase) 71 | dbStep = 2 * dbBase; 72 | else 73 | dbStep = dbBase; 74 | 75 | double fromDb = floor(s->yToDb(rect.top() + rect.height()) / dbStep) * dbStep; 76 | double toDb = ceil(s->yToDb(rect.top()) / dbStep) * dbStep; 77 | 78 | painter->setPen(palette().window().color()); 79 | for (double db = fromDb; db <= toDb; db += dbStep) 80 | { 81 | double y = floor(s->dbToY(db)) + 0.5; 82 | if (y != -1) 83 | painter->drawLine(topLeft.x(), y, bottomRight.x(), y); 84 | } 85 | 86 | double fromHz = s->xToHz(rect.left()); 87 | double toHz = s->xToHz(rect.left() + rect.width()); 88 | 89 | const vector& bands = s->getBands(); 90 | if (bands.empty()) 91 | { 92 | double hzBase = pow(10, floor(log10(fromHz))); 93 | fromHz = floor(fromHz / hzBase) * hzBase; 94 | fromHz += hzBase; 95 | if (round(fromHz / hzBase) >= 10) 96 | hzBase *= 10; 97 | for (double hz = fromHz; hz <= toHz;) 98 | { 99 | double x = floor(s->hzToX(hz)) + 0.5; 100 | if (x >= 0) 101 | painter->drawLine(x, topLeft.y(), x, bottomRight.y()); 102 | 103 | hz += hzBase; 104 | if (round(hz / hzBase) >= 10) 105 | hzBase *= 10; 106 | } 107 | } 108 | else 109 | { 110 | vector::const_iterator it = lower_bound(bands.cbegin(), bands.cend(), fromHz); 111 | for (; it != bands.cend() && *it < toHz; it++) 112 | { 113 | double hz = *it; 114 | double x = floor(s->hzToX(hz)) + 0.5; 115 | if (x >= 0) 116 | painter->drawLine(x, topLeft.y(), x, bottomRight.y()); 117 | } 118 | } 119 | } 120 | 121 | void FrequencyPlotView::updateHRuler() 122 | { 123 | hRuler->update(); 124 | } 125 | 126 | QPoint FrequencyPlotView::getLastMousePos() const 127 | { 128 | return lastMousePos; 129 | } 130 | 131 | void FrequencyPlotView::setLastMousePos(QPoint pos) 132 | { 133 | lastMousePos = pos; 134 | hRuler->update(); 135 | vRuler->update(); 136 | } 137 | 138 | void FrequencyPlotView::zoom(int deltaX, int deltaY, int mouseX, int mouseY) 139 | { 140 | FrequencyPlotScene* s = scene(); 141 | QPointF scenePos = mapToScene(mouseX, mouseY); 142 | double hz = s->xToHz(scenePos.x()); 143 | double db = s->yToDb(scenePos.y()); 144 | 145 | qreal zoomFactorX = pow(1.001, deltaX); 146 | qreal zoomFactorY = pow(1.001, deltaY); 147 | double zoomX = max(0.5, min(30.0, s->getZoomX() * zoomFactorX)); 148 | double zoomY = max(0.5, min(30.0, s->getZoomY() * zoomFactorY)); 149 | s->setZoom(zoomX, zoomY); 150 | 151 | if (deltaX != 0) 152 | { 153 | double x = s->hzToX(hz); 154 | if (x != -1) 155 | horizontalScrollBar()->setValue(horizontalScrollBar()->value() + round(x - scenePos.x())); 156 | } 157 | 158 | if (deltaY != 0) 159 | { 160 | double y = s->dbToY(db); 161 | if (y != -1) 162 | verticalScrollBar()->setValue(verticalScrollBar()->value() + round(y - scenePos.y())); 163 | } 164 | 165 | resetCachedContent(); 166 | viewport()->update(); 167 | if (deltaX != 0) 168 | hRuler->update(); 169 | if (deltaY != 0) 170 | vRuler->update(); 171 | } 172 | 173 | void FrequencyPlotView::setScrollOffsets(int x, int y) 174 | { 175 | presetScrollX = x; 176 | presetScrollY = y; 177 | } 178 | 179 | void FrequencyPlotView::wheelEvent(QWheelEvent* event) 180 | { 181 | event->accept(); 182 | int delta = event->angleDelta().y(); 183 | #if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) 184 | zoom(delta, delta, event->x(), event->y()); 185 | #else 186 | zoom(delta, delta, event->position().x(), event->position().y()); 187 | #endif 188 | } 189 | 190 | void FrequencyPlotView::scrollContentsBy(int dx, int dy) 191 | { 192 | QGraphicsView::scrollContentsBy(dx, dy); 193 | 194 | if (dx != 0) 195 | hRuler->update(); 196 | if (dy != 0) 197 | vRuler->update(); 198 | } 199 | 200 | void FrequencyPlotView::resizeEvent(QResizeEvent* event) 201 | { 202 | QGraphicsView::resizeEvent(event); 203 | 204 | const QRect rect = viewport()->geometry(); 205 | QMargins margins = viewportMargins(); 206 | hRuler->setGeometry(rect.x() - margins.left(), rect.y() + rect.height(), rect.width() + margins.left(), margins.bottom()); 207 | vRuler->setGeometry(rect.x() - margins.left(), rect.y(), margins.left(), rect.height() + margins.bottom()); 208 | } 209 | 210 | void FrequencyPlotView::mousePressEvent(QMouseEvent* event) 211 | { 212 | QGraphicsView::mousePressEvent(event); 213 | 214 | setLastMousePos(event->pos()); 215 | } 216 | 217 | void FrequencyPlotView::mouseMoveEvent(QMouseEvent* event) 218 | { 219 | if (event->buttons() & Qt::RightButton) 220 | { 221 | #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) 222 | horizontalScrollBar()->setValue(horizontalScrollBar()->value() - (event->x() - lastMousePos.x())); 223 | verticalScrollBar()->setValue(verticalScrollBar()->value() - (event->y() - lastMousePos.y())); 224 | #else 225 | horizontalScrollBar()->setValue(horizontalScrollBar()->value() - (event->position().x() - lastMousePos.x())); 226 | verticalScrollBar()->setValue(verticalScrollBar()->value() - (event->position().y() - lastMousePos.y())); 227 | #endif 228 | } 229 | else 230 | { 231 | QGraphicsView::mouseMoveEvent(event); 232 | } 233 | setLastMousePos(event->pos()); 234 | } 235 | 236 | void FrequencyPlotView::leaveEvent(QEvent*) 237 | { 238 | setLastMousePos(QPoint()); 239 | } 240 | 241 | void FrequencyPlotView::showEvent(QShowEvent* event) 242 | { 243 | QGraphicsView::showEvent(event); 244 | 245 | if (presetScrollX != -1) 246 | { 247 | horizontalScrollBar()->setValue(presetScrollX); 248 | presetScrollX = -1; 249 | } 250 | 251 | if (presetScrollY != -1) 252 | { 253 | verticalScrollBar()->setValue(presetScrollY); 254 | presetScrollY = -1; 255 | } 256 | } 257 | -------------------------------------------------------------------------------- /GraphicEQWidget/icons/resize_corner.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 23 | 25 | 28 | 32 | 36 | 37 | 45 | 50 | 51 | 59 | 64 | 65 | 73 | 78 | 79 | 87 | 92 | 93 | 101 | 106 | 107 | 115 | 120 | 121 | 129 | 134 | 135 | 143 | 148 | 149 | 158 | 159 | 178 | 180 | 181 | 183 | image/svg+xml 184 | 186 | 187 | 188 | 189 | 190 | 194 | 206 | 213 | 220 | 227 | 234 | 241 | 242 | 243 | -------------------------------------------------------------------------------- /GraphicEQWidget/GraphicEQFilterGUIScene.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of EqualizerAPO, a system-wide equalizer. 3 | Copyright (C) 2015 Jonas Thedering 4 | 5 | This program is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 2 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License along 16 | with this program; if not, write to the Free Software Foundation, Inc., 17 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 | */ 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | #include "widgets/FrequencyPlotView.h" 26 | #include "GraphicEQFilterGUIScene.h" 27 | 28 | using namespace std; 29 | 30 | GraphicEQFilterGUIScene::GraphicEQFilterGUIScene(QObject* parent) 31 | : FrequencyPlotScene(parent) 32 | { 33 | } 34 | 35 | void GraphicEQFilterGUIScene::setNodes(const std::vector& nodes) 36 | { 37 | noUpdateModel = true; 38 | 39 | for (int i = (int)this->nodes.size() - 1; i >= 0; i--) 40 | removeNode(i); 41 | 42 | this->nodes = nodes; 43 | 44 | int i = 0; 45 | for (FilterNode node : nodes) 46 | { 47 | GraphicEQFilterGUIItem* item = new GraphicEQFilterGUIItem(i, node.freq, node.dbGain); 48 | addItem(item); 49 | item->updatePos(); 50 | items.append(item); 51 | emit nodeInserted(i, node.freq, node.dbGain); 52 | i++; 53 | } 54 | 55 | update(); 56 | 57 | noUpdateModel = false; 58 | } 59 | 60 | void GraphicEQFilterGUIScene::addNode(double hz, double db) 61 | { 62 | FilterNode node(hz, db); 63 | vector::iterator it = lower_bound(nodes.begin(), nodes.end(), node); 64 | int index = it - nodes.begin(); 65 | nodes.insert(it, node); 66 | 67 | GraphicEQFilterGUIItem* item = new GraphicEQFilterGUIItem(index, hz, db); 68 | addItem(item); 69 | item->updatePos(); 70 | items.insert(index, item); 71 | for (int i = index + 1; i < items.size(); i++) 72 | items[i]->setIndex(i); 73 | emit nodeInserted(index, hz, db); 74 | 75 | QRectF rect = sceneRect(); 76 | if (index > 0) 77 | rect.setLeft(items[index - 1]->x()); 78 | if (index + 1 < items.size()) 79 | rect.setRight(items[index + 1]->x()); 80 | update(rect); 81 | for (int i = index + 1; i < items.size(); i++) 82 | items[i]->update(); 83 | 84 | if (!noUpdateModel) 85 | emit updateModel(false); 86 | } 87 | 88 | void GraphicEQFilterGUIScene::removeNode(int index) 89 | { 90 | nodes.erase(nodes.begin() + index); 91 | GraphicEQFilterGUIItem* item = items[index]; 92 | removeItem(item); 93 | items.removeAt(index); 94 | for (int i = index; i < items.size(); i++) 95 | items[i]->setIndex(i); 96 | emit nodeRemoved(index); 97 | 98 | QRectF rect = sceneRect(); 99 | if (index > 0) 100 | rect.setLeft(items[index - 1]->x()); 101 | if (index < items.size()) 102 | rect.setRight(items[index]->x()); 103 | update(rect); 104 | for (int i = index; i < items.size(); i++) 105 | items[i]->update(); 106 | 107 | if (!noUpdateModel) 108 | emit updateModel(false); 109 | } 110 | 111 | void GraphicEQFilterGUIScene::setNode(int index, double hz, double db) 112 | { 113 | GraphicEQFilterGUIItem* item = items[index]; 114 | item->setHz(hz); 115 | item->setDb(db); 116 | item->updatePos(); 117 | 118 | FilterNode node(hz, db); 119 | vector::iterator it = lower_bound(nodes.begin(), nodes.end(), node); 120 | int newIndex = it - nodes.begin(); 121 | if (newIndex > index) 122 | newIndex--; 123 | if (newIndex != index) 124 | { 125 | items.move(index, newIndex); 126 | if (newIndex < index) 127 | { 128 | for (int i = index; i > newIndex; i--) 129 | nodes[i] = nodes[i - 1]; 130 | for (int i = newIndex; i <= index; i++) 131 | items[i]->setIndex(i); 132 | emit nodeMoved(index, newIndex); 133 | } 134 | else 135 | { 136 | for (int i = index; i < newIndex; i++) 137 | nodes[i] = nodes[i + 1]; 138 | for (int i = index; i <= newIndex; i++) 139 | items[i]->setIndex(i); 140 | emit nodeMoved(index, newIndex); 141 | } 142 | } 143 | nodes[newIndex] = node; 144 | emit nodeUpdated(newIndex, hz, db); 145 | 146 | QRectF rect = sceneRect(); 147 | int lowerIndex = min(index, newIndex); 148 | int upperIndex = max(index, newIndex); 149 | if (lowerIndex > 0) 150 | rect.setLeft(items[lowerIndex - 1]->x()); 151 | if (upperIndex + 1 < items.size()) 152 | rect.setRight(items[upperIndex + 1]->x()); 153 | update(rect); 154 | 155 | if (!noUpdateModel) 156 | emit updateModel(false); 157 | } 158 | 159 | void GraphicEQFilterGUIScene::setSelectedNodes(QSet indices) 160 | { 161 | for (GraphicEQFilterGUIItem* item : items) 162 | item->setSelected(indices.contains(item->getIndex())); 163 | } 164 | 165 | QSet GraphicEQFilterGUIScene::getSelectedIndices() 166 | { 167 | QSet set; 168 | 169 | for (GraphicEQFilterGUIItem* item : items) 170 | if (item->isSelected()) 171 | set.insert(item->getIndex()); 172 | 173 | return set; 174 | } 175 | 176 | void GraphicEQFilterGUIScene::itemMoved(int index) 177 | { 178 | GraphicEQFilterGUIItem* item = items[index]; 179 | double db = yToDb(item->scenePos().y()); 180 | double oldHz = item->getHz(); 181 | double hz; 182 | if (getBandCount() != -1 && !freeMode15) 183 | { 184 | hz = oldHz; 185 | } 186 | else 187 | { 188 | hz = xToHz(item->scenePos().x()); 189 | if (hz >= 10000) 190 | hz = round(hz); 191 | else 192 | hz = round(hz * 10) / 10; 193 | item->setHz(hz); 194 | } 195 | if (getZoomY() < 4) 196 | db = round(db * 10) / 10; 197 | else 198 | db = round(db * 100) / 100; 199 | item->setDb(db); 200 | 201 | int newIndex = index; 202 | if (hz < oldHz) 203 | { 204 | while (newIndex > 0 && nodes[newIndex - 1].freq > hz) 205 | { 206 | nodes[newIndex] = nodes[newIndex - 1]; 207 | items[newIndex] = items[newIndex - 1]; 208 | items[newIndex]->setIndex(newIndex); 209 | newIndex--; 210 | } 211 | } 212 | else if (hz > oldHz) 213 | { 214 | while (newIndex < (int)nodes.size() - 1 && nodes[newIndex + 1].freq < hz) 215 | { 216 | nodes[newIndex] = nodes[newIndex + 1]; 217 | items[newIndex] = items[newIndex + 1]; 218 | items[newIndex]->setIndex(newIndex); 219 | newIndex++; 220 | } 221 | } 222 | nodes[newIndex] = FilterNode(hz, db); 223 | if (newIndex != index) 224 | { 225 | items[newIndex] = item; 226 | item->setIndex(newIndex); 227 | emit nodeMoved(index, newIndex); 228 | } 229 | emit nodeUpdated(newIndex, hz, db); 230 | 231 | QRectF rect = sceneRect(); 232 | int lowerIndex = min(index, newIndex); 233 | int upperIndex = max(index, newIndex); 234 | if (lowerIndex > 0) 235 | rect.setLeft(items[lowerIndex - 1]->x()); 236 | if (upperIndex + 1 < items.size()) 237 | rect.setRight(items[upperIndex + 1]->x()); 238 | update(rect); 239 | 240 | if (!noUpdateModel) 241 | emit updateModel(true); 242 | } 243 | 244 | void GraphicEQFilterGUIScene::itemSelectionChanged(int index, bool selected) 245 | { 246 | emit nodeSelectionChanged(index, selected); 247 | } 248 | 249 | void GraphicEQFilterGUIScene::mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event) 250 | { 251 | if (getBandCount() != -1) 252 | return; 253 | 254 | double hz = xToHz(event->scenePos().x()); 255 | double db = yToDb(event->scenePos().y()); 256 | addNode(hz, db); 257 | } 258 | 259 | void GraphicEQFilterGUIScene::keyPressEvent(QKeyEvent* event) 260 | { 261 | switch (event->key()) 262 | { 263 | case Qt::Key_Delete: 264 | if (getBandCount() == -1) 265 | { 266 | for (QGraphicsItem* item : selectedItems()) 267 | { 268 | GraphicEQFilterGUIItem* plotItem = qgraphicsitem_cast(item); 269 | if (plotItem != NULL) 270 | { 271 | // this works for multiple items because the index of the other items is updated inside removeNode 272 | int index = plotItem->getIndex(); 273 | removeNode(index); 274 | } 275 | } 276 | } 277 | break; 278 | 279 | case Qt::Key_Up: 280 | case Qt::Key_Down: 281 | case Qt::Key_Left: 282 | case Qt::Key_Right: 283 | for (QGraphicsItem* item : selectedItems()) 284 | { 285 | GraphicEQFilterGUIItem* plotItem = qgraphicsitem_cast(item); 286 | if (plotItem != NULL) 287 | { 288 | int index = plotItem->getIndex(); 289 | FilterNode node = nodes[index]; 290 | switch (event->key()) 291 | { 292 | case Qt::Key_Up: 293 | node.dbGain += 1; 294 | break; 295 | case Qt::Key_Down: 296 | node.dbGain -= 1; 297 | break; 298 | case Qt::Key_Left: 299 | node.freq -= 1; 300 | break; 301 | case Qt::Key_Right: 302 | node.freq += 1; 303 | break; 304 | } 305 | setNode(index, node.freq, node.dbGain); 306 | } 307 | } 308 | break; 309 | 310 | case Qt::Key_A: 311 | if (event->modifiers() & Qt::ControlModifier) 312 | { 313 | QPainterPath painterPath; 314 | painterPath.addRect(sceneRect()); 315 | setSelectionArea(painterPath); 316 | } 317 | break; 318 | } 319 | } 320 | 321 | vector& GraphicEQFilterGUIScene::getNodes() 322 | { 323 | return nodes; 324 | } 325 | 326 | int GraphicEQFilterGUIScene::verifyBands(const std::vector& nodes) 327 | { 328 | const vector& bands = getBands((int)nodes.size()); 329 | 330 | int bandCount = -1; 331 | if (!bands.empty()) 332 | { 333 | bandCount = (int)nodes.size(); 334 | for (unsigned i = 0; i < nodes.size(); i++) 335 | { 336 | if (abs(nodes[i].freq - bands[i]) > 0.1) 337 | { 338 | bandCount = -1; 339 | break; 340 | } 341 | } 342 | } 343 | 344 | return bandCount; 345 | } 346 | 347 | void GraphicEQFilterGUIScene::setBandCount(int value) 348 | { 349 | if (value != getBandCount()) 350 | { 351 | const vector& bands = getBands(value); 352 | if (!bands.empty()) 353 | { 354 | vector newNodes; 355 | GainIterator gainIterator(nodes); 356 | for (double band : bands) 357 | { 358 | double dbGain = gainIterator.gainAt(band); 359 | dbGain = round(dbGain * 100) / 100; 360 | FilterNode node(band, dbGain); 361 | newNodes.push_back(node); 362 | } 363 | 364 | setNodes(newNodes); 365 | } 366 | 367 | FrequencyPlotScene::setBandCount(value); 368 | 369 | if (!noUpdateModel) 370 | emit updateModel(false); 371 | } 372 | } 373 | 374 | void GraphicEQFilterGUIScene::set15BandFreeMode(bool e){ 375 | freeMode15 = e; 376 | } 377 | bool GraphicEQFilterGUIScene::get15BandFreeMode(){ 378 | return freeMode15; 379 | } 380 | -------------------------------------------------------------------------------- /GraphicEQWidget/GraphicEQFilterGUI.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | GraphicEQFilterGUI 4 | 5 | 6 | 7 | 0 8 | 0 9 | 495 10 | 238 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 6 19 | 20 | 21 | 0 22 | 23 | 24 | 0 25 | 26 | 27 | 0 28 | 29 | 30 | 0 31 | 32 | 33 | 34 | 35 | 36 | 0 37 | 0 38 | 39 | 40 | 41 | 42 | 0 43 | 100 44 | 45 | 46 | 47 | true 48 | 49 | 50 | QPainter::Antialiasing|QPainter::TextAntialiasing 51 | 52 | 53 | QGraphicsView::RubberBandDrag 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 130 62 | 0 63 | 64 | 65 | 66 | 67 | 16777215 68 | 16777215 69 | 70 | 71 | 72 | 73 | 0 74 | 75 | 76 | 0 77 | 78 | 79 | 0 80 | 81 | 82 | 0 83 | 84 | 85 | 0 86 | 87 | 88 | 89 | 90 | Enable Graphic EQ 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 0 99 | 0 100 | 101 | 102 | 103 | 104 | 50 105 | 0 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 51 115 | 153 116 | 255 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 122 126 | 189 127 | 255 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 51 137 | 153 138 | 255 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | QAbstractScrollArea::AdjustToContents 147 | 148 | 149 | QAbstractItemView::ScrollPerPixel 150 | 151 | 152 | false 153 | 154 | 155 | 2 156 | 157 | 158 | false 159 | 160 | 161 | 10 162 | 163 | 164 | 10 165 | 166 | 167 | false 168 | 169 | 170 | 23 171 | 172 | 173 | 23 174 | 175 | 176 | 177 | Freq. 178 | 179 | 180 | 181 | 182 | Gain 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 4 191 | 192 | 193 | 194 | 195 | AutoEQ database... 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 6 205 | 206 | 207 | 6 208 | 209 | 210 | 4 211 | 212 | 213 | 0 214 | 215 | 216 | 217 | 218 | 15-band 219 | 220 | 221 | 222 | 223 | 224 | 225 | 31-band 226 | 227 | 228 | 229 | 230 | 231 | 232 | variable 233 | 234 | 235 | true 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | :/icons/document-open.ico:/icons/document-open.ico 252 | 253 | 254 | Import 255 | 256 | 257 | 258 | 259 | 260 | :/icons/document-save.ico:/icons/document-save.ico 261 | 262 | 263 | Export 264 | 265 | 266 | 267 | 268 | 269 | :/icons/invert_response.ico:/icons/invert_response.ico 270 | 271 | 272 | Invert response 273 | 274 | 275 | 276 | 277 | 278 | :/icons/normalize_response.ico:/icons/normalize_response.ico 279 | 280 | 281 | Normalize response 282 | 283 | 284 | 285 | 286 | 287 | :/icons/reset_response.ico:/icons/reset_response.ico 288 | 289 | 290 | Reset response 291 | 292 | 293 | 294 | 295 | 296 | :/icons/document-open.ico:/icons/document-open.ico 297 | 298 | 299 | Import EqualizerAPO settings 300 | 301 | 302 | Import EqualizerAPO settings 303 | 304 | 305 | 306 | 307 | 308 | GraphicEQFilterGUIView 309 | QGraphicsView 310 |
GraphicEQFilterGUIView.h
311 | 312 | itemMoved() 313 | 314 |
315 |
316 | 317 | 318 | 319 | 320 | 321 | updateItemList() 322 | on_actionImport_AutoEQ_result() 323 | 324 |
325 | -------------------------------------------------------------------------------- /GraphicEQWidget/icons/resize_corner_20.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 23 | 25 | 28 | 32 | 36 | 37 | 45 | 51 | 52 | 60 | 66 | 67 | 75 | 81 | 82 | 90 | 96 | 97 | 105 | 111 | 112 | 120 | 126 | 127 | 135 | 141 | 142 | 150 | 156 | 157 | 167 | 177 | 187 | 197 | 207 | 217 | 218 | 237 | 239 | 240 | 242 | image/svg+xml 243 | 245 | 246 | 247 | 248 | 249 | 254 | 266 | 278 | 290 | 302 | 314 | 326 | 327 | 328 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | 294 | Copyright (C) 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | , 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. 340 | -------------------------------------------------------------------------------- /GraphicEQWidget/LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | 294 | Copyright (C) 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | , 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. 340 | -------------------------------------------------------------------------------- /demo.pro.user: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | EnvironmentId 7 | {42acfada-6cc9-466c-9070-353e6208faa2} 8 | 9 | 10 | ProjectExplorer.Project.ActiveTarget 11 | 0 12 | 13 | 14 | ProjectExplorer.Project.EditorSettings 15 | 16 | true 17 | false 18 | true 19 | 20 | Cpp 21 | 22 | CppGlobal 23 | 24 | 25 | 26 | QmlJS 27 | 28 | QmlJSGlobal 29 | 30 | 31 | 2 32 | UTF-8 33 | false 34 | 4 35 | false 36 | 80 37 | true 38 | true 39 | 1 40 | false 41 | true 42 | false 43 | 0 44 | true 45 | true 46 | 0 47 | 8 48 | true 49 | false 50 | 1 51 | true 52 | true 53 | true 54 | *.md, *.MD, Makefile 55 | false 56 | true 57 | 58 | 59 | 60 | ProjectExplorer.Project.PluginSettings 61 | 62 | 63 | true 64 | false 65 | true 66 | true 67 | true 68 | true 69 | 70 | 71 | 0 72 | true 73 | 74 | true 75 | Builtin.BuildSystem 76 | 77 | true 78 | true 79 | Builtin.DefaultTidyAndClazy 80 | 4 81 | 82 | 83 | 84 | true 85 | 86 | 87 | 88 | 89 | ProjectExplorer.Project.Target.0 90 | 91 | Desktop 92 | Desktop Qt 5.15.2 GCC 64bit 93 | Desktop Qt 5.15.2 GCC 64bit 94 | qt.qt5.5152.gcc_64_kit 95 | 0 96 | 0 97 | 0 98 | 99 | 0 100 | /home/tim/Development/build-demo-Desktop_Qt_5_15_2_GCC_64bit-Debug 101 | /home/tim/Development/build-demo-Desktop_Qt_5_15_2_GCC_64bit-Debug 102 | 103 | 104 | true 105 | QtProjectManager.QMakeBuildStep 106 | false 107 | 108 | 109 | 110 | true 111 | Qt4ProjectManager.MakeStep 112 | 113 | 2 114 | Build 115 | Build 116 | ProjectExplorer.BuildSteps.Build 117 | 118 | 119 | 120 | true 121 | Qt4ProjectManager.MakeStep 122 | clean 123 | 124 | 1 125 | Clean 126 | Clean 127 | ProjectExplorer.BuildSteps.Clean 128 | 129 | 2 130 | false 131 | 132 | false 133 | 134 | Debug 135 | Qt4ProjectManager.Qt4BuildConfiguration 136 | 2 137 | 138 | 139 | /home/tim/Development/build-demo-Desktop_Qt_5_15_2_GCC_64bit-Release 140 | /home/tim/Development/build-demo-Desktop_Qt_5_15_2_GCC_64bit-Release 141 | 142 | 143 | true 144 | QtProjectManager.QMakeBuildStep 145 | false 146 | 147 | 148 | 149 | true 150 | Qt4ProjectManager.MakeStep 151 | 152 | 2 153 | Build 154 | Build 155 | ProjectExplorer.BuildSteps.Build 156 | 157 | 158 | 159 | true 160 | Qt4ProjectManager.MakeStep 161 | clean 162 | 163 | 1 164 | Clean 165 | Clean 166 | ProjectExplorer.BuildSteps.Clean 167 | 168 | 2 169 | false 170 | 171 | false 172 | 173 | Release 174 | Qt4ProjectManager.Qt4BuildConfiguration 175 | 0 176 | 0 177 | 178 | 179 | 0 180 | /home/tim/Development/build-demo-Desktop_Qt_5_15_2_GCC_64bit-Profile 181 | /home/tim/Development/build-demo-Desktop_Qt_5_15_2_GCC_64bit-Profile 182 | 183 | 184 | true 185 | QtProjectManager.QMakeBuildStep 186 | false 187 | 188 | 189 | 190 | true 191 | Qt4ProjectManager.MakeStep 192 | 193 | 2 194 | Build 195 | Build 196 | ProjectExplorer.BuildSteps.Build 197 | 198 | 199 | 200 | true 201 | Qt4ProjectManager.MakeStep 202 | clean 203 | 204 | 1 205 | Clean 206 | Clean 207 | ProjectExplorer.BuildSteps.Clean 208 | 209 | 2 210 | false 211 | 212 | false 213 | 214 | Profile 215 | Qt4ProjectManager.Qt4BuildConfiguration 216 | 0 217 | 0 218 | 0 219 | 220 | 3 221 | 222 | 223 | 0 224 | Deploy 225 | Deploy 226 | ProjectExplorer.BuildSteps.Deploy 227 | 228 | 1 229 | 230 | false 231 | ProjectExplorer.DefaultDeployConfiguration 232 | 233 | 1 234 | 235 | true 236 | true 237 | true 238 | 239 | 2 240 | 241 | ProjectExplorer.CustomExecutableRunConfiguration 242 | 243 | false 244 | true 245 | false 246 | true 247 | 248 | 1 249 | 250 | 251 | 252 | ProjectExplorer.Project.TargetCount 253 | 1 254 | 255 | 256 | ProjectExplorer.Project.Updater.FileVersion 257 | 22 258 | 259 | 260 | Version 261 | 22 262 | 263 | 264 | -------------------------------------------------------------------------------- /GraphicEQWidget/GraphicEQFilterGUI.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of EqualizerAPO, a system-wide equalizer. 3 | Copyright (C) 2015 Jonas Thedering 4 | 5 | This program is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 2 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License along 16 | with this program; if not, write to the Free Software Foundation, Inc., 17 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 | */ 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | #include "helpers/GainIterator.h" 29 | #include "helpers/DPIHelper.h" 30 | #include "GraphicEQFilterGUIView.h" 31 | #include "GraphicEQFilterGUI.h" 32 | #include "ui_GraphicEQFilterGUI.h" 33 | 34 | using namespace std; 35 | 36 | QRegularExpression GraphicEQFilterGUI::numberRegEx("[-+]?[0-9]*\\.?[0-9]+([eE][-+]?[0-9]+)?"); 37 | 38 | GraphicEQFilterGUI::GraphicEQFilterGUI(QWidget* parent) : QWidget(parent), 39 | ui(new Ui::GraphicEQFilterGUI) 40 | { 41 | ui->setupUi(this); 42 | chk_enable = ui->chk_enable; 43 | 44 | ui->tableWidget->horizontalHeader()->setMinimumSectionSize(DPIHelper::scale(10)); 45 | ui->tableWidget->horizontalHeader()->setDefaultSectionSize(DPIHelper::scale(10)); 46 | ui->tableWidget->verticalHeader()->setMinimumSectionSize(DPIHelper::scale(23)); 47 | ui->tableWidget->verticalHeader()->setDefaultSectionSize(DPIHelper::scale(23)); 48 | 49 | scene = new GraphicEQFilterGUIScene(ui->graphicsView); 50 | ui->graphicsView->setScene(scene); 51 | 52 | setPalette(qApp->style()->standardPalette()); 53 | 54 | ui->toolBar->addAction(ui->actionInvertResponse); 55 | ui->toolBar->addAction(ui->actionNormalizeResponse); 56 | ui->toolBar->addAction(ui->actionResetResponse); 57 | ui->toolBar->addAction(ui->actionImport); 58 | ui->toolBar->addAction(ui->actionImport_AutoEQ_result); 59 | ui->toolBar->addAction(ui->actionExport); 60 | 61 | connect(scene, SIGNAL(nodeInserted(int,double,double)), this, SLOT(insertRow(int,double,double))); 62 | connect(scene, SIGNAL(nodeRemoved(int)), this, SLOT(removeRow(int))); 63 | connect(scene, SIGNAL(nodeUpdated(int,double,double)), this, SLOT(updateRow(int,double,double))); 64 | connect(scene, SIGNAL(nodeMoved(int,int)), this, SLOT(moveRow(int,int))); 65 | connect(scene, SIGNAL(nodeSelectionChanged(int,bool)), this, SLOT(selectRow(int,bool))); 66 | connect(scene, SIGNAL(updateModel(bool)), this, SIGNAL(updateModel(bool))); 67 | connect(scene, SIGNAL(nodeMouseUp(int)), this, SIGNAL(mouseUp())); 68 | 69 | connect(this, &GraphicEQFilterGUI::updateModel, this, [this](bool isMoving){ 70 | if(!isMoving) emit updateModelEnd(); 71 | }); 72 | 73 | setEnableSwitchVisible(false); 74 | setAutoEqAvailable(false); 75 | connect(ui->autoeq,&QAbstractButton::clicked,this,&GraphicEQFilterGUI::autoeqClicked); 76 | 77 | ui->tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); 78 | } 79 | 80 | GraphicEQFilterGUI::~GraphicEQFilterGUI() 81 | { 82 | delete ui; 83 | } 84 | 85 | void GraphicEQFilterGUI::setSidebarHidden(bool hidden){ 86 | ui->sidebar->setVisible(!hidden); 87 | } 88 | 89 | void GraphicEQFilterGUI::set15BandFreeMode(bool e){ 90 | freeMode15 = e; 91 | scene->setBandCount(15); 92 | setFreqEditable(true); 93 | scene->set15BandFreeMode(true); 94 | } 95 | 96 | void GraphicEQFilterGUI::store(QString& parameters) 97 | { 98 | parameters = "GraphicEQ: "; 99 | 100 | bool first = true; 101 | for (FilterNode node : scene->getNodes()) 102 | { 103 | if (first) 104 | first = false; 105 | else 106 | parameters += "; "; 107 | 108 | parameters += QString("%0 %1").arg(node.freq).arg(node.dbGain); 109 | } 110 | } 111 | 112 | void GraphicEQFilterGUI::storeCsv(QString& parameters) 113 | { 114 | bool first = true; 115 | for (FilterNode node : scene->getNodes()) 116 | { 117 | if (first) 118 | first = false; 119 | else 120 | parameters += ";"; 121 | 122 | parameters += QString::number(node.freq); 123 | } 124 | for (FilterNode node : scene->getNodes()) 125 | { 126 | parameters += ";"; 127 | parameters += QString::number(node.dbGain); 128 | } 129 | } 130 | 131 | void GraphicEQFilterGUI::load(const QString& parameters) 132 | { 133 | QStringList parameterList(parameters.split(":")); 134 | if(parameterList.count() < 2) 135 | return; 136 | 137 | std::vector nodes; 138 | QStringList nodeList = parameterList.at(1).split(";"); 139 | for(QString nodeStr : nodeList){ 140 | #if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) 141 | QStringList values = nodeStr.trimmed().split(" ", QString::SkipEmptyParts); 142 | #else 143 | QStringList values = nodeStr.trimmed().split(" ", Qt::SkipEmptyParts); 144 | #endif 145 | if(values.count() != 2) 146 | continue; 147 | FilterNode node(values.at(0).toDouble(),values.at(1).toDouble()); 148 | nodes.push_back(node); 149 | } 150 | 151 | sort(nodes.begin(), nodes.end()); 152 | 153 | scene->setNodes(nodes); 154 | 155 | int bandCount = scene->verifyBands(nodes); 156 | if (bandCount != scene->getBandCount()) 157 | { 158 | switch (bandCount) 159 | { 160 | case 15: 161 | ui->radioButton15->click(); 162 | break; 163 | case 31: 164 | ui->radioButton31->click(); 165 | break; 166 | default: 167 | ui->radioButtonVar->click(); 168 | } 169 | } 170 | else 171 | { 172 | // Don't send signals if load() is called 173 | // emit updateModel(false); 174 | } 175 | } 176 | 177 | void GraphicEQFilterGUI::loadMap(const QMap& parameters) 178 | { 179 | std::vector nodes; 180 | for(auto p : parameters.toStdMap()){ 181 | FilterNode node(p.first,p.second); 182 | nodes.push_back(node); 183 | } 184 | 185 | sort(nodes.begin(), nodes.end()); 186 | 187 | scene->setNodes(nodes); 188 | 189 | int bandCount = scene->verifyBands(nodes); 190 | if (bandCount != scene->getBandCount()) 191 | { 192 | switch (bandCount) 193 | { 194 | case 15: 195 | ui->radioButton15->click(); 196 | break; 197 | case 31: 198 | ui->radioButton31->click(); 199 | break; 200 | default: 201 | ui->radioButtonVar->click(); 202 | } 203 | } 204 | else 205 | { 206 | emit updateModel(false); 207 | } 208 | } 209 | 210 | void GraphicEQFilterGUI::loadPreferences(const QVariantMap& prefs) 211 | { 212 | /*ui->tableWidget->setFixedWidth(DPIHelper::scale(prefs.value("tableWidth", DEFAULT_TABLE_WIDTH).toDouble())); 213 | ui->graphicsView->setFixedHeight(DPIHelper::scale(prefs.value("viewHeight", DEFAULT_VIEW_HEIGHT).toDouble()));*/ 214 | double zoomX = DPIHelper::scaleZoom(prefs.value("zoomX", 0.561).toDouble()); 215 | double zoomY = DPIHelper::scaleZoom(prefs.value("zoomY", 3.773).toDouble()); 216 | scene->setZoom(zoomX, zoomY); 217 | bool ok; 218 | int scrollX = DPIHelper::scale(prefs.value("scrollX", 102).toDouble(&ok)); 219 | if (!ok) 220 | scrollX = round(scene->hzToX(20)); 221 | int scrollY = DPIHelper::scale(prefs.value("scrollY", 825).toDouble(&ok)); 222 | if (!ok) 223 | scrollY = round(scene->dbToY(22)); 224 | ui->graphicsView->setScrollOffsets(scrollX, scrollY); 225 | } 226 | 227 | void GraphicEQFilterGUI::storePreferences(QVariantMap& prefs) 228 | { 229 | /*if (DPIHelper::invScale(ui->tableWidget->width()) != DEFAULT_TABLE_WIDTH) 230 | prefs.insert("tableWidth", DPIHelper::invScale(ui->tableWidget->width())); 231 | if (DPIHelper::invScale(ui->graphicsView->height()) != DEFAULT_VIEW_HEIGHT) 232 | prefs.insert("viewHeight", DPIHelper::invScale(ui->graphicsView->height())); 233 | */if (DPIHelper::invScaleZoom(scene->getZoomX()) != 1.0) 234 | prefs.insert("zoomX", DPIHelper::invScaleZoom(scene->getZoomX())); 235 | if (DPIHelper::invScaleZoom(scene->getZoomY()) != 1.0) 236 | prefs.insert("zoomY", DPIHelper::invScaleZoom(scene->getZoomY())); 237 | QScrollBar* hScrollBar = ui->graphicsView->horizontalScrollBar(); 238 | int value = hScrollBar->value(); 239 | if (value != round(scene->hzToX(20))) 240 | prefs.insert("scrollX", DPIHelper::invScale(value)); 241 | QScrollBar* vScrollBar = ui->graphicsView->verticalScrollBar(); 242 | value = vScrollBar->value(); 243 | if (value != round(scene->dbToY(22))) 244 | prefs.insert("scrollY", DPIHelper::invScale(value)); 245 | } 246 | 247 | void GraphicEQFilterGUI::insertRow(int index, double hz, double db) 248 | { 249 | ui->tableWidget->blockSignals(true); 250 | ui->tableWidget->insertRow(index); 251 | QTableWidgetItem* freqItem = new QTableWidgetItem(QString("%0").arg(hz)); 252 | ui->tableWidget->setItem(index, 0, freqItem); 253 | 254 | QTableWidgetItem* gainItem = new QTableWidgetItem(QString("%0").arg(db)); 255 | ui->tableWidget->setItem(index, 1, gainItem); 256 | ui->tableWidget->blockSignals(false); 257 | } 258 | 259 | void GraphicEQFilterGUI::removeRow(int index) 260 | { 261 | ui->tableWidget->blockSignals(true); 262 | ui->tableWidget->removeRow(index); 263 | ui->tableWidget->blockSignals(false); 264 | } 265 | 266 | void GraphicEQFilterGUI::updateRow(int index, double hz, double db) 267 | { 268 | ui->tableWidget->blockSignals(true); 269 | QTableWidgetItem* freqItem = ui->tableWidget->item(index, 0); 270 | freqItem->setText(QString("%0").arg(hz)); 271 | 272 | QTableWidgetItem* gainItem = ui->tableWidget->item(index, 1); 273 | gainItem->setText(QString("%0").arg(db)); 274 | ui->tableWidget->blockSignals(false); 275 | } 276 | 277 | void GraphicEQFilterGUI::moveRow(int fromIndex, int toIndex) 278 | { 279 | ui->tableWidget->blockSignals(true); 280 | QTableWidgetItem* freqItem = ui->tableWidget->takeItem(fromIndex, 0); 281 | QTableWidgetItem* gainItem = ui->tableWidget->takeItem(fromIndex, 1); 282 | bool selected = ui->tableWidget->selectionModel()->isRowSelected(fromIndex, ui->tableWidget->rootIndex()); 283 | ui->tableWidget->removeRow(fromIndex); 284 | ui->tableWidget->insertRow(toIndex); 285 | ui->tableWidget->setItem(toIndex, 0, freqItem); 286 | ui->tableWidget->setItem(toIndex, 1, gainItem); 287 | if (selected) 288 | { 289 | QModelIndex modelIndex = ui->tableWidget->model()->index(toIndex, 0); 290 | ui->tableWidget->selectionModel()->select(modelIndex, QItemSelectionModel::Rows | QItemSelectionModel::Select); 291 | ui->tableWidget->scrollTo(modelIndex); 292 | } 293 | ui->tableWidget->blockSignals(false); 294 | } 295 | 296 | void GraphicEQFilterGUI::selectRow(int index, bool select) 297 | { 298 | ui->tableWidget->blockSignals(true); 299 | QItemSelectionModel::SelectionFlags command = QItemSelectionModel::Rows; 300 | if (select) 301 | command |= QItemSelectionModel::Select; 302 | else 303 | command |= QItemSelectionModel::Deselect; 304 | QModelIndex modelIndex = ui->tableWidget->model()->index(index, 0); 305 | ui->tableWidget->selectionModel()->select(modelIndex, command); 306 | ui->tableWidget->scrollTo(modelIndex); 307 | ui->tableWidget->blockSignals(false); 308 | } 309 | 310 | void GraphicEQFilterGUI::on_tableWidget_cellChanged(int row, int column) 311 | { 312 | if (column == 0) 313 | { 314 | QTableWidgetItem* freqItem = ui->tableWidget->item(row, 0); 315 | bool ok; 316 | double freq = freqItem->text().toDouble(&ok); 317 | if (ok) 318 | { 319 | double gain = scene->getNodes()[row].dbGain; 320 | scene->setNode(row, freq, gain); 321 | } 322 | else 323 | { 324 | freq = scene->getNodes()[row].freq; 325 | freqItem->setText(QString("%0").arg(freq)); 326 | } 327 | } 328 | else if (column == 1) 329 | { 330 | QTableWidgetItem* gainItem = ui->tableWidget->item(row, 1); 331 | bool ok; 332 | double gain = gainItem->text().toDouble(&ok); 333 | if (ok) 334 | { 335 | double freq = scene->getNodes()[row].freq; 336 | scene->setNode(row, freq, gain); 337 | } 338 | else 339 | { 340 | gain = scene->getNodes()[row].dbGain; 341 | gainItem->setText(QString("%0").arg(gain)); 342 | } 343 | } 344 | } 345 | 346 | void GraphicEQFilterGUI::on_tableWidget_itemSelectionChanged() 347 | { 348 | QSet selectedRows; 349 | for (QTableWidgetItem* item : ui->tableWidget->selectedItems()) 350 | selectedRows.insert(item->row()); 351 | 352 | scene->setSelectedNodes(selectedRows); 353 | } 354 | 355 | void GraphicEQFilterGUI::on_radioButton15_toggled(bool checked) 356 | { 357 | if (checked && !freeMode15) 358 | { 359 | scene->setBandCount(15); 360 | setFreqEditable(false); 361 | } 362 | } 363 | 364 | void GraphicEQFilterGUI::on_radioButton31_toggled(bool checked) 365 | { 366 | if (checked && !freeMode15) 367 | { 368 | scene->setBandCount(31); 369 | setFreqEditable(false); 370 | } 371 | } 372 | 373 | void GraphicEQFilterGUI::on_radioButtonVar_toggled(bool checked) 374 | { 375 | if (checked && !freeMode15) 376 | { 377 | scene->setBandCount(-1); 378 | setFreqEditable(true); 379 | } 380 | } 381 | 382 | void GraphicEQFilterGUI::setFreqEditable(bool editable) 383 | { 384 | ui->tableWidget->blockSignals(true); 385 | for (int i = 0; i < ui->tableWidget->rowCount(); i++) 386 | { 387 | QTableWidgetItem* item = ui->tableWidget->item(i, 0); 388 | if (editable) 389 | item->setFlags(item->flags() | Qt::ItemIsEditable | Qt::ItemIsEnabled); 390 | else 391 | item->setFlags(item->flags() & ~(Qt::ItemIsEditable | Qt::ItemIsEnabled)); 392 | } 393 | ui->tableWidget->blockSignals(false); 394 | } 395 | 396 | void GraphicEQFilterGUI::setAutoEqAvailable(bool visible) 397 | { 398 | ui->autoeq->setVisible(visible); 399 | } 400 | 401 | void GraphicEQFilterGUI::setEnableSwitchVisible(bool visible) 402 | { 403 | ui->chk_enable->setVisible(visible); 404 | } 405 | 406 | void GraphicEQFilterGUI::on_actionImport_triggered() 407 | { 408 | QFileInfo fileInfo(configPath); 409 | QFileDialog dialog(this, tr("Import frequency response"), fileInfo.absolutePath(), "*.csv"); 410 | dialog.setFileMode(QFileDialog::ExistingFiles); 411 | QStringList nameFilters; 412 | nameFilters.append(tr("CSV frequency response (*.csv)")); 413 | nameFilters.append(tr("All files (*.*)")); 414 | dialog.setNameFilters(nameFilters); 415 | if (dialog.exec() == QDialog::Accepted) 416 | { 417 | vector newNodes; 418 | 419 | for (QString path : dialog.selectedFiles()) 420 | { 421 | QFile file(path); 422 | if (file.open(QFile::ReadOnly)) 423 | { 424 | QTextStream stream(&file); 425 | while (!stream.atEnd()) 426 | { 427 | QString text = stream.readLine(); 428 | if (text.startsWith('*')) 429 | continue; 430 | 431 | if (!text.contains('.')) 432 | text = text.replace(',', '.'); 433 | QRegularExpressionMatchIterator it = numberRegEx.globalMatch(text); 434 | while (it.hasNext()) 435 | { 436 | QRegularExpressionMatch match = it.next(); 437 | QString freqString = match.captured(); 438 | bool ok; 439 | double freq = freqString.toDouble(&ok); 440 | if (ok && it.hasNext()) 441 | { 442 | match = it.next(); 443 | QString gainString = match.captured(); 444 | double gain = gainString.toDouble(&ok); 445 | if (ok) 446 | newNodes.push_back(FilterNode(freq, gain)); 447 | } 448 | } 449 | } 450 | } 451 | } 452 | sort(newNodes.begin(), newNodes.end()); 453 | 454 | scene->setNodes(newNodes); 455 | 456 | int bandCount = scene->verifyBands(newNodes); 457 | if (bandCount != scene->getBandCount()) 458 | { 459 | switch (bandCount) 460 | { 461 | case 15: 462 | ui->radioButton15->click(); 463 | break; 464 | case 31: 465 | ui->radioButton31->click(); 466 | break; 467 | default: 468 | ui->radioButtonVar->click(); 469 | } 470 | } 471 | else 472 | { 473 | emit updateModel(false); 474 | } 475 | } 476 | } 477 | 478 | void GraphicEQFilterGUI::on_actionImport_AutoEQ_result_triggered() 479 | { 480 | QFileInfo fileInfo(configPath); 481 | QFileDialog dialog(this, tr("Import EqualizerAPO graphic EQ preset"), fileInfo.absolutePath(), "*.txt"); 482 | dialog.setFileMode(QFileDialog::ExistingFile); 483 | QStringList nameFilters; 484 | nameFilters.append(tr("EqualizerAPO GraphicEQ (*.txt)")); 485 | nameFilters.append(tr("All files (*.*)")); 486 | dialog.setNameFilters(nameFilters); 487 | if (dialog.exec() == QDialog::Accepted) 488 | { 489 | QFile file(dialog.selectedFiles().at(0)); 490 | if (file.open(QFile::ReadOnly)) 491 | { 492 | QTextStream stream(&file); 493 | load(file.readAll()); 494 | emit updateModel(false); 495 | } 496 | } 497 | } 498 | 499 | void GraphicEQFilterGUI::on_actionExport_triggered() 500 | { 501 | QFileInfo fileInfo(configPath); 502 | QFileDialog dialog(this, tr("Export frequency response"), fileInfo.absolutePath(), "*.csv"); 503 | dialog.setFileMode(QFileDialog::AnyFile); 504 | dialog.setAcceptMode(QFileDialog::AcceptSave); 505 | QStringList nameFilters; 506 | nameFilters.append(tr("CSV frequency response (*.csv)")); 507 | nameFilters.append(tr("All files (*.*)")); 508 | dialog.setNameFilters(nameFilters); 509 | dialog.setDefaultSuffix(".csv"); 510 | 511 | if (dialog.exec() == QDialog::Accepted) 512 | { 513 | QString savePath = dialog.selectedFiles().first(); 514 | 515 | QFile file(savePath); 516 | if (file.open(QFile::WriteOnly | QFile::Truncate)) 517 | { 518 | QTextStream stream(&file); 519 | for (FilterNode node : scene->getNodes()) 520 | { 521 | stream << node.freq << '\t' << node.dbGain << '\n'; 522 | } 523 | stream.flush(); 524 | } 525 | } 526 | } 527 | 528 | void GraphicEQFilterGUI::on_actionInvertResponse_triggered() 529 | { 530 | vector newNodes = scene->getNodes(); 531 | for (FilterNode& node : newNodes) 532 | node.dbGain = -node.dbGain; 533 | 534 | scene->setNodes(newNodes); 535 | emit updateModel(false); 536 | } 537 | 538 | void GraphicEQFilterGUI::on_actionNormalizeResponse_triggered() 539 | { 540 | vector newNodes = scene->getNodes(); 541 | 542 | double maxGain = -DBL_MAX; 543 | for (FilterNode node : newNodes) 544 | { 545 | if (node.dbGain > maxGain) 546 | maxGain = node.dbGain; 547 | } 548 | 549 | if (maxGain != 0) 550 | { 551 | for (FilterNode& node : newNodes) 552 | node.dbGain -= maxGain; 553 | 554 | scene->setNodes(newNodes); 555 | emit updateModel(false); 556 | } 557 | } 558 | 559 | void GraphicEQFilterGUI::on_actionResetResponse_triggered() 560 | { 561 | vector newNodes = scene->getNodes(); 562 | QSet selectedIndices = scene->getSelectedIndices(); 563 | 564 | int index = 0; 565 | for (FilterNode& node : newNodes) 566 | { 567 | if (selectedIndices.isEmpty() || selectedIndices.contains(index)) 568 | node.dbGain = 0.0; 569 | index++; 570 | } 571 | 572 | scene->setNodes(newNodes); 573 | scene->setSelectedNodes(selectedIndices); 574 | emit updateModel(false); 575 | } 576 | --------------------------------------------------------------------------------