summaryrefslogtreecommitdiff
path: root/muse_qt4_evolution/midiplugins/metronom
diff options
context:
space:
mode:
Diffstat (limited to 'muse_qt4_evolution/midiplugins/metronom')
-rw-r--r--muse_qt4_evolution/midiplugins/metronom/CMakeLists.txt46
-rw-r--r--muse_qt4_evolution/midiplugins/metronom/metronom.cpp167
-rw-r--r--muse_qt4_evolution/midiplugins/metronom/metronom.h53
-rw-r--r--muse_qt4_evolution/midiplugins/metronom/metronomgui.cpp75
-rw-r--r--muse_qt4_evolution/midiplugins/metronom/metronomgui.h36
-rw-r--r--muse_qt4_evolution/midiplugins/metronom/metronomgui.ui150
6 files changed, 527 insertions, 0 deletions
diff --git a/muse_qt4_evolution/midiplugins/metronom/CMakeLists.txt b/muse_qt4_evolution/midiplugins/metronom/CMakeLists.txt
new file mode 100644
index 00000000..5153e6d4
--- /dev/null
+++ b/muse_qt4_evolution/midiplugins/metronom/CMakeLists.txt
@@ -0,0 +1,46 @@
+#=============================================================================
+# MusE
+# Linux Music Editor
+# $Id:$
+#
+# Copyright (C) 2002-2006 by Werner Schweer and others
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 2.
+#
+# 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+#=============================================================================
+
+QT4_WRAP_CPP ( metronom_mocs metronomgui.h )
+QT4_WRAP_UI ( metronom_uis metronomgui.ui )
+
+add_library ( metronom SHARED
+ metronom.cpp
+ metronomgui.cpp
+ metronomgui.h
+ ${metronom_mocs}
+ ${metronom_uis}
+ )
+target_link_libraries( metronom
+ midiplugin
+ ${QT_LIBRARIES}
+ )
+
+# - tell cmake to name target metronom.so instead of
+# libmetronom.so
+# - use precompiled header files
+#
+set_target_properties ( metronom
+ PROPERTIES PREFIX ""
+ COMPILE_FLAGS "-include ${PROJECT_BINARY_DIR}/all-pic.h"
+ )
+
+install_targets ( /${CMAKE_INSTALL_LIBDIR}/${MusE_INSTALL_NAME}/midiplugins/ metronom )
+
diff --git a/muse_qt4_evolution/midiplugins/metronom/metronom.cpp b/muse_qt4_evolution/midiplugins/metronom/metronom.cpp
new file mode 100644
index 00000000..ece1e466
--- /dev/null
+++ b/muse_qt4_evolution/midiplugins/metronom/metronom.cpp
@@ -0,0 +1,167 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: metronom.cpp,v 1.3 2005/11/16 17:55:59 wschweer Exp $
+//
+// metronom - midi metronom
+//
+// (C) Copyright 2005 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include "metronomgui.h"
+#include "metronom.h"
+#include "midi.h"
+#include "midievent.h"
+
+//---------------------------------------------------------
+// Metronom
+//---------------------------------------------------------
+
+Metronom::Metronom(const char* name, const MempiHost* h)
+ : Mempi(name, h)
+ {
+ gui = 0;
+ }
+
+//---------------------------------------------------------
+// Metronom
+//---------------------------------------------------------
+
+Metronom::~Metronom()
+ {
+ if (gui)
+ delete gui;
+ }
+
+//---------------------------------------------------------
+// init
+//---------------------------------------------------------
+
+bool Metronom::init()
+ {
+ nextTick = 0;
+ lastTo = 0;
+ data.measureNote = 63;
+ data.measureVelo = 127;
+ data.beatNote = 63;
+ data.beatVelo = 70;
+
+ gui = new MetronomGui(this, 0);
+ gui->hide();
+ gui->setWindowTitle(QString(name()));
+
+ return false;
+ }
+
+//---------------------------------------------------------
+// getGeometry
+//---------------------------------------------------------
+
+void Metronom::getGeometry(int* x, int* y, int* w, int* h) const
+ {
+ QPoint pos(gui->pos());
+ QSize size(gui->size());
+ *x = pos.x();
+ *y = pos.y();
+ *w = size.width();
+ *h = size.height();
+ }
+
+//---------------------------------------------------------
+// setGeometry
+//---------------------------------------------------------
+
+void Metronom::setGeometry(int x, int y, int w, int h)
+ {
+ gui->resize(QSize(w, h));
+ gui->move(QPoint(x, y));
+ }
+
+//---------------------------------------------------------
+// process
+//---------------------------------------------------------
+
+void Metronom::process(unsigned from, unsigned to, MidiEventList* /*il*/, MidiEventList* ol)
+ {
+ if (from == to) {
+ nextTick = 0;
+ return;
+ }
+ if (lastTo != from) { // seek?
+// printf(" seek? %d-%d\n", lastTo, from);
+ nextTick = 0;
+ }
+ lastTo = to;
+ if (nextTick > to)
+ return;
+ while (nextTick < to) {
+ int bar, beat;
+ unsigned tick;
+ if (nextTick < from) {
+ host->bar(from, &bar, &beat, &tick);
+ if (tick)
+ nextTick = host->bar2tick(bar, beat+1, 0);
+ else
+ nextTick = from;
+ }
+ host->bar(nextTick, &bar, &beat, &tick);
+ bool isMeasure = beat == 0;
+
+ MidiEvent ev(nextTick, 0, ME_NOTEON, data.beatNote, data.beatVelo);
+ if (isMeasure) {
+ ev.setA(data.measureNote);
+ ev.setB(data.measureVelo);
+ }
+ ol->insert(ev); // insert note on
+ ev.setB(0);
+ ev.setTime(nextTick + 10);
+ ev.setB(0);
+ ol->insert(ev); // insert note off
+
+ nextTick = host->bar2tick(bar, beat+1, 0);
+ }
+ }
+
+//---------------------------------------------------------
+// getInitData
+//---------------------------------------------------------
+
+void Metronom::getInitData(int* n, const unsigned char** p) const
+ {
+ *n = sizeof(data);
+ *p = (unsigned char*)&data;
+ }
+
+//---------------------------------------------------------
+// setInitData
+//---------------------------------------------------------
+
+void Metronom::setInitData(int n, const unsigned char* p)
+ {
+ memcpy((void*)&data, p, n);
+ if (gui)
+ gui->init();
+ }
+
+//---------------------------------------------------------
+// inst
+//---------------------------------------------------------
+
+static Mempi* instantiate(const char* name, const MempiHost* h)
+ {
+ return new Metronom(name, h);
+ }
+
+extern "C" {
+ static MEMPI descriptor = {
+ "Metronom",
+ "MusE Simple Midi Metronom",
+ "0.1", // version string
+ MEMPI_GENERATOR,
+ MEMPI_MAJOR_VERSION, MEMPI_MINOR_VERSION,
+ instantiate
+ };
+
+ const MEMPI* mempi_descriptor() { return &descriptor; }
+ }
+
diff --git a/muse_qt4_evolution/midiplugins/metronom/metronom.h b/muse_qt4_evolution/midiplugins/metronom/metronom.h
new file mode 100644
index 00000000..3d570613
--- /dev/null
+++ b/muse_qt4_evolution/midiplugins/metronom/metronom.h
@@ -0,0 +1,53 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: metronom.h,v 1.3 2005/06/12 09:22:51 wschweer Exp $
+//
+// metronom - simple midi metronom
+//
+// (C) Copyright 2005 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __METRONOM_H__
+#define __METRONOM_H__
+
+#include "../libmidiplugin/mempi.h"
+
+//---------------------------------------------------------
+// metronom - simple midi metronom
+//---------------------------------------------------------
+
+class Metronom : public Mempi {
+
+ protected:
+ struct InitData {
+ char measureNote;
+ char measureVelo;
+ char beatNote;
+ char beatVelo;
+ } data;
+ MetronomGui* gui;
+ friend class MetronomGui;
+
+ unsigned int nextTick;
+ unsigned int lastTo;
+
+ virtual void process(unsigned, unsigned, MidiEventList*, MidiEventList*);
+
+ public:
+ Metronom(const char* name, const MempiHost*);
+ ~Metronom();
+ virtual bool init();
+
+ virtual bool hasGui() const { return true; }
+ virtual bool guiVisible() const { return gui->isVisible(); }
+ virtual void showGui(bool val) { gui->setShown(val); }
+ virtual void getGeometry(int* x, int* y, int* w, int* h) const;
+ virtual void setGeometry(int, int, int, int);
+
+ virtual void getInitData(int*, const unsigned char**) const;
+ virtual void setInitData(int, const unsigned char*);
+ };
+
+#endif
+
diff --git a/muse_qt4_evolution/midiplugins/metronom/metronomgui.cpp b/muse_qt4_evolution/midiplugins/metronom/metronomgui.cpp
new file mode 100644
index 00000000..e6705f7c
--- /dev/null
+++ b/muse_qt4_evolution/midiplugins/metronom/metronomgui.cpp
@@ -0,0 +1,75 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: metronomgui.cpp,v 1.2 2005/10/05 17:02:03 lunar_shuttle Exp $
+//
+// (C) Copyright 2005 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include "metronomgui.h"
+#include "metronom.h"
+
+//---------------------------------------------------------
+// MidiMetronomConfig
+//---------------------------------------------------------
+
+MetronomGui::MetronomGui(Metronom* f, QWidget* parent)
+ : QDialog(parent)
+ {
+ setupUi(this);
+ metronom = f;
+ init();
+ connect(beatNote, SIGNAL(valueChanged(int)), SLOT(beatNoteChanged(int)));
+ connect(measureVelocity, SIGNAL(valueChanged(int)), SLOT(measureVelocityChanged(int)));
+ connect(measureNote, SIGNAL(valueChanged(int)), SLOT(measureNoteChanged(int)));
+ connect(beatVelocity, SIGNAL(valueChanged(int)), SLOT(beatVelocityChanged(int)));
+ }
+
+//---------------------------------------------------------
+// init
+//---------------------------------------------------------
+
+void MetronomGui::init()
+ {
+ beatNote->setValue(metronom->data.beatNote);
+ measureNote->setValue(metronom->data.measureNote);
+ beatVelocity->setValue(metronom->data.beatVelo);
+ measureVelocity->setValue(metronom->data.measureVelo);
+ }
+
+//---------------------------------------------------------
+// beatNoteChanged
+//---------------------------------------------------------
+
+void MetronomGui::beatNoteChanged(int val)
+ {
+ metronom->data.beatNote = val;
+ }
+
+//---------------------------------------------------------
+// measureVelocityChanged
+//---------------------------------------------------------
+
+void MetronomGui::measureVelocityChanged(int val)
+ {
+ metronom->data.measureVelo = val;
+ }
+
+//---------------------------------------------------------
+// measureNoteChanged
+//---------------------------------------------------------
+
+void MetronomGui::measureNoteChanged(int val)
+ {
+ metronom->data.measureNote = val;
+ }
+
+//---------------------------------------------------------
+// beatVelocityChanged
+//---------------------------------------------------------
+
+void MetronomGui::beatVelocityChanged(int val)
+ {
+ metronom->data.beatVelo = val;
+ }
+
diff --git a/muse_qt4_evolution/midiplugins/metronom/metronomgui.h b/muse_qt4_evolution/midiplugins/metronom/metronomgui.h
new file mode 100644
index 00000000..cceea61d
--- /dev/null
+++ b/muse_qt4_evolution/midiplugins/metronom/metronomgui.h
@@ -0,0 +1,36 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: metronomgui.h,v 1.3 2005/10/05 17:02:03 lunar_shuttle Exp $
+//
+// (C) Copyright 2005 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __METRONOMGUI_H__
+#define __METRONOMGUI_H__
+
+#include "ui_metronomgui.h"
+
+class Metronom;
+
+//---------------------------------------------------------
+// MetronomGui
+//---------------------------------------------------------
+
+class MetronomGui : public QDialog, public Ui::MetronomBase {
+ Q_OBJECT
+ Metronom* metronom;
+
+ private slots:
+ void beatNoteChanged(int);
+ void measureVelocityChanged(int);
+ void measureNoteChanged(int);
+ void beatVelocityChanged(int);
+
+ public:
+ MetronomGui(Metronom*, QWidget* parent=0);
+ void init();
+ };
+
+#endif
+
diff --git a/muse_qt4_evolution/midiplugins/metronom/metronomgui.ui b/muse_qt4_evolution/midiplugins/metronom/metronomgui.ui
new file mode 100644
index 00000000..188735d4
--- /dev/null
+++ b/muse_qt4_evolution/midiplugins/metronom/metronomgui.ui
@@ -0,0 +1,150 @@
+<ui version="4.0" >
+ <author></author>
+ <comment></comment>
+ <exportmacro></exportmacro>
+ <class>MetronomBase</class>
+ <widget class="QDialog" name="MetronomBase" >
+ <property name="geometry" >
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>429</width>
+ <height>164</height>
+ </rect>
+ </property>
+ <property name="sizePolicy" >
+ <sizepolicy>
+ <hsizetype>3</hsizetype>
+ <vsizetype>5</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="windowTitle" >
+ <string>MusE: Midi Metronome</string>
+ </property>
+ <layout class="QVBoxLayout" >
+ <property name="margin" >
+ <number>9</number>
+ </property>
+ <property name="spacing" >
+ <number>6</number>
+ </property>
+ <item>
+ <layout class="QHBoxLayout" >
+ <property name="margin" >
+ <number>0</number>
+ </property>
+ <property name="spacing" >
+ <number>6</number>
+ </property>
+ <item>
+ <widget class="QLabel" name="label" >
+ <property name="sizePolicy" >
+ <sizepolicy>
+ <hsizetype>0</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="font" >
+ <font>
+ <family>ZappedChancellor</family>
+ <pointsize>48</pointsize>
+ <weight>75</weight>
+ <italic>false</italic>
+ <bold>true</bold>
+ <underline>false</underline>
+ <strikeout>false</strikeout>
+ </font>
+ </property>
+ <property name="toolTip" >
+ <string>Metronome</string>
+ </property>
+ <property name="whatsThis" >
+ <string>Metronome</string>
+ </property>
+ <property name="text" >
+ <string>M</string>
+ </property>
+ <property name="alignment" >
+ <set>Qt::AlignCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <layout class="QGridLayout" >
+ <property name="margin" >
+ <number>0</number>
+ </property>
+ <property name="spacing" >
+ <number>6</number>
+ </property>
+ <item row="0" column="1" >
+ <widget class="QLabel" name="TextLabel1" >
+ <property name="text" >
+ <string>Measure Note</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1" >
+ <widget class="QLabel" name="TextLabel2" >
+ <property name="text" >
+ <string>Measure Velocity</string>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="1" >
+ <widget class="QLabel" name="TextLabel4" >
+ <property name="text" >
+ <string>Beat Velocity</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1" >
+ <widget class="QLabel" name="TextLabel3" >
+ <property name="text" >
+ <string>Beat Note</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0" >
+ <widget class="QSpinBox" name="beatNote" >
+ <property name="maximum" >
+ <number>127</number>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0" >
+ <widget class="QSpinBox" name="measureVelocity" >
+ <property name="maximum" >
+ <number>127</number>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="0" >
+ <widget class="QSpinBox" name="measureNote" >
+ <property name="maximum" >
+ <number>127</number>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="0" >
+ <widget class="QSpinBox" name="beatVelocity" >
+ <property name="maximum" >
+ <number>127</number>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ <layoutdefault spacing="6" margin="11" />
+ <pixmapfunction>qPixmapFromMimeSource</pixmapfunction>
+ <resources/>
+ <connections/>
+</ui>