diff --git a/data/nyancat.png b/data/nyancat.png index a129ea0f2..5af9a0028 100644 Binary files a/data/nyancat.png and b/data/nyancat.png differ diff --git a/src/analyzers/analyzerbase.cpp b/src/analyzers/analyzerbase.cpp index 8c5d2626e..d23a3fd75 100644 --- a/src/analyzers/analyzerbase.cpp +++ b/src/analyzers/analyzerbase.cpp @@ -49,6 +49,7 @@ Analyzer::Base::Base( QWidget *parent, uint scopeSize ) , m_engine(NULL) , m_lastScope(512) , new_frame_(false) + , is_playing_(false) { } @@ -81,16 +82,14 @@ void Analyzer::Base::transform( Scope &scope ) //virtual void Analyzer::Base::paintEvent(QPaintEvent * e) { - EngineBase *engine = m_engine; - QPainter p(this); p.fillRect(e->rect(), palette().color(QPalette::Window)); - switch( engine->state() ) + switch( m_engine->state() ) { case Engine::Playing: { - const Engine::Scope &thescope = engine->scope(); + const Engine::Scope &thescope = m_engine->scope(); int i = 0; // convert to mono here - our built in analyzers need mono, but we the engines provide interleaved pcm @@ -100,6 +99,7 @@ void Analyzer::Base::paintEvent(QPaintEvent * e) i += 2; } + is_playing_ = true; transform( m_lastScope ); analyze( p, m_lastScope, new_frame_ ); @@ -108,13 +108,16 @@ void Analyzer::Base::paintEvent(QPaintEvent * e) break; } case Engine::Paused: + is_playing_ = false; analyze(p, m_lastScope, new_frame_); break; default: + is_playing_ = false; demo(p); } + new_frame_ = false; } @@ -152,9 +155,6 @@ int Analyzer::Base::resizeForBands( int bands ) return m_fht->size() / 2; } -void Analyzer::Base::paused(QPainter&) //virtual -{} - void Analyzer::Base::demo(QPainter& p) //virtual { static int t = 201; //FIXME make static to namespace perhaps diff --git a/src/analyzers/analyzerbase.h b/src/analyzers/analyzerbase.h index b7f751280..dc79af002 100644 --- a/src/analyzers/analyzerbase.h +++ b/src/analyzers/analyzerbase.h @@ -68,7 +68,6 @@ protected: virtual void init() {} virtual void transform( Scope& ); virtual void analyze( QPainter& p, const Scope&, bool new_frame) = 0; - virtual void paused(QPainter& p); virtual void demo(QPainter& p); protected: @@ -79,6 +78,7 @@ protected: Scope m_lastScope; bool new_frame_; + bool is_playing_; }; diff --git a/src/analyzers/nyancatanalyzer.cpp b/src/analyzers/nyancatanalyzer.cpp index 5c0b107ab..39ea101a0 100644 --- a/src/analyzers/nyancatanalyzer.cpp +++ b/src/analyzers/nyancatanalyzer.cpp @@ -78,7 +78,8 @@ void NyanCatAnalyzer::analyze(QPainter& p, const Analyzer::Scope& s, bool new_fr // Discard the second half of the transform const int scope_size = s.size() / 2; - if (new_frame) { + if ((new_frame && is_playing_) || + (buffer_[0].isNull() && buffer_[1].isNull())) { // Transform the music into rainbows! for (int band=0 ; band