2014-11-29 20:07:01 +01:00
|
|
|
/* This file is part of Clementine.
|
|
|
|
Copyright 2003-2005, Max Howell <max.howell@methylblue.com>
|
|
|
|
Copyright 2009-2010, David Sansome <davidsansome@gmail.com>
|
|
|
|
Copyright 2010, 2014, John Maguire <john.maguire@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 A. Sobiecki <sobkas@gmail.com>
|
2022-08-18 23:23:59 +02:00
|
|
|
Copyright 2022, Andrew Reading <andrew@areading.me>
|
2009-12-24 20:16:07 +01:00
|
|
|
|
2014-11-29 20:07:01 +01:00
|
|
|
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> 2003-2005
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef ANALYZERS_BLOCKANALYZER_H_
|
|
|
|
#define ANALYZERS_BLOCKANALYZER_H_
|
2009-12-24 20:16:07 +01:00
|
|
|
|
2010-08-28 20:48:16 +02:00
|
|
|
#include <qcolor.h>
|
2009-12-24 20:16:07 +01:00
|
|
|
|
2020-09-18 16:15:19 +02:00
|
|
|
#include "analyzerbase.h"
|
|
|
|
|
2009-12-24 20:16:07 +01:00
|
|
|
class QResizeEvent;
|
|
|
|
class QMouseEvent;
|
|
|
|
class QPalette;
|
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
class BlockAnalyzer : public Analyzer::Base {
|
2010-03-20 23:45:54 +01:00
|
|
|
Q_OBJECT
|
2014-11-29 20:07:01 +01:00
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
public:
|
|
|
|
Q_INVOKABLE BlockAnalyzer(QWidget*);
|
|
|
|
~BlockAnalyzer();
|
|
|
|
|
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 uint kHeight;
|
|
|
|
static const uint kWidth;
|
|
|
|
static const uint kMinRows;
|
2022-08-18 23:23:59 +02:00
|
|
|
static const uint kMaxRows;
|
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 uint kMinColumns;
|
|
|
|
static const uint kMaxColumns;
|
|
|
|
static const uint kFadeSize;
|
2022-08-18 23:23:59 +02:00
|
|
|
static const uint kFadeInitial;
|
2014-02-07 16:34:20 +01:00
|
|
|
|
|
|
|
static const char* kName;
|
|
|
|
|
|
|
|
protected:
|
2014-05-13 14:46:22 +02:00
|
|
|
virtual void transform(Analyzer::Scope&);
|
|
|
|
virtual void analyze(QPainter& p, const Analyzer::Scope&, bool new_frame);
|
2014-02-07 16:34:20 +01:00
|
|
|
virtual void resizeEvent(QResizeEvent*);
|
|
|
|
virtual void paletteChange(const QPalette&);
|
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-02-07 16:34:20 +01:00
|
|
|
|
|
|
|
void determineStep();
|
|
|
|
|
|
|
|
private:
|
2022-08-18 23:23:59 +02:00
|
|
|
struct FHTBand {
|
|
|
|
FHTBand()
|
|
|
|
: height(0.f),
|
|
|
|
row(0),
|
|
|
|
fade_row(0),
|
|
|
|
fade_coloridx(kMaxRows),
|
|
|
|
fade_intensity(kFadeInitial) {}
|
|
|
|
|
|
|
|
// Top of the spectral activity bar.
|
|
|
|
float height; // Foreground-Background transition row.
|
|
|
|
uint row; // Integer floor of the height value.
|
|
|
|
|
|
|
|
// Vertical color fade effect (a sort of hysteresis).
|
|
|
|
uint fade_row; // Row in which to begin showing BG gradient.
|
|
|
|
uint fade_coloridx; // Current fade_bars_[] offset.
|
|
|
|
int fade_intensity; // Current intensity frame counter value.
|
|
|
|
};
|
|
|
|
|
|
|
|
inline quint32 colorFromRowAndBand(uint cur_r, const FHTBand& band);
|
|
|
|
|
|
|
|
Analyzer::Scope scope_;
|
|
|
|
|
|
|
|
uint columns_; // Number of columns of blocks.
|
|
|
|
uint rows_; // Number of rows of blocks.
|
|
|
|
uint y_; // y-offset from top of widget.
|
|
|
|
float step_; // Rows to fall per frame (during inactivity).
|
|
|
|
|
|
|
|
QColor fg_color_; // Foreground/Active block color.
|
|
|
|
QColor bg_color_; // Background/Inactive block color.
|
|
|
|
QColor pad_color_; // Color of 'lines' dividing the blocks.
|
|
|
|
QImage canvas_; // Drawable canvas of widget.
|
|
|
|
|
|
|
|
QVector<float> rthresh_; // [rows_+1] Rowwise intensity thresholds.
|
|
|
|
QVector<quint32> bg_grad_; // [rows_+1] Vertical background gradient.
|
|
|
|
QVector<quint32> fade_bars_; // [kFadeSize] Block colors per fade level.
|
|
|
|
QVector<FHTBand> bandinfo_; // [columns_] FHT band info.
|
2009-12-24 20:16:07 +01:00
|
|
|
};
|
|
|
|
|
2022-08-18 23:23:59 +02:00
|
|
|
inline quint32 BlockAnalyzer::colorFromRowAndBand(uint r, const FHTBand& band) {
|
|
|
|
// Calculate the block color given band info and the current row.
|
|
|
|
// Note: 0 <= r <= rows_.
|
|
|
|
if (r == band.row)
|
|
|
|
return fg_color_.rgba();
|
|
|
|
else if (r > band.row)
|
|
|
|
return bg_grad_[r];
|
|
|
|
else if ((band.fade_intensity > 0) && (r >= band.fade_row))
|
|
|
|
return fade_bars_[band.fade_coloridx];
|
|
|
|
else
|
|
|
|
return bg_color_.rgba();
|
|
|
|
}
|
|
|
|
|
2014-11-29 20:07:01 +01:00
|
|
|
#endif // ANALYZERS_BLOCKANALYZER_H_
|