00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef VUMETER_H
00024 #define VUMETER_H
00025
00026 #include <QWidget>
00027 #include <QString>
00028 #include <QVector>
00029 #include <QTimer>
00030
00031 class AudioBus;
00032 class AudioChannel;
00033 class VUMeterLevel;
00034 class QLabel;
00035
00036 class VUMeterRuler : public QWidget
00037 {
00038 Q_OBJECT
00039
00040 public:
00041 VUMeterRuler(QWidget* parent);
00042
00043 protected:
00044 void paintEvent( QPaintEvent* e);
00045
00046
00047 private:
00048 std::vector<int> presetMark;
00049 std::vector<int> lineMark;
00050 QFont m_font;
00051 };
00052
00053
00054
00055 class VUMeter : public QWidget
00056 {
00057 Q_OBJECT
00058
00059 public:
00060 VUMeter(QWidget* parent, AudioBus* bus);
00061 ~VUMeter();
00062
00063 void reset();
00064
00065 static QVector<float>* vumeter_lut();
00066
00067 protected:
00068 void resizeEvent( QResizeEvent* e);
00069 void paintEvent( QPaintEvent* e);
00070 QSize sizeHint () const;
00071 QSize minimumSizeHint () const;
00072
00073 private:
00074 bool isActive;
00075 int m_channels;
00076 int m_minSpace;
00077 QString m_name;
00078 QLabel* channelNameLabel;
00079 VUMeterRuler* ruler;
00080 static QVector<float> lut;
00081 QList<VUMeterLevel*> m_levels;
00082
00083 static void calculate_lut_data();
00084
00085 private slots:
00086 void peak_monitoring_stopped();
00087 void peak_monitoring_started();
00088 };
00089
00102 inline QVector<float>* VUMeter::vumeter_lut()
00103 {
00104 if (lut.isEmpty()) {
00105 calculate_lut_data();
00106 }
00107 return &lut;
00108 }
00109
00110
00111
00112 class VUMeterOverLed : public QWidget
00113 {
00114 Q_OBJECT
00115
00116 public:
00117
00118 VUMeterOverLed(QWidget* parent);
00119
00120 public slots:
00127 void set_active(bool b);
00128
00129 protected:
00130 void paintEvent( QPaintEvent* e);
00131
00132
00133 private:
00134 bool isActive;
00135 };
00136
00137
00138 class VUMeterLevel : public QWidget
00139 {
00140 Q_OBJECT
00141
00142 public:
00143 VUMeterLevel(QWidget* parent, AudioChannel* chan);
00144
00145 void reset();
00146
00147 protected:
00148 void paintEvent( QPaintEvent* e);
00149 void resizeEvent( QResizeEvent * );
00150 QSize sizeHint () const;
00151 QSize minimumSizeHint () const;
00152
00153
00154 private:
00155 bool activeTail;
00156 bool peakHoldFalling;
00157 AudioChannel* m_channel;
00158 QColor levelClearColor;
00159 QPixmap levelPixmap;
00160 QPixmap clearPixmap;
00161 QTimer timer,
00162 phTimer;
00163 QLinearGradient gradient2D;
00164
00165 float presetMark[7];
00166 float tailDeltaY;
00167 float prevPeakValue;
00168 float peak;
00169 float rms;
00170 float maxFalloff;
00171 float peakHoldValue;
00172 float peakHistory[50];
00173 short unsigned int rmsIndex;
00174 short unsigned int overCount;
00175
00176 void resize_level_pixmap();
00177 void create_gradients();
00178 int get_meter_position(float);
00179
00180 private slots:
00181 void stop();
00182 void start();
00183 void update_peak();
00184 void reset_peak_hold_value();
00185
00186 signals:
00187
00193 void activate_over_led(bool);
00194
00195 };
00196
00197
00198 #endif
00199