Rename AnalyzerBase
This commit is contained in:
parent
e9f3281694
commit
4c1c322b54
@ -50,7 +50,7 @@
|
|||||||
// Make an INSTRUCTIONS file
|
// Make an INSTRUCTIONS file
|
||||||
// can't mod scope in analyze you have to use transform for 2D use setErasePixmap Qt function insetead of m_background
|
// can't mod scope in analyze you have to use transform for 2D use setErasePixmap Qt function insetead of m_background
|
||||||
|
|
||||||
Analyzer::Base::Base(QWidget *parent, const uint scopeSize)
|
AnalyzerBase::AnalyzerBase(QWidget *parent, const uint scopeSize)
|
||||||
: QWidget(parent),
|
: QWidget(parent),
|
||||||
fht_(new FHT(scopeSize)),
|
fht_(new FHT(scopeSize)),
|
||||||
engine_(nullptr),
|
engine_(nullptr),
|
||||||
@ -63,19 +63,19 @@ Analyzer::Base::Base(QWidget *parent, const uint scopeSize)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Analyzer::Base::~Base() {
|
AnalyzerBase::~AnalyzerBase() {
|
||||||
delete fht_;
|
delete fht_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Analyzer::Base::showEvent(QShowEvent*) {
|
void AnalyzerBase::showEvent(QShowEvent*) {
|
||||||
timer_.start(timeout(), this);
|
timer_.start(timeout(), this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Analyzer::Base::hideEvent(QHideEvent*) {
|
void AnalyzerBase::hideEvent(QHideEvent*) {
|
||||||
timer_.stop();
|
timer_.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Analyzer::Base::ChangeTimeout(const int timeout) {
|
void AnalyzerBase::ChangeTimeout(const int timeout) {
|
||||||
|
|
||||||
timeout_ = timeout;
|
timeout_ = timeout;
|
||||||
if (timer_.isActive()) {
|
if (timer_.isActive()) {
|
||||||
@ -85,7 +85,7 @@ void Analyzer::Base::ChangeTimeout(const int timeout) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Analyzer::Base::transform(Scope &scope) {
|
void AnalyzerBase::transform(Scope &scope) {
|
||||||
|
|
||||||
QVector<float> aux(fht_->size());
|
QVector<float> aux(fht_->size());
|
||||||
if (static_cast<unsigned long int>(aux.size()) >= scope.size()) {
|
if (static_cast<unsigned long int>(aux.size()) >= scope.size()) {
|
||||||
@ -102,7 +102,7 @@ void Analyzer::Base::transform(Scope &scope) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Analyzer::Base::paintEvent(QPaintEvent *e) {
|
void AnalyzerBase::paintEvent(QPaintEvent *e) {
|
||||||
|
|
||||||
QPainter p(this);
|
QPainter p(this);
|
||||||
p.fillRect(e->rect(), palette().color(QPalette::Window));
|
p.fillRect(e->rect(), palette().color(QPalette::Window));
|
||||||
@ -140,7 +140,7 @@ void Analyzer::Base::paintEvent(QPaintEvent *e) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int Analyzer::Base::resizeExponent(int exp) {
|
int AnalyzerBase::resizeExponent(int exp) {
|
||||||
|
|
||||||
if (exp < 3) {
|
if (exp < 3) {
|
||||||
exp = 3;
|
exp = 3;
|
||||||
@ -157,7 +157,7 @@ int Analyzer::Base::resizeExponent(int exp) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int Analyzer::Base::resizeForBands(const int bands) {
|
int AnalyzerBase::resizeForBands(const int bands) {
|
||||||
|
|
||||||
int exp = 0;
|
int exp = 0;
|
||||||
if (bands <= 8) {
|
if (bands <= 8) {
|
||||||
@ -184,7 +184,7 @@ int Analyzer::Base::resizeForBands(const int bands) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Analyzer::Base::demo(QPainter &p) {
|
void AnalyzerBase::demo(QPainter &p) {
|
||||||
|
|
||||||
static int t = 201; // FIXME make static to namespace perhaps
|
static int t = 201; // FIXME make static to namespace perhaps
|
||||||
|
|
||||||
@ -209,7 +209,7 @@ void Analyzer::Base::demo(QPainter &p) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Analyzer::interpolate(const Scope &inVec, Scope &outVec) {
|
void AnalyzerBase::interpolate(const Scope &inVec, Scope &outVec) {
|
||||||
|
|
||||||
double pos = 0.0;
|
double pos = 0.0;
|
||||||
const double step = static_cast<double>(inVec.size()) / static_cast<double>(outVec.size());
|
const double step = static_cast<double>(inVec.size()) / static_cast<double>(outVec.size());
|
||||||
@ -235,7 +235,7 @@ void Analyzer::interpolate(const Scope &inVec, Scope &outVec) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Analyzer::initSin(Scope &v, const uint size) {
|
void AnalyzerBase::initSin(Scope &v, const uint size) {
|
||||||
|
|
||||||
double step = (M_PI * 2) / size;
|
double step = (M_PI * 2) / size;
|
||||||
double radian = 0;
|
double radian = 0;
|
||||||
@ -247,7 +247,7 @@ void Analyzer::initSin(Scope &v, const uint size) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Analyzer::Base::timerEvent(QTimerEvent *e) {
|
void AnalyzerBase::timerEvent(QTimerEvent *e) {
|
||||||
|
|
||||||
QWidget::timerEvent(e);
|
QWidget::timerEvent(e);
|
||||||
if (e->timerId() != timer_.timerId()) {
|
if (e->timerId() != timer_.timerId()) {
|
||||||
|
@ -46,15 +46,11 @@ class QShowEvent;
|
|||||||
class QPaintEvent;
|
class QPaintEvent;
|
||||||
class QTimerEvent;
|
class QTimerEvent;
|
||||||
|
|
||||||
namespace Analyzer {
|
class AnalyzerBase : public QWidget {
|
||||||
|
|
||||||
using Scope = std::vector<float>;
|
|
||||||
|
|
||||||
class Base : public QWidget {
|
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
~Base() override;
|
~AnalyzerBase() override;
|
||||||
|
|
||||||
int timeout() const { return timeout_; }
|
int timeout() const { return timeout_; }
|
||||||
|
|
||||||
@ -65,7 +61,8 @@ class Base : public QWidget {
|
|||||||
virtual void framerateChanged() {}
|
virtual void framerateChanged() {}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
explicit Base(QWidget*, const uint scopeSize = 7);
|
using Scope = std::vector<float>;
|
||||||
|
explicit AnalyzerBase(QWidget*, const uint scopeSize = 7);
|
||||||
|
|
||||||
void hideEvent(QHideEvent*) override;
|
void hideEvent(QHideEvent*) override;
|
||||||
void showEvent(QShowEvent*) override;
|
void showEvent(QShowEvent*) override;
|
||||||
@ -79,6 +76,9 @@ class Base : public QWidget {
|
|||||||
virtual void analyze(QPainter &p, const Scope&, const bool new_frame) = 0;
|
virtual void analyze(QPainter &p, const Scope&, const bool new_frame) = 0;
|
||||||
virtual void demo(QPainter &p);
|
virtual void demo(QPainter &p);
|
||||||
|
|
||||||
|
void interpolate(const Scope&, Scope&);
|
||||||
|
void initSin(Scope&, const uint = 6000);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QBasicTimer timer_;
|
QBasicTimer timer_;
|
||||||
FHT *fht_;
|
FHT *fht_;
|
||||||
@ -90,10 +90,5 @@ class Base : public QWidget {
|
|||||||
int timeout_;
|
int timeout_;
|
||||||
};
|
};
|
||||||
|
|
||||||
void interpolate(const Scope&, Scope&);
|
|
||||||
void initSin(Scope&, const uint = 6000);
|
|
||||||
|
|
||||||
} // namespace Analyzer
|
|
||||||
|
|
||||||
#endif // ANALYZERBASE_H
|
#endif // ANALYZERBASE_H
|
||||||
|
|
||||||
|
@ -83,8 +83,8 @@ AnalyzerContainer::AnalyzerContainer(QWidget *parent)
|
|||||||
|
|
||||||
AddAnalyzerType<BlockAnalyzer>();
|
AddAnalyzerType<BlockAnalyzer>();
|
||||||
AddAnalyzerType<BoomAnalyzer>();
|
AddAnalyzerType<BoomAnalyzer>();
|
||||||
AddAnalyzerType<Rainbow::NyanCatAnalyzer>();
|
AddAnalyzerType<NyanCatAnalyzer>();
|
||||||
AddAnalyzerType<Rainbow::RainbowDashAnalyzer>();
|
AddAnalyzerType<RainbowDashAnalyzer>();
|
||||||
AddAnalyzerType<Sonogram>();
|
AddAnalyzerType<Sonogram>();
|
||||||
|
|
||||||
disable_action_ = context_menu_->addAction(tr("No analyzer"), this, &AnalyzerContainer::DisableAnalyzer);
|
disable_action_ = context_menu_->addAction(tr("No analyzer"), this, &AnalyzerContainer::DisableAnalyzer);
|
||||||
@ -149,7 +149,7 @@ void AnalyzerContainer::ChangeAnalyzer(const int id) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
delete current_analyzer_;
|
delete current_analyzer_;
|
||||||
current_analyzer_ = qobject_cast<Analyzer::Base*>(instance);
|
current_analyzer_ = qobject_cast<AnalyzerBase*>(instance);
|
||||||
current_analyzer_->set_engine(engine_);
|
current_analyzer_->set_engine(engine_);
|
||||||
// Even if it is not supposed to happen, I don't want to get a dbz error
|
// Even if it is not supposed to happen, I don't want to get a dbz error
|
||||||
current_framerate_ = current_framerate_ == 0 ? kMediumFramerate : current_framerate_;
|
current_framerate_ = current_framerate_ == 0 ? kMediumFramerate : current_framerate_;
|
||||||
|
@ -36,9 +36,7 @@ class QTimer;
|
|||||||
class QMouseEvent;
|
class QMouseEvent;
|
||||||
class QWheelEvent;
|
class QWheelEvent;
|
||||||
|
|
||||||
namespace Analyzer {
|
class AnalyzerBase;
|
||||||
class Base;
|
|
||||||
} // namespace Analyzer
|
|
||||||
|
|
||||||
class AnalyzerContainer : public QWidget {
|
class AnalyzerContainer : public QWidget {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -94,7 +92,7 @@ class AnalyzerContainer : public QWidget {
|
|||||||
QPoint last_click_pos_;
|
QPoint last_click_pos_;
|
||||||
bool ignore_next_click_;
|
bool ignore_next_click_;
|
||||||
|
|
||||||
Analyzer::Base *current_analyzer_;
|
AnalyzerBase *current_analyzer_;
|
||||||
EngineBase *engine_;
|
EngineBase *engine_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ const int BlockAnalyzer::kFadeSize = 90;
|
|||||||
const char *BlockAnalyzer::kName = QT_TRANSLATE_NOOP("AnalyzerContainer", "Block analyzer");
|
const char *BlockAnalyzer::kName = QT_TRANSLATE_NOOP("AnalyzerContainer", "Block analyzer");
|
||||||
|
|
||||||
BlockAnalyzer::BlockAnalyzer(QWidget *parent)
|
BlockAnalyzer::BlockAnalyzer(QWidget *parent)
|
||||||
: Analyzer::Base(parent, 9),
|
: AnalyzerBase(parent, 9),
|
||||||
columns_(0),
|
columns_(0),
|
||||||
rows_(0),
|
rows_(0),
|
||||||
y_(0),
|
y_(0),
|
||||||
@ -124,7 +124,7 @@ void BlockAnalyzer::framerateChanged() {
|
|||||||
determineStep();
|
determineStep();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BlockAnalyzer::transform(Analyzer::Scope &s) {
|
void BlockAnalyzer::transform(Scope &s) {
|
||||||
|
|
||||||
for (uint x = 0; x < s.size(); ++x) s[x] *= 2;
|
for (uint x = 0; x < s.size(); ++x) s[x] *= 2;
|
||||||
|
|
||||||
@ -136,7 +136,7 @@ void BlockAnalyzer::transform(Analyzer::Scope &s) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BlockAnalyzer::analyze(QPainter &p, const Analyzer::Scope &s, bool new_frame) {
|
void BlockAnalyzer::analyze(QPainter &p, const Scope &s, bool new_frame) {
|
||||||
|
|
||||||
// y = 2 3 2 1 0 2
|
// y = 2 3 2 1 0 2
|
||||||
// . . . . # .
|
// . . . . # .
|
||||||
@ -158,7 +158,7 @@ void BlockAnalyzer::analyze(QPainter &p, const Analyzer::Scope &s, bool new_fram
|
|||||||
|
|
||||||
QPainter canvas_painter(&canvas_);
|
QPainter canvas_painter(&canvas_);
|
||||||
|
|
||||||
Analyzer::interpolate(s, scope_);
|
interpolate(s, scope_);
|
||||||
|
|
||||||
// Paint the background
|
// Paint the background
|
||||||
canvas_painter.drawPixmap(0, 0, background_);
|
canvas_painter.drawPixmap(0, 0, background_);
|
||||||
|
@ -37,7 +37,7 @@
|
|||||||
class QWidget;
|
class QWidget;
|
||||||
class QResizeEvent;
|
class QResizeEvent;
|
||||||
|
|
||||||
class BlockAnalyzer : public Analyzer::Base {
|
class BlockAnalyzer : public AnalyzerBase {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -53,8 +53,8 @@ class BlockAnalyzer : public Analyzer::Base {
|
|||||||
static const char *kName;
|
static const char *kName;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void transform(Analyzer::Scope&) override;
|
void transform(Scope&) override;
|
||||||
void analyze(QPainter &p, const Analyzer::Scope&, bool new_frame) override;
|
void analyze(QPainter &p, const Scope&, bool new_frame) override;
|
||||||
void resizeEvent(QResizeEvent*) override;
|
void resizeEvent(QResizeEvent*) override;
|
||||||
virtual void paletteChange(const QPalette&);
|
virtual void paletteChange(const QPalette&);
|
||||||
void framerateChanged() override;
|
void framerateChanged() override;
|
||||||
@ -71,7 +71,7 @@ class BlockAnalyzer : public Analyzer::Base {
|
|||||||
QPixmap topbarpixmap_;
|
QPixmap topbarpixmap_;
|
||||||
QPixmap background_;
|
QPixmap background_;
|
||||||
QPixmap canvas_;
|
QPixmap canvas_;
|
||||||
Analyzer::Scope scope_; // so we don't create a vector every frame
|
Scope scope_; // so we don't create a vector every frame
|
||||||
QVector<double> store_; // current bar heights
|
QVector<double> store_; // current bar heights
|
||||||
QVector<double> yscale_;
|
QVector<double> yscale_;
|
||||||
|
|
||||||
|
@ -36,8 +36,6 @@
|
|||||||
#include "fht.h"
|
#include "fht.h"
|
||||||
#include "analyzerbase.h"
|
#include "analyzerbase.h"
|
||||||
|
|
||||||
using Analyzer::Scope;
|
|
||||||
|
|
||||||
const int BoomAnalyzer::kColumnWidth = 4;
|
const int BoomAnalyzer::kColumnWidth = 4;
|
||||||
const int BoomAnalyzer::kMaxBandCount = 256;
|
const int BoomAnalyzer::kMaxBandCount = 256;
|
||||||
const int BoomAnalyzer::kMinBandCount = 32;
|
const int BoomAnalyzer::kMinBandCount = 32;
|
||||||
@ -45,7 +43,7 @@ const int BoomAnalyzer::kMinBandCount = 32;
|
|||||||
const char *BoomAnalyzer::kName = QT_TRANSLATE_NOOP("AnalyzerContainer", "Boom analyzer");
|
const char *BoomAnalyzer::kName = QT_TRANSLATE_NOOP("AnalyzerContainer", "Boom analyzer");
|
||||||
|
|
||||||
BoomAnalyzer::BoomAnalyzer(QWidget *parent)
|
BoomAnalyzer::BoomAnalyzer(QWidget *parent)
|
||||||
: Analyzer::Base(parent, 9),
|
: AnalyzerBase(parent, 9),
|
||||||
bands_(0),
|
bands_(0),
|
||||||
scope_(kMinBandCount),
|
scope_(kMinBandCount),
|
||||||
fg_(palette().color(QPalette::Highlight)),
|
fg_(palette().color(QPalette::Highlight)),
|
||||||
@ -119,7 +117,7 @@ void BoomAnalyzer::analyze(QPainter &p, const Scope &scope, const bool new_frame
|
|||||||
QPainter canvas_painter(&canvas_);
|
QPainter canvas_painter(&canvas_);
|
||||||
canvas_.fill(palette().color(QPalette::Window));
|
canvas_.fill(palette().color(QPalette::Window));
|
||||||
|
|
||||||
Analyzer::interpolate(scope, scope_);
|
interpolate(scope, scope_);
|
||||||
|
|
||||||
for (int i = 0, x = 0, y = 0; i < bands_; ++i, x += kColumnWidth + 1) {
|
for (int i = 0, x = 0, y = 0; i < bands_; ++i, x += kColumnWidth + 1) {
|
||||||
h = log10(scope_[i] * 256.0) * F_;
|
h = log10(scope_[i] * 256.0) * F_;
|
||||||
|
@ -36,7 +36,7 @@
|
|||||||
class QWidget;
|
class QWidget;
|
||||||
class QResizeEvent;
|
class QResizeEvent;
|
||||||
|
|
||||||
class BoomAnalyzer : public Analyzer::Base {
|
class BoomAnalyzer : public AnalyzerBase {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -44,8 +44,8 @@ class BoomAnalyzer : public Analyzer::Base {
|
|||||||
|
|
||||||
static const char *kName;
|
static const char *kName;
|
||||||
|
|
||||||
void transform(Analyzer::Scope &s) override;
|
void transform(Scope &s) override;
|
||||||
void analyze(QPainter &p, const Analyzer::Scope&, const bool new_frame) override;
|
void analyze(QPainter &p, const Scope&, const bool new_frame) override;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void changeK_barHeight(int);
|
void changeK_barHeight(int);
|
||||||
@ -59,7 +59,7 @@ class BoomAnalyzer : public Analyzer::Base {
|
|||||||
static const int kMinBandCount;
|
static const int kMinBandCount;
|
||||||
|
|
||||||
int bands_;
|
int bands_;
|
||||||
Analyzer::Scope scope_;
|
Scope scope_;
|
||||||
QColor fg_;
|
QColor fg_;
|
||||||
|
|
||||||
double K_barHeight_, F_peakSpeed_, F_;
|
double K_barHeight_, F_peakSpeed_, F_;
|
||||||
|
@ -41,23 +41,21 @@
|
|||||||
#include "fht.h"
|
#include "fht.h"
|
||||||
#include "analyzerbase.h"
|
#include "analyzerbase.h"
|
||||||
|
|
||||||
using Analyzer::Scope;
|
const int RainbowAnalyzer::kHeight[] = { 21, 33 };
|
||||||
|
const int RainbowAnalyzer::kWidth[] = { 34, 53 };
|
||||||
|
const int RainbowAnalyzer::kFrameCount[] = { 6, 16 };
|
||||||
|
const int RainbowAnalyzer::kRainbowHeight[] = { 21, 16 };
|
||||||
|
const int RainbowAnalyzer::kRainbowOverlap[] = { 13, 15 };
|
||||||
|
const int RainbowAnalyzer::kSleepingHeight[] = { 24, 33 };
|
||||||
|
|
||||||
const int Rainbow::RainbowAnalyzer::kHeight[] = { 21, 33 };
|
const char *NyanCatAnalyzer::kName = "Nyanalyzer Cat";
|
||||||
const int Rainbow::RainbowAnalyzer::kWidth[] = { 34, 53 };
|
const char *RainbowDashAnalyzer::kName = "Rainbow Dash";
|
||||||
const int Rainbow::RainbowAnalyzer::kFrameCount[] = { 6, 16 };
|
const float RainbowAnalyzer::kPixelScale = 0.02F;
|
||||||
const int Rainbow::RainbowAnalyzer::kRainbowHeight[] = { 21, 16 };
|
|
||||||
const int Rainbow::RainbowAnalyzer::kRainbowOverlap[] = { 13, 15 };
|
|
||||||
const int Rainbow::RainbowAnalyzer::kSleepingHeight[] = { 24, 33 };
|
|
||||||
|
|
||||||
const char *Rainbow::NyanCatAnalyzer::kName = "Nyanalyzer Cat";
|
RainbowAnalyzer::RainbowType RainbowAnalyzer::rainbowtype;
|
||||||
const char *Rainbow::RainbowDashAnalyzer::kName = "Rainbow Dash";
|
|
||||||
const float Rainbow::RainbowAnalyzer::kPixelScale = 0.02F;
|
|
||||||
|
|
||||||
Rainbow::RainbowAnalyzer::RainbowType Rainbow::RainbowAnalyzer::rainbowtype;
|
RainbowAnalyzer::RainbowAnalyzer(const RainbowType rbtype, QWidget *parent)
|
||||||
|
: AnalyzerBase(parent, 9),
|
||||||
Rainbow::RainbowAnalyzer::RainbowAnalyzer(const RainbowType rbtype, QWidget *parent)
|
|
||||||
: Analyzer::Base(parent, 9),
|
|
||||||
timer_id_(startTimer(kFrameIntervalMs)),
|
timer_id_(startTimer(kFrameIntervalMs)),
|
||||||
frame_(0),
|
frame_(0),
|
||||||
current_buffer_(0),
|
current_buffer_(0),
|
||||||
@ -81,20 +79,20 @@ Rainbow::RainbowAnalyzer::RainbowAnalyzer(const RainbowType rbtype, QWidget *par
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Rainbow::RainbowAnalyzer::transform(Scope &s) { fht_->spectrum(s.data()); }
|
void RainbowAnalyzer::transform(Scope &s) { fht_->spectrum(s.data()); }
|
||||||
|
|
||||||
void Rainbow::RainbowAnalyzer::timerEvent(QTimerEvent *e) {
|
void RainbowAnalyzer::timerEvent(QTimerEvent *e) {
|
||||||
|
|
||||||
if (e->timerId() == timer_id_) {
|
if (e->timerId() == timer_id_) {
|
||||||
frame_ = (frame_ + 1) % kFrameCount[rainbowtype];
|
frame_ = (frame_ + 1) % kFrameCount[rainbowtype];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Analyzer::Base::timerEvent(e);
|
AnalyzerBase::timerEvent(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Rainbow::RainbowAnalyzer::resizeEvent(QResizeEvent *e) {
|
void RainbowAnalyzer::resizeEvent(QResizeEvent *e) {
|
||||||
|
|
||||||
Q_UNUSED(e);
|
Q_UNUSED(e);
|
||||||
|
|
||||||
@ -108,7 +106,7 @@ void Rainbow::RainbowAnalyzer::resizeEvent(QResizeEvent *e) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Rainbow::RainbowAnalyzer::analyze(QPainter &p, const Analyzer::Scope &s, bool new_frame) {
|
void RainbowAnalyzer::analyze(QPainter &p, const Scope &s, bool new_frame) {
|
||||||
|
|
||||||
// Discard the second half of the transform
|
// Discard the second half of the transform
|
||||||
const int scope_size = static_cast<int>(s.size() / 2);
|
const int scope_size = static_cast<int>(s.size() / 2);
|
||||||
@ -203,8 +201,8 @@ void Rainbow::RainbowAnalyzer::analyze(QPainter &p, const Analyzer::Scope &s, bo
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Rainbow::NyanCatAnalyzer::NyanCatAnalyzer(QWidget *parent)
|
NyanCatAnalyzer::NyanCatAnalyzer(QWidget *parent)
|
||||||
: RainbowAnalyzer(Rainbow::RainbowAnalyzer::Nyancat, parent) {}
|
: RainbowAnalyzer(RainbowAnalyzer::Nyancat, parent) {}
|
||||||
|
|
||||||
Rainbow::RainbowDashAnalyzer::RainbowDashAnalyzer(QWidget *parent)
|
RainbowDashAnalyzer::RainbowDashAnalyzer(QWidget *parent)
|
||||||
: RainbowAnalyzer(Rainbow::RainbowAnalyzer::Dash, parent) {}
|
: RainbowAnalyzer(RainbowAnalyzer::Dash, parent) {}
|
||||||
|
@ -40,8 +40,7 @@ class QWidget;
|
|||||||
class QTimerEvent;
|
class QTimerEvent;
|
||||||
class QResizeEvent;
|
class QResizeEvent;
|
||||||
|
|
||||||
namespace Rainbow {
|
class RainbowAnalyzer : public AnalyzerBase {
|
||||||
class RainbowAnalyzer : public Analyzer::Base {
|
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -53,8 +52,8 @@ class RainbowAnalyzer : public Analyzer::Base {
|
|||||||
RainbowAnalyzer(const RainbowType rbtype, QWidget *parent);
|
RainbowAnalyzer(const RainbowType rbtype, QWidget *parent);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void transform(Analyzer::Scope&) override;
|
void transform(Scope&) override;
|
||||||
void analyze(QPainter &p, const Analyzer::Scope&, bool new_frame) override;
|
void analyze(QPainter &p, const Scope&, bool new_frame) override;
|
||||||
|
|
||||||
void timerEvent(QTimerEvent *e) override;
|
void timerEvent(QTimerEvent *e) override;
|
||||||
void resizeEvent(QResizeEvent *e) override;
|
void resizeEvent(QResizeEvent *e) override;
|
||||||
@ -142,6 +141,5 @@ class RainbowDashAnalyzer : public RainbowAnalyzer {
|
|||||||
|
|
||||||
static const char *kName;
|
static const char *kName;
|
||||||
};
|
};
|
||||||
} // namespace Rainbow
|
|
||||||
|
|
||||||
#endif // RAINBOWANALYZER_H
|
#endif // RAINBOWANALYZER_H
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
const char *Sonogram::kName = QT_TRANSLATE_NOOP("AnalyzerContainer", "Sonogram");
|
const char *Sonogram::kName = QT_TRANSLATE_NOOP("AnalyzerContainer", "Sonogram");
|
||||||
|
|
||||||
Sonogram::Sonogram(QWidget *parent)
|
Sonogram::Sonogram(QWidget *parent)
|
||||||
: Analyzer::Base(parent, 9) {}
|
: AnalyzerBase(parent, 9) {}
|
||||||
|
|
||||||
void Sonogram::resizeEvent(QResizeEvent *e) {
|
void Sonogram::resizeEvent(QResizeEvent *e) {
|
||||||
|
|
||||||
@ -42,7 +42,7 @@ void Sonogram::resizeEvent(QResizeEvent *e) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sonogram::analyze(QPainter &p, const Analyzer::Scope &s, bool new_frame) {
|
void Sonogram::analyze(QPainter &p, const Scope &s, bool new_frame) {
|
||||||
|
|
||||||
if (!new_frame || engine_->state() == EngineBase::State::Paused) {
|
if (!new_frame || engine_->state() == EngineBase::State::Paused) {
|
||||||
p.drawPixmap(0, 0, canvas_);
|
p.drawPixmap(0, 0, canvas_);
|
||||||
@ -52,7 +52,7 @@ void Sonogram::analyze(QPainter &p, const Analyzer::Scope &s, bool new_frame) {
|
|||||||
QPainter canvas_painter(&canvas_);
|
QPainter canvas_painter(&canvas_);
|
||||||
canvas_painter.drawPixmap(0, 0, canvas_, 1, 0, width() - 1, -1);
|
canvas_painter.drawPixmap(0, 0, canvas_, 1, 0, width() - 1, -1);
|
||||||
|
|
||||||
Analyzer::Scope::const_iterator it = s.begin(), end = s.end();
|
Scope::const_iterator it = s.begin(), end = s.end();
|
||||||
|
|
||||||
for (int y = height() - 1; y;) {
|
for (int y = height() - 1; y;) {
|
||||||
QColor c;
|
QColor c;
|
||||||
@ -81,7 +81,7 @@ void Sonogram::analyze(QPainter &p, const Analyzer::Scope &s, bool new_frame) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sonogram::transform(Analyzer::Scope &scope) {
|
void Sonogram::transform(Scope &scope) {
|
||||||
|
|
||||||
fht_->power2(scope.data());
|
fht_->power2(scope.data());
|
||||||
fht_->scale(scope.data(), 1.0 / 256);
|
fht_->scale(scope.data(), 1.0 / 256);
|
||||||
@ -90,5 +90,5 @@ void Sonogram::transform(Analyzer::Scope &scope) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Sonogram::demo(QPainter &p) {
|
void Sonogram::demo(QPainter &p) {
|
||||||
analyze(p, Analyzer::Scope(fht_->size(), 0), new_frame_);
|
analyze(p, Scope(fht_->size(), 0), new_frame_);
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
|
|
||||||
#include "analyzerbase.h"
|
#include "analyzerbase.h"
|
||||||
|
|
||||||
class Sonogram : public Analyzer::Base {
|
class Sonogram : public AnalyzerBase {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
Q_INVOKABLE explicit Sonogram(QWidget *parent);
|
Q_INVOKABLE explicit Sonogram(QWidget *parent);
|
||||||
@ -38,8 +38,8 @@ class Sonogram : public Analyzer::Base {
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
void resizeEvent(QResizeEvent *e) override;
|
void resizeEvent(QResizeEvent *e) override;
|
||||||
void analyze(QPainter &p, const Analyzer::Scope &s, bool new_frame) override;
|
void analyze(QPainter &p, const Scope &s, bool new_frame) override;
|
||||||
void transform(Analyzer::Scope &scope) override;
|
void transform(Scope &scope) override;
|
||||||
void demo(QPainter &p) override;
|
void demo(QPainter &p) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user