diff options
| author | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2015-12-27 12:41:10 +0000 |
|---|---|---|
| committer | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2015-12-27 12:41:10 +0000 |
| commit | 4f38154653813fe88b7b332f4d3ea10bba59d92f (patch) | |
| tree | 903813f0b1caa32179cbce9162d2a8e473daf3d6 /src/plugins/Visual/projectm/projectmplugin.cpp | |
| parent | 8150882845f1eb089a0cba6fecd25c7bdc3c9540 (diff) | |
| download | qmmp-4f38154653813fe88b7b332f4d3ea10bba59d92f.tar.gz qmmp-4f38154653813fe88b7b332f4d3ea10bba59d92f.tar.bz2 qmmp-4f38154653813fe88b7b332f4d3ea10bba59d92f.zip | |
enabled projectm plugin
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@5903 90c681e8-e032-0410-971d-27865f9a5e38
Diffstat (limited to 'src/plugins/Visual/projectm/projectmplugin.cpp')
| -rw-r--r-- | src/plugins/Visual/projectm/projectmplugin.cpp | 54 |
1 files changed, 18 insertions, 36 deletions
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) |
