diff options
| author | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2017-01-17 06:32:42 +0000 |
|---|---|---|
| committer | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2017-01-17 06:32:42 +0000 |
| commit | 740b179d7565ca0f846817d4abc6fee8fb8ca7cc (patch) | |
| tree | a930dc1b66479bad3efa99900836b3db6e078523 /src/plugins/Visual | |
| parent | 240d991e41a3bb874d5289456215e67d23856361 (diff) | |
| download | qmmp-740b179d7565ca0f846817d4abc6fee8fb8ca7cc.tar.gz qmmp-740b179d7565ca0f846817d4abc6fee8fb8ca7cc.tar.bz2 qmmp-740b179d7565ca0f846817d4abc6fee8fb8ca7cc.zip | |
removed old visual api usage
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@6986 90c681e8-e032-0410-971d-27865f9a5e38
Diffstat (limited to 'src/plugins/Visual')
| -rw-r--r-- | src/plugins/Visual/Visual.pro | 2 | ||||
| -rw-r--r-- | src/plugins/Visual/analyzer/analyzer.cpp | 65 | ||||
| -rw-r--r-- | src/plugins/Visual/analyzer/analyzer.h | 15 |
3 files changed, 31 insertions, 51 deletions
diff --git a/src/plugins/Visual/Visual.pro b/src/plugins/Visual/Visual.pro index e3f6d5ecb..fad9d2b8d 100644 --- a/src/plugins/Visual/Visual.pro +++ b/src/plugins/Visual/Visual.pro @@ -3,5 +3,5 @@ TEMPLATE = subdirs SUBDIRS += analyzer contains(CONFIG, PROJECTM_PLUGIN){ - SUBDIRS += projectm +# SUBDIRS += projectm } diff --git a/src/plugins/Visual/analyzer/analyzer.cpp b/src/plugins/Visual/analyzer/analyzer.cpp index 62d6a5593..6675a0416 100644 --- a/src/plugins/Visual/analyzer/analyzer.cpp +++ b/src/plugins/Visual/analyzer/analyzer.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2007-2015 by Ilya Kotov * + * Copyright (C) 2007-2017 by Ilya Kotov * * forkotov02@hotmail.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -31,25 +31,22 @@ #include "inlines.h" #include "analyzer.h" -#define VISUAL_NODE_SIZE 512 //samples -#define VISUAL_BUFFER_SIZE (5*VISUAL_NODE_SIZE) - Analyzer::Analyzer (QWidget *parent) : Visual (parent) { m_intern_vis_data = 0; m_peaks = 0; m_x_scale = 0; - m_buffer_at = 0; m_rows = 0; m_cols = 0; m_update = false; + m_running = false; setWindowTitle (tr("Qmmp Analyzer")); setMinimumSize(2*300-30,105); m_timer = new QTimer (this); connect(m_timer, SIGNAL (timeout()), this, SLOT (timeout())); - m_left_buffer = new float[VISUAL_BUFFER_SIZE]; - m_right_buffer = new float[VISUAL_BUFFER_SIZE]; + m_left_buffer = new float[QMMP_VISUAL_NODE_SIZE]; + m_right_buffer = new float[QMMP_VISUAL_NODE_SIZE]; clear(); createMenu(); @@ -69,51 +66,34 @@ Analyzer::~Analyzer() delete [] m_x_scale; } -void Analyzer::add (float *data, size_t samples, int chan) +void Analyzer::start() { - if (!m_timer->isActive ()) - return; - - 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 * sizeof(float)); - memmove(m_right_buffer, m_right_buffer + VISUAL_NODE_SIZE, m_buffer_at * sizeof(float)); - return; - } - - int frames = qMin(int(samples/chan), VISUAL_BUFFER_SIZE - m_buffer_at); - - stereo_from_multichannel(m_left_buffer + m_buffer_at, - m_right_buffer + m_buffer_at, data, frames, chan); + m_running = true; + if(isVisible()) + m_timer->start(); +} - m_buffer_at += frames; +void Analyzer::stop() +{ + m_running = false; + m_timer->stop(); + clear(); } void Analyzer::clear() { - m_buffer_at = 0; m_rows = 0; m_cols = 0; update(); } - void Analyzer::timeout() { - mutex()->lock(); - if(m_buffer_at < VISUAL_NODE_SIZE) + if(takeData(m_left_buffer, m_right_buffer)) { - mutex()->unlock (); - return; + process(); + update(); } - - 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 * sizeof(float)); - memmove(m_right_buffer, m_right_buffer + VISUAL_NODE_SIZE, m_buffer_at * sizeof(float)); - mutex()->unlock (); - update(); } void Analyzer::toggleFullScreen() @@ -200,7 +180,8 @@ void Analyzer::hideEvent (QHideEvent *) void Analyzer::showEvent (QShowEvent *) { - m_timer->start(); + if(m_running) + m_timer->start(); } void Analyzer::closeEvent (QCloseEvent *event) @@ -224,7 +205,7 @@ void Analyzer::mousePressEvent(QMouseEvent *e) m_menu->exec(e->globalPos()); } -void Analyzer::process (float *left, float *right) +void Analyzer::process() { static fft_state *state = 0; if (!state) @@ -261,8 +242,8 @@ void Analyzer::process (float *left, float *right) short yl, yr; int j, k, magnitude_l, magnitude_r; - calc_freq (dest_l, left); - calc_freq (dest_r, right); + calc_freq (dest_l, m_left_buffer); + calc_freq (dest_r, m_right_buffer); double y_scale = (double) 1.25 * m_rows / log(256); @@ -314,7 +295,7 @@ void Analyzer::process (float *left, float *right) } } -void Analyzer::draw (QPainter *p) +void Analyzer::draw(QPainter *p) { QBrush brush(Qt::SolidPattern); int x = 0; diff --git a/src/plugins/Visual/analyzer/analyzer.h b/src/plugins/Visual/analyzer/analyzer.h index d2c2d6cd1..b6c93e39b 100644 --- a/src/plugins/Visual/analyzer/analyzer.h +++ b/src/plugins/Visual/analyzer/analyzer.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2007-2015 by Ilya Kotov * + * Copyright (C) 2007-2017 by Ilya Kotov * * forkotov02@hotmail.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -32,7 +32,6 @@ class QPaintEvent; class QHideEvent; class QShowEvent; - class Analyzer : public Visual { Q_OBJECT @@ -41,9 +40,9 @@ public: Analyzer( QWidget *parent = 0); virtual ~Analyzer(); - void add(float *data, size_t samples, int chan); - void clear(); - +public slots: + void start(); + void stop(); private slots: void timeout(); @@ -51,14 +50,14 @@ private slots: void readSettings(); void writeSettings(); - private: + void clear(); virtual void hideEvent (QHideEvent *); virtual void showEvent (QShowEvent *); virtual void closeEvent (QCloseEvent *); void paintEvent(QPaintEvent *); void mousePressEvent(QMouseEvent *e); - void process(float *l, float *r); + void process(); void draw(QPainter *p); void createMenu(); QTimer *m_timer; @@ -70,9 +69,9 @@ private: bool m_show_peaks; float *m_left_buffer; float *m_right_buffer; - int m_buffer_at; int m_cols, m_rows; bool m_update; + bool m_running; //colors QColor m_color1; QColor m_color2; |
