aboutsummaryrefslogtreecommitdiff
path: root/src/ui/mainvisual.cpp
diff options
context:
space:
mode:
authortrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2010-01-20 23:03:05 +0000
committertrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2010-01-20 23:03:05 +0000
commitdbcf03bb3946253d0156834cc8e49c0575c8fcc5 (patch)
tree2ccda5534f1c982842d468e846043888d7c15264 /src/ui/mainvisual.cpp
parentc05c3679e4fad5034a53ce2b7cfde8ad932faa59 (diff)
downloadqmmp-dbcf03bb3946253d0156834cc8e49c0575c8fcc5.tar.gz
qmmp-dbcf03bb3946253d0156834cc8e49c0575c8fcc5.tar.bz2
qmmp-dbcf03bb3946253d0156834cc8e49c0575c8fcc5.zip
fixed visualization
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@1519 90c681e8-e032-0410-971d-27865f9a5e38
Diffstat (limited to 'src/ui/mainvisual.cpp')
-rw-r--r--src/ui/mainvisual.cpp47
1 files changed, 19 insertions, 28 deletions
diff --git a/src/ui/mainvisual.cpp b/src/ui/mainvisual.cpp
index ada7291df..185107e7a 100644
--- a/src/ui/mainvisual.cpp
+++ b/src/ui/mainvisual.cpp
@@ -52,7 +52,6 @@ MainVisual::MainVisual (QWidget *parent)
m_nodes.clear();
createMenu();
readSettings();
- m_buf_at = 0;
m_instance = this;
}
@@ -102,36 +101,28 @@ void MainVisual::add (unsigned char *data, qint64 size, int chan)
{
if (!m_timer->isActive () || !m_vis)
return;
- long len = size, cnt;
- short *l = 0, *r = 0;
-
- memcpy(m_buf + m_buf_at, data, qMin(qint64(2048 - m_buf_at), size));
- m_buf_at += qMin(qint64(2048 - m_buf_at), size);
- if(m_buf_at < 2048)
- return;
- len = m_buf_at;
- len /= chan;
- len /= 2;
- if (len > 512)
- len = 512;
- cnt = len;
-
- if (chan >= 2)
- {
- l = new short[len];
- r = new short[len];
- stereo16_from_stereopcm16 (l, r, (short *) m_buf, cnt);
- }
- else if (chan == 1)
+ short *l = 0, *r = 0;
+ qint64 samples = size/chan >> 1;
+ int frames = samples/512;
+ for (int i = 0; i < frames; ++i)
{
- l = new short[len];
- mono16_from_monopcm16 (l, (short *) m_buf, cnt);
+ l = new short[512];
+ r = 0;
+ if (chan == 2)
+ {
+ r = new short[512];
+ stereo16_from_stereopcm16 (l, r, (short *) (data + i*4*512), 512);
+ }
+ else if (chan == 1)
+ mono16_from_monopcm16 (l, (short *) (data + i*2*512), 512);
+ else
+ {
+ r = new short[512];
+ stereo16_from_multichannel(l, r, (short *) (data + i*2*chan*512), 512, chan);
+ }
+ m_nodes.append (new VisualNode (l, r, 512));
}
- else
- len = 0;
- m_buf_at = 0;
- m_nodes.append (new VisualNode (l, r, len));
}
void MainVisual::timeout()