2014-11-29 20:07:01 +01:00
|
|
|
/* This file is part of Clementine.
|
|
|
|
Copyright 2004, Max Howell <max.howell@methylblue.com>
|
|
|
|
Copyright 2009-2010, David Sansome <davidsansome@gmail.com>
|
|
|
|
Copyright 2010, 2014, John Maguire <john.maguire@gmail.com>
|
|
|
|
Copyright 2011, Arnaud Bienner <arnaud.bienner@gmail.com>
|
Add "Psychedelic Colour" mode to all analyzers
(Well, except Nyanalyzer and Rainbow dash because they are already colourful enough.)
I have added functionality for any 2D analyzer to change any part of its colour palatte with the frequency content of the music, in the same way that Moodbars do.
I find this gives the analyzer a sort of "third dimention".
This is built into Analyzer::Base, so all analyzers can use it and override it as they please. I have thus added support for Block, Boom, Turbine, Sonogram, and Bar, however Boom and Block seem to look the best in my opinion.
This is of course all optional and is toggled by a checkbox in the context menu for the analyzer, disabled by default.
I have not been able to measure any increase in CPU activity with this enabled, even at 60fps.
2015-07-01 17:48:03 +02:00
|
|
|
Copyright 2014-2015, Mark Furneaux <mark@furneaux.ca>
|
2014-11-29 20:07:01 +01:00
|
|
|
Copyright 2014, Krzysztof Sobiecki <sobkas@gmail.com>
|
|
|
|
|
|
|
|
Clementine is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
Clementine is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Original Author: Max Howell <max.howell@methylblue.com> 2004
|
2020-09-18 16:15:19 +02:00
|
|
|
*/
|
2014-11-29 20:07:01 +01:00
|
|
|
|
|
|
|
#ifndef ANALYZERS_ANALYZERBASE_H_
|
|
|
|
#define ANALYZERS_ANALYZERBASE_H_
|
2009-12-24 20:16:07 +01:00
|
|
|
|
2018-11-29 22:32:12 +01:00
|
|
|
#include "config.h"
|
|
|
|
|
2009-12-24 20:16:07 +01:00
|
|
|
#ifdef __FreeBSD__
|
|
|
|
#include <sys/types.h>
|
|
|
|
#endif
|
|
|
|
|
2014-11-29 20:07:01 +01:00
|
|
|
#include <QBasicTimer>
|
2020-09-18 16:15:19 +02:00
|
|
|
#include <QPixmap>
|
2014-11-29 20:07:01 +01:00
|
|
|
#include <QWidget>
|
|
|
|
#include <vector>
|
2010-08-28 20:48:16 +02:00
|
|
|
|
2020-09-18 16:15:19 +02:00
|
|
|
#include "engines/engine_fwd.h"
|
|
|
|
#include "engines/enginebase.h"
|
|
|
|
#include "fht.h"
|
|
|
|
|
2018-11-29 22:32:12 +01:00
|
|
|
#ifdef HAVE_OPENGL
|
2014-11-29 20:07:01 +01:00
|
|
|
#include <QGLWidget>
|
2018-11-17 15:08:37 +01:00
|
|
|
#ifdef Q_OS_MACX
|
2014-11-29 20:07:01 +01:00
|
|
|
#include <OpenGL/gl.h>
|
|
|
|
#include <OpenGL/glu.h>
|
2010-08-28 20:48:16 +02:00
|
|
|
#else
|
2014-11-29 20:07:01 +01:00
|
|
|
#include <GL/gl.h>
|
|
|
|
#include <GL/glu.h>
|
2010-08-28 20:48:16 +02:00
|
|
|
#endif
|
2018-11-29 22:32:12 +01:00
|
|
|
#endif
|
2009-12-24 20:16:07 +01:00
|
|
|
|
|
|
|
class QEvent;
|
|
|
|
class QPaintEvent;
|
|
|
|
class QResizeEvent;
|
|
|
|
|
|
|
|
namespace Analyzer {
|
|
|
|
|
2010-08-28 20:48:16 +02:00
|
|
|
typedef std::vector<float> Scope;
|
2009-12-24 20:16:07 +01:00
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
class Base : public QWidget {
|
2010-03-20 23:45:54 +01:00
|
|
|
Q_OBJECT
|
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
public:
|
Add "Psychedelic Colour" mode to all analyzers
(Well, except Nyanalyzer and Rainbow dash because they are already colourful enough.)
I have added functionality for any 2D analyzer to change any part of its colour palatte with the frequency content of the music, in the same way that Moodbars do.
I find this gives the analyzer a sort of "third dimention".
This is built into Analyzer::Base, so all analyzers can use it and override it as they please. I have thus added support for Block, Boom, Turbine, Sonogram, and Bar, however Boom and Block seem to look the best in my opinion.
This is of course all optional and is toggled by a checkbox in the context menu for the analyzer, disabled by default.
I have not been able to measure any increase in CPU activity with this enabled, even at 60fps.
2015-07-01 17:48:03 +02:00
|
|
|
~Base() { delete fht_; }
|
2010-08-28 20:48:16 +02:00
|
|
|
|
Add "Psychedelic Colour" mode to all analyzers
(Well, except Nyanalyzer and Rainbow dash because they are already colourful enough.)
I have added functionality for any 2D analyzer to change any part of its colour palatte with the frequency content of the music, in the same way that Moodbars do.
I find this gives the analyzer a sort of "third dimention".
This is built into Analyzer::Base, so all analyzers can use it and override it as they please. I have thus added support for Block, Boom, Turbine, Sonogram, and Bar, however Boom and Block seem to look the best in my opinion.
This is of course all optional and is toggled by a checkbox in the context menu for the analyzer, disabled by default.
I have not been able to measure any increase in CPU activity with this enabled, even at 60fps.
2015-07-01 17:48:03 +02:00
|
|
|
uint timeout() const { return timeout_; }
|
2010-08-28 20:48:16 +02:00
|
|
|
|
Add "Psychedelic Colour" mode to all analyzers
(Well, except Nyanalyzer and Rainbow dash because they are already colourful enough.)
I have added functionality for any 2D analyzer to change any part of its colour palatte with the frequency content of the music, in the same way that Moodbars do.
I find this gives the analyzer a sort of "third dimention".
This is built into Analyzer::Base, so all analyzers can use it and override it as they please. I have thus added support for Block, Boom, Turbine, Sonogram, and Bar, however Boom and Block seem to look the best in my opinion.
This is of course all optional and is toggled by a checkbox in the context menu for the analyzer, disabled by default.
I have not been able to measure any increase in CPU activity with this enabled, even at 60fps.
2015-07-01 17:48:03 +02:00
|
|
|
void set_engine(EngineBase* engine) { engine_ = engine; }
|
2009-12-24 20:16:07 +01:00
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
void changeTimeout(uint newTimeout) {
|
Add "Psychedelic Colour" mode to all analyzers
(Well, except Nyanalyzer and Rainbow dash because they are already colourful enough.)
I have added functionality for any 2D analyzer to change any part of its colour palatte with the frequency content of the music, in the same way that Moodbars do.
I find this gives the analyzer a sort of "third dimention".
This is built into Analyzer::Base, so all analyzers can use it and override it as they please. I have thus added support for Block, Boom, Turbine, Sonogram, and Bar, however Boom and Block seem to look the best in my opinion.
This is of course all optional and is toggled by a checkbox in the context menu for the analyzer, disabled by default.
I have not been able to measure any increase in CPU activity with this enabled, even at 60fps.
2015-07-01 17:48:03 +02:00
|
|
|
timeout_ = newTimeout;
|
|
|
|
if (timer_.isActive()) {
|
|
|
|
timer_.stop();
|
|
|
|
timer_.start(timeout_, this);
|
2011-03-04 01:38:15 +01:00
|
|
|
}
|
2014-02-07 16:34:20 +01:00
|
|
|
}
|
|
|
|
|
2014-05-13 22:43:46 +02:00
|
|
|
virtual void framerateChanged() {}
|
Add "Psychedelic Colour" mode to all analyzers
(Well, except Nyanalyzer and Rainbow dash because they are already colourful enough.)
I have added functionality for any 2D analyzer to change any part of its colour palatte with the frequency content of the music, in the same way that Moodbars do.
I find this gives the analyzer a sort of "third dimention".
This is built into Analyzer::Base, so all analyzers can use it and override it as they please. I have thus added support for Block, Boom, Turbine, Sonogram, and Bar, however Boom and Block seem to look the best in my opinion.
This is of course all optional and is toggled by a checkbox in the context menu for the analyzer, disabled by default.
I have not been able to measure any increase in CPU activity with this enabled, even at 60fps.
2015-07-01 17:48:03 +02:00
|
|
|
virtual void psychedelicModeChanged(bool);
|
2014-05-13 22:43:46 +02:00
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
protected:
|
2014-11-29 20:07:01 +01:00
|
|
|
explicit Base(QWidget*, uint scopeSize = 7);
|
2014-02-07 16:34:20 +01:00
|
|
|
|
|
|
|
void hideEvent(QHideEvent*);
|
|
|
|
void showEvent(QShowEvent*);
|
|
|
|
void paintEvent(QPaintEvent*);
|
|
|
|
void timerEvent(QTimerEvent*);
|
|
|
|
|
|
|
|
void polishEvent();
|
|
|
|
|
|
|
|
int resizeExponent(int);
|
|
|
|
int resizeForBands(int);
|
Add "Psychedelic Colour" mode to all analyzers
(Well, except Nyanalyzer and Rainbow dash because they are already colourful enough.)
I have added functionality for any 2D analyzer to change any part of its colour palatte with the frequency content of the music, in the same way that Moodbars do.
I find this gives the analyzer a sort of "third dimention".
This is built into Analyzer::Base, so all analyzers can use it and override it as they please. I have thus added support for Block, Boom, Turbine, Sonogram, and Bar, however Boom and Block seem to look the best in my opinion.
This is of course all optional and is toggled by a checkbox in the context menu for the analyzer, disabled by default.
I have not been able to measure any increase in CPU activity with this enabled, even at 60fps.
2015-07-01 17:48:03 +02:00
|
|
|
int BandFrequency(int) const;
|
|
|
|
void updateBandSize(const int);
|
|
|
|
QColor getPsychedelicColor(const Scope&, const int, const int);
|
2014-02-07 16:34:20 +01:00
|
|
|
virtual void init() {}
|
|
|
|
virtual void transform(Scope&);
|
|
|
|
virtual void analyze(QPainter& p, const Scope&, bool new_frame) = 0;
|
|
|
|
virtual void demo(QPainter& p);
|
|
|
|
|
|
|
|
protected:
|
Add "Psychedelic Colour" mode to all analyzers
(Well, except Nyanalyzer and Rainbow dash because they are already colourful enough.)
I have added functionality for any 2D analyzer to change any part of its colour palatte with the frequency content of the music, in the same way that Moodbars do.
I find this gives the analyzer a sort of "third dimention".
This is built into Analyzer::Base, so all analyzers can use it and override it as they please. I have thus added support for Block, Boom, Turbine, Sonogram, and Bar, however Boom and Block seem to look the best in my opinion.
This is of course all optional and is toggled by a checkbox in the context menu for the analyzer, disabled by default.
I have not been able to measure any increase in CPU activity with this enabled, even at 60fps.
2015-07-01 17:48:03 +02:00
|
|
|
static const int kSampleRate =
|
|
|
|
44100; // we shouldn't need to care about ultrasonics
|
|
|
|
|
|
|
|
QBasicTimer timer_;
|
|
|
|
uint timeout_;
|
|
|
|
FHT* fht_;
|
|
|
|
EngineBase* engine_;
|
|
|
|
Scope lastScope_;
|
2014-02-07 16:34:20 +01:00
|
|
|
|
|
|
|
bool new_frame_;
|
|
|
|
bool is_playing_;
|
Add "Psychedelic Colour" mode to all analyzers
(Well, except Nyanalyzer and Rainbow dash because they are already colourful enough.)
I have added functionality for any 2D analyzer to change any part of its colour palatte with the frequency content of the music, in the same way that Moodbars do.
I find this gives the analyzer a sort of "third dimention".
This is built into Analyzer::Base, so all analyzers can use it and override it as they please. I have thus added support for Block, Boom, Turbine, Sonogram, and Bar, however Boom and Block seem to look the best in my opinion.
This is of course all optional and is toggled by a checkbox in the context menu for the analyzer, disabled by default.
I have not been able to measure any increase in CPU activity with this enabled, even at 60fps.
2015-07-01 17:48:03 +02:00
|
|
|
|
2017-03-11 18:14:11 +01:00
|
|
|
QVector<uint> barkband_table_;
|
Add "Psychedelic Colour" mode to all analyzers
(Well, except Nyanalyzer and Rainbow dash because they are already colourful enough.)
I have added functionality for any 2D analyzer to change any part of its colour palatte with the frequency content of the music, in the same way that Moodbars do.
I find this gives the analyzer a sort of "third dimention".
This is built into Analyzer::Base, so all analyzers can use it and override it as they please. I have thus added support for Block, Boom, Turbine, Sonogram, and Bar, however Boom and Block seem to look the best in my opinion.
This is of course all optional and is toggled by a checkbox in the context menu for the analyzer, disabled by default.
I have not been able to measure any increase in CPU activity with this enabled, even at 60fps.
2015-07-01 17:48:03 +02:00
|
|
|
double prev_colors_[10][3];
|
|
|
|
int prev_color_index_;
|
|
|
|
int bands_;
|
|
|
|
bool psychedelic_enabled_;
|
2009-12-24 20:16:07 +01:00
|
|
|
};
|
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
void interpolate(const Scope&, Scope&);
|
|
|
|
void initSin(Scope&, const uint = 6000);
|
2010-08-28 20:48:16 +02:00
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
} // END namespace Analyzer
|
2009-12-24 20:16:07 +01:00
|
|
|
|
2014-11-29 20:07:01 +01:00
|
|
|
#endif // ANALYZERS_ANALYZERBASE_H_
|