Clementine-audio-player-Mac.../src/analyzers/analyzerbase.h

91 lines
2.0 KiB
C
Raw Normal View History

2009-12-24 20:16:07 +01:00
// Maintainer: Max Howell <max.howell@methylblue.com>, (C) 2004
// Copyright: See COPYING file that comes with this distribution
#ifndef ANALYZERBASE_H
#define ANALYZERBASE_H
#ifdef __FreeBSD__
#include <sys/types.h>
#endif
2010-08-28 20:48:16 +02:00
#include "core/fht.h" //stack allocated and convenience
#include "engines/engine_fwd.h"
2009-12-24 20:16:07 +01:00
#include <QPixmap> //stack allocated and convenience
#include <QBasicTimer> //stack allocated
2009-12-24 20:16:07 +01:00
#include <QWidget> //baseclass
2010-08-28 20:48:16 +02:00
#include <vector> //included for convenience
#include <QGLWidget> //baseclass
#ifdef Q_WS_MACX
#include <OpenGL/gl.h> //included for convenience
#include <OpenGL/glu.h> //included for convenience
#else
#include <GL/gl.h> //included for convenience
#include <GL/glu.h> //included for convenience
#endif
2009-12-24 20:16:07 +01:00
class QEvent;
class QPaintEvent;
class QResizeEvent;
namespace Analyzer {
2010-08-28 20:48:16 +02:00
typedef std::vector<float> Scope;
2009-12-24 20:16:07 +01:00
class Base : public QWidget
{
Q_OBJECT
2010-08-28 20:48:16 +02:00
public:
~Base() { delete m_fht; }
uint timeout() const { return m_timeout; }
void set_engine(EngineBase* engine) { m_engine = engine; }
2009-12-24 20:16:07 +01:00
void changeTimeout( uint newTimeout ) {
m_timeout = newTimeout;
if (m_timer.isActive()) {
m_timer.stop();
m_timer.start(m_timeout, this);
}
}
2009-12-24 20:16:07 +01:00
protected:
2010-08-28 20:48:16 +02:00
Base( QWidget*, uint scopeSize = 7 );
2009-12-24 20:16:07 +01:00
2010-08-28 20:48:16 +02:00
void hideEvent(QHideEvent *);
void showEvent(QShowEvent *);
2009-12-24 20:16:07 +01:00
void paintEvent( QPaintEvent* );
2010-08-28 20:48:16 +02:00
void timerEvent(QTimerEvent *);
2009-12-24 20:16:07 +01:00
void polishEvent();
2010-08-28 20:48:16 +02:00
int resizeExponent( int );
int resizeForBands( int );
2009-12-24 20:16:07 +01:00
virtual void init() {}
2010-08-28 20:48:16 +02:00
virtual void transform( Scope& );
virtual void analyze( QPainter& p, const Scope& ) = 0;
2009-12-24 20:16:07 +01:00
virtual void paused(QPainter& p);
virtual void demo(QPainter& p);
protected:
2010-08-28 20:48:16 +02:00
QBasicTimer m_timer;
uint m_timeout;
FHT *m_fht;
2009-12-24 20:16:07 +01:00
EngineBase* m_engine;
Scope m_lastScope;
};
2010-08-28 20:48:16 +02:00
2009-12-24 20:16:07 +01:00
void interpolate( const Scope&, Scope& );
void initSin( Scope&, const uint = 6000 );
} //END namespace Analyzer
using Analyzer::Scope;
#endif