Formatting

This commit is contained in:
Jonas Kvinge
2021-06-12 20:53:23 +02:00
parent 427b9c1ebc
commit f786a17014
117 changed files with 444 additions and 434 deletions

View File

@@ -56,7 +56,7 @@
template class Analyzer::Base<QWidget>;
#endif
Analyzer::Base::Base(QWidget *parent, uint scopeSize)
Analyzer::Base::Base(QWidget *parent, const uint scopeSize)
: QWidget(parent),
timeout_(40),
fht_(new FHT(scopeSize)),
@@ -69,7 +69,7 @@ void Analyzer::Base::hideEvent(QHideEvent*) { timer_.stop(); }
void Analyzer::Base::showEvent(QShowEvent*) { timer_.start(timeout(), this); }
void Analyzer::Base::transform(Scope& scope) {
void Analyzer::Base::transform(Scope &scope) {
QVector<float> aux(fht_->size());
if (static_cast<long unsigned int>(aux.size()) >= scope.size()) {
@@ -93,7 +93,7 @@ void Analyzer::Base::paintEvent(QPaintEvent *e) {
switch (engine_->state()) {
case Engine::Playing: {
const Engine::Scope& thescope = engine_->scope(timeout_);
const Engine::Scope &thescope = engine_->scope(timeout_);
int i = 0;
// convert to mono here - our built in analyzers need mono, but the engines provide interleaved pcm
@@ -139,7 +139,7 @@ int Analyzer::Base::resizeExponent(int exp) {
}
int Analyzer::Base::resizeForBands(int bands) {
int Analyzer::Base::resizeForBands(const int bands) {
int exp = 0;
if (bands <= 8)
@@ -160,7 +160,7 @@ int Analyzer::Base::resizeForBands(int bands) {
}
void Analyzer::Base::demo(QPainter& p) {
void Analyzer::Base::demo(QPainter &p) {
static int t = 201; // FIXME make static to namespace perhaps
@@ -185,7 +185,7 @@ void Analyzer::Base::polishEvent() {
init();
}
void Analyzer::interpolate(const Scope& inVec, Scope& outVec) {
void Analyzer::interpolate(const Scope &inVec, Scope &outVec) {
double pos = 0.0;
const double step = static_cast<double>(inVec.size()) / outVec.size();
@@ -207,7 +207,7 @@ void Analyzer::interpolate(const Scope& inVec, Scope& outVec) {
}
void Analyzer::initSin(Scope& v, const uint size) {
void Analyzer::initSin(Scope &v, const uint size) {
double step = (M_PI * 2) / size;
double radian = 0;

View File

@@ -72,7 +72,7 @@ class Base : public QWidget {
virtual void framerateChanged() {}
protected:
explicit Base(QWidget*, uint scopeSize = 7);
explicit Base(QWidget*, const uint scopeSize = 7);
void hideEvent(QHideEvent*) override;
void showEvent(QShowEvent*) override;
@@ -82,11 +82,11 @@ class Base : public QWidget {
void polishEvent();
int resizeExponent(int);
int resizeForBands(int);
int resizeForBands(const int);
virtual void init() {}
virtual void transform(Scope&);
virtual void analyze(QPainter& p, const Scope&, bool new_frame) = 0;
virtual void demo(QPainter& p);
virtual void analyze(QPainter &p, const Scope&, const bool new_frame) = 0;
virtual void demo(QPainter &p);
protected:
QBasicTimer timer_;

View File

@@ -222,7 +222,7 @@ void AnalyzerContainer::Save() {
}
void AnalyzerContainer::AddFramerate(const QString& name, const int framerate) {
void AnalyzerContainer::AddFramerate(const QString &name, const int framerate) {
QAction *action = context_menu_framerate_->addAction(name);
group_framerate_->addAction(action);

View File

@@ -76,7 +76,7 @@ class AnalyzerContainer : public QWidget {
void SaveFramerate(const int framerate);
template <typename T>
void AddAnalyzerType();
void AddFramerate(const QString& name, const int framerate);
void AddFramerate(const QString &name, const int framerate);
private:
int current_framerate_; // fps
@@ -94,7 +94,7 @@ class AnalyzerContainer : public QWidget {
QPoint last_click_pos_;
bool ignore_next_click_;
Analyzer::Base* current_analyzer_;
Analyzer::Base *current_analyzer_;
EngineBase *engine_;
};

View File

@@ -43,9 +43,9 @@ const int BoomAnalyzer::kColumnWidth = 4;
const int BoomAnalyzer::kMaxBandCount = 256;
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),
bands_(0),
scope_(kMinBandCount),
@@ -65,15 +65,15 @@ BoomAnalyzer::BoomAnalyzer(QWidget* parent)
}
void BoomAnalyzer::changeK_barHeight(int newValue) {
void BoomAnalyzer::changeK_barHeight(const int newValue) {
K_barHeight_ = static_cast<double>(newValue) / 1000;
}
void BoomAnalyzer::changeF_peakSpeed(int newValue) {
void BoomAnalyzer::changeF_peakSpeed(const int newValue) {
F_peakSpeed_ = static_cast<double>(newValue) / 1000;
}
void BoomAnalyzer::resizeEvent(QResizeEvent* e) {
void BoomAnalyzer::resizeEvent(QResizeEvent *e) {
QWidget::resizeEvent(e);
@@ -101,7 +101,7 @@ void BoomAnalyzer::resizeEvent(QResizeEvent* e) {
}
void BoomAnalyzer::transform(Scope& s) {
void BoomAnalyzer::transform(Scope &s) {
fht_->spectrum(s.data());
fht_->scale(s.data(), 1.0 / 50);
@@ -110,7 +110,7 @@ void BoomAnalyzer::transform(Scope& s) {
}
void BoomAnalyzer::analyze(QPainter& p, const Scope& scope, bool new_frame) {
void BoomAnalyzer::analyze(QPainter &p, const Scope &scope, const bool new_frame) {
if (!new_frame || engine_->state() == Engine::Paused) {
p.drawPixmap(0, 0, canvas_);

View File

@@ -42,10 +42,10 @@ class BoomAnalyzer : public Analyzer::Base {
public:
Q_INVOKABLE explicit BoomAnalyzer(QWidget*);
static const char* kName;
static const char *kName;
void transform(Analyzer::Scope &s) override;
void analyze(QPainter &p, const Analyzer::Scope&, bool new_frame) override;
void analyze(QPainter &p, const Analyzer::Scope&, const bool new_frame) override;
public slots:
void changeK_barHeight(int);

View File

@@ -40,13 +40,13 @@ FHT::~FHT() {}
int FHT::sizeExp() const { return exp2_; }
int FHT::size() const { return num_; }
float* FHT::buf_() { return buf_vector_.data(); }
float* FHT::tab_() { return tab_vector_.data(); }
int* FHT::log_() { return log_vector_.data(); }
float *FHT::buf_() { return buf_vector_.data(); }
float *FHT::tab_() { return tab_vector_.data(); }
int *FHT::log_() { return log_vector_.data(); }
void FHT::makeCasTable(void) {
float* costab = tab_();
float* sintab = tab_() + num_ / 2 + 1;
float *costab = tab_();
float *sintab = tab_() + num_ / 2 + 1;
for (int ul = 0; ul < num_; ul++) {
float d = M_PI * ul / (num_ / 2);
@@ -58,15 +58,15 @@ void FHT::makeCasTable(void) {
}
}
void FHT::scale(float* p, float d) {
void FHT::scale(float *p, float d) {
for (int i = 0; i < (num_ / 2); i++) *p++ *= d;
}
void FHT::ewma(float* d, float* s, float w) {
void FHT::ewma(float *d, float *s, float w) {
for (int i = 0; i < (num_ / 2); i++, d++, s++) *d = *d * w + *s * (1 - w);
}
void FHT::logSpectrum(float* out, float* p) {
void FHT::logSpectrum(float *out, float *p) {
int n = num_ / 2, i = 0, j = 0, k = 0, *r = nullptr;
if (log_vector_.size() < n) {
@@ -93,7 +93,7 @@ void FHT::logSpectrum(float* out, float* p) {
}
void FHT::semiLogSpectrum(float* p) {
void FHT::semiLogSpectrum(float *p) {
power2(p);
for (int i = 0; i < (num_ / 2); i++, p++) {
float e = 10.0 * log10(sqrt(*p / 2));
@@ -101,24 +101,24 @@ void FHT::semiLogSpectrum(float* p) {
}
}
void FHT::spectrum(float* p) {
void FHT::spectrum(float *p) {
power2(p);
for (int i = 0; i < (num_ / 2); i++, p++)
*p = static_cast<float>(sqrt(*p / 2));
}
void FHT::power(float* p) {
void FHT::power(float *p) {
power2(p);
for (int i = 0; i < (num_ / 2); i++) *p++ /= 2;
}
void FHT::power2(float* p) {
void FHT::power2(float *p) {
_transform(p, num_, 0);
*p = static_cast<float>(2 * pow(*p, 2));
p++;
float* q = p + num_ - 2;
float *q = p + num_ - 2;
for (int i = 1; i < (num_ / 2); i++) {
*p = static_cast<float>(pow(*p, 2) + pow(*q, 2));
p++;
@@ -126,14 +126,14 @@ void FHT::power2(float* p) {
}
}
void FHT::transform(float* p) {
void FHT::transform(float *p) {
if (num_ == 8)
transform8(p);
else
_transform(p, num_, 0);
}
void FHT::transform8(float* p) {
void FHT::transform8(float *p) {
float a = 0.0, b = 0.0, c = 0.0, d = 0.0, e = 0.0, f = 0.0, g = 0.0, h = 0.0, b_f2 = 0.0, d_h2 = 0.0;
float a_c_eg = 0.0, a_ce_g = 0.0, ac_e_g = 0.0, aceg = 0.0, b_df_h = 0.0, bdfh = 0.0;
@@ -162,7 +162,7 @@ void FHT::transform8(float* p) {
}
void FHT::_transform(float* p, int n, int k) {
void FHT::_transform(float *p, int n, int k) {
if (n == 8) {
transform8(p + k);

View File

@@ -41,9 +41,9 @@ class FHT {
QVector<float> tab_vector_;
QVector<int> log_vector_;
float* buf_();
float* tab_();
int* log_();
float *buf_();
float *tab_();
int *log_();
/**
* Create a table of "cas" (cosine and sine) values.
@@ -76,7 +76,7 @@ class FHT {
* @param s is fresh input.
* @param w is the weighting factor.
*/
void ewma(float* d, float* s, float w);
void ewma(float *d, float *s, float w);
/**
* Logarithmic audio spectrum. Maps semi-logarithmic spectrum
@@ -85,7 +85,7 @@ class FHT {
* @param p is the input array.
* @param out is the spectrum.
*/
void logSpectrum(float* out, float* p);
void logSpectrum(float *out, float *p);
/**
* Semi-logarithmic audio spectrum.

View File

@@ -50,13 +50,13 @@ 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";
const char* Rainbow::RainbowDashAnalyzer::kName = "Rainbow Dash";
const char *Rainbow::NyanCatAnalyzer::kName = "Nyanalyzer Cat";
const char *Rainbow::RainbowDashAnalyzer::kName = "Rainbow Dash";
const float Rainbow::RainbowAnalyzer::kPixelScale = 0.02f;
Rainbow::RainbowAnalyzer::RainbowType Rainbow::RainbowAnalyzer::rainbowtype;
Rainbow::RainbowAnalyzer::RainbowAnalyzer(const RainbowType& rbtype, QWidget* parent)
Rainbow::RainbowAnalyzer::RainbowAnalyzer(const RainbowType &rbtype, QWidget *parent)
: Analyzer::Base(parent, 9),
timer_id_(startTimer(kFrameIntervalMs)),
frame_(0),
@@ -82,9 +82,9 @@ Rainbow::RainbowAnalyzer::RainbowAnalyzer(const RainbowType& rbtype, QWidget* pa
}
void Rainbow::RainbowAnalyzer::transform(Scope& s) { fht_->spectrum(s.data()); }
void Rainbow::RainbowAnalyzer::transform(Scope &s) { fht_->spectrum(s.data()); }
void Rainbow::RainbowAnalyzer::timerEvent(QTimerEvent* e) {
void Rainbow::RainbowAnalyzer::timerEvent(QTimerEvent *e) {
if (e->timerId() == timer_id_) {
frame_ = (frame_ + 1) % kFrameCount[rainbowtype];
@@ -95,7 +95,7 @@ void Rainbow::RainbowAnalyzer::timerEvent(QTimerEvent* e) {
}
void Rainbow::RainbowAnalyzer::resizeEvent(QResizeEvent* e) {
void Rainbow::RainbowAnalyzer::resizeEvent(QResizeEvent *e) {
Q_UNUSED(e);
@@ -109,7 +109,7 @@ void Rainbow::RainbowAnalyzer::resizeEvent(QResizeEvent* e) {
}
void Rainbow::RainbowAnalyzer::analyze(QPainter& p, const Analyzer::Scope& s, bool new_frame) {
void Rainbow::RainbowAnalyzer::analyze(QPainter &p, const Analyzer::Scope &s, bool new_frame) {
// Discard the second half of the transform
const int scope_size = static_cast<int>(s.size() / 2);
@@ -117,7 +117,7 @@ void Rainbow::RainbowAnalyzer::analyze(QPainter& p, const Analyzer::Scope& s, bo
if ((new_frame && is_playing_) || (buffer_[0].isNull() && buffer_[1].isNull())) {
// Transform the music into rainbows!
for (int band = 0; band < kRainbowBands; ++band) {
float* band_start = history_ + band * kHistorySize;
float *band_start = history_ + band * kHistorySize;
// Move the history of each band across by 1 frame.
memmove(band_start, band_start + 1, (kHistorySize - 1) * sizeof(float));
@@ -139,8 +139,8 @@ void Rainbow::RainbowAnalyzer::analyze(QPainter& p, const Analyzer::Scope& s, bo
// Create polylines for the rainbows.
QPointF polyline[kRainbowBands * kHistorySize];
QPointF* dest = polyline;
float* source = history_;
QPointF *dest = polyline;
float *source = history_;
const float top_of = static_cast<float>(height()) / 2 - static_cast<float>(kRainbowHeight[rainbowtype]) / 2;
for (int band = 0; band < kRainbowBands; ++band) {
@@ -204,8 +204,8 @@ void Rainbow::RainbowAnalyzer::analyze(QPainter& p, const Analyzer::Scope& s, bo
}
Rainbow::NyanCatAnalyzer::NyanCatAnalyzer(QWidget* parent)
Rainbow::NyanCatAnalyzer::NyanCatAnalyzer(QWidget *parent)
: RainbowAnalyzer(Rainbow::RainbowAnalyzer::Nyancat, parent) {}
Rainbow::RainbowDashAnalyzer::RainbowDashAnalyzer(QWidget* parent)
Rainbow::RainbowDashAnalyzer::RainbowDashAnalyzer(QWidget *parent)
: RainbowAnalyzer(Rainbow::RainbowAnalyzer::Dash, parent) {}

View File

@@ -129,18 +129,18 @@ class NyanCatAnalyzer : public RainbowAnalyzer {
Q_OBJECT
public:
Q_INVOKABLE explicit NyanCatAnalyzer(QWidget* parent);
Q_INVOKABLE explicit NyanCatAnalyzer(QWidget *parent);
static const char* kName;
static const char *kName;
};
class RainbowDashAnalyzer : public RainbowAnalyzer {
Q_OBJECT
public:
Q_INVOKABLE explicit RainbowDashAnalyzer(QWidget* parent);
Q_INVOKABLE explicit RainbowDashAnalyzer(QWidget *parent);
static const char* kName;
static const char *kName;
};
}