[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [dragon] src/app/analyzer: Fix analyzer drawing on non-stereo audio samples
From: Harald Sitter <sitter () kde ! org>
Date: 2012-05-31 20:57:46
Message-ID: 20120531205746.7F709A60A9 () git ! kde ! org
[Download RAW message or body]
Git commit e3ac7335e1647b01d4c71a571c807da60d306c80 by Harald Sitter.
Committed on 31/05/2012 at 22:57.
Pushed by sitter into branch 'master'.
Fix analyzer drawing on non-stereo audio samples
- don't draw anything if there is no sample
- only use left channel on a mono sample
- handle everything that is not empty or mono as stereo
Should fix all possible causes of
BUG: 298192
M +10 -3 src/app/analyzer/analyzerBase.cpp
http://commits.kde.org/dragon/e3ac7335e1647b01d4c71a571c807da60d306c80
diff --git a/src/app/analyzer/analyzerBase.cpp b/src/app/analyzer/analyzerBase.cpp
index 45493a7..b3179b1 100644
--- a/src/app/analyzer/analyzerBase.cpp
+++ b/src/app/analyzer/analyzerBase.cpp
@@ -49,14 +49,21 @@ void Analyzer::Base::transform(QVector<float> &scope ) //virtual
void Analyzer::Base::drawFrame(const QMap<Phonon::AudioDataOutput::Channel, QVector<qint16> > &thescope)
{
+ if (thescope.isEmpty())
+ return;
+
static QVector<float> scope( 512 );
int i = 0;
for( uint x = 0; (int)x < m_fht->size(); ++x )
{
- scope[x] = double(thescope[Phonon::AudioDataOutput::LeftChannel][x]
- + thescope[Phonon::AudioDataOutput::RightChannel][x])
- / (2*(1<<15)); // Average between the channels
+ if (thescope.size() == 1) { // Mono
+ scope[x] = double(thescope[Phonon::AudioDataOutput::LeftChannel][x]);
+ } else { // Anything > Mono is treated as Stereo
+ scope[x] = double(thescope[Phonon::AudioDataOutput::LeftChannel][x]
+ + thescope[Phonon::AudioDataOutput::RightChannel][x])
+ / (2*(1<<15)); // Average between the channels
+ }
i += 2;
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic