Tweak nyan cat's values a bit to make him more interesting

This commit is contained in:
David Sansome 2011-06-23 00:22:56 +00:00
parent dad22297d1
commit db26c788f4
2 changed files with 7 additions and 6 deletions

View File

@ -18,7 +18,7 @@
#include "nyancatanalyzer.h"
#include "core/logging.h"
#include <algorithm>
#include <cmath>
#include <QTimerEvent>
@ -73,7 +73,7 @@ void NyanCatAnalyzer::analyze(QPainter& p, const Analyzer::Scope& s) {
for (int band=0 ; band<kRainbowBands ; ++band) {
float* accumulator = &history_[(band+1) * kHistorySize - 1];
for (int i=0 ; i<samples_per_band ; ++i) {
*accumulator += qAbs(s[sample++]);
*accumulator += s[sample++];
}
}
@ -85,11 +85,12 @@ void NyanCatAnalyzer::analyze(QPainter& p, const Analyzer::Scope& s) {
for (int band=0 ; band<kRainbowBands ; ++band) {
// Calculate the Y position of this band.
float y = float(height()) / (kRainbowBands) * (band + 0.5);
const float y = float(height()) / (kRainbowBands + 2) * (band + 0.5);
const float band_scale = std::pow(2, band);
// Add each point in the line.
for (int x=0 ; x<kHistorySize ; ++x) {
*dest = QPointF(px_per_frame * x, y + *source * kPixelScale * (band+1));
*dest = QPointF(px_per_frame * x, y + *source * kPixelScale * band_scale);
++ dest;
++ source;
}

View File

@ -43,9 +43,9 @@ private:
static const int kCatFrameCount = 5;
static const int kRainbowOverlap = 13;
static const int kHistorySize = 256;
static const int kHistorySize = 128;
static const int kRainbowBands = 6;
static const float kPixelScale = 0.01;
static const float kPixelScale = 0.03;
static const int kFrameIntervalMs = 150;