-
Notifications
You must be signed in to change notification settings - Fork 0
/
analyzerbase.h
99 lines (70 loc) · 2.2 KB
/
analyzerbase.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
// Author: Max Howell <[email protected]>, (C) 2004
// Maintainer: Martin Sandsmark <[email protected]>, (C) 2009
// Copyright: See the COPYING file shipped with this distribution
#ifndef ANALYZERBASE_H
#define ANALYZERBASE_H
#ifdef __FreeBSD__
#include <sys/types.h>
#endif
#include "fht.h" //stack allocated and convenience
#include <qpixmap.h> //stack allocated and convenience
#include <qtimer.h> //stack allocated
#include <qwidget.h> //baseclass
#include <vector> //included for convenience
#include <phonon/audiodataoutput.h>
class QEvent;
class QPaintEvent;
class QResizeEvent;
namespace Analyzer {
typedef std::vector<float> Scope;
class Base : public QWidget
{
Q_OBJECT
public slots:
void drawFrame(const QMap<Phonon::AudioDataOutput::Channel, QVector<qint16> > &thescope);
protected:
Base(QWidget*, uint = 7);
~Base() { delete m_fht; }
int resizeExponent(int);
int resizeForBands(int);
virtual void transform(QVector<float>&);
virtual void analyze(const QVector<float>&) = 0;
virtual void paused();
virtual void demo();
FHT *m_fht;
};
class Base2D : public Base
{
Q_OBJECT
public:
const QPixmap *canvas() const { return &m_canvas; }
// private slots:
// void draw() { drawFrame(); bitBlt( this, 0, 0, canvas() ); }
protected:
Base2D( QWidget*, uint scopeSize = 7);
QPixmap *canvas() { return &m_canvas; }
void eraseCanvas() { m_canvas.fill(Qt::transparent); }
void paintEvent( QPaintEvent* );
void resizeEvent( QResizeEvent* );
protected slots:
virtual void init() {}
private:
QPixmap m_canvas;
};
class Factory
{
//Currently this is a rather small class, its only purpose
//to ensure that making changes to analyzers will not require
//rebuilding the world!
//eventually it would be better to make analyzers pluggable
//but I can't be arsed, nor can I see much reason to do so
//yet!
public:
static QWidget* createAnalyzer(QWidget*);
static QWidget* createPlaylistAnalyzer(QWidget *);
};
void interpolate(const QVector<float>&, QVector<float>&);
void initSin(QVector<float>&, const uint = 6000);
} //END namespace Analyzer
using Analyzer::Scope;
#endif