diff options
| author | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2015-12-27 11:32:16 +0000 |
|---|---|---|
| committer | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2015-12-27 11:32:16 +0000 |
| commit | 8150882845f1eb089a0cba6fecd25c7bdc3c9540 (patch) | |
| tree | 6e73cf953a0b7272e9b2a9968edde8764e757db3 /src/plugins/Visual/analyzer/analyzer.cpp | |
| parent | b5dc393952c84dbd53c60afb8d367ad99bbd16ca (diff) | |
| download | qmmp-8150882845f1eb089a0cba6fecd25c7bdc3c9540.tar.gz qmmp-8150882845f1eb089a0cba6fecd25c7bdc3c9540.tar.bz2 qmmp-8150882845f1eb089a0cba6fecd25c7bdc3c9540.zip | |
ported analyzer plugin
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@5902 90c681e8-e032-0410-971d-27865f9a5e38
Diffstat (limited to 'src/plugins/Visual/analyzer/analyzer.cpp')
| -rw-r--r-- | src/plugins/Visual/analyzer/analyzer.cpp | 34 |
1 files changed, 13 insertions, 21 deletions
diff --git a/src/plugins/Visual/analyzer/analyzer.cpp b/src/plugins/Visual/analyzer/analyzer.cpp index d7cb683d0..62d6a5593 100644 --- a/src/plugins/Visual/analyzer/analyzer.cpp +++ b/src/plugins/Visual/analyzer/analyzer.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2007-2013 by Ilya Kotov * + * Copyright (C) 2007-2015 by Ilya Kotov * * forkotov02@hotmail.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -48,8 +48,8 @@ Analyzer::Analyzer (QWidget *parent) : Visual (parent) setMinimumSize(2*300-30,105); m_timer = new QTimer (this); connect(m_timer, SIGNAL (timeout()), this, SLOT (timeout())); - m_left_buffer = new short[VISUAL_BUFFER_SIZE]; - m_right_buffer = new short[VISUAL_BUFFER_SIZE]; + m_left_buffer = new float[VISUAL_BUFFER_SIZE]; + m_right_buffer = new float[VISUAL_BUFFER_SIZE]; clear(); createMenu(); @@ -69,7 +69,7 @@ Analyzer::~Analyzer() delete [] m_x_scale; } -void Analyzer::add (unsigned char *data, qint64 size, int chan) +void Analyzer::add (float *data, size_t samples, int chan) { if (!m_timer->isActive ()) return; @@ -77,23 +77,15 @@ void Analyzer::add (unsigned char *data, qint64 size, int chan) if(VISUAL_BUFFER_SIZE == m_buffer_at) { m_buffer_at -= VISUAL_NODE_SIZE; - memmove(m_left_buffer, m_left_buffer + VISUAL_NODE_SIZE, m_buffer_at << 1); - memmove(m_right_buffer, m_right_buffer + VISUAL_NODE_SIZE, m_buffer_at << 1); + memmove(m_left_buffer, m_left_buffer + VISUAL_NODE_SIZE, m_buffer_at * sizeof(float)); + memmove(m_right_buffer, m_right_buffer + VISUAL_NODE_SIZE, m_buffer_at * sizeof(float)); return; } - int frames = qMin((int)size/chan >> 1, VISUAL_BUFFER_SIZE - m_buffer_at); + int frames = qMin(int(samples/chan), VISUAL_BUFFER_SIZE - m_buffer_at); - if (chan >= 2) - { - stereo16_from_multichannel(m_left_buffer + m_buffer_at, - m_right_buffer + m_buffer_at,(short *) data, frames, chan); - } - else - { - memcpy(m_left_buffer + m_buffer_at, (short *) data, frames << 1); - memcpy(m_right_buffer + m_buffer_at, (short *) data, frames << 1); - } + stereo_from_multichannel(m_left_buffer + m_buffer_at, + m_right_buffer + m_buffer_at, data, frames, chan); m_buffer_at += frames; } @@ -109,7 +101,7 @@ void Analyzer::clear() void Analyzer::timeout() { - mutex()->lock (); + mutex()->lock(); if(m_buffer_at < VISUAL_NODE_SIZE) { mutex()->unlock (); @@ -118,8 +110,8 @@ void Analyzer::timeout() process (m_left_buffer, m_right_buffer); m_buffer_at -= VISUAL_NODE_SIZE; - memmove(m_left_buffer, m_left_buffer + VISUAL_NODE_SIZE, m_buffer_at << 1); - memmove(m_right_buffer, m_right_buffer + VISUAL_NODE_SIZE, m_buffer_at << 1); + memmove(m_left_buffer, m_left_buffer + VISUAL_NODE_SIZE, m_buffer_at * sizeof(float)); + memmove(m_right_buffer, m_right_buffer + VISUAL_NODE_SIZE, m_buffer_at * sizeof(float)); mutex()->unlock (); update(); } @@ -232,7 +224,7 @@ void Analyzer::mousePressEvent(QMouseEvent *e) m_menu->exec(e->globalPos()); } -void Analyzer::process (short *left, short *right) +void Analyzer::process (float *left, float *right) { static fft_state *state = 0; if (!state) |
