diff options
Diffstat (limited to 'src/volumefader.cc')
-rw-r--r-- | src/volumefader.cc | 62 |
1 files changed, 32 insertions, 30 deletions
diff --git a/src/volumefader.cc b/src/volumefader.cc index 08bab80..9d3e15a 100644 --- a/src/volumefader.cc +++ b/src/volumefader.cc @@ -34,26 +34,27 @@ #define SCALAR 10 #define P 0.5 -VolumeFader::VolumeFader() +VolumeFader::VolumeFader() { - peak = 0; - volslider = new QSlider(); - volslider->setRange(-60 * SCALAR , 10 * SCALAR); - volslider->setOrientation(Qt::Horizontal); + peak = 0; + volslider = new QSlider(); + volslider->setRange(-60 * SCALAR , 10 * SCALAR); + volslider->setOrientation(Qt::Horizontal); - volumepeak = new QLabel(); + volumepeak = new QLabel(); - volume = new QLabel(); + volume = new QLabel(); - connect(volslider, SIGNAL(valueChanged(int)), this, SLOT(handleValueChanged())); + connect(volslider, SIGNAL(valueChanged(int)), + this, SLOT(handleValueChanged())); - QVBoxLayout* lo = new QVBoxLayout(); - lo->addWidget(volslider); - - lo->addWidget(volumepeak); - lo->addWidget(volume); + QVBoxLayout* lo = new QVBoxLayout(); + lo->addWidget(volslider); - setLayout(lo); + lo->addWidget(volumepeak); + lo->addWidget(volume); + + setLayout(lo); } VolumeFader::~VolumeFader() @@ -61,37 +62,38 @@ VolumeFader::~VolumeFader() } -void VolumeFader::updatePeakDb(double db) +void VolumeFader::updatePeakDb(double db) { -// updatePeakPower(pow(10, db/20)); + //updatePeakPower(pow(10, db / 20)); } void VolumeFader::updatePeakPower(double newpeak) { - peak = (newpeak * (1.0-P) + peak * P); - volumepeak->setText("Peak " + QString::number(peak, 'f', 5)); - handleValueChanged(); + peak = (newpeak * (1.0 - P) + peak * P); + volumepeak->setText("Peak " + QString::number(peak, 'f', 5)); + handleValueChanged(); } void VolumeFader::setVolumeDb(double db) { - volslider->setValue(db*SCALAR); - handleValueChanged(); + volslider->setValue(db * SCALAR); + handleValueChanged(); } void VolumeFader::setVolumePower(double power) { - double db = 20 * log10(power); - setVolumeDb(db); - handleValueChanged(); + double db = 20 * log10(power); + setVolumeDb(db); + handleValueChanged(); } -void VolumeFader::handleValueChanged() +void VolumeFader::handleValueChanged() { - double db = ((double)volslider->value())/((double)SCALAR); - double power = pow(10, db/20); - emit volumeChangedDb(db); - emit volumeChangedPower(power); + double db = ((double)volslider->value()) / ((double)SCALAR); + double power = pow(10, db / 20); + emit volumeChangedDb(db); + emit volumeChangedPower(power); - volume->setText("Gain " + QString::number(volslider->value()/SCALAR) + " dB"); + volume->setText("Gain " + QString::number(volslider->value() / SCALAR) + + " dB"); } |