diff options
| author | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2013-09-27 06:13:22 +0000 |
|---|---|---|
| committer | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2013-09-27 06:13:22 +0000 |
| commit | c8704a9c1ae72da724d037bb3d19a8c8e7e61f70 (patch) | |
| tree | cfe2cc24d8b1b286a3ba59af5eb96f4533e1e5f2 /src/plugins/General/rgscan/rgscaner.cpp | |
| parent | 6b48eaf5918e54b4f6cc7e9366da72ee6fe416b6 (diff) | |
| download | qmmp-c8704a9c1ae72da724d037bb3d19a8c8e7e61f70.tar.gz qmmp-c8704a9c1ae72da724d037bb3d19a8c8e7e61f70.tar.bz2 qmmp-c8704a9c1ae72da724d037bb3d19a8c8e7e61f70.zip | |
rgscan: added peak value calculation
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@3724 90c681e8-e032-0410-971d-27865f9a5e38
Diffstat (limited to 'src/plugins/General/rgscan/rgscaner.cpp')
| -rw-r--r-- | src/plugins/General/rgscan/rgscaner.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/plugins/General/rgscan/rgscaner.cpp b/src/plugins/General/rgscan/rgscaner.cpp index fc46142e9..069a4e0da 100644 --- a/src/plugins/General/rgscan/rgscaner.cpp +++ b/src/plugins/General/rgscan/rgscaner.cpp @@ -29,6 +29,7 @@ RGScaner::RGScaner() { m_gain = 0.; + m_peak = 0.; m_user_stop = false; m_is_running = false; m_handle = 0; @@ -118,11 +119,16 @@ bool RGScaner::isRunning() return m_is_running; } -double RGScaner::gain() +double RGScaner::gain() const { return m_gain; } +double RGScaner::peak() const +{ + return m_peak; +} + GainHandle_t *RGScaner::handle() { return m_handle; @@ -142,6 +148,7 @@ void RGScaner::run() qint64 total = 0; qint64 len = 0; qint64 totalSize = m_decoder->totalTime() * ap.sampleRate() * ap.channels() * ap.sampleSize() / 1000; + qint32 max = 0; double out_left[buf_size/4]; double out_right[buf_size/4]; @@ -169,6 +176,8 @@ void RGScaner::run() { out_left[i] = ((short *) output_buf)[i*2]; out_right[i] = ((short *) output_buf)[i*2+1]; + max = qMax(abs(out_left[i]), max); + max = qMax(abs(out_right[i]), max); } AnalyzeSamples(m_handle, out_left, out_right, len/4, 2); @@ -187,6 +196,8 @@ void RGScaner::run() } m_gain = GetTitleGain(m_handle); + m_peak = max / 32768.0; + qDebug("peak = %f", m_peak); qDebug("RGScaner: thread %ld finished", QThread::currentThreadId()); m_is_running = false; emit progress(100); |
