kwave  18.07.70
LevelMeter.h
Go to the documentation of this file.
1 /*************************************************************************
2  LevelMeter.h - multi-track audio level meter
3  -------------------
4  view copyright : Copyright 2002 Rik Hemsley (rikkus) <rik@kde.org>
5 
6  begin : Mon Nov 17 2003
7  copyright : (C) 2003 by Thomas Eschenbacher
8  email : Thomas.Eschenbacher@gmx.de
9  ***************************************************************************/
10 
11 /***************************************************************************
12  * *
13  * This program is free software; you can redistribute it and/or modify *
14  * it under the terms of the GNU General Public License as published by *
15  * the Free Software Foundation; either version 2 of the License, or *
16  * (at your option) any later version. *
17  * *
18  ***************************************************************************/
19 
20 #ifndef LEVEL_METER_H
21 #define LEVEL_METER_H
22 
23 #include "config.h"
24 
25 #include <QColor>
26 #include <QQueue>
27 #include <QTimer>
28 #include <QVector>
29 #include <QWidget>
30 
31 #include "libkwave/Sample.h"
32 #include "libkwave/SampleArray.h"
33 
34 class QPaintEvent;
35 class QTimer;
36 
37 namespace Kwave
38 {
39  class LevelMeter: public QWidget
40  {
41  Q_OBJECT
42  public:
44  explicit LevelMeter(QWidget *parent);
45 
47  virtual ~LevelMeter() Q_DECL_OVERRIDE;
48 
50  virtual void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE;
51 
53  virtual void resizeEvent(QResizeEvent *) Q_DECL_OVERRIDE;
54 
55  public slots:
56 
58  virtual void setTracks(unsigned int tracks);
59 
64  virtual void setSampleRate(double rate);
65 
71  virtual void updateTrack(unsigned int track,
72  const Kwave::SampleArray &buffer);
73 
77  virtual void reset();
78 
84  virtual void drawContents();
85 
86  protected slots:
87 
89  virtual void timedUpdate();
90 
91  protected:
92 
103  virtual void enqueue(unsigned int track, float fast, float peak,
104  unsigned int queue_depth);
105 
115  virtual bool dequeue(unsigned int track, float &fast, float &peak);
116 
121  void drawScale(QPainter &p);
122 
123  private:
124 
126  int m_tracks;
127 
130 
132  QVector<float> m_yf;
133 
135  QVector<float> m_yp;
136 
138  QVector< QQueue<float> > m_fast_queue;
139 
141  QVector< QQueue<float> > m_peak_queue;
142 
144  QVector<float> m_current_fast;
145 
147  QVector<float> m_current_peak;
148 
150  QTimer *m_timer;
151 
153  QColor m_color_low;
154 
157 
159  QColor m_color_high;
160 
161  };
162 }
163 
164 #endif /* LEVEL_METER_H */
165 
166 //***************************************************************************
167 //***************************************************************************
virtual void enqueue(unsigned int track, float fast, float peak, unsigned int queue_depth)
Definition: LevelMeter.cpp:192
virtual void drawContents()
Definition: LevelMeter.cpp:344
Definition: App.h:33
QVector< float > m_yp
Definition: LevelMeter.h:135
QVector< float > m_yf
Definition: LevelMeter.h:132
QColor m_color_normal
Definition: LevelMeter.h:156
QVector< float > m_current_fast
Definition: LevelMeter.h:144
virtual ~LevelMeter() Q_DECL_OVERRIDE
Definition: LevelMeter.cpp:71
virtual bool dequeue(unsigned int track, float &fast, float &peak)
Definition: LevelMeter.cpp:226
virtual void setSampleRate(double rate)
Definition: LevelMeter.cpp:97
QVector< QQueue< float > > m_peak_queue
Definition: LevelMeter.h:141
QVector< QQueue< float > > m_fast_queue
Definition: LevelMeter.h:138
QTimer * m_timer
Definition: LevelMeter.h:150
virtual void resizeEvent(QResizeEvent *) Q_DECL_OVERRIDE
Definition: LevelMeter.cpp:83
virtual void setTracks(unsigned int tracks)
Definition: LevelMeter.cpp:89
LevelMeter(QWidget *parent)
Definition: LevelMeter.cpp:54
virtual void timedUpdate()
Definition: LevelMeter.cpp:250
virtual void reset()
Definition: LevelMeter.cpp:174
virtual void updateTrack(unsigned int track, const Kwave::SampleArray &buffer)
Definition: LevelMeter.cpp:104
virtual void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE
Definition: LevelMeter.cpp:77
QVector< float > m_current_peak
Definition: LevelMeter.h:147
void drawScale(QPainter &p)
Definition: LevelMeter.cpp:272