From 4b2720ed4f29c2d7c66cf62aa603fa253f49d8df Mon Sep 17 00:00:00 2001 From: Jonas Suhr Christensen Date: Thu, 17 Apr 2014 13:56:35 +0200 Subject: Added values to signals. --- dgedit/volumefader.cc | 21 ++++++++++++++++++++- dgedit/volumefader.h | 12 ++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) (limited to 'dgedit') diff --git a/dgedit/volumefader.cc b/dgedit/volumefader.cc index 9a153a6..c7cb9d0 100644 --- a/dgedit/volumefader.cc +++ b/dgedit/volumefader.cc @@ -29,10 +29,20 @@ #include #include +#include + +#define SCALAR 10 + VolumeFader::VolumeFader() { + volslider = new QSlider(); + volslider->setRange(-60 * SCALAR , 10 * SCALAR); + + connect(volslider, SIGNAL(valueChanged(int)), this, SLOT(handleValueChanged())); + QVBoxLayout* lo = new QVBoxLayout(); - lo->addWidget(new QSlider()); + lo->addWidget(volslider); + setLayout(lo); } @@ -59,3 +69,12 @@ void VolumeFader::setVolumePower(double vol) { } + +void VolumeFader::handleValueChanged() +{ + double db = ((double)volslider->value())/((double)SCALAR); + double power = pow(10, db/10); +// printf("Volume %f db, %f power\n", vol, pow(10, vol/10)); + emit volumeChangedDb(db); + emit volumeChangedPower(power); +} diff --git a/dgedit/volumefader.h b/dgedit/volumefader.h index 51ff953..33dfc2b 100644 --- a/dgedit/volumefader.h +++ b/dgedit/volumefader.h @@ -28,6 +28,9 @@ #define __DRUMGIZMO_VOLUMEFADER_H__ #include +#include + +#include class VolumeFader : public QWidget { Q_OBJECT @@ -35,15 +38,24 @@ public: VolumeFader(); ~VolumeFader(); + void volumeDb(); + void volumePower(); + public slots: void updatePeakDb(double vol); void updatePeakPower(double vol); void setVolumeDb(double vol); void setVolumePower(double vol); +private slots: + void handleValueChanged(); + signals: void volumeChangedDb(double vol); void volumeChangedPower(double vol); + +private: + QSlider *volslider; }; #endif/*__DRUMGIZMO_VOLUMEFADER_H__*/ -- cgit v1.2.3