diff options
| author | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2015-12-26 10:26:11 +0000 |
|---|---|---|
| committer | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2015-12-26 10:26:11 +0000 |
| commit | c3b05ebdc87be03e1cce5ccc5aa9398db3054f53 (patch) | |
| tree | 187bd56977c1318c99b906e48c3153c5fed34a7d /src | |
| parent | 5c9ab872f2d8fbb3871e79216663e4c8213962a6 (diff) | |
| download | qmmp-c3b05ebdc87be03e1cce5ccc5aa9398db3054f53.tar.gz qmmp-c3b05ebdc87be03e1cce5ccc5aa9398db3054f53.tar.bz2 qmmp-c3b05ebdc87be03e1cce5ccc5aa9398db3054f53.zip | |
changed visual api, disabled broken plugins
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@5885 90c681e8-e032-0410-971d-27865f9a5e38
Diffstat (limited to 'src')
| -rw-r--r-- | src/plugins/Ui/Ui.pro | 2 | ||||
| -rw-r--r-- | src/plugins/Ui/skinned/fft.c | 15 | ||||
| -rw-r--r-- | src/plugins/Ui/skinned/fft.h | 9 | ||||
| -rw-r--r-- | src/plugins/Ui/skinned/inlines.h | 30 | ||||
| -rw-r--r-- | src/plugins/Ui/skinned/mainvisual.cpp | 32 | ||||
| -rw-r--r-- | src/plugins/Ui/skinned/mainvisual.h | 10 | ||||
| -rw-r--r-- | src/plugins/Ui/skinned/shadedvisual.cpp | 43 | ||||
| -rw-r--r-- | src/plugins/Ui/skinned/shadedvisual.h | 11 | ||||
| -rw-r--r-- | src/plugins/Visual/Visual.pro | 4 | ||||
| -rw-r--r-- | src/qmmp/outputwriter.cpp | 11 | ||||
| -rw-r--r-- | src/qmmp/visual.h | 5 |
11 files changed, 94 insertions, 78 deletions
diff --git a/src/plugins/Ui/Ui.pro b/src/plugins/Ui/Ui.pro index 52ec45666..cf206d974 100644 --- a/src/plugins/Ui/Ui.pro +++ b/src/plugins/Ui/Ui.pro @@ -7,6 +7,6 @@ SUBDIRS += skinned } contains(CONFIG, WITH_QSUI){ -SUBDIRS += qsui +#SUBDIRS += qsui } diff --git a/src/plugins/Ui/skinned/fft.c b/src/plugins/Ui/skinned/fft.c index 0ea89eae6..2865e878e 100644 --- a/src/plugins/Ui/skinned/fft.c +++ b/src/plugins/Ui/skinned/fft.c @@ -25,6 +25,11 @@ * More optimisations. */ +/* + modifications compared to original code: + using float format for input data +*/ + #ifdef HAVE_CONFIG_H # include "config.h" #endif @@ -56,7 +61,7 @@ struct _struct_fft_state { /* # Local function prototypes # */ /* ############################# */ -static void fft_prepare(const sound_sample * input, float *re, float *im); +static void fft_prepare(const float *input, float *re, float *im); static void fft_calculate(float *re, float *im); static void fft_output(const float *re, const float *im, float *output); static int reverseBits(unsigned int initial); @@ -126,7 +131,7 @@ fft_init(void) * state is a (non-NULL) pointer returned by fft_init. */ void -fft_perform(const sound_sample * input, float *output, fft_state * state) +fft_perform(const float *input, float *output, fft_state * state) { /* Convert data from sound format to be ready for FFT */ fft_prepare(input, state->real, state->imag); @@ -156,7 +161,7 @@ fft_close(fft_state * state) * Prepare data to perform an FFT on */ static void -fft_prepare(const sound_sample * input, float *re, float *im) +fft_prepare(const float *input, float *re, float *im) { unsigned int i; float *realptr = re; @@ -164,7 +169,7 @@ fft_prepare(const sound_sample * input, float *re, float *im) /* Get input, in reverse bit order */ for (i = 0; i < FFT_BUFFER_SIZE; i++) { - *realptr++ = input[bitReverse[i]]; + *realptr++ = input[bitReverse[i]] * 32767.0; *imagptr++ = 0; } } @@ -174,7 +179,7 @@ fft_prepare(const sound_sample * input, float *re, float *im) * Note: only produces half as many data points as the input had. * This is roughly a consequence of the Nyquist sampling theorm thingy. * (FIXME - make this comment better, and helpful.) - * + * * The two divisions by 4 are also a consequence of this: the contributions * returned for each frequency are split into two parts, one at i in the * table, and the other at FFT_BUFFER_SIZE - i, except for i = 0 and diff --git a/src/plugins/Ui/skinned/fft.h b/src/plugins/Ui/skinned/fft.h index 915bccaf6..c24e2e584 100644 --- a/src/plugins/Ui/skinned/fft.h +++ b/src/plugins/Ui/skinned/fft.h @@ -23,8 +23,11 @@ #define FFT_BUFFER_SIZE (1 << FFT_BUFFER_SIZE_LOG) -/* sound sample - should be an signed 16 bit value */ -typedef short int sound_sample; +/* + modifications compared to original code: + using float format for input data +*/ + #ifdef __cplusplus extern "C" { @@ -33,7 +36,7 @@ extern "C" { /* FFT library */ typedef struct _struct_fft_state fft_state; fft_state *fft_init(void); - void fft_perform(const sound_sample * input, float *output, + void fft_perform(const float *input, float *output, fft_state * state); void fft_close(fft_state * state); diff --git a/src/plugins/Ui/skinned/inlines.h b/src/plugins/Ui/skinned/inlines.h index 39b81bd57..e07b37fbe 100644 --- a/src/plugins/Ui/skinned/inlines.h +++ b/src/plugins/Ui/skinned/inlines.h @@ -4,13 +4,19 @@ // warranty, or liability of any kind. // +/* + modifications compared to original code: + using float format +*/ + #ifndef INLINES_H #define INLINES_H #include "fft.h" +#include <string.h> // *fast* convenience functions -static inline void calc_freq(short* dest, short *src) +static inline void calc_freq(short* dest, float *src) { static fft_state *state = NULL; float tmp_out[257]; @@ -25,11 +31,17 @@ static inline void calc_freq(short* dest, short *src) dest[i] = ((int) sqrt(tmp_out[i + 1])) >> 8; } -static inline void stereo16_from_multichannel(register short *l, - register short *r, - register short *s, +static inline void stereo16_from_multichannel(float *l, + float *r, + float *s, long cnt, int chan) { + if(chan == 1) + { + memcpy(l, s, cnt * sizeof(float)); + memcpy(r, s, cnt * sizeof(float)); + return; + } while (cnt > 0) { l[0] = s[0]; @@ -41,10 +53,16 @@ static inline void stereo16_from_multichannel(register short *l, } } -static inline void mono16_from_multichannel(register short *l, - register short *s, +static inline void mono16_from_multichannel(float *l, + float *s, long cnt, int chan) { + if(chan == 1) + { + memcpy(l, s, cnt * sizeof(float)); + return; + } + while (cnt > 0) { l[0] = s[0]; diff --git a/src/plugins/Ui/skinned/mainvisual.cpp b/src/plugins/Ui/skinned/mainvisual.cpp index 0da769c05..9ed464048 100644 --- a/src/plugins/Ui/skinned/mainvisual.cpp +++ b/src/plugins/Ui/skinned/mainvisual.cpp @@ -50,7 +50,7 @@ MainVisual::MainVisual (QWidget *parent) : Visual (parent), m_vis (0) connect(m_skin, SIGNAL(skinChanged()), this, SLOT(readSettings())); m_timer = new QTimer (this); connect(m_timer, SIGNAL (timeout()), this, SLOT (timeout())); - m_buffer = new short[VISUAL_BUFFER_SIZE]; + m_buffer = new float[VISUAL_BUFFER_SIZE]; m_buffer_at = 0; m_instance = this; m_update = false; @@ -95,7 +95,7 @@ void MainVisual::clear() update(); } -void MainVisual::add (unsigned char *data, qint64 size, int chan) +void MainVisual::add (float *data, size_t samples, int chan) { if (!m_timer->isActive () || !m_vis) return; @@ -103,20 +103,12 @@ void MainVisual::add (unsigned char *data, qint64 size, int chan) if(VISUAL_BUFFER_SIZE == m_buffer_at) { m_buffer_at -= VISUAL_NODE_SIZE; - memmove(m_buffer, m_buffer + VISUAL_NODE_SIZE, m_buffer_at << 1); + memmove(m_buffer, m_buffer + VISUAL_NODE_SIZE, m_buffer_at * sizeof(float)); return; } - int frames = qMin((int)size/chan >> 1, VISUAL_BUFFER_SIZE - m_buffer_at); - - if (chan >= 2) - { - mono16_from_multichannel(m_buffer + m_buffer_at, (short *) data, frames, chan); - } - else - { - memcpy(m_buffer + m_buffer_at, (short *) data, frames << 1); - } + int frames = qMin(int(samples/chan), VISUAL_BUFFER_SIZE - m_buffer_at); + mono16_from_multichannel(m_buffer + m_buffer_at, data, frames, chan); m_buffer_at += frames; } @@ -135,7 +127,7 @@ void MainVisual::timeout() { m_vis->process (m_buffer); m_buffer_at -= VISUAL_NODE_SIZE; - memmove(m_buffer, m_buffer + VISUAL_NODE_SIZE, m_buffer_at << 1); + memmove(m_buffer, m_buffer + VISUAL_NODE_SIZE, m_buffer_at*sizeof(float)); m_pixmap = m_bg; QPainter p(&m_pixmap); m_vis->draw (&p); @@ -423,7 +415,7 @@ void Analyzer::clear() } } -bool Analyzer::process (short *l) +bool Analyzer::process (float *l) { static fft_state *state = 0; if (!state) @@ -558,7 +550,7 @@ void Scope::clear() Scope::~Scope() {} -bool Scope::process(short *l) +bool Scope::process(float *l) { int step = (VISUAL_NODE_SIZE << 8)/76; int pos = 0; @@ -566,12 +558,8 @@ bool Scope::process(short *l) for (int i = 0; i < 76; ++i) { pos += step; - m_intern_vis_data[i] = (l[pos >> 8] >> 12); - - if (m_intern_vis_data[i] > 4) - m_intern_vis_data[i] = 4; - else if (m_intern_vis_data[i] < -4) - m_intern_vis_data[i] = -4; + m_intern_vis_data[i] = int(l[pos >> 8] * 8.0); + m_intern_vis_data[i] = qBound(-4, m_intern_vis_data[i], 4); } return true; } diff --git a/src/plugins/Ui/skinned/mainvisual.h b/src/plugins/Ui/skinned/mainvisual.h index ff0175bac..2998d48ce 100644 --- a/src/plugins/Ui/skinned/mainvisual.h +++ b/src/plugins/Ui/skinned/mainvisual.h @@ -33,7 +33,7 @@ class VisualBase public: virtual ~VisualBase(){} virtual void clear() = 0; - virtual bool process(short *l) = 0; + virtual bool process(float *l) = 0; virtual void draw(QPainter *) = 0; virtual const QString name() = 0; }; @@ -50,7 +50,7 @@ public: static MainVisual *instance(); void setVisual(VisualBase *newvis); - void add(unsigned char *data, qint64 size, int chan); + void add(float *data, size_t samples, int chan); void clear(); void paintEvent(QPaintEvent *); @@ -88,7 +88,7 @@ private: QAction *m_peaksAction; QAction *m_transparentAction; int m_ratio; - short *m_buffer; + float *m_buffer; int m_buffer_at; bool m_update; }; @@ -102,7 +102,7 @@ public: virtual ~Analyzer(); void clear(); - bool process(short *l); + bool process(float *l); void draw(QPainter *p); const QString name() { @@ -127,7 +127,7 @@ public: Scope(); virtual ~Scope(); void clear(); - bool process(short *l); + bool process(float *l); void draw(QPainter *p); const QString name() { diff --git a/src/plugins/Ui/skinned/shadedvisual.cpp b/src/plugins/Ui/skinned/shadedvisual.cpp index 21ddcf2b5..ab522211f 100644 --- a/src/plugins/Ui/skinned/shadedvisual.cpp +++ b/src/plugins/Ui/skinned/shadedvisual.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2007-2012 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 * @@ -29,7 +29,7 @@ #define VISUAL_BUFFER_SIZE (5*VISUAL_NODE_SIZE) ShadedVisual::ShadedVisual(QWidget *parent) : Visual(parent) -{ +{ m_skin = Skin::instance(); m_ratio = m_skin->ratio(); resize(m_ratio*38,m_ratio*5); @@ -37,8 +37,8 @@ ShadedVisual::ShadedVisual(QWidget *parent) : Visual(parent) m_timer = new QTimer(this); connect(m_timer, SIGNAL (timeout()), this, SLOT (timeout())); connect(m_skin, SIGNAL(skinChanged()), this, SLOT(updateSkin())); - 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]; m_buffer_at = 0; m_timer->setInterval(50); m_timer->start(); @@ -51,7 +51,7 @@ ShadedVisual::~ShadedVisual() delete [] m_right_buffer; } -void ShadedVisual::add(unsigned char *data, qint64 size, int chan) +void ShadedVisual::add(float *data, size_t samples, int chan) { if (!m_timer->isActive ()) return; @@ -59,24 +59,15 @@ void ShadedVisual::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); - - 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); - } + int frames = qMin(int(samples/chan), VISUAL_BUFFER_SIZE - m_buffer_at); + stereo16_from_multichannel(m_left_buffer + m_buffer_at, + m_right_buffer + m_buffer_at, data, frames, chan); m_buffer_at += frames; } @@ -102,15 +93,15 @@ void ShadedVisual::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)); QPainter p(&m_pixmap); draw (&p); mutex()->unlock (); update(); } -void ShadedVisual::process (short *left, short *right) +void ShadedVisual::process (float *left, float *right) { int step = (VISUAL_NODE_SIZE << 8)/74; int pos = 0; @@ -124,7 +115,7 @@ void ShadedVisual::process (short *left, short *right) if (left) { - j_l = abs((left[pos >> 8] >> 12)); + j_l = abs(left[pos >> 8] * 8.0); if (j_l > 15) j_l = 15; @@ -132,16 +123,16 @@ void ShadedVisual::process (short *left, short *right) } if (right) { - j_r = abs((right[pos >> 8] >> 12)); + j_r = abs(right[pos >> 8] * 8.0); if (j_r > 15) j_r = 15; r = qMax(r, j_r); } } m_l -= 0.5; - m_l = m_l > l ? m_l : l; + m_l = qMax(m_l, (double)l); m_r -= 0.5; - m_r = m_r > r ? m_r : r; + m_r = qMax(m_r, (double)r); } void ShadedVisual::draw (QPainter *p) diff --git a/src/plugins/Ui/skinned/shadedvisual.h b/src/plugins/Ui/skinned/shadedvisual.h index 93ca5b217..0089139bc 100644 --- a/src/plugins/Ui/skinned/shadedvisual.h +++ b/src/plugins/Ui/skinned/shadedvisual.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2007-2012 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 * @@ -27,7 +27,6 @@ class QTimer; class QPixmap; class Skin; -//class VisualNode; /** @author Ilya Kotov <forkotov02@hotmail.ru> @@ -40,7 +39,7 @@ public: ~ShadedVisual(); - void add(unsigned char *data, qint64 size, int chan); + void add(float *data, size_t samples, int chan); void clear(); void paintEvent (QPaintEvent *); @@ -54,13 +53,13 @@ private slots: void updateSkin(); private: - void process (short *l, short *r); + void process (float *l, float *r); void draw (QPainter *); Skin *m_skin; QTimer *m_timer; QPixmap m_pixmap; - short *m_left_buffer; - short *m_right_buffer; + float *m_left_buffer; + float *m_right_buffer; int m_buffer_at; double m_l, m_r; int m_ratio; diff --git a/src/plugins/Visual/Visual.pro b/src/plugins/Visual/Visual.pro index e3f6d5ecb..6ee5a7d59 100644 --- a/src/plugins/Visual/Visual.pro +++ b/src/plugins/Visual/Visual.pro @@ -1,7 +1,7 @@ include(../../../qmmp.pri) TEMPLATE = subdirs -SUBDIRS += analyzer +#SUBDIRS += analyzer contains(CONFIG, PROJECTM_PLUGIN){ - SUBDIRS += projectm +# SUBDIRS += projectm } diff --git a/src/qmmp/outputwriter.cpp b/src/qmmp/outputwriter.cpp index 6ba10702a..e8bd65de4 100644 --- a/src/qmmp/outputwriter.cpp +++ b/src/qmmp/outputwriter.cpp @@ -233,6 +233,17 @@ int OutputWriter::sampleSize() const void OutputWriter::dispatchVisual (Buffer *buffer) { + if(!buffer) + return; + + foreach (Visual *visual, *Visual::visuals()) + { + visual->mutex()->lock (); + visual->add (buffer->data, buffer->samples, m_channels); + visual->mutex()->unlock(); + } + + /*if (!buffer) return; diff --git a/src/qmmp/visual.h b/src/qmmp/visual.h index 957e9e0a1..26de8d230 100644 --- a/src/qmmp/visual.h +++ b/src/qmmp/visual.h @@ -24,6 +24,7 @@ #include <QStringList> #include <QWidget> #include <QHash> +#include <stddef.h> class Buffer; class Decoder; @@ -51,10 +52,10 @@ public: * Adds data for visualization. * Subclass should reimplement this function. * @param data Audio data. - * @param size Size of audio data. + * @param samples Number of samples. * @param chan Number of channels. */ - virtual void add(unsigned char *data, qint64 size, int chan) = 0; + virtual void add(float *data, size_t samples, int chan) = 0; /*! * Resets visual plugin buffers and widgets. * Subclass should reimplement this function. |
