aboutsummaryrefslogtreecommitdiff
path: root/src/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/Visual/projectm/analyzer.cpp128
-rw-r--r--src/plugins/Visual/projectm/analyzer.h95
-rw-r--r--src/plugins/Visual/projectm/projectm.pro39
-rw-r--r--src/plugins/Visual/projectm/projectmwidget.cpp99
-rw-r--r--src/plugins/Visual/projectm/projectmwidget.h53
-rw-r--r--src/plugins/Visual/projectm/qprojectm.h35
-rw-r--r--src/plugins/Visual/projectm/visualprojectmfactory.cpp62
-rw-r--r--src/plugins/Visual/projectm/visualprojectmfactory.h46
8 files changed, 557 insertions, 0 deletions
diff --git a/src/plugins/Visual/projectm/analyzer.cpp b/src/plugins/Visual/projectm/analyzer.cpp
new file mode 100644
index 000000000..86a2b4021
--- /dev/null
+++ b/src/plugins/Visual/projectm/analyzer.cpp
@@ -0,0 +1,128 @@
+/***************************************************************************
+ * Copyright (C) 2007 by Ilya Kotov *
+ * forkotov02@hotmail.ru *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+#include <QTimer>
+#include <QSettings>
+#include <QPainter>
+#include <QMenu>
+#include <QActionGroup>
+#include <QHBoxLayout>
+
+#include <qmmp/buffer.h>
+#include <qmmp/constants.h>
+#include <qmmp/output.h>
+#include <math.h>
+#include <stdlib.h>
+#include <locale.h>
+#include <projectM.hpp>
+
+#include "projectmwidget.h"
+#include "analyzer.h"
+
+
+Analyzer::Analyzer (QWidget *parent)
+ : Visual (parent), m_fps ( 20 )
+{
+ setlocale(LC_NUMERIC, "C");
+ m_projectMWidget = new ProjectMWidget(this);
+ QHBoxLayout *layout = new QHBoxLayout;
+ layout->addWidget(m_projectMWidget);
+ layout->setContentsMargins(0,0,0,0);
+ setLayout(layout);
+ resize(300,300);
+}
+
+Analyzer::~Analyzer()
+{
+ while (!m_nodes.isEmpty())
+ m_nodes.removeFirst();
+ //m_window->deleteLater();
+}
+
+void Analyzer::clear()
+{
+ while (!m_nodes.isEmpty())
+ m_nodes.removeFirst();
+ for ( int i = 0; i< 75; ++i )
+ {
+ m_intern_vis_data[i] = 0;
+ m_peaks[i] = 0;
+ }
+ update();
+}
+
+void Analyzer::add ( Buffer *b, unsigned long w, int c, int p )
+{
+ if (m_projectMWidget->projectM())
+ m_projectMWidget->projectM()->pcm()->addPCM16Data((short *)b->data, b->nbytes/4);
+}
+
+void Analyzer::keyReleaseEvent (QKeyEvent *e)
+{
+
+ projectMKeycode pkey;
+ bool ignore = FALSE;
+ switch (e->key())
+ {
+ case Qt::Key_F:
+ {
+ setWindowState (windowState() ^Qt::WindowFullScreen);
+ return;
+ }
+ case Qt::Key_M:
+ pkey = PROJECTM_K_M;
+ break;
+ case Qt::Key_F4:
+ pkey = PROJECTM_K_F4;
+ break;
+ case Qt::Key_F3:
+ pkey = PROJECTM_K_F3;
+ break;
+ case Qt::Key_F2:
+ pkey = PROJECTM_K_F2;
+ break;
+ case Qt::Key_F1:
+ pkey = PROJECTM_K_F1;
+ break;
+ case Qt::Key_R:
+ pkey = PROJECTM_K_r;
+ break;
+ case Qt::Key_L:
+ pkey = PROJECTM_K_l;
+ ignore = true;
+ break;
+ case Qt::Key_N:
+ pkey = PROJECTM_K_n;
+ break;
+ case Qt::Key_P:
+ pkey = PROJECTM_K_p;
+ break;
+ case Qt::Key_F5:
+ pkey = PROJECTM_K_F5;
+ break;
+ default:
+ e->ignore();
+ return;
+ }
+ projectMModifier modifier;
+
+ m_projectMWidget->projectM()->key_handler(PROJECTM_KEYDOWN, pkey, modifier);
+ if (ignore)
+ e->ignore();
+}
diff --git a/src/plugins/Visual/projectm/analyzer.h b/src/plugins/Visual/projectm/analyzer.h
new file mode 100644
index 000000000..77f9b5d3a
--- /dev/null
+++ b/src/plugins/Visual/projectm/analyzer.h
@@ -0,0 +1,95 @@
+/***************************************************************************
+ * Copyright (C) 2007 by Ilya Kotov *
+ * forkotov02@hotmail.ru *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+#ifndef ANALYZER_H
+#define ANALYZER_H
+
+#include <QWidget>
+#include <QMutex>
+#include <QResizeEvent>
+#include <qmmp/visual.h>
+#include <qmmp/constants.h>
+#include <QDir>
+#include <libprojectM-qt/qprojectm_mainwindow.hpp>
+
+class QSettings;
+class QTimer;
+class QMenu;
+class QActionGroup;
+
+class Buffer;
+
+class ProjectMWidget;
+
+
+class VisualNode
+{
+public:
+ VisualNode(short *l, short *r, unsigned long n, unsigned long o)
+ : left(l), right(r), length(n), offset(o)
+ {
+ // left and right are allocated and then passed to this class
+ // the code that allocated left and right should give up all ownership
+ }
+
+ ~VisualNode()
+ {
+ delete [] left;
+ delete [] right;
+ }
+
+ short *left, *right;
+ long length, offset;
+};
+
+class Analyzer : public Visual
+{
+ Q_OBJECT
+
+public:
+ Analyzer(QWidget *parent = 0);
+ virtual ~Analyzer();
+
+ void add(Buffer *, unsigned long, int, int);
+ void clear();
+
+private:
+ void keyReleaseEvent (QKeyEvent *e);
+ QPixmap m_pixmap;
+ QPixmap m_bg;
+ QList <VisualNode*> m_nodes;
+ QTimer *m_timer;
+ ProjectMWidget *m_projectMWidget;
+ QMutex mutex;
+ int m_fps;
+ double m_intern_vis_data[75];
+ double m_peaks[75];
+ double m_peaks_falloff;
+ double m_analyzer_falloff;
+ bool m_show_peaks;
+ //colors
+ QColor m_color1;
+ QColor m_color2;
+ QColor m_color3;
+ QColor m_bgColor;
+ QColor m_peakColor;
+};
+
+
+#endif
diff --git a/src/plugins/Visual/projectm/projectm.pro b/src/plugins/Visual/projectm/projectm.pro
new file mode 100644
index 000000000..9f3682077
--- /dev/null
+++ b/src/plugins/Visual/projectm/projectm.pro
@@ -0,0 +1,39 @@
+include(../../plugins.pri)
+
+TARGET =$$PLUGINS_PREFIX/Visual/projectm
+QMAKE_CLEAN =$$PLUGINS_PREFIX/Visual/libprojectm.so
+
+
+#FORMS += settingsdialog.ui
+HEADERS += analyzer.h \
+ visualprojectmfactory.h \
+ projectmwidget.h \
+ qprojectm.h
+SOURCES += analyzer.cpp \
+ visualprojectmfactory.cpp \
+ projectmwidget.cpp
+INCLUDEPATH += ../../../
+CONFIG += release \
+warn_on \
+plugin \
+link_pkgconfig
+
+PKGCONFIG += libprojectM-qt libprojectM
+INCLUDEPATH += /usr/include/libprojectM
+
+TEMPLATE = lib
+QMAKE_LIBDIR += ../../../../lib
+LIBS += -lqmmp -L/usr/lib -I/usr/include
+#TRANSLATIONS = translations/projectm_plugin_cs.ts
+# translations/projectm_plugin_de.ts
+# translations/projectm_plugin_zh_CN.ts
+# translations/projectm_plugin_zh_TW.ts
+# translations/projectm_plugin_ru.ts
+# translations/projectm_plugin_uk_UA.ts
+#RESOURCES = translations/translations.qrc
+
+isEmpty(LIB_DIR){
+ LIB_DIR = /lib
+}
+target.path = $$LIB_DIR/qmmp/Visual
+INSTALLS += target
diff --git a/src/plugins/Visual/projectm/projectmwidget.cpp b/src/plugins/Visual/projectm/projectmwidget.cpp
new file mode 100644
index 000000000..7cc7d233b
--- /dev/null
+++ b/src/plugins/Visual/projectm/projectmwidget.cpp
@@ -0,0 +1,99 @@
+/***************************************************************************
+ * Copyright (C) 2009 by Ilya Kotov *
+ * forkotov02@hotmail.ru *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+
+#include <QTimer>
+#include <QDir>
+#include <QKeyEvent>
+
+#include "projectmwidget.h"
+
+ProjectMWidget::ProjectMWidget(QWidget *parent)
+ : QGLWidget(parent)
+{
+ setMouseTracking(TRUE);
+ m_projectM = 0;
+ QTimer *timer = new QTimer(this);
+ connect(timer, SIGNAL(timeout()),SLOT(updateGL ()));
+ timer->start(0);
+}
+
+
+ProjectMWidget::~ProjectMWidget()
+{
+ if (m_projectM)
+ delete m_projectM;
+ m_projectM = 0;
+}
+
+QProjectM *ProjectMWidget::projectM()
+{
+ return m_projectM;
+}
+
+void ProjectMWidget::initializeGL()
+{
+ glShadeModel(GL_SMOOTH);
+ glClearColor(0,0,0,0);
+ // Setup our viewport
+ glViewport(0, 0, width(), height());
+ // Change to the projection matrix and set our viewing volume.
+ glMatrixMode(GL_TEXTURE);
+ glLoadIdentity();
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glMatrixMode(GL_MODELVIEW);
+ glLoadIdentity();
+ glDrawBuffer(GL_BACK);
+ glReadBuffer(GL_BACK);
+ glEnable(GL_BLEND);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ glEnable(GL_LINE_SMOOTH);
+ glEnable(GL_POINT_SMOOTH);
+ glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
+ glLineStipple(2, 0xAAAA);
+ if (!m_projectM)
+ {
+ m_projectM = new QProjectM("/usr/share/projectM/config.inp");
+
+
+ QString file(m_projectM->settings().presetURL.c_str());
+
+ foreach (QFileInfo info, QDir(file).entryInfoList())
+ {
+ if (info.fileName().toLower().endsWith(".prjm") || info.fileName().toLower().endsWith(".milk"))
+ m_projectM->addPresetURL ( info.absoluteFilePath().toStdString(), info.fileName().toStdString(), 1);
+ }
+ }
+}
+
+void ProjectMWidget::resizeGL (int w, int h)
+{
+ if (m_projectM)
+ {
+ m_projectM->projectM_resetGL(w, h);
+ initializeGL();
+ }
+}
+
+void ProjectMWidget::paintGL()
+{
+ if (m_projectM)
+ m_projectM->renderFrame();
+}
diff --git a/src/plugins/Visual/projectm/projectmwidget.h b/src/plugins/Visual/projectm/projectmwidget.h
new file mode 100644
index 000000000..55809e80f
--- /dev/null
+++ b/src/plugins/Visual/projectm/projectmwidget.h
@@ -0,0 +1,53 @@
+/***************************************************************************
+ * Copyright (C) 2009 by Ilya Kotov *
+ * forkotov02@hotmail.ru *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+#ifndef PROJECTMWIDGET_H
+#define PROJECTMWIDGET_H
+
+
+#include "qprojectm.h"
+#include <QGLWidget>
+
+class QProjectM;
+
+
+/**
+ @author Ilya Kotov <forkotov02@hotmail.ru>
+*/
+class ProjectMWidget : public QGLWidget
+{
+ Q_OBJECT
+public:
+ ProjectMWidget(QWidget *parent = 0);
+
+ ~ProjectMWidget();
+
+ QProjectM *projectM();
+
+protected:
+ virtual void initializeGL();
+ virtual void resizeGL(int width, int height);
+ virtual void paintGL();
+
+private:
+ QProjectM *m_projectM;
+
+};
+
+#endif
diff --git a/src/plugins/Visual/projectm/qprojectm.h b/src/plugins/Visual/projectm/qprojectm.h
new file mode 100644
index 000000000..b96280fd2
--- /dev/null
+++ b/src/plugins/Visual/projectm/qprojectm.h
@@ -0,0 +1,35 @@
+//
+// C++ Interface: qprojectm
+//
+// Description:
+//
+//
+// Author: Carmelo Piccione <carmelo.piccione@gmail.com>, (C) 2008
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+
+#ifndef QPROJECTM_HPP
+#define QPROJECTM_HPP
+#include <libprojectM/projectM.hpp>
+#include <QObject>
+
+class QProjectM : public QObject, public projectM
+{
+
+ Q_OBJECT
+
+public:
+ QProjectM(const std::string & config_file) : projectM(config_file, projectM::FLAG_DISABLE_PLAYLIST_LOAD) {}
+
+ void presetSwitchedEvent(bool hardCut, unsigned int index) const
+ {
+ presetSwitchedSignal(hardCut, index);
+ }
+
+signals:
+ void presetSwitchedSignal(bool hardCut, unsigned int index) const;
+
+};
+#endif
diff --git a/src/plugins/Visual/projectm/visualprojectmfactory.cpp b/src/plugins/Visual/projectm/visualprojectmfactory.cpp
new file mode 100644
index 000000000..f3fb377db
--- /dev/null
+++ b/src/plugins/Visual/projectm/visualprojectmfactory.cpp
@@ -0,0 +1,62 @@
+/***************************************************************************
+ * Copyright (C) 2008 by Ilya Kotov *
+ * forkotov02@hotmail.ru *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+
+#include <QtGui>
+
+//#include "settingsdialog.h"
+#include "visualprojectmfactory.h"
+#include "analyzer.h"
+
+const VisualProperties VisualProjectMFactory::properties() const
+{
+ VisualProperties properties;
+ properties.name = tr("ProjectM Plugin");
+ properties.shortName = "projectm";
+ properties.hasSettings = FALSE;
+ properties.hasAbout = TRUE;
+ return properties;
+};
+
+Visual *VisualProjectMFactory::create(QWidget *parent)
+{
+ return new Analyzer(parent);
+};
+
+QDialog *VisualProjectMFactory::createConfigDialog(QWidget *parent)
+{
+ return 0;
+};
+
+void VisualProjectMFactory::showAbout(QWidget *parent)
+{
+ QMessageBox::about (parent, tr("About Analyzer Visual Plugin"),
+ tr("Qmmp Analyzer Visual Plugin")+"\n"+
+ tr("Writen by: Ilya Kotov <forkotov02@hotmail.ru>"));
+};
+
+QTranslator *VisualProjectMFactory::createTranslator(QObject *parent)
+{
+ QTranslator *translator = new QTranslator(parent);
+ QString locale = QLocale::system().name();
+ translator->load(QString(":/analyzer_plugin_") + locale);
+ return translator;
+};
+
+Q_EXPORT_PLUGIN(VisualProjectMFactory)
diff --git a/src/plugins/Visual/projectm/visualprojectmfactory.h b/src/plugins/Visual/projectm/visualprojectmfactory.h
new file mode 100644
index 000000000..be7a9ba1f
--- /dev/null
+++ b/src/plugins/Visual/projectm/visualprojectmfactory.h
@@ -0,0 +1,46 @@
+/***************************************************************************
+ * Copyright (C) 2008 by Ilya Kotov *
+ * forkotov02@hotmail.ru *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+#ifndef VISUALPROJECTMFACTORY_H
+#define VISUALPROJECTMFACTORY_H
+
+
+#include <QObject>
+
+#include <qmmp/visualfactory.h>
+#include <qmmp/visual.h>
+
+/**
+ @author Ilya Kotov <forkotov02@hotmail.ru>
+*/
+class VisualProjectMFactory : public QObject, public VisualFactory
+{
+Q_OBJECT
+Q_INTERFACES(VisualFactory);
+
+public:
+ const VisualProperties properties() const;
+ Visual *create(QWidget *parent);
+ QDialog *createConfigDialog(QWidget *parent);
+ void showAbout(QWidget *parent);
+ QTranslator *createTranslator(QObject *parent);
+};
+
+
+#endif