Fix cpplint.py errors, fix copyright notices in src/analyzers, move src/core/fht* to src/analyzers

This commit is contained in:
Krzysztof Sobiecki 2014-11-29 20:07:01 +01:00
parent 64c34f58ae
commit dc669eb603
28 changed files with 688 additions and 482 deletions

View File

@ -78,6 +78,7 @@ set(SOURCES
analyzers/rainbowdashanalyzer.cpp analyzers/rainbowdashanalyzer.cpp
analyzers/sonogram.cpp analyzers/sonogram.cpp
analyzers/turbine.cpp analyzers/turbine.cpp
analyzers/fht.cpp
core/appearance.cpp core/appearance.cpp
core/application.cpp core/application.cpp
@ -88,7 +89,6 @@ set(SOURCES
core/deletefiles.cpp core/deletefiles.cpp
core/filesystemmusicstorage.cpp core/filesystemmusicstorage.cpp
core/filesystemwatcherinterface.cpp core/filesystemwatcherinterface.cpp
core/fht.cpp
core/globalshortcutbackend.cpp core/globalshortcutbackend.cpp
core/globalshortcuts.cpp core/globalshortcuts.cpp
core/gnomeglobalshortcutbackend.cpp core/gnomeglobalshortcutbackend.cpp

View File

@ -1,3 +1,21 @@
/* This file is part of Clementine.
Copyright 2010, 2014, John Maguire <john.maguire@gmail.com>
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/>.
*/
#include "analyzer.h" #include "analyzer.h"
#include "engines/enginebase.h" #include "engines/enginebase.h"

75
src/analyzers/analyzerbase.cpp Executable file → Normal file
View File

@ -1,25 +1,32 @@
/*************************************************************************** /* This file is part of Clementine.
viswidget.cpp - description Copyright 2003, Max Howell <max.howell@methylblue.com>
------------------- Copyright 2009, 2011-2012, David Sansome <me@davidsansome.com>
begin : Die Jan 7 2003 Copyright 2010, 2012, 2014, John Maguire <john.maguire@gmail.com>
copyright : (C) 2003 by Max Howell Copyright 2014, Mark Furneaux <mark@romaco.ca>
email : markey@web.de 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
* This program is free software; you can redistribute it and/or modify * the Free Software Foundation, either version 3 of the License, or
* it under the terms of the GNU General Public License as published by * (at your option) any later version.
* the Free Software Foundation; either version 2 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
*/
#include "analyzerbase.h" #include "analyzerbase.h"
#include <cmath> //interpolate() #include <cmath>
#include <QEvent> //event() #include <QEvent>
#include <QPainter> #include <QPainter>
#include <QPaintEvent> #include <QPaintEvent>
#include <QtDebug> #include <QtDebug>
@ -34,10 +41,10 @@
// widget when you return control to it // widget when you return control to it
// 4. if you want to manipulate the scope, reimplement transform() // 4. if you want to manipulate the scope, reimplement transform()
// 5. for convenience <vector> <qpixmap.h> <qwdiget.h> are pre-included // 5. for convenience <vector> <qpixmap.h> <qwdiget.h> are pre-included
// TODO make an INSTRUCTIONS file // TODO(David Sansome): make an INSTRUCTIONS file
// can't mod scope in analyze you have to use transform // can't mod scope in analyze you have to use transform
// TODO for 2D use setErasePixmap Qt function insetead of m_background // TODO(John Maguire): for 2D use setErasePixmap Qt function insetead of m_background
// make the linker happy only for gcc < 4.0 // make the linker happy only for gcc < 4.0
#if !(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 0)) && \ #if !(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 0)) && \
@ -60,8 +67,7 @@ void Analyzer::Base::hideEvent(QHideEvent*) { m_timer.stop(); }
void Analyzer::Base::showEvent(QShowEvent*) { m_timer.start(timeout(), this); } void Analyzer::Base::showEvent(QShowEvent*) { m_timer.start(timeout(), this); }
void Analyzer::Base::transform(Scope& scope) // virtual void Analyzer::Base::transform(Scope& scope) {
{
// this is a standard transformation that should give // this is a standard transformation that should give
// an FFT scope that has bands for pretty analyzers // an FFT scope that has bands for pretty analyzers
@ -91,9 +97,9 @@ void Analyzer::Base::paintEvent(QPaintEvent* e) {
// convert to mono here - our built in analyzers need mono, but the // convert to mono here - our built in analyzers need mono, but the
// engines provide interleaved pcm // engines provide interleaved pcm
for (uint x = 0; (int)x < m_fht->size(); ++x) { for (uint x = 0; static_cast<int>(x) < m_fht->size(); ++x) {
m_lastScope[x] = m_lastScope[x] =
double(thescope[i] + thescope[i + 1]) / (2 * (1 << 15)); static_cast<double>(thescope[i] + thescope[i + 1]) / (2 * (1 << 15));
i += 2; i += 2;
} }
@ -150,22 +156,21 @@ int Analyzer::Base::resizeForBands(int bands) {
return m_fht->size() / 2; return m_fht->size() / 2;
} }
void Analyzer::Base::demo(QPainter& p) // virtual void Analyzer::Base::demo(QPainter& p) {
{
static int t = 201; // FIXME make static to namespace perhaps static int t = 201; // FIXME make static to namespace perhaps
if (t > 999) t = 1; // 0 = wasted calculations if (t > 999) t = 1; // 0 = wasted calculations
if (t < 201) { if (t < 201) {
Scope s(32); Scope s(32);
const double dt = double(t) / 200; const double dt = static_cast<double>(t) / 200;
for (uint i = 0; i < s.size(); ++i) for (uint i = 0; i < s.size(); ++i)
s[i] = dt * (sin(M_PI + (i * M_PI) / s.size()) + 1.0); s[i] = dt * (sin(M_PI + (i * M_PI) / s.size()) + 1.0);
analyze(p, s, new_frame_); analyze(p, s, new_frame_);
} else } else {
analyze(p, Scope(32, 0), new_frame_); analyze(p, Scope(32, 0), new_frame_);
}
++t; ++t;
} }
@ -173,20 +178,19 @@ void Analyzer::Base::polishEvent() {
init(); // virtual init(); // virtual
} }
void Analyzer::interpolate(const Scope& inVec, Scope& outVec) // static void Analyzer::interpolate(const Scope& inVec, Scope& outVec) {
{
double pos = 0.0; double pos = 0.0;
const double step = (double)inVec.size() / outVec.size(); const double step = static_cast<double>(inVec.size()) / outVec.size();
for (uint i = 0; i < outVec.size(); ++i, pos += step) { for (uint i = 0; i < outVec.size(); ++i, pos += step) {
const double error = pos - std::floor(pos); const double error = pos - std::floor(pos);
const unsigned long offset = (unsigned long)pos; const unsigned int64 offset = static_cast<unsigned int64>(pos);
unsigned long indexLeft = offset + 0; unsigned int64 indexLeft = offset + 0;
if (indexLeft >= inVec.size()) indexLeft = inVec.size() - 1; if (indexLeft >= inVec.size()) indexLeft = inVec.size() - 1;
unsigned long indexRight = offset + 1; unsigned int64 indexRight = offset + 1;
if (indexRight >= inVec.size()) indexRight = inVec.size() - 1; if (indexRight >= inVec.size()) indexRight = inVec.size() - 1;
@ -194,8 +198,7 @@ void Analyzer::interpolate(const Scope& inVec, Scope& outVec) // static
} }
} }
void Analyzer::initSin(Scope& v, const uint size) // static void Analyzer::initSin(Scope& v, const uint size) {
{
double step = (M_PI * 2) / size; double step = (M_PI * 2) / size;
double radian = 0; double radian = 0;

54
src/analyzers/analyzerbase.h Executable file → Normal file
View File

@ -1,27 +1,49 @@
// Maintainer: Max Howell <max.howell@methylblue.com>, (C) 2004 /* This file is part of Clementine.
// Copyright: See COPYING file that comes with this distribution 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>
Copyright 2014, Mark Furneaux <mark@romaco.ca>
Copyright 2014, Krzysztof Sobiecki <sobkas@gmail.com>
#ifndef ANALYZERBASE_H Clementine is free software: you can redistribute it and/or modify
#define ANALYZERBASE_H 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
*/
#ifndef ANALYZERS_ANALYZERBASE_H_
#define ANALYZERS_ANALYZERBASE_H_
#ifdef __FreeBSD__ #ifdef __FreeBSD__
#include <sys/types.h> #include <sys/types.h>
#endif #endif
#include "core/fht.h" //stack allocated and convenience #include "fht.h"
#include "engines/engine_fwd.h" #include "engines/engine_fwd.h"
#include <QPixmap> //stack allocated and convenience #include <QPixmap>
#include <QBasicTimer> //stack allocated #include <QBasicTimer>
#include <QWidget> //baseclass #include <QWidget>
#include <vector> //included for convenience #include <vector>
#include <QGLWidget> //baseclass #include <QGLWidget>
#ifdef Q_WS_MACX #ifdef Q_WS_MACX
#include <OpenGL/gl.h> //included for convenience #include <OpenGL/gl.h>
#include <OpenGL/glu.h> //included for convenience #include <OpenGL/glu.h>
#else #else
#include <GL/gl.h> //included for convenience #include <GL/gl.h>
#include <GL/glu.h> //included for convenience #include <GL/glu.h>
#endif #endif
class QEvent; class QEvent;
@ -53,7 +75,7 @@ class Base : public QWidget {
virtual void framerateChanged() {} virtual void framerateChanged() {}
protected: protected:
Base(QWidget*, uint scopeSize = 7); explicit Base(QWidget*, uint scopeSize = 7);
void hideEvent(QHideEvent*); void hideEvent(QHideEvent*);
void showEvent(QShowEvent*); void showEvent(QShowEvent*);
@ -86,4 +108,4 @@ void initSin(Scope&, const uint = 6000);
} // END namespace Analyzer } // END namespace Analyzer
#endif #endif // ANALYZERS_ANALYZERBASE_H_

View File

@ -1,5 +1,10 @@
/* This file is part of Clementine. /* This file is part of Clementine.
Copyright 2010, David Sansome <me@davidsansome.com> Copyright 2010-2011, David Sansome <davidsansome@gmail.com>
Copyright 2010, 2014, John Maguire <john.maguire@gmail.com>
Copyright 2011-2012, Arnaud Bienner <arnaud.bienner@gmail.com>
Copyright 2013, Vasily Fomin <vasili.fomin@gmail.com>
Copyright 2014, Mark Furneaux <mark@romaco.ca>
Copyright 2014, Krzysztof Sobiecki <sobkas@gmail.com>
Clementine is free software: you can redistribute it and/or modify Clementine is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by

View File

@ -1,5 +1,9 @@
/* This file is part of Clementine. /* This file is part of Clementine.
Copyright 2010, David Sansome <me@davidsansome.com> Copyright 2010, David Sansome <davidsansome@gmail.com>
Copyright 2010, 2014, John Maguire <john.maguire@gmail.com>
Copyright 2011-2012, Arnaud Bienner <arnaud.bienner@gmail.com>
Copyright 2013, Vasily Fomin <vasili.fomin@gmail.com>
Copyright 2014, Krzysztof Sobiecki <sobkas@gmail.com>
Clementine is free software: you can redistribute it and/or modify Clementine is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -15,8 +19,8 @@
along with Clementine. If not, see <http://www.gnu.org/licenses/>. along with Clementine. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef ANALYZERCONTAINER_H #ifndef ANALYZERS_ANALYZERCONTAINER_H_
#define ANALYZERCONTAINER_H #define ANALYZERS_ANALYZERCONTAINER_H_
#include <QWidget> #include <QWidget>
#include <QMenu> #include <QMenu>
@ -29,15 +33,14 @@ class AnalyzerContainer : public QWidget {
Q_OBJECT Q_OBJECT
public: public:
AnalyzerContainer(QWidget* parent); explicit AnalyzerContainer(QWidget* parent);
void SetEngine(EngineBase* engine); void SetEngine(EngineBase* engine);
void SetActions(QAction* visualisation); void SetActions(QAction* visualisation);
static const char* kSettingsGroup; static const char* kSettingsGroup;
static const char* kSettingsFramerate; static const char* kSettingsFramerate;
signals: signals:
void WheelEvent(int delta); void WheelEvent(int delta);
protected: protected:
@ -100,4 +103,4 @@ void AnalyzerContainer::AddAnalyzerType() {
actions_ << action; actions_ << action;
} }
#endif #endif // ANALYZERS_ANALYZERCONTAINER_H_

View File

@ -1,18 +1,31 @@
// /* This file is part of Clementine.
// Copyright 2003, Mark Kretschmann <markey@web.de>
// C++ Implementation: $MODULE$ Copyright 2009-2010, David Sansome <davidsansome@gmail.com>
// Copyright 2014, Alibek Omarov <a1ba.omarov@gmail.com>
// Description: Copyright 2014, Mark Furneaux <mark@romaco.ca>
// Copyright 2014, Krzysztof Sobiecki <sobkas@gmail.com>
// Copyright 2014, John Maguire <john.maguire@gmail.com>
// Author: Mark Kretschmann <markey@web.de>, (C) 2003
// Clementine is free software: you can redistribute it and/or modify
// Copyright: See COPYING file that comes with this distribution 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: Mark Kretschmann <markey@web.de> 2003
*/
#include "baranalyzer.h" #include "baranalyzer.h"
#include <cmath> //log10(), etc. #include <cmath>
#include <QtDebug> #include <QtDebug>
#include <QPainter> #include <QPainter>
@ -27,15 +40,15 @@ BarAnalyzer::BarAnalyzer(QWidget* parent) : Analyzer::Base(parent, 8) {
QColor fg(parent->palette().color(QPalette::Highlight).lighter(150)); QColor fg(parent->palette().color(QPalette::Highlight).lighter(150));
double dr = double(m_bg.red() - fg.red()) / double dr = static_cast<double>(m_bg.red() - fg.red()) /
(NUM_ROOFS - 1); //-1 because we start loop below at 0 (NUM_ROOFS - 1); // -1 because we start loop below at 0
double dg = double(m_bg.green() - fg.green()) / (NUM_ROOFS - 1); double dg = static_cast<double>(m_bg.green() - fg.green()) / (NUM_ROOFS - 1);
double db = double(m_bg.blue() - fg.blue()) / (NUM_ROOFS - 1); double db = static_cast<double>(m_bg.blue() - fg.blue()) / (NUM_ROOFS - 1);
for (uint i = 0; i < NUM_ROOFS; ++i) { for (uint i = 0; i < NUM_ROOFS; ++i) {
m_pixRoof[i] = QPixmap(COLUMN_WIDTH, 1); m_pixRoof[i] = QPixmap(COLUMN_WIDTH, 1);
m_pixRoof[i].fill(QColor(fg.red() + int(dr * i), fg.green() + int(dg * i), m_pixRoof[i].fill(QColor(fg.red() + static_cast<int>(dr * i), fg.green() + static_cast<int>(dg * i),
fg.blue() + int(db * i))); fg.blue() + static_cast<int>(db * i)));
} }
} }
@ -45,11 +58,11 @@ void BarAnalyzer::resizeEvent(QResizeEvent* e) { init(); }
void BarAnalyzer::init() { void BarAnalyzer::init() {
const double MAX_AMPLITUDE = 1.0; const double MAX_AMPLITUDE = 1.0;
const double F = double(height() - 2) / (log10(255) * MAX_AMPLITUDE); const double F = static_cast<double>(height() - 2) / (log10(255) * MAX_AMPLITUDE);
BAND_COUNT = width() / 5; BAND_COUNT = width() / 5;
MAX_DOWN = int(0 - (qMax(1, height() / 50))); MAX_DOWN = static_cast<int>(0 - (qMax(1, height() / 50)));
MAX_UP = int(qMax(1, height() / 25)); MAX_UP = static_cast<int>(qMax(1, height() / 25));
barVector.resize(BAND_COUNT, 0); barVector.resize(BAND_COUNT, 0);
roofVector.resize(BAND_COUNT, height() - 5); roofVector.resize(BAND_COUNT, height() - 5);
@ -60,7 +73,7 @@ void BarAnalyzer::init() {
// generate a list of values that express amplitudes in range 0-MAX_AMP as // generate a list of values that express amplitudes in range 0-MAX_AMP as
// ints from 0-height() on log scale // ints from 0-height() on log scale
for (uint x = 0; x < 256; ++x) { for (uint x = 0; x < 256; ++x) {
m_lvlMapper[x] = uint(F * log10(x + 1)); m_lvlMapper[x] = static_cast<uint>(F * log10(x + 1));
} }
m_pixBarGradient = QPixmap(height() * COLUMN_WIDTH, height()); m_pixBarGradient = QPixmap(height() * COLUMN_WIDTH, height());
@ -74,11 +87,11 @@ void BarAnalyzer::init() {
for (int x = 0, r = rgb.red(), g = rgb.green(), b = rgb.blue(), r2 = 255 - r; x < height(); for (int x = 0, r = rgb.red(), g = rgb.green(), b = rgb.blue(), r2 = 255 - r; x < height();
++x) { ++x) {
for (int y = x; y > 0; --y) { for (int y = x; y > 0; --y) {
const double fraction = (double)y / height(); const double fraction = static_cast<double>y / height();
// p.setPen( QColor( r + (int)(r2 * fraction), g, b - (int)(255 * // p.setPen( QColor( r + (int)(r2 * fraction), g, b - (int)(255 *
// fraction) ) ); // fraction) ) );
p.setPen(QColor(r + (int)(r2 * fraction), g, b)); p.setPen(QColor(r + static_cast<int>(r2 * fraction), g, b));
p.drawLine(x * COLUMN_WIDTH, height() - y, (x + 1) * COLUMN_WIDTH, p.drawLine(x * COLUMN_WIDTH, height() - y, (x + 1) * COLUMN_WIDTH,
height() - y); height() - y);
} }
@ -102,8 +115,8 @@ void BarAnalyzer::analyze(QPainter& p, const Scope& s, bool new_frame) {
for (uint i = 0, x = 0, y2; i < v.size(); ++i, x += COLUMN_WIDTH + 1) { for (uint i = 0, x = 0, y2; i < v.size(); ++i, x += COLUMN_WIDTH + 1) {
// assign pre[log10]'d value // assign pre[log10]'d value
y2 = uint(v[i] * y2 = static_cast<uint>(v[i] *
256); // 256 will be optimised to a bitshift //no, it's a float 256); // 256 will be optimised to a bitshift //no, it's a float
y2 = m_lvlMapper[(y2 > 255) ? 255 : y2]; // lvlMapper is array of ints with y2 = m_lvlMapper[(y2 > 255) ? 255 : y2]; // lvlMapper is array of ints with
// values 0 to height() // values 0 to height()
@ -124,8 +137,8 @@ void BarAnalyzer::analyze(QPainter& p, const Scope& s, bool new_frame) {
MAX_DOWN) MAX_DOWN)
y2 = barVector[i] + MAX_DOWN; y2 = barVector[i] + MAX_DOWN;
if ((int)y2 > roofVector[i]) { if (static_cast<int>y2 > roofVector[i]) {
roofVector[i] = (int)y2; roofVector[i] = static_cast<int>y2;
roofVelocityVector[i] = 1; roofVelocityVector[i] = 1;
} }
@ -162,8 +175,9 @@ void BarAnalyzer::analyze(QPainter& p, const Scope& s, bool new_frame) {
if (roofVector[i] < 0) { if (roofVector[i] < 0) {
roofVector[i] = 0; // not strictly necessary roofVector[i] = 0; // not strictly necessary
roofVelocityVector[i] = 0; roofVelocityVector[i] = 0;
} else } else {
++roofVelocityVector[i]; ++roofVelocityVector[i];
}
} }
} }

View File

@ -1,10 +1,31 @@
// Maintainer: Max Howell <max.howell@methylblue.com> /* This file is part of Clementine.
// Authors: Mark Kretschmann & Max Howell (C) 2003-4 Copyright 2003-2005, Max Howell <max.howell@methylblue.com>
// Copyright: See COPYING file that comes with this distribution Copyright 2005, Mark Kretschmann <markey@web.de>
// Copyright 2009-2010, David Sansome <davidsansome@gmail.com>
Copyright 2014, Mark Furneaux <mark@romaco.ca>
Copyright 2014, Krzysztof A. Sobiecki <sobkas@gmail.com>
Copyright 2014, John Maguire <john.maguire@gmail.com>
#ifndef BARANALYZER_H Clementine is free software: you can redistribute it and/or modify
#define BARANALYZER_H 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
*/
#ifndef ANALYZERS_BARANALYZER_H_
#define ANALYZERS_BARANALYZER_H_
#include "analyzerbase.h" #include "analyzerbase.h"
@ -12,6 +33,7 @@ typedef std::vector<uint> aroofMemVec;
class BarAnalyzer : public Analyzer::Base { class BarAnalyzer : public Analyzer::Base {
Q_OBJECT Q_OBJECT
public: public:
Q_INVOKABLE BarAnalyzer(QWidget*); Q_INVOKABLE BarAnalyzer(QWidget*);
@ -57,4 +79,4 @@ class BarAnalyzer : public Analyzer::Base {
QColor m_bg; QColor m_bg;
}; };
#endif #endif // ANALYZERS_BARANALYZER_H_

View File

@ -1,7 +1,28 @@
// Author: Max Howell <max.howell@methylblue.com>, (C) 2003-5 /* This file is part of Clementine.
// Mark Kretschmann <markey@web.de>, (C) 2005 Copyright 2003-2005, Max Howell <max.howell@methylblue.com>
// Copyright: See COPYING file that comes with this distribution Copyright 2005, Mark Kretschmann <markey@web.de>
// Copyright 2009-2010, David Sansome <davidsansome@gmail.com>
Copyright 2010, 2014, John Maguire <john.maguire@gmail.com>
Copyright 2014, Mark Furneaux <mark@romaco.ca>
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
*/
#include "blockanalyzer.h" #include "blockanalyzer.h"
@ -24,28 +45,19 @@ const char* BlockAnalyzer::kName =
BlockAnalyzer::BlockAnalyzer(QWidget* parent) BlockAnalyzer::BlockAnalyzer(QWidget* parent)
: Analyzer::Base(parent, 9), : Analyzer::Base(parent, 9),
m_columns(0) // uint m_columns(0),
, m_rows(0),
m_rows(0) // uint m_y(0),
, m_barPixmap(1, 1),
m_y(0) // uint
,
m_barPixmap(1, 1) // null qpixmaps cause crashes
,
m_topBarPixmap(WIDTH, HEIGHT), m_topBarPixmap(WIDTH, HEIGHT),
m_scope(MIN_COLUMNS) // Scope m_scope(MIN_COLUMNS),
, m_store(1 << 8, 0),
m_store(1 << 8, 0) // vector<uint> m_fade_bars(FADE_SIZE),
, m_fade_pos(1 << 8, 50),
m_fade_bars(FADE_SIZE) // vector<QPixmap> m_fade_intensity(1 << 8, 32) {
,
m_fade_pos(1 << 8, 50) // vector<uint>
,
m_fade_intensity(1 << 8, 32) // vector<uint>
{
setMinimumSize(MIN_COLUMNS * (WIDTH + 1) - 1, setMinimumSize(MIN_COLUMNS * (WIDTH + 1) - 1,
MIN_ROWS * (HEIGHT + 1) - MIN_ROWS * (HEIGHT + 1) - 1);
1); //-1 is padding, no drawing takes place there // -1 is padding, no drawing takes place there
setMaximumWidth(MAX_COLUMNS * (WIDTH + 1) - 1); setMaximumWidth(MAX_COLUMNS * (WIDTH + 1) - 1);
// mxcl says null pixmaps cause crashes, so let's play it safe // mxcl says null pixmaps cause crashes, so let's play it safe
@ -63,9 +75,9 @@ void BlockAnalyzer::resizeEvent(QResizeEvent* e) {
const uint oldRows = m_rows; const uint oldRows = m_rows;
// all is explained in analyze().. // all is explained in analyze()..
//+1 to counter -1 in maxSizes, trust me we need this! // +1 to counter -1 in maxSizes, trust me we need this!
m_columns = qMax(uint(double(width() + 1) / (WIDTH + 1)), MAX_COLUMNS); m_columns = qMax(static_cast<uint>(static_cast<double>(width() + 1) / (WIDTH + 1)), MAX_COLUMNS);
m_rows = uint(double(height() + 1) / (HEIGHT + 1)); m_rows = static_cast<uint>(static_cast<double>(height() + 1) / (HEIGHT + 1));
// this is the y-offset for drawing from the top of the widget // this is the y-offset for drawing from the top of the widget
m_y = (height() - (m_rows * (HEIGHT + 1)) + 2) / 2; m_y = (height() - (m_rows * (HEIGHT + 1)) + 2) / 2;
@ -103,15 +115,14 @@ void BlockAnalyzer::determineStep() {
// the fall time of 30 is too slow on framerates above 50fps // the fall time of 30 is too slow on framerates above 50fps
const double fallTime = timeout() < 20 ? 20 * m_rows : 30 * m_rows; const double fallTime = timeout() < 20 ? 20 * m_rows : 30 * m_rows;
m_step = double(m_rows * timeout()) / fallTime; m_step = static_cast<double>(m_rows * timeout()) / fallTime;
} }
void BlockAnalyzer::framerateChanged() { // virtual void BlockAnalyzer::framerateChanged() { // virtual
determineStep(); determineStep();
} }
void BlockAnalyzer::transform(Analyzer::Scope& s) // pure virtual void BlockAnalyzer::transform(Analyzer::Scope& s) {
{
for (uint x = 0; x < s.size(); ++x) s[x] *= 2; for (uint x = 0; x < s.size(); ++x) s[x] *= 2;
float* front = static_cast<float*>(&s.front()); float* front = static_cast<float*>(&s.front());
@ -157,12 +168,12 @@ void BlockAnalyzer::analyze(QPainter& p, const Analyzer::Scope& s,
for (uint y, x = 0; x < m_scope.size(); ++x) { for (uint y, x = 0; x < m_scope.size(); ++x) {
// determine y // determine y
for (y = 0; m_scope[x] < m_yscale[y]; ++y) for (y = 0; m_scope[x] < m_yscale[y]; ++y)
; continue;
// this is opposite to what you'd think, higher than y // this is opposite to what you'd think, higher than y
// means the bar is lower than y (physically) // means the bar is lower than y (physically)
if ((float)y > m_store[x]) if (static_cast<float>y > m_store[x])
y = int(m_store[x] += m_step); y = static_cast<int>(m_store[x] += m_step);
else else
m_store[x] = y; m_store[x] = y;
@ -191,8 +202,9 @@ void BlockAnalyzer::analyze(QPainter& p, const Analyzer::Scope& s,
} }
for (uint x = 0; x < m_store.size(); ++x) for (uint x = 0; x < m_store.size(); ++x)
canvas_painter.drawPixmap( canvas_painter.drawPixmap(x * (WIDTH + 1),
x * (WIDTH + 1), int(m_store[x]) * (HEIGHT + 1) + m_y, m_topBarPixmap); static_cast<int>(m_store[x]) * (HEIGHT + 1) + m_y,
m_topBarPixmap);
p.drawPixmap(0, 0, canvas_); p.drawPixmap(0, 0, canvas_);
} }
@ -231,7 +243,7 @@ static inline void adjustToLimits(int& b, int& f, uint& amount) {
QColor ensureContrast(const QColor& bg, const QColor& fg, uint _amount = 150) { QColor ensureContrast(const QColor& bg, const QColor& fg, uint _amount = 150) {
class OutputOnExit { class OutputOnExit {
public: public:
OutputOnExit(const QColor& color) : c(color) {} explicit OutputOnExit(const QColor& color) : c(color) {}
~OutputOnExit() { ~OutputOnExit() {
int h, s, v; int h, s, v;
c.getHsv(&h, &s, &v); c.getHsv(&h, &s, &v);
@ -241,14 +253,6 @@ QColor ensureContrast(const QColor& bg, const QColor& fg, uint _amount = 150) {
const QColor& c; const QColor& c;
}; };
// hack so I don't have to cast everywhere
#define amount static_cast<int>(_amount)
// #define STAMP debug() << (QValueList<int>() << fh << fs << fv) << endl;
// #define STAMP1( string ) debug() << string << ": " <<
// (QValueList<int>() << fh << fs << fv) << endl;
// #define STAMP2( string, value ) debug() << string << "=" << value << ":
// " << (QValueList<int>() << fh << fs << fv) << endl;
OutputOnExit allocateOnTheStack(fg); OutputOnExit allocateOnTheStack(fg);
int bh, bs, bv; int bh, bs, bv;
@ -259,23 +263,17 @@ QColor ensureContrast(const QColor& bg, const QColor& fg, uint _amount = 150) {
int dv = abs(bv - fv); int dv = abs(bv - fv);
// STAMP2( "DV", dv );
// value is the best measure of contrast // value is the best measure of contrast
// if there is enough difference in value already, return fg unchanged // if there is enough difference in value already, return fg unchanged
if (dv > amount) return fg; if (dv > static_cast<int>(_amount)) return fg;
int ds = abs(bs - fs); int ds = abs(bs - fs);
// STAMP2( "DS", ds );
// saturation is good enough too. But not as good. TODO adapt this a little // saturation is good enough too. But not as good. TODO adapt this a little
if (ds > amount) return fg; if (ds > static_cast<int>(_amount)) return fg;
int dh = abs(bh - fh); int dh = abs(bh - fh);
// STAMP2( "DH", dh );
if (dh > 120) { if (dh > 120) {
// a third of the colour wheel automatically guarentees contrast // a third of the colour wheel automatically guarentees contrast
// but only if the values are high enough and saturations significant enough // but only if the values are high enough and saturations significant enough
@ -283,105 +281,75 @@ QColor ensureContrast(const QColor& bg, const QColor& fg, uint _amount = 150) {
// check the saturation for the two colours is sufficient that hue alone can // check the saturation for the two colours is sufficient that hue alone can
// provide sufficient contrast // provide sufficient contrast
if (ds > amount / 2 && (bs > 125 && fs > 125)) if (ds > static_cast<int>(_amount) / 2 && (bs > 125 && fs > 125))
// STAMP1( "Sufficient saturation difference, and hues are
// compliemtary" );
return fg; return fg;
else if (dv > amount / 2 && (bv > 125 && fv > 125)) else if (dv > static_cast<int>(_amount) / 2 && (bv > 125 && fv > 125))
// STAMP1( "Sufficient value difference, and hues are
// compliemtary" );
return fg; return fg;
// STAMP1( "Hues are complimentary but we must modify the value or
// saturation of the contrasting colour" );
// but either the colours are two desaturated, or too dark
// so we need to adjust the system, although not as much
///_amount /= 2;
} }
if (fs < 50 && ds < 40) { if (fs < 50 && ds < 40) {
// low saturation on a low saturation is sad // low saturation on a low saturation is sad
const int tmp = 50 - fs; const int tmp = 50 - fs;
fs = 50; fs = 50;
if (amount > tmp) if (static_cast<int>(_amount) > tmp)
_amount -= tmp; _amount -= tmp;
else else
_amount = 0; _amount = 0;
} }
// test that there is available value to honor our contrast requirement // test that there is available value to honor our contrast requirement
if (255 - dv < amount) { if (255 - dv < static_cast<int>(_amount)) {
// we have to modify the value and saturation of fg // we have to modify the value and saturation of fg
// adjustToLimits( bv, fv, amount ); // adjustToLimits( bv, fv, amount );
// STAMP
// see if we need to adjust the saturation // see if we need to adjust the saturation
if (amount > 0) adjustToLimits(bs, fs, _amount); if (static_cast<int>(_amount) > 0) adjustToLimits(bs, fs, _amount);
// STAMP
// see if we need to adjust the hue // see if we need to adjust the hue
if (amount > 0) fh += amount; // cycles around; if (static_cast<int>(_amount) > 0) fh += static_cast<int>(_amount); // cycles around;
// STAMP
return QColor::fromHsv(fh, fs, fv); return QColor::fromHsv(fh, fs, fv);
} }
// STAMP if (fv > bv && bv > static_cast<int>(_amount))
return QColor::fromHsv(fh, fs, bv - static_cast<int>(_amount));
if (fv > bv && bv > amount) return QColor::fromHsv(fh, fs, bv - amount); if (fv < bv && fv > static_cast<int>(_amount))
return QColor::fromHsv(fh, fs, fv - static_cast<int>(_amount));
// STAMP if (fv > bv && (255 - fv > static_cast<int>(_amount)))
return QColor::fromHsv(fh, fs, fv + static_cast<int>(_amount));
if (fv < bv && fv > amount) return QColor::fromHsv(fh, fs, fv - amount); if (fv < bv && (255 - bv > static_cast<int>(_amount)))
return QColor::fromHsv(fh, fs, bv + static_cast<int>(_amount));
// STAMP
if (fv > bv && (255 - fv > amount))
return QColor::fromHsv(fh, fs, fv + amount);
// STAMP
if (fv < bv && (255 - bv > amount))
return QColor::fromHsv(fh, fs, bv + amount);
// STAMP
// debug() << "Something went wrong!\n";
return Qt::blue; return Qt::blue;
#undef amount
// #undef STAMP
} }
void BlockAnalyzer::paletteChange(const QPalette&) // virtual void BlockAnalyzer::paletteChange(const QPalette&) {
{
const QColor bg = palette().color(QPalette::Background); const QColor bg = palette().color(QPalette::Background);
const QColor fg = ensureContrast(bg, palette().color(QPalette::Highlight)); const QColor fg = ensureContrast(bg, palette().color(QPalette::Highlight));
m_topBarPixmap.fill(fg); m_topBarPixmap.fill(fg);
const double dr = 15 * double(bg.red() - fg.red()) / (m_rows * 16); const double dr = 15 * static_cast<double>(bg.red() - fg.red()) / (m_rows * 16);
const double dg = 15 * double(bg.green() - fg.green()) / (m_rows * 16); const double dg = 15 * static_cast<double>(bg.green() - fg.green()) / (m_rows * 16);
const double db = 15 * double(bg.blue() - fg.blue()) / (m_rows * 16); const double db = 15 * static_cast<double>(bg.blue() - fg.blue()) / (m_rows * 16);
const int r = fg.red(), g = fg.green(), b = fg.blue(); const int r = fg.red(), g = fg.green(), b = fg.blue();
bar()->fill(bg); bar()->fill(bg);
QPainter p(bar()); QPainter p(bar());
for (int y = 0; (uint)y < m_rows; ++y) for (int y = 0; static_cast<uint>y < m_rows; ++y)
// graduate the fg color // graduate the fg color
p.fillRect(0, y * (HEIGHT + 1), WIDTH, HEIGHT, p.fillRect(0, y * (HEIGHT + 1), WIDTH, HEIGHT,
QColor(r + int(dr * y), g + int(dg * y), b + int(db * y))); QColor(r + static_cast<int>(dr * y), g + static_cast<int>(dg * y),
b + static_cast<int>(db * y)));
{ {
const QColor bg = palette().color(QPalette::Background).dark(112); const QColor bg = palette().color(QPalette::Background).dark(112);
// make a complimentary fadebar colour // make a complimentary fadebar colour
// TODO dark is not always correct, dumbo! // TODO(John Maguire): dark is not always correct, dumbo!
int h, s, v; int h, s, v;
palette().color(QPalette::Background).dark(150).getHsv(&h, &s, &v); palette().color(QPalette::Background).dark(150).getHsv(&h, &s, &v);
const QColor fg(QColor::fromHsv(h + 120, s, v)); const QColor fg(QColor::fromHsv(h + 120, s, v));
@ -395,10 +363,10 @@ void BlockAnalyzer::paletteChange(const QPalette&) // virtual
for (uint y = 0; y < FADE_SIZE; ++y) { for (uint y = 0; y < FADE_SIZE; ++y) {
m_fade_bars[y].fill(palette().color(QPalette::Background)); m_fade_bars[y].fill(palette().color(QPalette::Background));
QPainter f(&m_fade_bars[y]); QPainter f(&m_fade_bars[y]);
for (int z = 0; (uint)z < m_rows; ++z) { for (int z = 0; static_cast<uint>z < m_rows; ++z) {
const double Y = 1.0 - (log10(FADE_SIZE - y) / log10(FADE_SIZE)); const double Y = 1.0 - (log10(FADE_SIZE - y) / log10(FADE_SIZE));
f.fillRect(0, z * (HEIGHT + 1), WIDTH, HEIGHT, f.fillRect(0, z * (HEIGHT + 1), WIDTH, HEIGHT,
QColor(r + int(dr * Y), g + int(dg * Y), b + int(db * Y))); QColor(r + static_cast<int>(dr * Y), g + static_cast<int>(dg * Y), b + static_cast<int>(db * Y)));
} }
} }
} }

View File

@ -1,9 +1,29 @@
// Maintainer: Max Howell <mac.howell@methylblue.com>, (C) 2003-5 /* This file is part of Clementine.
// Copyright: See COPYING file that comes with this distribution 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>
Copyright 2014, Mark Furneaux <mark@romaco.ca>
Copyright 2014, Krzysztof A. Sobiecki <sobkas@gmail.com>
#ifndef BLOCKANALYZER_H Clementine is free software: you can redistribute it and/or modify
#define BLOCKANALYZER_H 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_
#include "analyzerbase.h" #include "analyzerbase.h"
#include <qcolor.h> #include <qcolor.h>
@ -12,12 +32,9 @@ class QResizeEvent;
class QMouseEvent; class QMouseEvent;
class QPalette; class QPalette;
/**
* @author Max Howell
*/
class BlockAnalyzer : public Analyzer::Base { class BlockAnalyzer : public Analyzer::Base {
Q_OBJECT Q_OBJECT
public: public:
Q_INVOKABLE BlockAnalyzer(QWidget*); Q_INVOKABLE BlockAnalyzer(QWidget*);
~BlockAnalyzer(); ~BlockAnalyzer();
@ -62,4 +79,4 @@ class BlockAnalyzer : public Analyzer::Base {
float m_step; // rows to fall per frame float m_step; // rows to fall per frame
}; };
#endif #endif // ANALYZERS_BLOCKANALYZER_H_

View File

@ -1,5 +1,26 @@
// Author: Max Howell <max.howell@methylblue.com>, (C) 2004 /* This file is part of Clementine.
// Copyright: See COPYING file that comes with this distribution 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 2014, Mark Furneaux <mark@romaco.ca>
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
*/
#include "boomanalyzer.h" #include "boomanalyzer.h"
#include <cmath> #include <cmath>
@ -23,11 +44,11 @@ BoomAnalyzer::BoomAnalyzer(QWidget* parent)
barPixmap(COLUMN_WIDTH, 50) {} barPixmap(COLUMN_WIDTH, 50) {}
void BoomAnalyzer::changeK_barHeight(int newValue) { void BoomAnalyzer::changeK_barHeight(int newValue) {
K_barHeight = (double)newValue / 1000; K_barHeight = static_cast<double>newValue / 1000;
} }
void BoomAnalyzer::changeF_peakSpeed(int newValue) { void BoomAnalyzer::changeF_peakSpeed(int newValue) {
F_peakSpeed = (double)newValue / 1000; F_peakSpeed = static_cast<double>newValue / 1000;
} }
void BoomAnalyzer::resizeEvent(QResizeEvent*) { init(); } void BoomAnalyzer::resizeEvent(QResizeEvent*) { init(); }
@ -36,7 +57,7 @@ void BoomAnalyzer::init() {
const uint HEIGHT = height() - 2; const uint HEIGHT = height() - 2;
const double h = 1.2 / HEIGHT; const double h = 1.2 / HEIGHT;
F = double(HEIGHT) / (log10(256) * 1.1 /*<- max. amplitude*/); F = static_cast<double>(HEIGHT) / (log10(256) * 1.1 /*<- max. amplitude*/);
barPixmap = QPixmap(COLUMN_WIDTH - 2, HEIGHT); barPixmap = QPixmap(COLUMN_WIDTH - 2, HEIGHT);
canvas_ = QPixmap(size()); canvas_ = QPixmap(size());
@ -44,11 +65,11 @@ void BoomAnalyzer::init() {
QPainter p(&barPixmap); QPainter p(&barPixmap);
for (uint y = 0; y < HEIGHT; ++y) { for (uint y = 0; y < HEIGHT; ++y) {
const double F = (double)y * h; const double F = static_cast<double>y * h;
p.setPen(QColor(qMax(0, 255 - int(229.0 * F)), p.setPen(QColor(qMax(0, 255 - static_cast<int>(229.0 * F)),
qMax(0, 255 - int(229.0 * F)), qMax(0, 255 - static_cast<int>(229.0 * F)),
qMax(0, 255 - int(191.0 * F)))); qMax(0, 255 - static_cast<int>(191.0 * F))));
p.drawLine(0, y, COLUMN_WIDTH - 2, y); p.drawLine(0, y, COLUMN_WIDTH - 2, y);
} }
} }
@ -94,8 +115,9 @@ void BoomAnalyzer::analyze(QPainter& p, const Scope& scope, bool new_frame) {
if (h > peak_height[i]) { if (h > peak_height[i]) {
peak_height[i] = h; peak_height[i] = h;
peak_speed[i] = 0.01; peak_speed[i] = 0.01;
} else } else {
goto peak_handling; goto peak_handling;
}
} else { } else {
if (bar_height[i] > 0.0) { if (bar_height[i] > 0.0) {
bar_height[i] -= K_barHeight; // 1.4 bar_height[i] -= K_barHeight; // 1.4

View File

@ -1,9 +1,29 @@
// Author: Max Howell <max.howell@methylblue.com>, (C) 2004 /* This file is part of Clementine.
// Copyright: See COPYING file that comes with this distribution Copyright 2004, Max Howell <max.howell@methylblue.com>
// Copyright 2009-2010, David Sansome <davidsansome@gmail.com>
Copyright 2014, Mark Furneaux <mark@romaco.ca>
Copyright 2014, Krzysztof Sobiecki <sobkas@gmail.com>
Copyright 2014, John Maguire <john.maguire@gmail.com>
#ifndef BOOMANALYZER_H Clementine is free software: you can redistribute it and/or modify
#define BOOMANALYZER_H 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
*/
#ifndef ANALYZERS_BOOMANALYZER_H_
#define ANALYZERS_BOOMANALYZER_H_
#include "analyzerbase.h" #include "analyzerbase.h"
@ -13,6 +33,7 @@
class BoomAnalyzer : public Analyzer::Base { class BoomAnalyzer : public Analyzer::Base {
Q_OBJECT Q_OBJECT
public: public:
Q_INVOKABLE BoomAnalyzer(QWidget*); Q_INVOKABLE BoomAnalyzer(QWidget*);
@ -42,4 +63,4 @@ class BoomAnalyzer : public Analyzer::Base {
QPixmap canvas_; QPixmap canvas_;
}; };
#endif #endif // ANALYZERS_BOOMANALYZER_H_

View File

@ -1,22 +1,24 @@
// FHT - Fast Hartley Transform Class /* This file is part of Clementine.
// Copyright 2004, Melchior FRANZ <mfranz@kde.org>
// Copyright (C) 2004 Melchior FRANZ - mfranz@kde.org Copyright 2010, 2014, John Maguire <john.maguire@gmail.com>
// Copyright 2014, Krzysztof Sobiecki <sobkas@gmail.com>
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as Clementine is free software: you can redistribute it and/or modify
// published by the Free Software Foundation; either version 2 of the it under the terms of the GNU General Public License as published by
// License, or (at your option) any later version. the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of Clementine is distributed in the hope that it will be useful,
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU but WITHOUT ANY WARRANTY; without even the implied warranty of
// General Public License for more details. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software You should have received a copy of the GNU General Public License
// Foundation, 51 Franklin Steet, Fifth Floor, Boston, MA 02110-1301, USA along with Clementine. If not, see <http://www.gnu.org/licenses/>.
// */
// $Id$
/* Original Author: Melchior FRANZ <mfranz@kde.org> 2004
*/
#include <math.h> #include <math.h>
#include <string.h> #include <string.h>

View File

@ -1,25 +1,27 @@
// FHT - Fast Hartley Transform Class /* This file is part of Clementine.
// Copyright 2004, Melchior FRANZ <mfranz@kde.org>
// Copyright (C) 2004 Melchior FRANZ - mfranz@kde.org Copyright 2010, 2014, John Maguire <john.maguire@gmail.com>
// Copyright 2014, Krzysztof Sobiecki <sobkas@gmail.com>
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; either version 2 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, 51 Franklin Steet, Fifth Floor, Boston, MA 02110-1301, USA
//
// $Id$
#ifndef CORE_FHT_H_ Clementine is free software: you can redistribute it and/or modify
#define CORE_FHT_H_ 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: Melchior FRANZ <mfranz@kde.org> 2004
*/
#ifndef ANALYZERS_FHT_H_
#define ANALYZERS_FHT_H_
/** /**
* Implementation of the Hartley Transform after Bracewell's discrete * Implementation of the Hartley Transform after Bracewell's discrete
@ -115,4 +117,4 @@ class FHT {
void transform(float*); void transform(float*);
}; };
#endif // CORE_FHT_H_ #endif // ANALYZERS_FHT_H_

View File

@ -1,19 +1,25 @@
/*************************************************************************** /* This file is part of Clementine.
gloscope.cpp - description Copyright 2004, Adam Pigg <adam@piggz.co.uk>
------------------- Copyright 2009, David Sansome <davidsansome@gmail.com>
begin : Jan 17 2004 Copyright 2014, Krzysztof Sobiecki <sobkas@gmail.com>
copyright : (C) 2004 by Adam Pigg Copyright 2014, John Maguire <john.maguire@gmail.com>
email : adam@piggz.co.uk
***************************************************************************/
/*************************************************************************** Clementine is free software: you can redistribute it and/or modify
* * it under the terms of the GNU General Public License as published by
* This program is free software; you can redistribute it and/or modify * the Free Software Foundation, either version 3 of the License, or
* it under the terms of the GNU General Public License as published by * (at your option) any later version.
* the Free Software Foundation; either version 2 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: Adam Pigg <adam@piggz.co.uk> 2004
*/
#include <config.h> #include <config.h>
@ -28,8 +34,6 @@ GLAnalyzer::GLAnalyzer(QWidget* parent)
GLAnalyzer::~GLAnalyzer() {} GLAnalyzer::~GLAnalyzer() {}
// METHODS =====================================================
void GLAnalyzer::analyze(const Scope& s) { void GLAnalyzer::analyze(const Scope& s) {
// kdDebug() << "Scope Size: " << s.size() << endl; // kdDebug() << "Scope Size: " << s.size() << endl;
/* Scope t(32); /* Scope t(32);
@ -66,16 +70,13 @@ void GLAnalyzer::analyze(const Scope& s) {
mfactor = 20 / peak; mfactor = 20 / peak;
for (uint i = 0; i < 32; i++) { for (uint i = 0; i < 32; i++) {
// kdDebug() << "Scope item " << i << " value: " << s[i] << endl;
// Calculate new horizontal position (x) depending on number of samples // Calculate new horizontal position (x) depending on number of samples
x = -16.0f + i; x = -16.0f + i;
// Calculating new vertical position (y) depending on the data passed by // Calculating new vertical position (y) depending on the data passed by
// amarok // amarok
y = float(s[i + offset] * mfactor); // This make it kinda dynamically y = static_cast<float>(s[i + offset] * mfactor); // This make it kinda dynamically
// resize depending on the data // resize depending on the data
// Some basic bounds checking // Some basic bounds checking
if (y > 30) if (y > 30)
@ -83,10 +84,10 @@ void GLAnalyzer::analyze(const Scope& s) {
else if (y < 0) else if (y < 0)
y = 0; y = 0;
if ((y - m_oldy[i]) < -0.6f) // Going Down Too Much if ((y - m_oldy[i]) < -0.6f) {
{
y = m_oldy[i] - 0.7f; y = m_oldy[i] - 0.7f;
} }
if (y < 0.0f) { if (y < 0.0f) {
y = 0.0f; y = 0.0f;
} }
@ -145,9 +146,6 @@ void GLAnalyzer::resizeGL(int w, int h) {
void GLAnalyzer::paintGL() { void GLAnalyzer::paintGL() {
glMatrixMode(GL_MODELVIEW); glMatrixMode(GL_MODELVIEW);
#if 0
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
#else
glEnable(GL_DEPTH_TEST); glEnable(GL_DEPTH_TEST);
glEnable(GL_BLEND); glEnable(GL_BLEND);
glPushMatrix(); glPushMatrix();

View File

@ -1,32 +1,34 @@
/*************************************************************************** /* This file is part of Clementine.
gloscope.h - description Copyright 2004, Adam Pigg <adam@piggz.co.uk>
------------------- Copyright 2009, David Sansome <davidsansome@gmail.com>
begin : Jan 17 2004 Copyright 2014, Krzysztof Sobiecki <sobkas@gmail.com>
copyright : (C) 2004 by Adam Pigg Copyright 2014, John Maguire <john.maguire@gmail.com>
email : adam@piggz.co.uk
***************************************************************************/
/*************************************************************************** Clementine is free software: you can redistribute it and/or modify
* * it under the terms of the GNU General Public License as published by
* This program is free software; you can redistribute it and/or modify * the Free Software Foundation, either version 3 of the License, or
* it under the terms of the GNU General Public License as published by * (at your option) any later version.
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef GLOSCOPE_H Clementine is distributed in the hope that it will be useful,
#define GLOSCOPE_H 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: Adam Pigg <adam@piggz.co.uk> 2004
*/
#ifndef ANALYZERS_GLANALYZER_H_
#define ANALYZERS_GLANALYZER_H_
#include <config.h> #include <config.h>
#ifdef HAVE_QGLWIDGET #ifdef HAVE_QGLWIDGET
#include "analyzerbase.h" #include "analyzerbase.h"
/**
*@author piggz
*/
typedef struct { typedef struct {
float level; float level;
uint delay; uint delay;
@ -46,7 +48,7 @@ class GLAnalyzer : public Analyzer::Base3D {
GLfloat x, y; GLfloat x, y;
public: public:
GLAnalyzer(QWidget*); explicit GLAnalyzer(QWidget*);
~GLAnalyzer(); ~GLAnalyzer();
void analyze(const Scope&); void analyze(const Scope&);
@ -57,4 +59,4 @@ class GLAnalyzer : public Analyzer::Base3D {
}; };
#endif #endif
#endif #endif // ANALYZERS_GLANALYZER_H_

View File

@ -1,19 +1,25 @@
/*************************************************************************** /* This file is part of Clementine.
glanalyzer2.cpp - description Copyright 2004, Enrico Ros <eros.kde@email.it>
------------------- Copyright 2009, David Sansome <davidsansome@gmail.com>
begin : Feb 16 2004 Copyright 2014, Krzysztof Sobiecki <sobkas@gmail.com>
copyright : (C) 2004 by Enrico Ros Copyright 2014, John Maguire <john.maguire@gmail.com>
email : eros.kde@email.it
***************************************************************************/
/*************************************************************************** Clementine is free software: you can redistribute it and/or modify
* * it under the terms of the GNU General Public License as published by
* This program is free software; you can redistribute it and/or modify * the Free Software Foundation, either version 3 of the License, or
* it under the terms of the GNU General Public License as published by * (at your option) any later version.
* the Free Software Foundation; either version 2 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: Enrico Ros <eros.kde@email.it> 2004
*/
#include <config.h> #include <config.h>
@ -71,7 +77,7 @@ void GLAnalyzer2::resizeGL(int w, int h) {
glOrtho(-10.0f, 10.0f, -10.0f, 10.0f, -5.0f, 5.0f); glOrtho(-10.0f, 10.0f, -10.0f, 10.0f, -5.0f, 5.0f);
// Get the aspect ratio of the screen to draw 'cicular' particles // Get the aspect ratio of the screen to draw 'cicular' particles
float ratio = (float)w / (float)h, eqPixH = 60, eqPixW = 80; float ratio = static_cast<float>w / static_cast<float>h, eqPixH = 60, eqPixW = 80;
if (ratio >= (4.0 / 3.0)) { if (ratio >= (4.0 / 3.0)) {
unitX = 10.0 / (eqPixH * ratio); unitX = 10.0 / (eqPixH * ratio);
unitY = 10.0 / eqPixH; unitY = 10.0 / eqPixH;
@ -83,7 +89,7 @@ void GLAnalyzer2::resizeGL(int w, int h) {
// Get current timestamp. // Get current timestamp.
timeval tv; timeval tv;
gettimeofday(&tv, nullptr); gettimeofday(&tv, nullptr);
show.timeStamp = (double)tv.tv_sec + (double)tv.tv_usec / 1000000.0; show.timeStamp = static_cast<double>tv.tv_sec + static_cast<double>tv.tv_usec / 1000000.0;
} }
void GLAnalyzer2::paused() { analyze(Scope()); } void GLAnalyzer2::paused() { analyze(Scope()); }
@ -103,19 +109,20 @@ void GLAnalyzer2::analyze(const Scope& s) {
for (int i = 0; i < bands; i++) { for (int i = 0; i < bands; i++) {
float value = s[i]; float value = s[i];
currentEnergy += value; currentEnergy += value;
currentMeanBand += (float)i * value; currentMeanBand += static_cast<float>i * value;
if (value > maxValue) maxValue = value; if (value > maxValue) maxValue = value;
} }
frame.silence = currentEnergy < 0.001; frame.silence = currentEnergy < 0.001;
if (!frame.silence) { if (!frame.silence) {
frame.meanBand = 100.0 * currentMeanBand / (currentEnergy * bands); frame.meanBand = 100.0 * currentMeanBand / (currentEnergy * bands);
currentEnergy = 100.0 * currentEnergy / (float)bands; currentEnergy = 100.0 * currentEnergy / static_cast<float>bands;
frame.dEnergy = currentEnergy - frame.energy; frame.dEnergy = currentEnergy - frame.energy;
frame.energy = currentEnergy; frame.energy = currentEnergy;
// printf( "%d [%f :: %f ]\t%f \n", bands, frame.energy, // printf( "%d [%f :: %f ]\t%f \n", bands, frame.energy,
// frame.meanBand, maxValue ); // frame.meanBand, maxValue );
} else } else {
frame.energy = 0.0; frame.energy = 0.0;
}
} }
// update the frame // update the frame
@ -126,7 +133,7 @@ void GLAnalyzer2::paintGL() {
// Compute the dT since the last call to paintGL and update timings // Compute the dT since the last call to paintGL and update timings
timeval tv; timeval tv;
gettimeofday(&tv, nullptr); gettimeofday(&tv, nullptr);
double currentTime = (double)tv.tv_sec + (double)tv.tv_usec / 1000000.0; double currentTime = static_cast<double>tv.tv_sec + static_cast<double>tv.tv_usec / 1000000.0;
show.dT = currentTime - show.timeStamp; show.dT = currentTime - show.timeStamp;
show.timeStamp = currentTime; show.timeStamp = currentTime;
@ -202,8 +209,9 @@ void GLAnalyzer2::paintGL() {
if (dotTexture) { if (dotTexture) {
glEnable(GL_TEXTURE_2D); glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, dotTexture); glBindTexture(GL_TEXTURE_2D, dotTexture);
} else } else {
glDisable(GL_TEXTURE_2D); glDisable(GL_TEXTURE_2D);
}
glLoadIdentity(); glLoadIdentity();
// glRotatef( -frame.rotDegrees, 0,0,1 ); // glRotatef( -frame.rotDegrees, 0,0,1 );

View File

@ -1,22 +1,28 @@
/*************************************************************************** /* This file is part of Clementine.
glanalyzer2.h - description Copyright 2004, Enrico Ros <eros.kde@email.it>
------------------- Copyright 2009, David Sansome <davidsansome@gmail.com>
begin : Feb 16 2004 Copyright 2014, Krzysztof Sobiecki <sobkas@gmail.com>
copyright : (C) 2004 by Enrico Ros Copyright 2014, John Maguire <john.maguire@gmail.com>
email : eros.kde@email.it
***************************************************************************/
/*************************************************************************** Clementine is free software: you can redistribute it and/or modify
* * it under the terms of the GNU General Public License as published by
* This program is free software; you can redistribute it and/or modify * the Free Software Foundation, either version 3 of the License, or
* it under the terms of the GNU General Public License as published by * (at your option) any later version.
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef GLSTARVIEW_H Clementine is distributed in the hope that it will be useful,
#define GLSTARVIEW_H 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: Enrico Ros <eros.kde@email.it> 2004
*/
#ifndef ANALYZERS_GLANALYZER2_H_
#define ANALYZERS_GLANALYZER2_H_
#include <config.h> #include <config.h>
#ifdef HAVE_QGLWIDGET #ifdef HAVE_QGLWIDGET
@ -27,7 +33,7 @@
class GLAnalyzer2 : public Analyzer::Base3D { class GLAnalyzer2 : public Analyzer::Base3D {
public: public:
GLAnalyzer2(QWidget*); explicit GLAnalyzer2(QWidget*);
~GLAnalyzer2(); ~GLAnalyzer2();
void analyze(const Scope&); void analyze(const Scope&);
void paused(); void paused();
@ -68,4 +74,4 @@ class GLAnalyzer2 : public Analyzer::Base3D {
}; };
#endif #endif
#endif #endif // ANALYZERS_GLANALYZER2_H_

View File

@ -1,19 +1,25 @@
/*************************************************************************** /* This file is part of Clementine.
glanalyzer3.cpp - Bouncing Ballzz Copyright 2004, Enrico Ros <eros.kde@email.it>
------------------- Copyright 2009, David Sansome <davidsansome@gmail.com>
begin : Feb 19 2004 Copyright 2014, Krzysztof Sobiecki <sobkas@gmail.com>
copyright : (C) 2004 by Enrico Ros Copyright 2014, John Maguire <john.maguire@gmail.com>
email : eros.kde@email.it
***************************************************************************/
/*************************************************************************** Clementine is free software: you can redistribute it and/or modify
* * it under the terms of the GNU General Public License as published by
* This program is free software; you can redistribute it and/or modify * the Free Software Foundation, either version 3 of the License, or
* it under the terms of the GNU General Public License as published by * (at your option) any later version.
* the Free Software Foundation; either version 2 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: Enrico Ros <eros.kde@email.it> 2004
*/
#include <config.h> #include <config.h>
@ -40,16 +46,8 @@ class Ball {
vx(0.0), vx(0.0),
vy(0.0), vy(0.0),
vz(0.0), vz(0.0),
mass(0.01 + drand48() / 10.0) mass(0.01 + drand48() / 10.0),
//,color( (float[3]) { 0.0, drand48()*0.5, 0.7 + drand48() * 0.3 } ) color((float[3]) { 0.0, drand48()*0.5, 0.7 + drand48() * 0.3 }) {}
{
// this is because GCC < 3.3 can't compile the above line, we aren't sure
// why though
color[0] = 0.0;
color[1] = drand48() * 0.5;
color[2] = 0.7 + drand48() * 0.3;
};
float x, y, z, vx, vy, vz, mass; float x, y, z, vx, vy, vz, mass;
float color[3]; float color[3];
@ -70,8 +68,8 @@ class Ball {
class Paddle { class Paddle {
public: public:
Paddle(float xPos) explicit Paddle(float xPos)
: onLeft(xPos < 0), mass(1.0), X(xPos), x(xPos), vx(0.0) {}; : onLeft(xPos < 0), mass(1.0), X(xPos), x(xPos), vx(0.0) {}
void updatePhysics(float dT) { void updatePhysics(float dT) {
x += vx * dT; // posision x += vx * dT; // posision
@ -165,7 +163,7 @@ void GLAnalyzer3::resizeGL(int w, int h) {
glFrustum(-0.5f, 0.5f, -0.5f, 0.5f, 0.5f, 4.5f); glFrustum(-0.5f, 0.5f, -0.5f, 0.5f, 0.5f, 4.5f);
// Get the aspect ratio of the screen to draw 'circular' particles // Get the aspect ratio of the screen to draw 'circular' particles
float ratio = (float)w / (float)h; float ratio = static_cast<float>w / static_cast<float>h;
if (ratio >= 1.0) { if (ratio >= 1.0) {
unitX = 0.34 / ratio; unitX = 0.34 / ratio;
unitY = 0.34; unitY = 0.34;
@ -177,7 +175,7 @@ void GLAnalyzer3::resizeGL(int w, int h) {
// Get current timestamp. // Get current timestamp.
timeval tv; timeval tv;
gettimeofday(&tv, nullptr); gettimeofday(&tv, nullptr);
show.timeStamp = (double)tv.tv_sec + (double)tv.tv_usec / 1000000.0; show.timeStamp = static_cast<double>tv.tv_sec + static_cast<double>tv.tv_usec / 1000000.0;
} }
void GLAnalyzer3::paused() { analyze(Scope()); } void GLAnalyzer3::paused() { analyze(Scope()); }
@ -186,7 +184,7 @@ void GLAnalyzer3::analyze(const Scope& s) {
// compute the dTime since the last call // compute the dTime since the last call
timeval tv; timeval tv;
gettimeofday(&tv, nullptr); gettimeofday(&tv, nullptr);
double currentTime = (double)tv.tv_sec + (double)tv.tv_usec / 1000000.0; double currentTime = static_cast<double>tv.tv_sec + static_cast<double>tv.tv_usec / 1000000.0;
show.dT = currentTime - show.timeStamp; show.dT = currentTime - show.timeStamp;
show.timeStamp = currentTime; show.timeStamp = currentTime;
@ -200,7 +198,7 @@ void GLAnalyzer3::analyze(const Scope& s) {
currentEnergy += value; currentEnergy += value;
if (value > maxValue) maxValue = value; if (value > maxValue) maxValue = value;
} }
currentEnergy *= 100.0 / (float)bands; currentEnergy *= 100.0 / static_cast<float>bands;
// emulate a peak detector: currentEnergy -> peakEnergy (3tau = 30 seconds) // emulate a peak detector: currentEnergy -> peakEnergy (3tau = 30 seconds)
show.peakEnergy = 1.0 + (show.peakEnergy - 1.0) * exp(-show.dT / 10.0); show.peakEnergy = 1.0 + (show.peakEnergy - 1.0) * exp(-show.dT / 10.0);
if (currentEnergy > show.peakEnergy) show.peakEnergy = currentEnergy; if (currentEnergy > show.peakEnergy) show.peakEnergy = currentEnergy;
@ -210,8 +208,9 @@ void GLAnalyzer3::analyze(const Scope& s) {
currentEnergy /= show.peakEnergy; currentEnergy /= show.peakEnergy;
frame.dEnergy = currentEnergy - frame.energy; frame.dEnergy = currentEnergy - frame.energy;
frame.energy = currentEnergy; frame.energy = currentEnergy;
} else } else {
frame.silence = true; frame.silence = true;
}
// update the frame // update the frame
updateGL(); updateGL();
@ -259,8 +258,10 @@ void GLAnalyzer3::paintGL() {
if (ballTexture) { if (ballTexture) {
glEnable(GL_TEXTURE_2D); glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, ballTexture); glBindTexture(GL_TEXTURE_2D, ballTexture);
} else } else {
glDisable(GL_TEXTURE_2D); glDisable(GL_TEXTURE_2D);
}
glEnable(GL_BLEND); glEnable(GL_BLEND);
Ball* ball = balls.first(); Ball* ball = balls.first();
for (; ball; ball = balls.next()) { for (; ball; ball = balls.next()) {

View File

@ -1,25 +1,31 @@
/*************************************************************************** /* This file is part of Clementine.
glanalyzer3.h - description Copyright 2004, Enrico Ros <eros.kde@email.it>
------------------- Copyright 2009, David Sansome <davidsansome@gmail.com>
begin : Feb 16 2004 Copyright 2014, Krzysztof Sobiecki <sobkas@gmail.com>
copyright : (C) 2004 by Enrico Ros Copyright 2014, John Maguire <john.maguire@gmail.com>
email : eros.kde@email.it
***************************************************************************/
/*************************************************************************** Clementine is free software: you can redistribute it and/or modify
* * it under the terms of the GNU General Public License as published by
* This program is free software; you can redistribute it and/or modify * the Free Software Foundation, either version 3 of the License, or
* it under the terms of the GNU General Public License as published by * (at your option) any later version.
* the Free Software Foundation; either version 2 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: Enrico Ros <eros.kde@email.it> 2004
*/
#include <config.h> #include <config.h>
#ifdef HAVE_QGLWIDGET #ifdef HAVE_QGLWIDGET
#ifndef GLBOUNCER_H #ifndef ANALYZERS_GLANALYZER3_H_
#define GLBOUNCER_H #define ANALYZERS_GLANALYZER3_H_
#include "analyzerbase.h" #include "analyzerbase.h"
#include <qstring.h> #include <qstring.h>
@ -31,7 +37,7 @@ class Paddle;
class GLAnalyzer3 : public Analyzer::Base3D { class GLAnalyzer3 : public Analyzer::Base3D {
public: public:
GLAnalyzer3(QWidget*); explicit GLAnalyzer3(QWidget*);
~GLAnalyzer3(); ~GLAnalyzer3();
void analyze(const Scope&); void analyze(const Scope&);
void paused(); void paused();
@ -76,4 +82,4 @@ class GLAnalyzer3 : public Analyzer::Base3D {
}; };
#endif #endif
#endif #endif // ANALYZERS_GLANALYZER3_H_

View File

@ -1,5 +1,8 @@
/* This file is part of Clementine. /* This file is part of Clementine.
Copyright 2010, David Sansome <me@davidsansome.com> Copyright 2011, Tyler Rhodes <tyler.s.rhodes@gmail.com>
Copyright 2011-2012, 2014, David Sansome <me@davidsansome.com>
Copyright 2014, John Maguire <john.maguire@gmail.com>
Copyright 2014, Krzysztof Sobiecki <sobkas@gmail.com>
Clementine is free software: you can redistribute it and/or modify Clementine is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -71,7 +74,7 @@ void NyanCatAnalyzer::resizeEvent(QResizeEvent* e) {
buffer_[1] = QPixmap(); buffer_[1] = QPixmap();
available_rainbow_width_ = width() - kCatWidth + kRainbowOverlap; available_rainbow_width_ = width() - kCatWidth + kRainbowOverlap;
px_per_frame_ = float(available_rainbow_width_) / (kHistorySize - 1) + 1; px_per_frame_ = static_cast<float>(available_rainbow_width_) / (kHistorySize - 1) + 1;
x_offset_ = px_per_frame_ * (kHistorySize - 1) - available_rainbow_width_; x_offset_ = px_per_frame_ * (kHistorySize - 1) - available_rainbow_width_;
} }
@ -109,11 +112,11 @@ void NyanCatAnalyzer::analyze(QPainter& p, const Analyzer::Scope& s,
QPointF* dest = polyline; QPointF* dest = polyline;
float* source = history_; float* source = history_;
const float top_of_cat = float(height()) / 2 - float(kCatHeight) / 2; const float top_of_cat = static_cast<float>(height()) / 2 - static_cast<float>(kCatHeight) / 2;
for (int band = 0; band < kRainbowBands; ++band) { for (int band = 0; band < kRainbowBands; ++band) {
// Calculate the Y position of this band. // Calculate the Y position of this band.
const float y = const float y =
float(kCatHeight) / (kRainbowBands + 1) * (band + 0.5) + top_of_cat; static_cast<float>(kCatHeight) / (kRainbowBands + 1) * (band + 0.5) + top_of_cat;
// Add each point in the line. // Add each point in the line.
for (int x = 0; x < kHistorySize; ++x) { for (int x = 0; x < kHistorySize; ++x) {

View File

@ -1,5 +1,8 @@
/* This file is part of Clementine. /* This file is part of Clementine.
Copyright 2010, David Sansome <me@davidsansome.com> Copyright 2011, Tyler Rhodes <tyler.s.rhodes@gmail.com>
Copyright 2011-2012, David Sansome <me@davidsansome.com>
Copyright 2011, 2014, John Maguire <john.maguire@gmail.com>
Copyright 2014, Krzysztof Sobiecki <sobkas@gmail.com>
Clementine is free software: you can redistribute it and/or modify Clementine is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -15,8 +18,8 @@
along with Clementine. If not, see <http://www.gnu.org/licenses/>. along with Clementine. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef NYANCATANALYZER_H #ifndef ANALYZERS_NYANCATANALYZER_H_
#define NYANCATANALYZER_H #define ANALYZERS_NYANCATANALYZER_H_
#include "analyzerbase.h" #include "analyzerbase.h"
@ -102,4 +105,4 @@ class NyanCatAnalyzer : public Analyzer::Base {
QBrush background_brush_; QBrush background_brush_;
}; };
#endif // NYANCATANALYZER_H #endif // ANALYZERS_NYANCATANALYZER_H_

View File

@ -1,5 +1,8 @@
/* This file is part of Clementine. /* This file is part of Clementine.
Copyright 2010, David Sansome <me@davidsansome.com> Copyright 2014, Alibek Omarov <a1ba.omarov@gmail.com>
Copyright 2014, Mark Furneaux <mark@romaco.ca>
Copyright 2014, Krzysztof Sobiecki <sobkas@gmail.com>
Copyright 2014, David Sansome <me@davidsansome.com>
Clementine is free software: you can redistribute it and/or modify Clementine is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -71,7 +74,7 @@ void RainbowDashAnalyzer::resizeEvent(QResizeEvent* e) {
buffer_[1] = QPixmap(); buffer_[1] = QPixmap();
available_rainbow_width_ = width() - kDashWidth + kRainbowOverlap; available_rainbow_width_ = width() - kDashWidth + kRainbowOverlap;
px_per_frame_ = float(available_rainbow_width_) / (kHistorySize - 1) + 1; px_per_frame_ = static_cast<float>(available_rainbow_width_) / (kHistorySize - 1) + 1;
x_offset_ = px_per_frame_ * (kHistorySize - 1) - available_rainbow_width_; x_offset_ = px_per_frame_ * (kHistorySize - 1) - available_rainbow_width_;
} }
@ -108,11 +111,11 @@ void RainbowDashAnalyzer::analyze(QPainter& p, const Analyzer::Scope& s,
QPointF* dest = polyline; QPointF* dest = polyline;
float* source = history_; float* source = history_;
const float top_of_Dash = float(height()) / 2 - float(kRainbowHeight) / 2; const float top_of_Dash = static_cast<float>(height()) / 2 - static_cast<float>(kRainbowHeight) / 2;
for (int band = 0; band < kRainbowBands; ++band) { for (int band = 0; band < kRainbowBands; ++band) {
// Calculate the Y position of this band. // Calculate the Y position of this band.
const float y = const float y =
float(kRainbowHeight) / (kRainbowBands + 1) * (band + 0.5) + static_cast<float>(kRainbowHeight) / (kRainbowBands + 1) * (band + 0.5) +
top_of_Dash; top_of_Dash;
// Add each point in the line. // Add each point in the line.

View File

@ -1,5 +1,7 @@
/* This file is part of Clementine. /* This file is part of Clementine.
Copyright 2010, David Sansome <me@davidsansome.com> Copyright 2014, Alibek Omarov <a1ba.omarov@gmail.com>
Copyright 2014, Mark Furneaux <mark@romaco.ca>
Copyright 2014, Krzysztof Sobiecki <sobkas@gmail.com>
Clementine is free software: you can redistribute it and/or modify Clementine is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -15,8 +17,8 @@
along with Clementine. If not, see <http://www.gnu.org/licenses/>. along with Clementine. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef RAINBOWDASHANALYZER_H #ifndef ANALYZERS_RAINBOWDASHANALYZER_H_
#define RAINBOWDASHANALYZER_H #define ANALYZERS_RAINBOWDASHANALYZER_H_
#include "analyzerbase.h" #include "analyzerbase.h"
@ -103,4 +105,4 @@ class RainbowDashAnalyzer : public Analyzer::Base {
QBrush background_brush_; QBrush background_brush_;
}; };
#endif // RAINBOWDASHANALYZER_H #endif // ANALYZERS_RAINBOWDASHANALYZER_H_

View File

@ -1,15 +1,26 @@
// /* This file is part of Clementine.
// Copyright 2004, Melchior FRANZ <mfranz@kde.org>
// C++ Implementation: Sonogram Copyright 2009-2010, David Sansome <davidsansome@gmail.com>
// Copyright 2010, 2014, John Maguire <john.maguire@gmail.com>
// Description: Copyright 2014, Mark Furneaux <mark@romaco.ca>
// Copyright 2014, Krzysztof Sobiecki <sobkas@gmail.com>
//
// Author: Melchior FRANZ <mfranz@kde.org>, (C) 2004 Clementine is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// Copyright: See COPYING file that comes with this distribution 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: Melchior FRANZ <mfranz@kde.org> 2004
*/
#include "sonogram.h" #include "sonogram.h"
@ -53,9 +64,9 @@ void Sonogram::analyze(QPainter& p, const Scope& s, bool new_frame) {
if (it >= end || *it < .005) if (it >= end || *it < .005)
c = palette().color(QPalette::Background); c = palette().color(QPalette::Background);
else if (*it < .05) else if (*it < .05)
c.setHsv(95, 255, 255 - int(*it * 4000.0)); c.setHsv(95, 255, 255 - static_cast<int>(*it * 4000.0));
else if (*it < 1.0) else if (*it < 1.0)
c.setHsv(95 - int(*it * 90.0), 255, 255); c.setHsv(95 - static_cast<int>(*it * 90.0), 255, 255);
else else
c = Qt::red; c = Qt::red;

View File

@ -1,18 +1,28 @@
// /* This file is part of Clementine.
// Copyright 2004, Melchior FRANZ <mfranz@kde.org>
// C++ Interface: Sonogram Copyright 2009-2010, David Sansome <davidsansome@gmail.com>
// Copyright 2014, Krzysztof Sobiecki <sobkas@gmail.com>
// Description: Copyright 2014, John Maguire <john.maguire@gmail.com>
//
//
// Author: Melchior FRANZ <mfranz@kde.org>, (C) 2004
//
// Copyright: See COPYING file that comes with this distribution
//
//
#ifndef SONOGRAM_H Clementine is free software: you can redistribute it and/or modify
#define SONOGRAM_H 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: Melchior FRANZ <mfranz@kde.org> 2004
*/
#ifndef ANALYZERS_SONOGRAM_H_
#define ANALYZERS_SONOGRAM_H_
#include "analyzerbase.h" #include "analyzerbase.h"
@ -37,4 +47,4 @@ class Sonogram : public Analyzer::Base {
QPixmap canvas_; QPixmap canvas_;
}; };
#endif #endif // ANALYZERS_SONOGRAM_H_

View File

@ -1,11 +1,28 @@
// /* This file is part of Clementine.
// Amarok BarAnalyzer 3 - Jet Turbine: Symmetric version of analyzer 1 Copyright 2003, Stanislav Karchebny <berkus@users.sf.net>
// Copyright 2003, Max Howell <max.howell@methylblue.com>
// Author: Stanislav Karchebny <berkus@users.sf.net>, (C) 2003 Copyright 2009-2010, David Sansome <davidsansome@gmail.com>
// Max Howell (I modified it to use boom analyzer code) Copyright 2014, Mark Furneaux <mark@romaco.ca>
// Copyright 2014, Krzysztof Sobiecki <sobkas@gmail.com>
// Copyright: like rest of Amarok Copyright 2014, John Maguire <john.maguire@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: Stanislav Karchebny <berkus@users.sf.net> 2003
* Original Author: Max Howell <max.howell@methylblue.com> 2003
*/
#include <cmath> #include <cmath>
#include <QPainter> #include <QPainter>
@ -41,8 +58,9 @@ void TurbineAnalyzer::analyze(QPainter& p, const Scope& scope, bool new_frame) {
if (h > peak_height[i]) { if (h > peak_height[i]) {
peak_height[i] = h; peak_height[i] = h;
peak_speed[i] = 0.01; peak_speed[i] = 0.01;
} else } else {
goto peak_handling; goto peak_handling;
}
} else { } else {
if (bar_height[i] > 0.0) { if (bar_height[i] > 0.0) {
bar_height[i] -= K_barHeight; // 1.4 bar_height[i] -= K_barHeight; // 1.4
@ -60,15 +78,16 @@ void TurbineAnalyzer::analyze(QPainter& p, const Scope& scope, bool new_frame) {
} }
} }
y = hd2 - uint(bar_height[i]); y = hd2 - static_cast<uint>(bar_height[i]);
canvas_painter.drawPixmap(x + 1, y, barPixmap, 0, y, -1, -1); canvas_painter.drawPixmap(x + 1, y, barPixmap, 0, y, -1, -1);
canvas_painter.drawPixmap(x + 1, hd2, barPixmap, 0, int(bar_height[i]), -1, canvas_painter.drawPixmap(x + 1, hd2, barPixmap, 0,
-1); static_cast<int>(bar_height[i]),
-1, -1);
canvas_painter.setPen(palette().color(QPalette::Highlight)); canvas_painter.setPen(palette().color(QPalette::Highlight));
if (bar_height[i] > 0) if (bar_height[i] > 0)
canvas_painter.drawRect(x, y, COLUMN_WIDTH - 1, canvas_painter.drawRect(x, y, COLUMN_WIDTH - 1,
(int)bar_height[i] * 2 - 1); static_cast<int>bar_height[i] * 2 - 1);
const uint x2 = x + COLUMN_WIDTH - 1; const uint x2 = x + COLUMN_WIDTH - 1;
canvas_painter.setPen(palette().color(QPalette::Base)); canvas_painter.setPen(palette().color(QPalette::Base));

View File

@ -1,13 +1,28 @@
// /* This file is part of Clementine.
// Amarok BarAnalyzer 3 - Jet Turbine: Symmetric version of analyzer 1 Copyright 2003, Stanislav Karchebny <berkus@users.sf.net>
// Copyright 2009-2010, David Sansome <davidsansome@gmail.com>
// Author: Stanislav Karchebny <berkus@users.sf.net>, (C) 2003 Copyright 2014, Krzysztof Sobiecki <sobkas@gmail.com>
// Copyright 2014, John Maguire <john.maguire@gmail.com>
// Copyright: like rest of Amarok
//
#ifndef ANALYZER_TURBINE_H Clementine is free software: you can redistribute it and/or modify
#define ANALYZER_TURBINE_H 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: Stanislav Karchebny <berkus@users.sf.net> 2003
*/
#ifndef ANALYZERS_TURBINE_H_
#define ANALYZERS_TURBINE_H_
#include "boomanalyzer.h" #include "boomanalyzer.h"
@ -21,4 +36,4 @@ class TurbineAnalyzer : public BoomAnalyzer {
static const char* kName; static const char* kName;
}; };
#endif #endif // ANALYZERS_TURBINE_H_