diff options
Diffstat (limited to 'src/plugins/Visual')
| -rw-r--r-- | src/plugins/Visual/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | src/plugins/Visual/Visual.pro | 2 | ||||
| -rw-r--r-- | src/plugins/Visual/projectm/projectmplugin.cpp | 54 | ||||
| -rw-r--r-- | src/plugins/Visual/projectm/projectmplugin.h | 7 |
4 files changed, 23 insertions, 42 deletions
diff --git a/src/plugins/Visual/CMakeLists.txt b/src/plugins/Visual/CMakeLists.txt index 656000b8d..c6571092a 100644 --- a/src/plugins/Visual/CMakeLists.txt +++ b/src/plugins/Visual/CMakeLists.txt @@ -6,5 +6,5 @@ add_subdirectory(analyzer) ENDIF(USE_ANALYZER) IF(USE_PROJECTM) -#add_subdirectory(projectm) +add_subdirectory(projectm) ENDIF(USE_PROJECTM) diff --git a/src/plugins/Visual/Visual.pro b/src/plugins/Visual/Visual.pro index fad9d2b8d..e3f6d5ecb 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/projectm/projectmplugin.cpp b/src/plugins/Visual/projectm/projectmplugin.cpp index 583f3650b..18bed4bcc 100644 --- a/src/plugins/Visual/projectm/projectmplugin.cpp +++ b/src/plugins/Visual/projectm/projectmplugin.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2009-2014 by Ilya Kotov * + * Copyright (C) 2009-2015 by Ilya Kotov * * forkotov02@hotmail.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -41,9 +41,6 @@ ProjectMPlugin::ProjectMPlugin (QWidget *parent) setWindowTitle(tr("ProjectM")); setWindowIcon(parent->windowIcon()); - m_buf = 0; - m_buf_size = 0; - m_splitter = new QSplitter(Qt::Horizontal, this); QListWidget *listWidget = new QListWidget(m_splitter); listWidget->setAlternatingRowColors(true); @@ -68,10 +65,7 @@ ProjectMPlugin::ProjectMPlugin (QWidget *parent) } ProjectMPlugin::~ProjectMPlugin() -{ - if(m_buf) - free(m_buf); -} +{} void ProjectMPlugin::clear() { @@ -86,45 +80,33 @@ void ProjectMPlugin::setFullScreen(bool yes) setWindowState(windowState() & ~Qt::WindowFullScreen); } -void ProjectMPlugin::add (unsigned char *data, qint64 size, int chan) +void ProjectMPlugin::add (float *data, size_t samples, int chan) { projectM *instance = m_projectMWidget->projectMInstance(); if (!instance) return; - if(chan == 2) - m_projectMWidget->projectMInstance()->pcm()->addPCM16Data((short *)data, size >> 2); - else + + size_t frames = qMin(samples / chan, (size_t)512); + + if(chan == 1) { - int samples = size / chan / 2; //number of samples for each channel (16 bit) - if(m_buf_size < samples * 4) //requied bytes + for(size_t i = 0; i <= frames; i++) { - m_buf = (short*)realloc(m_buf, samples * 4); - m_buf_size = samples * 4; + m_buf[0][i] = data[i*chan] * 32767.0; + m_buf[1][i] = data[i*chan] * 32767.0; } - short *in_buf = (short *)data; - if(chan == 1) - { - //convert mono to stereo - for(int i = 0; i < samples; ++i) - { - ((short *)m_buf)[i*2] = in_buf[0]; - ((short *)m_buf)[i*2+1] = in_buf[0]; - in_buf++; - } - } - else + } + else + { + for(size_t i = 0; i <= frames; i++) { - //convert multi-channel to stereo - for(int i = 0; i < samples; ++i) - { - ((short*)m_buf)[i*2] = in_buf[0]; - ((short*)m_buf)[i*2+1] = in_buf[1]; - in_buf += chan; - } + m_buf[0][i] = data[i*chan] * 32767.0; + m_buf[1][i] = data[i*chan+1] * 32767.0; } - m_projectMWidget->projectMInstance()->pcm()->addPCM16Data(m_buf, samples); } + + m_projectMWidget->projectMInstance()->pcm()->addPCM16(m_buf); } void ProjectMPlugin::closeEvent (QCloseEvent *event) diff --git a/src/plugins/Visual/projectm/projectmplugin.h b/src/plugins/Visual/projectm/projectmplugin.h index 99a7fc649..62344d0a6 100644 --- a/src/plugins/Visual/projectm/projectmplugin.h +++ b/src/plugins/Visual/projectm/projectmplugin.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2009-2014 by Ilya Kotov * + * Copyright (C) 2009-2015 by Ilya Kotov * * forkotov02@hotmail.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -35,7 +35,7 @@ public: ProjectMPlugin(QWidget *parent = 0); virtual ~ProjectMPlugin(); - void add(unsigned char *data, qint64 size, int chan); + void add(float *data, size_t samples, int chan); void clear(); private slots: @@ -46,8 +46,7 @@ private: QTimer *m_timer; ProjectMWidget *m_projectMWidget; QSplitter *m_splitter; - short *m_buf; - int m_buf_size; + short m_buf[2][512]; }; |
