2014-11-29 20:07:01 +01:00
|
|
|
/* This file is part of Clementine.
|
|
|
|
Copyright 2003-2005, Max Howell <max.howell@methylblue.com>
|
|
|
|
Copyright 2005, Mark Kretschmann <markey@web.de>
|
|
|
|
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 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> 2003-2005
|
|
|
|
* Original Author: Mark Kretschmann <markey@web.de> 2005
|
|
|
|
*/
|
2009-12-24 20:16:07 +01:00
|
|
|
|
|
|
|
#include "blockanalyzer.h"
|
|
|
|
|
|
|
|
#include <cmath>
|
|
|
|
|
|
|
|
#include <QMouseEvent>
|
|
|
|
#include <QResizeEvent>
|
|
|
|
#include <cstdlib>
|
2010-03-22 14:49:08 +01:00
|
|
|
#include <QPainter>
|
2009-12-24 20:16:07 +01: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
|
|
|
const uint BlockAnalyzer::kHeight = 2;
|
|
|
|
const uint BlockAnalyzer::kWidth = 4;
|
|
|
|
const uint BlockAnalyzer::kMinRows = 3; // arbituary
|
|
|
|
const uint BlockAnalyzer::kMinColumns = 32; // arbituary
|
|
|
|
const uint BlockAnalyzer::kMaxColumns = 256; // must be 2**n
|
|
|
|
const uint BlockAnalyzer::kFadeSize = 90;
|
2014-02-07 16:34:20 +01:00
|
|
|
|
|
|
|
const char* BlockAnalyzer::kName =
|
|
|
|
QT_TRANSLATE_NOOP("AnalyzerContainer", "Block analyzer");
|
|
|
|
|
|
|
|
BlockAnalyzer::BlockAnalyzer(QWidget* parent)
|
|
|
|
: Analyzer::Base(parent, 9),
|
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
|
|
|
columns_(0),
|
|
|
|
rows_(0),
|
|
|
|
y_(0),
|
|
|
|
barPixmap_(1, 1),
|
|
|
|
topBarPixmap_(kWidth, kHeight),
|
|
|
|
scope_(kMinColumns),
|
|
|
|
store_(1 << 8, 0),
|
|
|
|
fade_bars_(kFadeSize),
|
|
|
|
fade_pos_(1 << 8, 50),
|
|
|
|
fade_intensity_(1 << 8, 32) {
|
|
|
|
setMinimumSize(kMinColumns * (kWidth + 1) - 1, kMinRows * (kHeight + 1) - 1);
|
2014-11-29 20:07:01 +01:00
|
|
|
// -1 is padding, no drawing takes place there
|
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
|
|
|
setMaximumWidth(kMaxColumns * (kWidth + 1) - 1);
|
2009-12-24 20:16:07 +01:00
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
// mxcl says null pixmaps cause crashes, so let's play it safe
|
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
|
|
|
for (uint i = 0; i < kFadeSize; ++i) fade_bars_[i] = QPixmap(1, 1);
|
2009-12-24 20:16:07 +01:00
|
|
|
}
|
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
BlockAnalyzer::~BlockAnalyzer() {}
|
2009-12-24 20:16:07 +01:00
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
void BlockAnalyzer::resizeEvent(QResizeEvent* e) {
|
|
|
|
QWidget::resizeEvent(e);
|
2009-12-24 20:16:07 +01: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
|
|
|
background_ = QPixmap(size());
|
2014-04-27 07:54:42 +02:00
|
|
|
canvas_ = QPixmap(size());
|
2009-12-24 20:16:07 +01: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
|
|
|
const uint oldRows = rows_;
|
2009-12-24 20:16:07 +01:00
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
// all is explained in analyze()..
|
2014-11-29 20:07:01 +01:00
|
|
|
// +1 to counter -1 in maxSizes, trust me we need this!
|
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
|
|
|
columns_ = qMin(
|
|
|
|
static_cast<uint>(static_cast<double>(width() + 1) / (kWidth + 1)) + 1,
|
|
|
|
kMaxColumns);
|
|
|
|
rows_ = static_cast<uint>(static_cast<double>(height() + 1) / (kHeight + 1));
|
2009-12-24 20:16:07 +01:00
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
// this is the y-offset for drawing from the top of the widget
|
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
|
|
|
y_ = (height() - (rows_ * (kHeight + 1)) + 2) / 2;
|
2009-12-24 20:16:07 +01: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
|
|
|
scope_.resize(columns_);
|
2009-12-24 20:16:07 +01: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
|
|
|
if (rows_ != oldRows) {
|
|
|
|
barPixmap_ = QPixmap(kWidth, rows_ * (kHeight + 1));
|
2009-12-24 20:16:07 +01: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
|
|
|
for (uint i = 0; i < kFadeSize; ++i)
|
|
|
|
fade_bars_[i] = QPixmap(kWidth, rows_ * (kHeight + 1));
|
2009-12-24 20:16:07 +01: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
|
|
|
yscale_.resize(rows_ + 1);
|
2009-12-24 20:16:07 +01:00
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
const uint PRE = 1,
|
|
|
|
PRO = 1; // PRE and PRO allow us to restrict the range somewhat
|
2009-12-24 20:16:07 +01: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
|
|
|
for (uint z = 0; z < rows_; ++z)
|
|
|
|
yscale_[z] = 1 - (log10(PRE + z) / log10(PRE + rows_ + PRO));
|
2009-12-24 20:16:07 +01: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
|
|
|
yscale_[rows_] = 0;
|
2009-12-24 20:16:07 +01:00
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
determineStep();
|
|
|
|
paletteChange(palette());
|
|
|
|
}
|
2009-12-24 20:16:07 +01: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
|
|
|
updateBandSize(columns_);
|
2014-02-07 16:34:20 +01:00
|
|
|
drawBackground();
|
2009-12-24 20:16:07 +01:00
|
|
|
}
|
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
void BlockAnalyzer::determineStep() {
|
|
|
|
// falltime is dependent on rowcount due to our digital resolution (ie we have
|
|
|
|
// boxes/blocks of pixels)
|
|
|
|
// I calculated the value 30 based on some trial and error
|
2009-12-24 20:16:07 +01:00
|
|
|
|
2014-05-13 00:15:00 +02:00
|
|
|
// the fall time of 30 is too slow on framerates above 50fps
|
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
|
|
|
const double fallTime = timeout() < 20 ? 20 * rows_ : 30 * rows_;
|
2014-05-13 00:15:00 +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
|
|
|
step_ = static_cast<double>(rows_ * timeout()) / fallTime;
|
2010-08-28 20:48:16 +02:00
|
|
|
}
|
|
|
|
|
2014-05-13 22:43:46 +02:00
|
|
|
void BlockAnalyzer::framerateChanged() { // virtual
|
|
|
|
determineStep();
|
|
|
|
}
|
|
|
|
|
2014-11-29 20:07:01 +01:00
|
|
|
void BlockAnalyzer::transform(Analyzer::Scope& s) {
|
2014-02-07 16:34:20 +01:00
|
|
|
for (uint x = 0; x < s.size(); ++x) s[x] *= 2;
|
2010-08-28 20:48:16 +02:00
|
|
|
|
2017-03-11 18:14:11 +01:00
|
|
|
fht_->spectrum(s.data());
|
|
|
|
fht_->scale(s.data(), 1.0 / 20);
|
2010-08-28 20:48:16 +02:00
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
// the second half is pretty dull, so only show it if the user has a large
|
|
|
|
// analyzer
|
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
|
|
|
// by setting to scope_.size() if large we prevent interpolation of large
|
2014-02-07 16:34:20 +01:00
|
|
|
// analyzers, this is good!
|
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
|
|
|
s.resize(scope_.size() <= kMaxColumns / 2 ? kMaxColumns / 2 : scope_.size());
|
2009-12-24 20:16:07 +01:00
|
|
|
}
|
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
void BlockAnalyzer::analyze(QPainter& p, const Analyzer::Scope& s,
|
|
|
|
bool new_frame) {
|
|
|
|
// y = 2 3 2 1 0 2
|
|
|
|
// . . . . # .
|
|
|
|
// . . . # # .
|
|
|
|
// # . # # # #
|
|
|
|
// # # # # # #
|
|
|
|
//
|
|
|
|
// visual aid for how this analyzer works.
|
|
|
|
// y represents the number of blanks
|
|
|
|
// y starts from the top and increases in units of blocks
|
|
|
|
|
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
|
|
|
// yscale_ looks similar to: { 0.7, 0.5, 0.25, 0.15, 0.1, 0 }
|
2014-02-07 16:34:20 +01:00
|
|
|
// if it contains 6 elements there are 5 rows in the analyzer
|
|
|
|
|
2014-04-27 07:54:42 +02:00
|
|
|
if (!new_frame) {
|
|
|
|
p.drawPixmap(0, 0, canvas_);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
QPainter canvas_painter(&canvas_);
|
|
|
|
|
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
|
|
|
Analyzer::interpolate(s, scope_);
|
|
|
|
|
|
|
|
// update the graphics with the new colour
|
|
|
|
if (psychedelic_enabled_) {
|
|
|
|
paletteChange(QPalette());
|
|
|
|
}
|
2014-02-07 16:34:20 +01:00
|
|
|
|
|
|
|
// Paint the background
|
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
|
|
|
canvas_painter.drawPixmap(0, 0, background_);
|
2014-02-07 16:34:20 +01: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
|
|
|
for (uint y, x = 0; x < scope_.size(); ++x) {
|
2014-02-07 16:34:20 +01:00
|
|
|
// determine y
|
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
|
|
|
for (y = 0; scope_[x] < yscale_[y]; ++y) continue;
|
2014-02-07 16:34:20 +01:00
|
|
|
|
|
|
|
// this is opposite to what you'd think, higher than y
|
|
|
|
// means the bar is lower than y (physically)
|
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
|
|
|
if (static_cast<float>(y) > store_[x])
|
|
|
|
y = static_cast<int>(store_[x] += step_);
|
2014-02-07 16:34:20 +01:00
|
|
|
else
|
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
|
|
|
store_[x] = y;
|
2014-02-07 16:34:20 +01: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
|
|
|
// if y is lower than fade_pos_, then the bar has exceeded the kHeight of
|
2014-02-07 16:34:20 +01:00
|
|
|
// the fadeout
|
|
|
|
// if the fadeout is quite faded now, then display the new one
|
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
|
|
|
if (y <= fade_pos_[x] /*|| fade_intensity_[x] < kFadeSize / 3*/) {
|
|
|
|
fade_pos_[x] = y;
|
|
|
|
fade_intensity_[x] = kFadeSize;
|
2014-02-07 16:34:20 +01:00
|
|
|
}
|
2009-12-24 20:16:07 +01: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
|
|
|
if (fade_intensity_[x] > 0) {
|
|
|
|
const uint offset = --fade_intensity_[x];
|
|
|
|
const uint y = y_ + (fade_pos_[x] * (kHeight + 1));
|
|
|
|
canvas_painter.drawPixmap(x * (kWidth + 1), y, fade_bars_[offset], 0, 0,
|
|
|
|
kWidth, height() - y);
|
2014-02-07 16:34:20 +01:00
|
|
|
}
|
2009-12-24 20:16:07 +01: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
|
|
|
if (fade_intensity_[x] == 0) fade_pos_[x] = rows_;
|
2009-12-24 20:16:07 +01: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
|
|
|
// REMEMBER: y is a number from 0 to rows_, 0 means all blocks are glowing,
|
|
|
|
// rows_ means none are
|
|
|
|
canvas_painter.drawPixmap(x * (kWidth + 1), y * (kHeight + 1) + y_, *bar(),
|
|
|
|
0, y * (kHeight + 1), bar()->width(),
|
2014-04-27 07:54:42 +02:00
|
|
|
bar()->height());
|
2014-02-07 16:34:20 +01:00
|
|
|
}
|
2009-12-24 20:16:07 +01: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
|
|
|
for (uint x = 0; x < store_.size(); ++x)
|
|
|
|
canvas_painter.drawPixmap(x * (kWidth + 1),
|
|
|
|
static_cast<int>(store_[x]) * (kHeight + 1) + y_,
|
|
|
|
topBarPixmap_);
|
2014-04-27 07:54:42 +02:00
|
|
|
|
|
|
|
p.drawPixmap(0, 0, canvas_);
|
2010-08-18 20:21:30 +02:00
|
|
|
}
|
2009-12-24 20:16:07 +01:00
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
static inline void adjustToLimits(int& b, int& f, uint& amount) {
|
|
|
|
// with a range of 0-255 and maximum adjustment of amount,
|
|
|
|
// maximise the difference between f and b
|
|
|
|
|
|
|
|
if (b < f) {
|
|
|
|
if (b > 255 - f) {
|
|
|
|
amount -= f;
|
|
|
|
f = 0;
|
|
|
|
} else {
|
|
|
|
amount -= (255 - f);
|
|
|
|
f = 255;
|
2009-12-24 20:16:07 +01:00
|
|
|
}
|
2014-02-07 16:34:20 +01:00
|
|
|
} else {
|
|
|
|
if (f > 255 - b) {
|
|
|
|
amount -= f;
|
|
|
|
f = 0;
|
|
|
|
} else {
|
|
|
|
amount -= (255 - f);
|
|
|
|
f = 255;
|
2009-12-24 20:16:07 +01:00
|
|
|
}
|
2014-02-07 16:34:20 +01:00
|
|
|
}
|
2009-12-24 20:16:07 +01: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 BlockAnalyzer::psychedelicModeChanged(bool enabled) {
|
|
|
|
psychedelic_enabled_ = enabled;
|
|
|
|
// reset colours back to normal
|
|
|
|
paletteChange(QPalette());
|
|
|
|
}
|
|
|
|
|
2009-12-24 20:16:07 +01:00
|
|
|
/**
|
|
|
|
* Clever contrast function
|
|
|
|
*
|
2014-02-07 16:34:20 +01:00
|
|
|
* It will try to adjust the foreground color such that it contrasts well with
|
|
|
|
*the background
|
2009-12-24 20:16:07 +01:00
|
|
|
* It won't modify the hue of fg unless absolutely necessary
|
|
|
|
* @return the adjusted form of fg
|
|
|
|
*/
|
2014-02-07 16:34:20 +01:00
|
|
|
QColor ensureContrast(const QColor& bg, const QColor& fg, uint _amount = 150) {
|
|
|
|
class OutputOnExit {
|
|
|
|
public:
|
2014-11-29 20:07:01 +01:00
|
|
|
explicit OutputOnExit(const QColor& color) : c(color) {}
|
2014-02-07 16:34:20 +01:00
|
|
|
~OutputOnExit() {
|
|
|
|
int h, s, v;
|
|
|
|
c.getHsv(&h, &s, &v);
|
|
|
|
}
|
2009-12-24 20:16:07 +01:00
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
private:
|
|
|
|
const QColor& c;
|
|
|
|
};
|
2009-12-24 20:16:07 +01:00
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
OutputOnExit allocateOnTheStack(fg);
|
2009-12-24 20:16:07 +01:00
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
int bh, bs, bv;
|
|
|
|
int fh, fs, fv;
|
2009-12-24 20:16:07 +01:00
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
bg.getHsv(&bh, &bs, &bv);
|
|
|
|
fg.getHsv(&fh, &fs, &fv);
|
2009-12-24 20:16:07 +01:00
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
int dv = abs(bv - fv);
|
2009-12-24 20:16:07 +01:00
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
// value is the best measure of contrast
|
|
|
|
// if there is enough difference in value already, return fg unchanged
|
2014-11-29 20:07:01 +01:00
|
|
|
if (dv > static_cast<int>(_amount)) return fg;
|
2009-12-24 20:16:07 +01:00
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
int ds = abs(bs - fs);
|
2009-12-24 20:16:07 +01:00
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
// saturation is good enough too. But not as good. TODO adapt this a little
|
2014-11-29 20:07:01 +01:00
|
|
|
if (ds > static_cast<int>(_amount)) return fg;
|
2009-12-24 20:16:07 +01:00
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
int dh = abs(bh - fh);
|
2009-12-24 20:16:07 +01:00
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
if (dh > 120) {
|
|
|
|
// a third of the colour wheel automatically guarentees contrast
|
|
|
|
// but only if the values are high enough and saturations significant enough
|
|
|
|
// to allow the colours to be visible and not be shades of grey or black
|
2009-12-24 20:16:07 +01:00
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
// check the saturation for the two colours is sufficient that hue alone can
|
|
|
|
// provide sufficient contrast
|
2014-11-29 20:07:01 +01:00
|
|
|
if (ds > static_cast<int>(_amount) / 2 && (bs > 125 && fs > 125))
|
2014-02-07 16:34:20 +01:00
|
|
|
return fg;
|
2014-11-29 20:07:01 +01:00
|
|
|
else if (dv > static_cast<int>(_amount) / 2 && (bv > 125 && fv > 125))
|
2014-02-07 16:34:20 +01:00
|
|
|
return fg;
|
|
|
|
}
|
2009-12-24 20:16:07 +01:00
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
if (fs < 50 && ds < 40) {
|
|
|
|
// low saturation on a low saturation is sad
|
|
|
|
const int tmp = 50 - fs;
|
|
|
|
fs = 50;
|
2014-11-29 20:07:01 +01:00
|
|
|
if (static_cast<int>(_amount) > tmp)
|
2014-02-07 16:34:20 +01:00
|
|
|
_amount -= tmp;
|
|
|
|
else
|
|
|
|
_amount = 0;
|
|
|
|
}
|
2009-12-24 20:16:07 +01:00
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
// test that there is available value to honor our contrast requirement
|
2014-11-29 20:07:01 +01:00
|
|
|
if (255 - dv < static_cast<int>(_amount)) {
|
2014-02-07 16:34:20 +01:00
|
|
|
// we have to modify the value and saturation of fg
|
|
|
|
// adjustToLimits( bv, fv, amount );
|
|
|
|
// see if we need to adjust the saturation
|
2014-11-29 20:07:01 +01:00
|
|
|
if (static_cast<int>(_amount) > 0) adjustToLimits(bs, fs, _amount);
|
2009-12-24 20:16:07 +01:00
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
// see if we need to adjust the hue
|
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
|
|
|
if (static_cast<int>(_amount) > 0)
|
|
|
|
fh += static_cast<int>(_amount); // cycles around;
|
2014-02-07 16:34:20 +01:00
|
|
|
|
|
|
|
return QColor::fromHsv(fh, fs, fv);
|
|
|
|
}
|
2009-12-24 20:16:07 +01:00
|
|
|
|
2014-11-29 20:07:01 +01:00
|
|
|
if (fv > bv && bv > static_cast<int>(_amount))
|
|
|
|
return QColor::fromHsv(fh, fs, bv - static_cast<int>(_amount));
|
2009-12-24 20:16:07 +01:00
|
|
|
|
2014-11-29 20:07:01 +01:00
|
|
|
if (fv < bv && fv > static_cast<int>(_amount))
|
|
|
|
return QColor::fromHsv(fh, fs, fv - static_cast<int>(_amount));
|
2009-12-24 20:16:07 +01:00
|
|
|
|
2014-11-29 20:07:01 +01:00
|
|
|
if (fv > bv && (255 - fv > static_cast<int>(_amount)))
|
|
|
|
return QColor::fromHsv(fh, fs, fv + static_cast<int>(_amount));
|
2009-12-24 20:16:07 +01:00
|
|
|
|
2014-11-29 20:07:01 +01:00
|
|
|
if (fv < bv && (255 - bv > static_cast<int>(_amount)))
|
|
|
|
return QColor::fromHsv(fh, fs, bv + static_cast<int>(_amount));
|
2009-12-24 20:16:07 +01:00
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
return Qt::blue;
|
2009-12-24 20:16:07 +01:00
|
|
|
}
|
|
|
|
|
2014-11-29 20:07:01 +01:00
|
|
|
void BlockAnalyzer::paletteChange(const QPalette&) {
|
2014-02-07 16:34:20 +01:00
|
|
|
const QColor bg = palette().color(QPalette::Background);
|
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
|
|
|
QColor fg;
|
|
|
|
|
|
|
|
if (psychedelic_enabled_) {
|
|
|
|
fg = getPsychedelicColor(scope_, 10, 75);
|
|
|
|
} else {
|
|
|
|
fg = ensureContrast(bg, palette().color(QPalette::Highlight));
|
|
|
|
}
|
2014-02-07 16:34:20 +01: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
|
|
|
topBarPixmap_.fill(fg);
|
2014-02-07 16:34:20 +01: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
|
|
|
const double dr =
|
|
|
|
15 * static_cast<double>(bg.red() - fg.red()) / (rows_ * 16);
|
|
|
|
const double dg =
|
|
|
|
15 * static_cast<double>(bg.green() - fg.green()) / (rows_ * 16);
|
|
|
|
const double db =
|
|
|
|
15 * static_cast<double>(bg.blue() - fg.blue()) / (rows_ * 16);
|
2014-02-07 16:34:20 +01:00
|
|
|
const int r = fg.red(), g = fg.green(), b = fg.blue();
|
|
|
|
|
|
|
|
bar()->fill(bg);
|
|
|
|
|
|
|
|
QPainter p(bar());
|
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
|
|
|
|
|
|
|
for (int y = 0; static_cast<uint>(y) < rows_; ++y)
|
2014-02-07 16:34:20 +01:00
|
|
|
// graduate the fg color
|
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
|
|
|
p.fillRect(
|
|
|
|
0, y * (kHeight + 1), kWidth, kHeight,
|
|
|
|
QColor(r + static_cast<int>(dr * y), g + static_cast<int>(dg * y),
|
|
|
|
b + static_cast<int>(db * y)));
|
2014-02-07 16:34:20 +01:00
|
|
|
|
|
|
|
{
|
|
|
|
const QColor bg = palette().color(QPalette::Background).dark(112);
|
|
|
|
|
|
|
|
// make a complimentary fadebar colour
|
2014-11-29 20:07:01 +01:00
|
|
|
// TODO(John Maguire): dark is not always correct, dumbo!
|
2014-02-07 16:34:20 +01:00
|
|
|
int h, s, v;
|
|
|
|
palette().color(QPalette::Background).dark(150).getHsv(&h, &s, &v);
|
|
|
|
const QColor fg(QColor::fromHsv(h + 120, s, v));
|
|
|
|
|
|
|
|
const double dr = fg.red() - bg.red();
|
|
|
|
const double dg = fg.green() - bg.green();
|
|
|
|
const double db = fg.blue() - bg.blue();
|
|
|
|
const int r = bg.red(), g = bg.green(), b = bg.blue();
|
|
|
|
|
|
|
|
// Precalculate all fade-bar pixmaps
|
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
|
|
|
for (uint y = 0; y < kFadeSize; ++y) {
|
|
|
|
fade_bars_[y].fill(palette().color(QPalette::Background));
|
|
|
|
QPainter f(&fade_bars_[y]);
|
|
|
|
for (int z = 0; static_cast<uint>(z) < rows_; ++z) {
|
|
|
|
const double Y = 1.0 - (log10(kFadeSize - y) / log10(kFadeSize));
|
|
|
|
f.fillRect(
|
|
|
|
0, z * (kHeight + 1), kWidth, kHeight,
|
|
|
|
QColor(r + static_cast<int>(dr * Y), g + static_cast<int>(dg * Y),
|
|
|
|
b + static_cast<int>(db * Y)));
|
2009-12-24 20:16:07 +01:00
|
|
|
}
|
2014-02-07 16:34:20 +01:00
|
|
|
}
|
|
|
|
}
|
2009-12-24 20:16:07 +01:00
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
drawBackground();
|
2009-12-24 20:16:07 +01:00
|
|
|
}
|
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
void BlockAnalyzer::drawBackground() {
|
2017-03-27 13:57:24 +02:00
|
|
|
if (background_.isNull()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
const QColor bg = palette().color(QPalette::Background);
|
|
|
|
const QColor bgdark = bg.dark(112);
|
2009-12-24 20:16:07 +01: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
|
|
|
background_.fill(bg);
|
|
|
|
|
|
|
|
QPainter p(&background_);
|
|
|
|
|
|
|
|
if (p.paintEngine() == 0) {
|
|
|
|
return;
|
|
|
|
}
|
2009-12-24 20:16:07 +01: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
|
|
|
for (int x = 0; (uint)x < columns_; ++x)
|
|
|
|
for (int y = 0; (uint)y < rows_; ++y)
|
|
|
|
p.fillRect(x * (kWidth + 1), y * (kHeight + 1) + y_, kWidth, kHeight,
|
2014-02-07 16:34:20 +01:00
|
|
|
bgdark);
|
2009-12-24 20:16:07 +01:00
|
|
|
}
|