diff options
| author | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2017-01-16 20:04:21 +0000 |
|---|---|---|
| committer | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2017-01-16 20:04:21 +0000 |
| commit | 240d991e41a3bb874d5289456215e67d23856361 (patch) | |
| tree | b2fc84b24f066e4fc71c35fbea30916fbab0ae3d /src/plugins | |
| parent | a1f1349e58a8f8d3ebc220f188b9d26c49585e4a (diff) | |
| download | qmmp-240d991e41a3bb874d5289456215e67d23856361.tar.gz qmmp-240d991e41a3bb874d5289456215e67d23856361.tar.bz2 qmmp-240d991e41a3bb874d5289456215e67d23856361.zip | |
added virtual slots Visual::start() and Visual::stop()
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@6985 90c681e8-e032-0410-971d-27865f9a5e38
Diffstat (limited to 'src/plugins')
| -rw-r--r-- | src/plugins/Ui/qsui/mainwindow.cpp | 4 | ||||
| -rw-r--r-- | src/plugins/Ui/qsui/qsuianalyzer.cpp | 56 | ||||
| -rw-r--r-- | src/plugins/Ui/qsui/qsuianalyzer.h | 14 |
3 files changed, 19 insertions, 55 deletions
diff --git a/src/plugins/Ui/qsui/mainwindow.cpp b/src/plugins/Ui/qsui/mainwindow.cpp index 436501300..aff4bcb78 100644 --- a/src/plugins/Ui/qsui/mainwindow.cpp +++ b/src/plugins/Ui/qsui/mainwindow.cpp @@ -209,7 +209,7 @@ void MainWindow::showState(Qmmp::State state) case Qmmp::Playing: { updateStatus(); - m_analyzer->start(); + //m_analyzer->start(); m_analyzer->setCover(MetaDataManager::instance()->getCover(m_core->url())); CoverWidget *cw = qobject_cast<CoverWidget *>(m_ui.coverDockWidget->widget()); cw->setCover(MetaDataManager::instance()->getCover(m_core->url())); @@ -220,7 +220,7 @@ void MainWindow::showState(Qmmp::State state) break; case Qmmp::Stopped: updateStatus(); - m_analyzer->stop(); + //m_analyzer->stop(); m_timeLabel->clear(); m_positionSlider->setValue(0); m_analyzer->clearCover(); diff --git a/src/plugins/Ui/qsui/qsuianalyzer.cpp b/src/plugins/Ui/qsui/qsuianalyzer.cpp index 4b5f6f8d9..9146882ca 100644 --- a/src/plugins/Ui/qsui/qsuianalyzer.cpp +++ b/src/plugins/Ui/qsui/qsuianalyzer.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2012-2015 by Ilya Kotov * + * Copyright (C) 2012-2017 by Ilya Kotov * * forkotov02@hotmail.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -31,15 +31,11 @@ #include "inlines.h" #include "qsuianalyzer.h" -#define VISUAL_NODE_SIZE 512 //samples -#define VISUAL_BUFFER_SIZE (5*VISUAL_NODE_SIZE) - QSUiAnalyzer::QSUiAnalyzer (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_offset = 0; @@ -51,8 +47,8 @@ QSUiAnalyzer::QSUiAnalyzer (QWidget *parent) : Visual (parent) 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]; readSettings(); clear(); @@ -73,7 +69,6 @@ QSUiAnalyzer::~QSUiAnalyzer() void QSUiAnalyzer::clear() { - m_buffer_at = 0; m_rows = 0; m_cols = 0; update(); @@ -91,28 +86,6 @@ QSize QSUiAnalyzer::sizeHint() const return QSize(200, 100); } -void QSUiAnalyzer::add (float *data, size_t samples, int chan) -{ - 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_buffer_at += frames; -} - void QSUiAnalyzer::setCover(const QPixmap &pixmap) { m_cover = pixmap; @@ -121,21 +94,11 @@ void QSUiAnalyzer::setCover(const QPixmap &pixmap) void QSUiAnalyzer::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 ();*/ - takeData(m_left_buffer, m_right_buffer); - process (m_left_buffer, m_right_buffer); - update(); } void QSUiAnalyzer::paintEvent (QPaintEvent * e) @@ -161,7 +124,7 @@ void QSUiAnalyzer::resizeEvent(QResizeEvent *) updateCover(); } -void QSUiAnalyzer::process (float *left, float *right) +void QSUiAnalyzer::process() { int rows = qMax((height() - 2) / m_cell_size.height(),2); int cols = qMax((width() - m_offset - 2) / m_cell_size.width(),1); @@ -193,9 +156,9 @@ void QSUiAnalyzer::process (float *left, float *right) int k, magnitude; float data[512]; - for(int i = 0; i < VISUAL_NODE_SIZE; ++i) + for(int i = 0; i < QMMP_VISUAL_NODE_SIZE; ++i) { - data[i] = left[i] / 2 + right[i] / 2; + data[i] = m_left_buffer[i] / 2 + m_right_buffer[i] / 2; data[i] = qBound(-1.0f, data[i], 1.0f); } calc_freq (dest, data); @@ -412,4 +375,5 @@ void QSUiAnalyzer::stop() { m_running = false; m_timer->stop(); + clear(); } diff --git a/src/plugins/Ui/qsui/qsuianalyzer.h b/src/plugins/Ui/qsui/qsuianalyzer.h index 9dae2f9f1..14af24f4f 100644 --- a/src/plugins/Ui/qsui/qsuianalyzer.h +++ b/src/plugins/Ui/qsui/qsuianalyzer.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2012-2015 by Ilya Kotov * + * Copyright (C) 2012-2017 by Ilya Kotov * * forkotov02@hotmail.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -34,18 +34,19 @@ class QSUiAnalyzer : public Visual { Q_OBJECT public: - QSUiAnalyzer( QWidget *parent = 0); + QSUiAnalyzer(QWidget *parent = 0); virtual ~QSUiAnalyzer(); - void add(float *data, size_t samples, int chan); void setCover(const QPixmap &pixmap); void clear(); void clearCover(); QSize sizeHint() const; - void start(); - void stop(); + //void start(); + //void stop(); public slots: + void start(); + void stop(); void readSettings(); private slots: @@ -58,7 +59,7 @@ private: void hideEvent(QHideEvent *); void showEvent(QShowEvent *); void resizeEvent(QResizeEvent *); - void process(float *l, float *r); + void process(); void draw(QPainter *p); void createMenu(); void updateCover(); @@ -75,7 +76,6 @@ private: bool m_show_cover; float *m_left_buffer; float *m_right_buffer; - int m_buffer_at; int m_cols, m_rows; int m_offset; bool m_update; |
