~ubuntu-branches/ubuntu/natty/kdemultimedia/natty-proposed

« back to all changes in this revision

Viewing changes to dragonplayer/src/app/analyzer/analyzerBase.h

  • Committer: Bazaar Package Importer
  • Author(s): Debian Qt/KDE Maintainers
  • Date: 2011-05-26 02:41:36 UTC
  • mfrom: (0.2.3 upstream)
  • mto: This revision was merged to the branch mainline in revision 108.
  • Revision ID: james.westby@ubuntu.com-20110526024136-jjwsigfy402jhupm
Tags: upstream-4.6.3
ImportĀ upstreamĀ versionĀ 4.6.3

Show diffs side-by-side

added added

removed removed

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