aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/Visual/projectm/projectmplugin.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/Visual/projectm/projectmplugin.cpp')
-rw-r--r--src/plugins/Visual/projectm/projectmplugin.cpp63
1 files changed, 39 insertions, 24 deletions
diff --git a/src/plugins/Visual/projectm/projectmplugin.cpp b/src/plugins/Visual/projectm/projectmplugin.cpp
index a3efab8e1..e691dd89f 100644
--- a/src/plugins/Visual/projectm/projectmplugin.cpp
+++ b/src/plugins/Visual/projectm/projectmplugin.cpp
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2009-2015 by Ilya Kotov *
+ * Copyright (C) 2009-2017 by Ilya Kotov *
* forkotov02@hotmail.ru *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -37,6 +37,7 @@
ProjectMPlugin::ProjectMPlugin (QWidget *parent)
: Visual (parent, Qt::Window | Qt::MSWindowsOwnDC)
{
+ m_running = false;
setlocale(LC_NUMERIC, "C"); //fixes problem with none-english locales
setWindowTitle(tr("ProjectM"));
setWindowIcon(parent->windowIcon());
@@ -62,51 +63,55 @@ ProjectMPlugin::ProjectMPlugin (QWidget *parent)
restoreGeometry(settings.value("ProjectM/geometry").toByteArray());
m_splitter->setSizes(QList<int>() << 300 << 300);
m_splitter->restoreState(settings.value("ProjectM/splitter_sizes").toByteArray());
+
+ m_timer = new QTimer(this);
+ m_timer->setInterval(0);
+ connect(m_timer, SIGNAL(timeout()), SLOT(onTimeout()));
}
ProjectMPlugin::~ProjectMPlugin()
{}
-void ProjectMPlugin::clear()
+void ProjectMPlugin::start()
{
- update();
+ m_running = true;
+ if(isVisible())
+ m_timer->start();
}
-void ProjectMPlugin::setFullScreen(bool yes)
+void ProjectMPlugin::stop()
{
- if(yes)
- setWindowState(windowState() | Qt::WindowFullScreen);
- else
- setWindowState(windowState() & ~Qt::WindowFullScreen);
+ m_timer->stop();
+ m_running = false;
+ update();
}
-void ProjectMPlugin::add (float *data, size_t samples, int chan)
+void ProjectMPlugin::onTimeout()
{
projectM *instance = m_projectMWidget->projectMInstance();
if (!instance)
return;
- size_t frames = qMin(samples / chan, (size_t)512);
-
- if(chan == 1)
+ if(takeData(m_left, m_right))
{
- for(size_t i = 0; i < frames; i++)
+ for(size_t i = 0; i < 512; i++)
{
- m_buf[0][i] = data[i*chan] * 32767.0;
- m_buf[1][i] = data[i*chan] * 32767.0;
+ m_buf[0][i] = m_left[i] * 32767.0;
+ m_buf[1][i] = m_right[i] * 32767.0;
}
- }
- else
- {
- for(size_t i = 0; i < frames; i++)
- {
- m_buf[0][i] = data[i*chan] * 32767.0;
- m_buf[1][i] = data[i*chan+1] * 32767.0;
- }
+ m_projectMWidget->projectMInstance()->pcm()->addPCM16(m_buf);
}
- m_projectMWidget->projectMInstance()->pcm()->addPCM16(m_buf);
+ m_projectMWidget->updateGL();
+}
+
+void ProjectMPlugin::setFullScreen(bool yes)
+{
+ if(yes)
+ setWindowState(windowState() | Qt::WindowFullScreen);
+ else
+ setWindowState(windowState() & ~Qt::WindowFullScreen);
}
void ProjectMPlugin::closeEvent (QCloseEvent *event)
@@ -117,3 +122,13 @@ void ProjectMPlugin::closeEvent (QCloseEvent *event)
settings.setValue("ProjectM/splitter_sizes", m_splitter->saveState());
Visual::closeEvent(event); //removes visualization object
}
+
+void ProjectMPlugin::showEvent(QShowEvent *)
+{
+ m_timer->start();
+}
+
+void ProjectMPlugin::hideEvent(QHideEvent *)
+{
+ m_timer->stop();
+}