2014-05-03 22:54:38 -07:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <obs.hpp>
|
|
|
|
#include <QWidget>
|
2017-02-05 21:56:01 -08:00
|
|
|
#include <QSharedPointer>
|
|
|
|
#include <QTimer>
|
|
|
|
#include <QMutex>
|
|
|
|
#include <QList>
|
2014-05-03 22:54:38 -07:00
|
|
|
|
2015-06-20 18:56:07 -07:00
|
|
|
class QPushButton;
|
2017-02-05 21:56:01 -08:00
|
|
|
class VolumeMeterTimer;
|
2015-06-20 18:56:07 -07:00
|
|
|
|
2014-07-14 09:32:39 -07:00
|
|
|
class VolumeMeter : public QWidget
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
2015-01-13 23:01:14 -08:00
|
|
|
Q_PROPERTY(QColor bkColor READ getBkColor WRITE setBkColor DESIGNABLE true)
|
|
|
|
Q_PROPERTY(QColor magColor READ getMagColor WRITE setMagColor DESIGNABLE true)
|
|
|
|
Q_PROPERTY(QColor peakColor READ getPeakColor WRITE setPeakColor DESIGNABLE true)
|
|
|
|
Q_PROPERTY(QColor peakHoldColor READ getPeakHoldColor WRITE setPeakHoldColor DESIGNABLE true)
|
|
|
|
|
2014-07-14 09:32:39 -07:00
|
|
|
private:
|
2017-02-05 21:56:01 -08:00
|
|
|
static QWeakPointer<VolumeMeterTimer> updateTimer;
|
|
|
|
QSharedPointer<VolumeMeterTimer> updateTimerRef;
|
|
|
|
float curMag = 0.0f, curPeak = 0.0f, curPeakHold = 0.0f;
|
|
|
|
|
|
|
|
inline void calcLevels();
|
|
|
|
|
|
|
|
QMutex dataMutex;
|
|
|
|
float mag = 0.0f, peak = 0.0f, peakHold = 0.0f;
|
|
|
|
float multiple = 0.0f;
|
|
|
|
uint64_t lastUpdateTime = 0;
|
|
|
|
|
2014-07-14 09:32:39 -07:00
|
|
|
QColor bkColor, magColor, peakColor, peakHoldColor;
|
2015-03-22 14:58:07 -07:00
|
|
|
|
2014-07-14 09:32:39 -07:00
|
|
|
public:
|
|
|
|
explicit VolumeMeter(QWidget *parent = 0);
|
2017-02-05 21:56:01 -08:00
|
|
|
~VolumeMeter();
|
|
|
|
|
2014-07-14 09:32:39 -07:00
|
|
|
void setLevels(float nmag, float npeak, float npeakHold);
|
2015-01-13 23:01:14 -08:00
|
|
|
QColor getBkColor() const;
|
|
|
|
void setBkColor(QColor c);
|
|
|
|
QColor getMagColor() const;
|
|
|
|
void setMagColor(QColor c);
|
|
|
|
QColor getPeakColor() const;
|
|
|
|
void setPeakColor(QColor c);
|
|
|
|
QColor getPeakHoldColor() const;
|
|
|
|
void setPeakHoldColor(QColor c);
|
|
|
|
|
2014-07-14 09:32:39 -07:00
|
|
|
protected:
|
|
|
|
void paintEvent(QPaintEvent *event);
|
2017-02-05 21:56:01 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
class VolumeMeterTimer : public QTimer {
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
inline VolumeMeterTimer() : QTimer() {}
|
|
|
|
|
|
|
|
void AddVolControl(VolumeMeter *meter);
|
|
|
|
void RemoveVolControl(VolumeMeter *meter);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual void timerEvent(QTimerEvent *event) override;
|
|
|
|
QList<VolumeMeter*> volumeMeters;
|
2014-07-14 09:32:39 -07:00
|
|
|
};
|
2014-05-03 22:54:38 -07:00
|
|
|
|
|
|
|
class QLabel;
|
|
|
|
class QSlider;
|
2015-03-22 14:58:07 -07:00
|
|
|
class MuteCheckBox;
|
2014-05-03 22:54:38 -07:00
|
|
|
|
|
|
|
class VolControl : public QWidget {
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
private:
|
|
|
|
OBSSource source;
|
2014-05-20 07:26:18 -07:00
|
|
|
QLabel *nameLabel;
|
|
|
|
QLabel *volLabel;
|
2014-07-14 09:32:39 -07:00
|
|
|
VolumeMeter *volMeter;
|
2014-05-20 07:26:18 -07:00
|
|
|
QSlider *slider;
|
2015-03-22 14:58:07 -07:00
|
|
|
MuteCheckBox *mute;
|
2015-06-20 18:56:07 -07:00
|
|
|
QPushButton *config = nullptr;
|
2014-06-03 04:51:27 -07:00
|
|
|
float levelTotal;
|
|
|
|
float levelCount;
|
2014-11-19 07:41:07 -08:00
|
|
|
obs_fader_t *obs_fader;
|
2014-11-23 12:34:15 -08:00
|
|
|
obs_volmeter_t *obs_volmeter;
|
2014-05-03 22:54:38 -07:00
|
|
|
|
2016-01-07 19:48:36 -08:00
|
|
|
static void OBSVolumeChanged(void *param, float db);
|
|
|
|
static void OBSVolumeLevel(void *data, float level, float mag,
|
|
|
|
float peak, float muted);
|
2015-03-22 14:58:07 -07:00
|
|
|
static void OBSVolumeMuted(void *data, calldata_t *calldata);
|
2014-05-03 22:54:38 -07:00
|
|
|
|
2015-06-20 18:56:07 -07:00
|
|
|
void EmitConfigClicked();
|
|
|
|
|
2014-05-03 22:54:38 -07:00
|
|
|
private slots:
|
2014-11-19 07:41:07 -08:00
|
|
|
void VolumeChanged();
|
2015-03-22 14:58:07 -07:00
|
|
|
void VolumeMuted(bool muted);
|
2015-05-05 17:36:13 -07:00
|
|
|
void VolumeLevel(float mag, float peak, float peakHold, bool muted);
|
2015-03-22 14:58:07 -07:00
|
|
|
|
|
|
|
void SetMuted(bool checked);
|
2014-05-03 22:54:38 -07:00
|
|
|
void SliderChanged(int vol);
|
2014-12-28 03:31:21 -08:00
|
|
|
void updateText();
|
2014-05-03 22:54:38 -07:00
|
|
|
|
2015-06-20 18:56:07 -07:00
|
|
|
signals:
|
|
|
|
void ConfigClicked();
|
|
|
|
|
2014-05-03 22:54:38 -07:00
|
|
|
public:
|
2015-06-20 18:56:07 -07:00
|
|
|
VolControl(OBSSource source, bool showConfig = false);
|
2014-05-03 22:54:38 -07:00
|
|
|
~VolControl();
|
|
|
|
|
2014-09-25 17:44:05 -07:00
|
|
|
inline obs_source_t *GetSource() const {return source;}
|
2014-07-08 11:58:48 -07:00
|
|
|
|
|
|
|
QString GetName() const;
|
|
|
|
void SetName(const QString &newName);
|
2014-05-03 22:54:38 -07:00
|
|
|
};
|