From 521eaad10b2b9b7104b2b55e66864b54577e7b54 Mon Sep 17 00:00:00 2001 From: Jonas Suhr Christensen Date: Fri, 2 May 2014 13:04:58 +0200 Subject: Fixed peak reporting. Use fabs() not abs() when working with double! --- dgedit/mainwindow.cc | 3 +++ dgedit/player.cc | 4 +++- dgedit/volumefader.cc | 5 +++-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/dgedit/mainwindow.cc b/dgedit/mainwindow.cc index 9c88631..0e154ed 100644 --- a/dgedit/mainwindow.cc +++ b/dgedit/mainwindow.cc @@ -189,6 +189,9 @@ MainWindow::MainWindow() &player, SLOT(setGainDB(double))); connect(&player, SIGNAL(peakUpdate(double)), vol, SLOT(updatePeakPower(double))); +// connect(&player, SIGNAL(peakUpdateDB(double)), +// vol, SLOT(updatePeakDb(double))); + vol->setVolumeDb(0); dockWidget->widget()->layout()->addWidget(vol); diff --git a/dgedit/player.cc b/dgedit/player.cc index 64b3067..3a2bfd2 100644 --- a/dgedit/player.cc +++ b/dgedit/player.cc @@ -102,7 +102,9 @@ void Player::run() sample = pcm_data[p] * fade * gain_scalar; } - if(abs(sample) > peak) peak = abs(sample); + if(fabs(sample) > peak) { + peak = fabs(sample); + } s[i] = _MIN(sample * SHRT_MAX, SHRT_MAX); } diff --git a/dgedit/volumefader.cc b/dgedit/volumefader.cc index 33b1f57..08bab80 100644 --- a/dgedit/volumefader.cc +++ b/dgedit/volumefader.cc @@ -61,13 +61,14 @@ VolumeFader::~VolumeFader() } -void VolumeFader::updatePeakDb(double) +void VolumeFader::updatePeakDb(double db) { +// updatePeakPower(pow(10, db/20)); } void VolumeFader::updatePeakPower(double newpeak) { - peak = (newpeak * (1-P) + peak * P); + peak = (newpeak * (1.0-P) + peak * P); volumepeak->setText("Peak " + QString::number(peak, 'f', 5)); handleValueChanged(); } -- cgit v1.2.3