diff options
Diffstat (limited to 'attic/muse_qt4_evolution/midiplugins')
51 files changed, 5947 insertions, 0 deletions
diff --git a/attic/muse_qt4_evolution/midiplugins/CMakeLists.txt b/attic/muse_qt4_evolution/midiplugins/CMakeLists.txt new file mode 100644 index 00000000..465e1983 --- /dev/null +++ b/attic/muse_qt4_evolution/midiplugins/CMakeLists.txt @@ -0,0 +1,36 @@ +#============================================================================= +# 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. +#============================================================================= + +subdirs( + libmidiplugin + splitlayer + filter + metronom + transform + trigg + dump + drumglue + ) + +set ( CMAKE_CXX_FLAGS + "${CMAKE_CXX_FLAGS} -DQT_NO_DEBUG -DQT_PLUGIN -DQT_SHARED -fPIC" + ) + +set ( CMAKE_LDD_FLAGS -module -avoid-version ) diff --git a/attic/muse_qt4_evolution/midiplugins/drumglue/CMakeLists.txt b/attic/muse_qt4_evolution/midiplugins/drumglue/CMakeLists.txt new file mode 100644 index 00000000..f824c54b --- /dev/null +++ b/attic/muse_qt4_evolution/midiplugins/drumglue/CMakeLists.txt @@ -0,0 +1,50 @@ +#============================================================================= +# MusE +# Linux Music Editor +# $Id:$ +# +# Copyright (C) 2002-2008 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 ( drumglue_mocs drumgluegui.h globalinstrumentview.h outputinstrumentview.h ) +QT4_WRAP_UI ( drumglue_uis drumgluegui.ui globalinstrumentview.ui outputinstrumentview.ui ) + +add_library ( drumglue SHARED + drumglue.cpp + drumgluegui.cpp + drumgluegui.h + globalinstrumentview.cpp + globalinstrumentview.h + outputinstrumentview.cpp + outputinstrumentview.h + ${drumglue_mocs} + ${drumglue_uis} + ) + +target_link_libraries( drumglue + midiplugin awl + ${QT_LIBRARIES} + ) + +# - tell cmake to name target name.so instead of +# libname.so +# - use precompiled header files +set_target_properties ( drumglue + PROPERTIES PREFIX "" + COMPILE_FLAGS "-include ${PROJECT_BINARY_DIR}/all-pic.h" + ) + +install_targets ( /${CMAKE_INSTALL_LIBDIR}/${MusE_INSTALL_NAME}/midiplugins/ drumglue ) + diff --git a/attic/muse_qt4_evolution/midiplugins/drumglue/drumglue.cpp b/attic/muse_qt4_evolution/midiplugins/drumglue/drumglue.cpp new file mode 100644 index 00000000..7a9b6ed2 --- /dev/null +++ b/attic/muse_qt4_evolution/midiplugins/drumglue/drumglue.cpp @@ -0,0 +1,250 @@ +//========================================================= +// MusE +// Linux Music Editor +// +// drumglue - filter +// +// (C) Copyright 2008 Robert Jonsson (rj@spamatica.se) +// (C) Copyright 2005- Werner Schweer (ws@seh.de) +// Copyright: See COPYING file that comes with this distribution +//========================================================= + +#include "drumgluegui.h" +#include "drumglue.h" +#include "midi.h" +#include "midievent.h" + + + +//--------------------------------------------------------- +// DrumInstrument - get next index +// - next output instrument to use +//--------------------------------------------------------- +int DrumInstrument::getNextIndex(int /*velocity*/) +{ + // for now we simply do a round robin + // + // future improvements are to keep track of + // the time since the last hit and the + // weight set for each instrument. + // the incoming velocity should be checked that it's in range + if (outputInstruments.size() == 0) + return -1; + + if (lastOutputIndex+1 > outputInstruments.size()-1) + return 0; + else + return lastOutputIndex+1; +} + +//--------------------------------------------------------- +// DrumInstrument - get velocity +// - velocity value to use +//--------------------------------------------------------- +int DrumInstrument::getVelocity(int /*index*/, int velocity) +{ + // for now we just return the same velocity + // future improvements are to allow for some + return velocity; +} + + +//--------------------------------------------------------- +// DrumGlue - constructor +//--------------------------------------------------------- +DrumGlue::DrumGlue(const char* name, const MempiHost* h) + : Mempi(name, h) + { + gui = 0; + saveData = NULL; + } + +//--------------------------------------------------------- +// DrumGlue - destructor +//--------------------------------------------------------- +DrumGlue::~DrumGlue() + { + if (gui) + delete gui; + if (saveData) + delete saveData; + } + +//--------------------------------------------------------- +// init +//--------------------------------------------------------- + +bool DrumGlue::init() + { + gui = new DrumGlueGui(this, 0); + gui->setWindowTitle("MusE: "+QString(name())); + gui->show(); + return false; + } + +//--------------------------------------------------------- +// getGeometry +//--------------------------------------------------------- + +void DrumGlue::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 DrumGlue::setGeometry(int x, int y, int w, int h) + { + gui->resize(QSize(w, h)); + gui->move(QPoint(x, y)); + } + +//--------------------------------------------------------- +// process +//--------------------------------------------------------- + +void DrumGlue::process(unsigned , unsigned , MidiEventList* il, MidiEventList* ol) + { + + for (iMidiEvent i = il->begin(); i != il->end(); ++i) { + MidiEvent temp=*i; + if (temp.isNote() && !temp.isNoteOff()) + { + foreach(DrumInstrument *di, drumInstruments) { + if (temp.dataA() == di->inKey) { + int inVelocity = temp.dataB(); + int instrumentIdx = di->getNextIndex(inVelocity); + if (instrumentIdx==-1) { + // no instrument defined, yet, skip it + break; + } + int outKey = di->outputInstruments[instrumentIdx]->outKey; + int outVelocity= di->getVelocity(instrumentIdx, inVelocity); + printf("inKey=%d outKey =%d outVelocity=%d instrumentIdx=%d\n", di->inKey, outKey, outVelocity, instrumentIdx); + temp.setA(outKey); + temp.setB(outVelocity); + + ol->insert(temp); // note on + + temp.setB(0); + ol->insert(temp); // note off + + di->lastOutputIndex = instrumentIdx; + di->outputTime = temp.time(); + break; + } + } + } + if (temp.isNoteOff()) ; // we just throw it away, we will insert noteoffs for each note on + } + } + +// +// getInitData - return configuration to MusE +// +void DrumGlue::getInitData(int* n, const unsigned char** p) const + { + QString saveStr; + + foreach (DrumInstrument *di, drumInstruments) { + QString drumline = "DRUM " +di->name + " " + QString("%1").arg(di->inKey) + "\n"; + saveStr.append(drumline); + foreach (DrumOutputInstrument *doi, di->outputInstruments) { + QString outputline = "OUTPUT " + + QString("%1").arg(doi->outKey) + " " + + QString("%1").arg(doi->lowestVelocity) + " " + + QString("%1").arg(doi->highestVelocity) + " " + + QString("%1").arg(doi->prefer) + " " + + QString("%1").arg(doi->preferFast) + "\n"; + saveStr.append(outputline); + + } + } + + *n = saveStr.length(); + + if (saveData) + delete saveData; + + + saveData = new unsigned char[saveStr.length()]; + + strncpy((char*)saveData, saveStr.toLatin1().data(), saveStr.length()); + saveData[saveStr.length()]=0; + printf("getInitData -\n%s\n",saveData); + + *p = saveData; + + } + +void DrumGlue::setInitData(int n, const unsigned char* p) + { + if (saveData) + delete saveData; + saveData = new unsigned char[n+1]; + + strncpy((char*)saveData,(char*)p,n); + saveData[n]=0; + + QString loadStr = (char*)saveData; + printf("setInitData -\n%s\n",saveData); + + QStringList loadList = loadStr.split("\n"); + + DrumInstrument *currentInstrument=NULL; + foreach (QString line, loadList) { + QStringList splitLine = line.split(" "); + if (splitLine[0] == "DRUM") { + if (currentInstrument) + drumInstruments.append(currentInstrument); + + currentInstrument = new DrumInstrument(); + currentInstrument->name = splitLine[1]; + currentInstrument->inKey = splitLine[2].toInt(); + } + if (splitLine[0] == "OUTPUT") { + DrumOutputInstrument *doi = new DrumOutputInstrument; + doi->outKey = splitLine[1].toInt(); + doi->lowestVelocity = splitLine[2].toInt(); + doi->highestVelocity = splitLine[3].toInt(); + doi->prefer = splitLine[4].toInt(); + doi->preferFast = splitLine[5].toInt(); + currentInstrument->outputInstruments.append(doi); + } + } + if (currentInstrument) + drumInstruments.append(currentInstrument); + + if (gui) + gui->init(); + } + +//--------------------------------------------------------- +// inst +//--------------------------------------------------------- + +static Mempi* instantiate(const char* name, const MempiHost* h) + { + return new DrumGlue(name, h); + } + +extern "C" { + static MEMPI descriptor = { + "DrumGlue", + "Drum instrument mux filter", + "0.1", // filter version string + MEMPI_FILTER, // plugin type + MEMPI_MAJOR_VERSION, MEMPI_MINOR_VERSION, + instantiate + }; + + const MEMPI* mempi_descriptor() { return &descriptor; } + } + diff --git a/attic/muse_qt4_evolution/midiplugins/drumglue/drumglue.h b/attic/muse_qt4_evolution/midiplugins/drumglue/drumglue.h new file mode 100644 index 00000000..49a19b55 --- /dev/null +++ b/attic/muse_qt4_evolution/midiplugins/drumglue/drumglue.h @@ -0,0 +1,86 @@ +//========================================================= +// MusE +// Linux Music Editor +// +// drumglue - filter +// +// (C) Copyright 2008 Robert Jonsson (rj@spamatica.se) +// (C) Copyright 2005- Werner Schweer (ws@seh.de) +// Copyright: See COPYING file that comes with this distribution +//========================================================= + +#ifndef __DRUMGLUE_H__ +#define __DRUMGLUE_H__ + +#include <QtGui> + +#include "../libmidiplugin/mempi.h" + +#include "drumgluegui.h" +//--------------------------------------------------------- +// drumglue - filter +//--------------------------------------------------------- + +struct DrumOutputInstrument { + int outKey; // key to send + int lowestVelocity; // lower velocity valid for this instrument + int highestVelocity; // highest velocity valid for this instrument + bool prefer; // true if this instrument is preferred + bool preferFast; // true if this instrument is preferred for fast transitions +}; + +class DrumInstrument { + public: + DrumInstrument() + { + inKey=0; + lastOutputIndex=0; + outputTime=0; + } + + int getNextIndex(int velocity); + int getVelocity(int index, int velocity); + + + int inKey; // the key which triggers this instrument + QString name; + QList <DrumOutputInstrument *> outputInstruments; + +// storage of runtime variables + int lastOutputIndex; + unsigned int outputTime; +}; + + + + +class DrumGlue : public Mempi { + friend class DrumGlueGui; + friend class GlobalInstrumentView; + friend class OutputInstrumentView; + + QList<DrumInstrument *> drumInstruments; + + DrumGlueGui* gui; + + mutable unsigned char *saveData; + + virtual void process(unsigned, unsigned, MidiEventList*, MidiEventList*); + + public: + DrumGlue(const char* name, const MempiHost*); + ~DrumGlue(); + 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/attic/muse_qt4_evolution/midiplugins/drumglue/drumgluegui.cpp b/attic/muse_qt4_evolution/midiplugins/drumglue/drumgluegui.cpp new file mode 100644 index 00000000..562adf2c --- /dev/null +++ b/attic/muse_qt4_evolution/midiplugins/drumglue/drumgluegui.cpp @@ -0,0 +1,68 @@ +//========================================================= +// MusE +// Linux Music Editor +// +// (C) Copyright 2008 Robert Jonsson (rj@spamatica.se) +// (C) Copyright 2005- Werner Schweer (ws@seh.de) +// Copyright: See COPYING file that comes with this distribution +//========================================================= + +#include "drumgluegui.h" +#include "drumglue.h" +#include "globalinstrumentview.h" + +//--------------------------------------------------------- +// DrumGlueGui +//--------------------------------------------------------- + +DrumGlueGui::DrumGlueGui(DrumGlue* f, QWidget* parent) + : QDialog(parent) + { + drumGlue = f; + setupUi(this); + instrumentsTabWidget->clear(); + + connect (addInstrumentButton, SIGNAL(clicked()), this, SLOT(addInstrument())); + } + +//--------------------------------------------------------- +// init +//--------------------------------------------------------- +void DrumGlueGui::init() + { + foreach(DrumInstrument *di, drumGlue->drumInstruments) { + GlobalInstrumentView *giView = new GlobalInstrumentView(drumGlue,this, di->name); + instrumentsTabWidget->addTab(giView, di->name); + } + } + +//--------------------------------------------------------- +// addInstrument +//--------------------------------------------------------- +void DrumGlueGui::addInstrument() + { + bool ok; + QString text = QInputDialog::getText(this, tr("Instrument name"), + tr("Name of instrument:"), QLineEdit::Normal, + "", &ok); + if (ok && !text.isEmpty()) { + DrumInstrument *di = new DrumInstrument(); + di->name = text; + drumGlue->drumInstruments.append(di); + GlobalInstrumentView *giView = new GlobalInstrumentView(drumGlue,this, text); + instrumentsTabWidget->addTab(giView, text); + } + } + +//--------------------------------------------------------- +// removeInstrument +//--------------------------------------------------------- +void DrumGlueGui::removeInstrument() + { + int ret = QMessageBox::warning(this, tr("Remove instrument"), + tr("Are you sure you want to remove current instrument?"), + QMessageBox::No, + QMessageBox::Yes); + if (ret == QMessageBox::Yes) + instrumentsTabWidget->removeTab(instrumentsTabWidget->currentIndex()); + } diff --git a/attic/muse_qt4_evolution/midiplugins/drumglue/drumgluegui.h b/attic/muse_qt4_evolution/midiplugins/drumglue/drumgluegui.h new file mode 100644 index 00000000..cdbac7a3 --- /dev/null +++ b/attic/muse_qt4_evolution/midiplugins/drumglue/drumgluegui.h @@ -0,0 +1,41 @@ +//========================================================= +// MusE +// Linux Music Editor +// +// (C) Copyright 2008 Robert Jonsson (rj@spamatica.se) +// (C) Copyright 2005- Werner Schweer (ws@seh.de) +// Copyright: See COPYING file that comes with this distribution +//========================================================= + +#ifndef __DRUMGLUEGUI_H__ +#define __DRUMGLUEGUI_H__ + +//#include "ui_drumglue.h" +#include "ui_drumgluegui.h" + + +//--------------------------------------------------------- +// DrumGlueGui +//--------------------------------------------------------- +class DrumGlue; + +class DrumGlueGui : public QDialog, public Ui::DrumGlueBase { + Q_OBJECT + + DrumGlue* drumGlue; + + signals: + void hideWindow(); + + public: + DrumGlueGui(DrumGlue*, QWidget* parent=0); + void init(); + + private slots: + void addInstrument(); + void removeInstrument(); + + }; + +#endif + diff --git a/attic/muse_qt4_evolution/midiplugins/drumglue/drumgluegui.ui b/attic/muse_qt4_evolution/midiplugins/drumglue/drumgluegui.ui new file mode 100644 index 00000000..ddd402c4 --- /dev/null +++ b/attic/muse_qt4_evolution/midiplugins/drumglue/drumgluegui.ui @@ -0,0 +1,91 @@ +<ui version="4.0" > + <class>DrumGlueBase</class> + <widget class="QDialog" name="DrumGlueBase" > + <property name="geometry" > + <rect> + <x>0</x> + <y>0</y> + <width>444</width> + <height>270</height> + </rect> + </property> + <property name="windowTitle" > + <string>Drumglue - midi filter</string> + </property> + <layout class="QGridLayout" > + <item row="0" column="0" > + <layout class="QVBoxLayout" > + <item> + <layout class="QHBoxLayout" > + <item> + <widget class="QPushButton" name="addInstrumentButton" > + <property name="text" > + <string>Add instrument</string> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="pushButton" > + <property name="text" > + <string>Remove current</string> + </property> + </widget> + </item> + <item> + <spacer> + <property name="orientation" > + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" > + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QLabel" name="label" > + <property name="font" > + <font> + <family>Arial</family> + <pointsize>14</pointsize> + <weight>75</weight> + <bold>true</bold> + </font> + </property> + <property name="text" > + <string>DrumGlue 0.1</string> + </property> + </widget> + </item> + </layout> + </item> + <item> + <widget class="QTabWidget" name="instrumentsTabWidget" > + <property name="tabPosition" > + <enum>QTabWidget::North</enum> + </property> + <property name="tabShape" > + <enum>QTabWidget::Rounded</enum> + </property> + <property name="currentIndex" > + <number>0</number> + </property> + <property name="elideMode" > + <enum>Qt::ElideLeft</enum> + </property> + <widget class="QWidget" name="Tab1" > + <attribute name="title" > + <string>Snare</string> + </attribute> + </widget> + </widget> + </item> + </layout> + </item> + </layout> + </widget> + <resources/> + <connections/> +</ui> diff --git a/attic/muse_qt4_evolution/midiplugins/drumglue/globalinstrumentview.cpp b/attic/muse_qt4_evolution/midiplugins/drumglue/globalinstrumentview.cpp new file mode 100644 index 00000000..5ca81054 --- /dev/null +++ b/attic/muse_qt4_evolution/midiplugins/drumglue/globalinstrumentview.cpp @@ -0,0 +1,153 @@ +//========================================================= +// MusE +// Linux Music Editor +// +// (C) Copyright 2008 Robert Jonsson (rj@spamatica.se) +// (C) Copyright 2005- Werner Schweer (ws@seh.de) +// Copyright: See COPYING file that comes with this distribution +//========================================================= + +#include "globalinstrumentview.h" +#include "outputinstrumentview.h" +#include "drumglue.h" + +//--------------------------------------------------------- +// GlobalInstrumentView +//--------------------------------------------------------- + +GlobalInstrumentView::GlobalInstrumentView(DrumGlue* f, QWidget* parent, QString name) + : QWidget(parent) + { + setupUi(this); + drumGlue = f; + + instrumentName=name; + + DrumInstrument *di =getCurrentOutputInstrument(); + printf("di->inKey=%d\n", di->inKey); + if (di) + inKeySpinBox->setValue(di->inKey); + + connect (addOutputButton, SIGNAL(clicked()), this, SLOT(addOutput())); + connect (editOutputButton, SIGNAL(clicked()), this, SLOT(editOutput())); + connect (removeOutputButton, SIGNAL(clicked()), this, SLOT(removeOutput())); + connect (inKeySpinBox, SIGNAL(valueChanged(int)), this, SLOT(updateInKey())); + updateList(); + } + + +DrumInstrument *GlobalInstrumentView::getCurrentOutputInstrument() +{ + // get the global instrument belonging to this instance + QList<DrumInstrument *>::iterator iter = drumGlue->drumInstruments.begin(); + while(iter != drumGlue->drumInstruments.end()) { + printf("name = %s instrumentName= %s\n", (*iter)->name.toLatin1().data(), instrumentName.toLatin1().data()); + if ((*iter)->name == instrumentName) { + break; + } + iter++; + } + if (iter == drumGlue->drumInstruments.end()) { + printf("Reached the end without getting a hit\n"); + return NULL; + } + return *iter; +} + +void GlobalInstrumentView::addOutput() + { + DrumInstrument *di = getCurrentOutputInstrument(); + if (!di) + return; + // create new output + DrumOutputInstrument *doi = new DrumOutputInstrument; + di->outputInstruments.append(doi); + + OutputInstrumentView *outputView = new OutputInstrumentView(doi,this); + int res = outputView->exec(); + if (res == QDialog::Rejected) { + // roll back + di->outputInstruments.removeAll(doi); + delete doi; + } + delete outputView; + updateList(); + } + +void GlobalInstrumentView::editOutput() + { + DrumInstrument *di = getCurrentOutputInstrument(); + + int currIdx = outputListWidget->currentRow(); + if (currIdx < 0 || currIdx >= di->outputInstruments.size()) { + printf("out of range!!\n"); + return; + } + + DrumOutputInstrument *doi = di->outputInstruments[currIdx]; + + DrumOutputInstrument doi_backup = *doi; + OutputInstrumentView *outputView = new OutputInstrumentView(doi,this); + int res = outputView->exec(); + if (res == QDialog::Rejected) { + // roll back + *doi = doi_backup; + } + delete outputView; + updateList(); + } + +void GlobalInstrumentView::removeOutput() + { + int ret = QMessageBox::warning(this, tr("Remove output"), + tr("Are you sure you want to remove current output?"), + QMessageBox::No, + QMessageBox::Yes); + if (ret == QMessageBox::Yes) { + DrumInstrument *di = getCurrentOutputInstrument(); + + int currIdx = outputListWidget->currentRow(); + if (currIdx < 0 || currIdx >= di->outputInstruments.size()) { + printf("out of range!!\n"); + return; + } + + DrumOutputInstrument *doi = di->outputInstruments[currIdx]; + di->outputInstruments.removeAll(doi); + delete doi; + } + updateList(); + } + +void GlobalInstrumentView::updateList() +{ + printf("updateList\n"); + outputListWidget->clear(); + + QList<DrumInstrument *>::iterator iter = drumGlue->drumInstruments.begin(); + while(iter != drumGlue->drumInstruments.end()) { + printf("name = %s instrumentName= %s\n", (*iter)->name.toLatin1().data(), instrumentName.toLatin1().data()); + if ((*iter)->name == instrumentName) { + printf("updating current list\n"); + foreach (DrumOutputInstrument *doi, (*iter)->outputInstruments) { + QListWidgetItem *outDrumItem = new QListWidgetItem(outputListWidget); + QString str = QString("%1 %2 %3 %4 %5").arg(doi->outKey).arg(doi->lowestVelocity).arg(doi->highestVelocity).arg(doi->prefer).arg(doi->preferFast); + printf("setting item to %s\n",str.toLatin1().data()); + outDrumItem->setText(str); + } + } + iter++; + } +} + +void GlobalInstrumentView::updateInKey() +{ + QList<DrumInstrument *>::iterator iter = drumGlue->drumInstruments.begin(); + while(iter != drumGlue->drumInstruments.end()) { + if ((*iter)->name == instrumentName) { + (*iter)->inKey = inKeySpinBox->value(); + } + iter++; + } + +} diff --git a/attic/muse_qt4_evolution/midiplugins/drumglue/globalinstrumentview.h b/attic/muse_qt4_evolution/midiplugins/drumglue/globalinstrumentview.h new file mode 100644 index 00000000..f923ec49 --- /dev/null +++ b/attic/muse_qt4_evolution/midiplugins/drumglue/globalinstrumentview.h @@ -0,0 +1,41 @@ +//========================================================= +// MusE +// Linux Music Editor +// +// (C) Copyright 2008 Robert Jonsson (rj@spamatica.se) +// (C) Copyright 2005- Werner Schweer (ws@seh.de) +// Copyright: See COPYING file that comes with this distribution +//========================================================= + +#ifndef __GLOBALINSTRUMENTVIEW_H__ +#define __GLOBALINSTRUMENTVIEW_H__ + +#include "ui_globalinstrumentview.h" + +#include "drumglue.h" +//--------------------------------------------------------- +// GlobalInstrumentView +//--------------------------------------------------------- +class DrumGlue; + +class GlobalInstrumentView : public QWidget, public Ui::GlobalInstrumentViewBase { + Q_OBJECT + + DrumGlue *drumGlue; + QString instrumentName; + DrumInstrument *getCurrentOutputInstrument(); + + public: + GlobalInstrumentView(DrumGlue*, QWidget* parent, QString name); + private slots: + void addOutput(); + void editOutput(); + void removeOutput(); + void updateInKey(); + + public slots: + void updateList(); + }; + +#endif + diff --git a/attic/muse_qt4_evolution/midiplugins/drumglue/globalinstrumentview.ui b/attic/muse_qt4_evolution/midiplugins/drumglue/globalinstrumentview.ui new file mode 100644 index 00000000..e817906a --- /dev/null +++ b/attic/muse_qt4_evolution/midiplugins/drumglue/globalinstrumentview.ui @@ -0,0 +1,102 @@ +<ui version="4.0" > + <class>GlobalInstrumentViewBase</class> + <widget class="QWidget" name="GlobalInstrumentViewBase" > + <property name="geometry" > + <rect> + <x>0</x> + <y>0</y> + <width>386</width> + <height>256</height> + </rect> + </property> + <property name="windowTitle" > + <string>Form</string> + </property> + <layout class="QHBoxLayout" > + <property name="spacing" > + <number>-1</number> + </property> + <item> + <layout class="QHBoxLayout" > + <property name="spacing" > + <number>-1</number> + </property> + <item> + <layout class="QVBoxLayout" > + <property name="spacing" > + <number>-1</number> + </property> + <item> + <widget class="QLabel" name="label_2" > + <property name="text" > + <string>Midi input key:</string> + </property> + </widget> + </item> + <item> + <widget class="QSpinBox" name="inKeySpinBox" > + <property name="minimum" > + <number>1</number> + </property> + <property name="maximum" > + <number>127</number> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="addOutputButton" > + <property name="text" > + <string>Add output</string> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="removeOutputButton" > + <property name="text" > + <string>Remove output</string> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="editOutputButton" > + <property name="text" > + <string>Edit output</string> + </property> + </widget> + </item> + <item> + <spacer> + <property name="orientation" > + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" > + <size> + <width>20</width> + <height>40</height> + </size> + </property> + </spacer> + </item> + </layout> + </item> + <item> + <layout class="QVBoxLayout" > + <item> + <widget class="QLabel" name="label" > + <property name="text" > + <string>Midi output definitions:</string> + </property> + </widget> + </item> + <item> + <widget class="QListWidget" name="outputListWidget" /> + </item> + </layout> + </item> + </layout> + </item> + </layout> + </widget> + <resources/> + <connections/> +</ui> diff --git a/attic/muse_qt4_evolution/midiplugins/drumglue/outputinstrumentview.cpp b/attic/muse_qt4_evolution/midiplugins/drumglue/outputinstrumentview.cpp new file mode 100644 index 00000000..2e4c97ce --- /dev/null +++ b/attic/muse_qt4_evolution/midiplugins/drumglue/outputinstrumentview.cpp @@ -0,0 +1,45 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: filtergui.cpp,v 1.4 2005/11/06 17:49:34 wschweer Exp $ +// +// (C) Copyright 2005 Werner Schweer (ws@seh.de) +//========================================================= + +#include "outputinstrumentview.h" +#include "drumglue.h" +#include <QtGui> +//--------------------------------------------------------- +// OutputInstrumentView +//--------------------------------------------------------- + +OutputInstrumentView::OutputInstrumentView(DrumOutputInstrument* doi, QWidget* parent) + : QDialog(parent) + { + outputInstrument= doi; + setupUi(this); + + midiOutputSpinBox->setValue(outputInstrument->outKey); + highRangeSlider->setValue(outputInstrument->highestVelocity); + lowRangeSlider->setValue(outputInstrument->lowestVelocity); + preferWhenFastCheckBox->setChecked(outputInstrument->preferFast); + highProbabiltyCheckBox->setChecked(outputInstrument->prefer); + + + connect(midiOutputSpinBox,SIGNAL(valueChanged(int)),this, SLOT(update())); + connect(highRangeSlider,SIGNAL(valueChanged(int)),this, SLOT(update())); + connect(lowRangeSlider,SIGNAL(valueChanged(int)),this, SLOT(update())); + connect(preferWhenFastCheckBox,SIGNAL(stateChanged(int)),this, SLOT(update())); + connect(highProbabiltyCheckBox,SIGNAL(stateChanged(int)),this, SLOT(update())); + } + + +void OutputInstrumentView::update() +{ + outputInstrument->outKey = midiOutputSpinBox->value(); + outputInstrument->highestVelocity = highRangeSlider->value(); + outputInstrument->lowestVelocity = lowRangeSlider->value(); + outputInstrument->preferFast = preferWhenFastCheckBox->isChecked(); + outputInstrument->prefer = highProbabiltyCheckBox->isChecked(); + +} diff --git a/attic/muse_qt4_evolution/midiplugins/drumglue/outputinstrumentview.h b/attic/muse_qt4_evolution/midiplugins/drumglue/outputinstrumentview.h new file mode 100644 index 00000000..b2b5dc12 --- /dev/null +++ b/attic/muse_qt4_evolution/midiplugins/drumglue/outputinstrumentview.h @@ -0,0 +1,31 @@ +//========================================================= +// MusE +// Linux Music Editor +// +// (C) Copyright 2008 Robert Jonsson (rj@spamatica.se) +// (C) Copyright 2005- Werner Schweer (ws@seh.de) +// Copyright: See COPYING file that comes with this distribution +//========================================================= + +#ifndef __OUTPUTINSTRUMENTVIEW_H__ +#define __OUTPUTINSTRUMENTVIEW_H__ + +#include "ui_outputinstrumentview.h" + +#include "drumglue.h" +//--------------------------------------------------------- +// OutputInstrumentView +//--------------------------------------------------------- +class DrumGlue; + +class OutputInstrumentView : public QDialog, public Ui::OutputInstrumentViewBase { + Q_OBJECT + DrumOutputInstrument *outputInstrument; + public: + OutputInstrumentView(DrumOutputInstrument*, QWidget* parent); + private slots: + void update(); + }; + +#endif + diff --git a/attic/muse_qt4_evolution/midiplugins/drumglue/outputinstrumentview.ui b/attic/muse_qt4_evolution/midiplugins/drumglue/outputinstrumentview.ui new file mode 100644 index 00000000..250c2010 --- /dev/null +++ b/attic/muse_qt4_evolution/midiplugins/drumglue/outputinstrumentview.ui @@ -0,0 +1,292 @@ +<ui version="4.0" > + <class>OutputInstrumentViewBase</class> + <widget class="QDialog" name="OutputInstrumentViewBase" > + <property name="geometry" > + <rect> + <x>0</x> + <y>0</y> + <width>449</width> + <height>150</height> + </rect> + </property> + <property name="windowTitle" > + <string>Dialog</string> + </property> + <layout class="QVBoxLayout" > + <item> + <layout class="QVBoxLayout" > + <item> + <layout class="QHBoxLayout" > + <item> + <widget class="QLabel" name="label" > + <property name="text" > + <string>Midi output key:</string> + </property> + </widget> + </item> + <item> + <widget class="QSpinBox" name="midiOutputSpinBox" > + <property name="minimum" > + <number>1</number> + </property> + <property name="maximum" > + <number>127</number> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="highProbabiltyCheckBox" > + <property name="toolTip" > + <string>If this instrument is to be used more often than others check this box.</string> + </property> + <property name="statusTip" > + <string/> + </property> + <property name="text" > + <string>Prefer always</string> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="preferWhenFastCheckBox" > + <property name="toolTip" > + <string>If this instrument is to be used more often when used often, check this checkbox.</string> + </property> + <property name="statusTip" > + <string/> + </property> + <property name="text" > + <string>Prefer when fast</string> + </property> + </widget> + </item> + </layout> + </item> + <item> + <widget class="Line" name="line_4" > + <property name="orientation" > + <enum>Qt::Horizontal</enum> + </property> + </widget> + </item> + <item> + <layout class="QHBoxLayout" > + <item> + <widget class="QLabel" name="label_3" > + <property name="sizePolicy" > + <sizepolicy vsizetype="Fixed" hsizetype="Preferred" > + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text" > + <string> [low]</string> + </property> + </widget> + </item> + <item> + <widget class="Line" name="line_2" > + <property name="sizePolicy" > + <sizepolicy vsizetype="Fixed" hsizetype="Fixed" > + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="orientation" > + <enum>Qt::Vertical</enum> + </property> + </widget> + </item> + <item> + <widget class="Line" name="line_3" > + <property name="sizePolicy" > + <sizepolicy vsizetype="Fixed" hsizetype="Fixed" > + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="orientation" > + <enum>Qt::Vertical</enum> + </property> + </widget> + </item> + <item> + <widget class="QLabel" name="label_4" > + <property name="sizePolicy" > + <sizepolicy vsizetype="Fixed" hsizetype="Preferred" > + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="layoutDirection" > + <enum>Qt::RightToLeft</enum> + </property> + <property name="text" > + <string> [high]</string> + </property> + </widget> + </item> + </layout> + </item> + <item> + <layout class="QHBoxLayout" > + <item> + <layout class="QHBoxLayout" > + <item> + <widget class="QLabel" name="lowRangeLabel" > + <property name="minimumSize" > + <size> + <width>24</width> + <height>0</height> + </size> + </property> + <property name="frameShape" > + <enum>QFrame::Box</enum> + </property> + <property name="text" > + <string>1</string> + </property> + </widget> + </item> + <item> + <widget class="QSlider" name="lowRangeSlider" > + <property name="minimum" > + <number>1</number> + </property> + <property name="maximum" > + <number>127</number> + </property> + <property name="orientation" > + <enum>Qt::Horizontal</enum> + </property> + </widget> + </item> + </layout> + </item> + <item> + <widget class="QLabel" name="label_5" > + <property name="text" > + <string> use in range </string> + </property> + </widget> + </item> + <item> + <layout class="QHBoxLayout" > + <item> + <widget class="QLabel" name="highRangeLabel" > + <property name="minimumSize" > + <size> + <width>24</width> + <height>0</height> + </size> + </property> + <property name="frameShape" > + <enum>QFrame::Box</enum> + </property> + <property name="text" > + <string>127</string> + </property> + </widget> + </item> + <item> + <widget class="QSlider" name="highRangeSlider" > + <property name="minimum" > + <number>1</number> + </property> + <property name="maximum" > + <number>127</number> + </property> + <property name="value" > + <number>127</number> + </property> + <property name="orientation" > + <enum>Qt::Horizontal</enum> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </item> + <item> + <widget class="QDialogButtonBox" name="buttonBox" > + <property name="orientation" > + <enum>Qt::Horizontal</enum> + </property> + <property name="standardButtons" > + <set>QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok</set> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </widget> + <resources/> + <connections> + <connection> + <sender>buttonBox</sender> + <signal>accepted()</signal> + <receiver>OutputInstrumentViewBase</receiver> + <slot>accept()</slot> + <hints> + <hint type="sourcelabel" > + <x>248</x> + <y>254</y> + </hint> + <hint type="destinationlabel" > + <x>157</x> + <y>274</y> + </hint> + </hints> + </connection> + <connection> + <sender>buttonBox</sender> + <signal>rejected()</signal> + <receiver>OutputInstrumentViewBase</receiver> + <slot>reject()</slot> + <hints> + <hint type="sourcelabel" > + <x>316</x> + <y>260</y> + </hint> + <hint type="destinationlabel" > + <x>286</x> + <y>274</y> + </hint> + </hints> + </connection> + <connection> + <sender>highRangeSlider</sender> + <signal>valueChanged(int)</signal> + <receiver>highRangeLabel</receiver> + <slot>setNum(int)</slot> + <hints> + <hint type="sourcelabel" > + <x>215</x> + <y>107</y> + </hint> + <hint type="destinationlabel" > + <x>165</x> + <y>108</y> + </hint> + </hints> + </connection> + <connection> + <sender>lowRangeSlider</sender> + <signal>valueChanged(int)</signal> + <receiver>lowRangeLabel</receiver> + <slot>setNum(int)</slot> + <hints> + <hint type="sourcelabel" > + <x>75</x> + <y>107</y> + </hint> + <hint type="destinationlabel" > + <x>25</x> + <y>108</y> + </hint> + </hints> + </connection> + </connections> +</ui> diff --git a/attic/muse_qt4_evolution/midiplugins/dump/CMakeLists.txt b/attic/muse_qt4_evolution/midiplugins/dump/CMakeLists.txt new file mode 100644 index 00000000..c607ef1f --- /dev/null +++ b/attic/muse_qt4_evolution/midiplugins/dump/CMakeLists.txt @@ -0,0 +1,40 @@ +#============================================================================= +# 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. +#============================================================================= + +add_library ( dump SHARED + dump.cpp + ) + +target_link_libraries( dump + midiplugin awl + ${QT_LIBRARIES} + ) + +# - tell cmake to name target dump.so instead of +# libdump.so +# - use precompiled header files +# +set_target_properties ( dump + PROPERTIES PREFIX "" + COMPILE_FLAGS "-include ${PROJECT_BINARY_DIR}/all-pic.h" + ) + +install_targets ( /${CMAKE_INSTALL_LIBDIR}/${MusE_INSTALL_NAME}/midiplugins/ dump ) + diff --git a/attic/muse_qt4_evolution/midiplugins/dump/dump.cpp b/attic/muse_qt4_evolution/midiplugins/dump/dump.cpp new file mode 100644 index 00000000..e346a642 --- /dev/null +++ b/attic/muse_qt4_evolution/midiplugins/dump/dump.cpp @@ -0,0 +1,48 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: filter.cpp,v 1.10 2005/11/06 17:49:34 wschweer Exp $ +// +// dump- simple midi event dump for testing purposes +// +// (C) Copyright 2006 Werner Schweer (ws@seh.de) +//========================================================= + +#include "dump.h" +#include "midi.h" + +//--------------------------------------------------------- +// process +//--------------------------------------------------------- + +void Dump::process(unsigned, unsigned, MidiEventList* il, MidiEventList* ol) + { + for (iMidiEvent i = il->begin(); i != il->end(); ++i) { + printf("Event %6d ch:%2d type:%2d 0x%02x 0x%02x\n", i->time(), i->channel(), + i->type(), i->dataA(), i->dataB()); + ol->insert(*i); + } + } + +//--------------------------------------------------------- +// inst +//--------------------------------------------------------- + +static Mempi* instantiate(const char* name, const MempiHost* h) + { + return new Dump(name, h); + } + +extern "C" { + static MEMPI descriptor = { + "Dump", + "MusE Simple Midi Event Dump", + "0.1", // version string + MEMPI_FILTER, // plugin type + MEMPI_MAJOR_VERSION, MEMPI_MINOR_VERSION, + instantiate + }; + + const MEMPI* mempi_descriptor() { return &descriptor; } + } + diff --git a/attic/muse_qt4_evolution/midiplugins/dump/dump.h b/attic/muse_qt4_evolution/midiplugins/dump/dump.h new file mode 100644 index 00000000..2194e30f --- /dev/null +++ b/attic/muse_qt4_evolution/midiplugins/dump/dump.h @@ -0,0 +1,28 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: filter.h,v 1.4 2005/06/12 08:18:37 wschweer Exp $ +// +// dump- simple midi event dump for testing purposes +// +// (C) Copyright 2006 Werner Schweer (ws@seh.de) +//========================================================= + +#ifndef __DUMP_H__ +#define __DUMP_H__ + +#include "../libmidiplugin/mempi.h" + +//--------------------------------------------------------- +// dump - simple midi event dump +//--------------------------------------------------------- + +class Dump : public Mempi { + virtual void process(unsigned, unsigned, MidiEventList*, MidiEventList*); + + public: + Dump(const char* name, const MempiHost* h) :Mempi(name, h) {} + }; + +#endif + diff --git a/attic/muse_qt4_evolution/midiplugins/filter/CMakeLists.txt b/attic/muse_qt4_evolution/midiplugins/filter/CMakeLists.txt new file mode 100644 index 00000000..7bdb8544 --- /dev/null +++ b/attic/muse_qt4_evolution/midiplugins/filter/CMakeLists.txt @@ -0,0 +1,49 @@ +#============================================================================= +# 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 ( filter_mocs filtergui.h ctrlcombo.h ) +QT4_WRAP_UI ( filter_uis filtergui.ui ) + +add_library ( filter SHARED + filter.cpp + filtergui.cpp + filtergui.h + ctrlcombo.cpp + ctrlcombo.h + ${filter_mocs} + ${filter_uis} + ) + +target_link_libraries( filter + midiplugin awl + ${QT_LIBRARIES} + ) + +# - tell cmake to name target filter.so instead of +# libfilter.so +# - use precompiled header files +# +set_target_properties ( filter + PROPERTIES PREFIX "" + COMPILE_FLAGS "-include ${PROJECT_BINARY_DIR}/all-pic.h" + ) + +install_targets ( /${CMAKE_INSTALL_LIBDIR}/${MusE_INSTALL_NAME}/midiplugins/ filter ) + diff --git a/attic/muse_qt4_evolution/midiplugins/filter/ctrlcombo.cpp b/attic/muse_qt4_evolution/midiplugins/filter/ctrlcombo.cpp new file mode 100644 index 00000000..b4c436c6 --- /dev/null +++ b/attic/muse_qt4_evolution/midiplugins/filter/ctrlcombo.cpp @@ -0,0 +1,56 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: ctrlcombo.cpp,v 1.2 2005/11/06 17:49:34 wschweer Exp $ +// +// (C) Copyright 1999/2000 Werner Schweer (ws@seh.de) +//========================================================= + +#include "ctrlcombo.h" + +//--------------------------------------------------------- +// CtrlComboBox +//--------------------------------------------------------- + +CtrlComboBox::CtrlComboBox(QWidget* parent) + : QComboBox(parent) + { + const char* ctxt[] = { + "No Ctrl", "BankSelMSB", "Modulation", "BreathCtrl", + "Control 3", "Foot Ctrl", "Porta Time", "DataEntMSB", + "MainVolume", "Balance", "Control 9", "Pan", + "Expression", "Control 12", "Control 13", "Control 14", + "Control 15", "Gen.Purp.1", "Gen.Purp.2", "Gen.Purp.3", + "Gen.Purp.4", "Control 20", "Control 21", "Control 22", + "Control 23", "Control 24", "Control 25", "Control 26", + "Control 27", "Control 28", "Control 29", "Control 30", + "Control 31", "BankSelLSB", "Modul. LSB", "BrthCt.LSB", + "Control 35", "FootCt.LSB", "Port.T LSB", "DataEntLSB", + "MainVolLSB", "BalanceLSB", "Control 41", "Pan LSB", + "Expr. LSB", "Control 44", "Control 45", "Control 46", + "Control 47", "Gen.P.1LSB", "Gen.P.2LSB", "Gen.P.3LSB", + "Gen.P.4LSB", "Control 52", "Control 53", "Control 54", + "Control 55", "Control 56", "Control 57", "Control 58", + "Control 59", "Control 60", "Control 61", "Control 62", + "Control 63", "Sustain", "Porta Ped", "Sostenuto", + "Soft Pedal", "Control 68", "Hold 2", "Control 70", + "HarmonicCo", "ReleaseTime", "Attack Time", "Brightness", + "Control 75", "Control 76", "Control 77", "Control 78", + "Control 79", "Gen.Purp.5", "Gen.Purp.6", "Gen.Purp.7", + "Gen.Purp.8", "Porta Ctrl", "Control 85", "Control 86", + "Control 87", "Control 88", "Control 89", "Control 90", + "Effect1Dep", "Effect2Dep", "Effect3Dep", "Effect4Dep", + "Phaser Dep", "Data Incr", "Data Decr", "NRPN LSB", + "NRPN MSB", "RPN LSB", "RPN MSB", "Control102", + "Control103", "Control104", "Control105", "Control106", + "Control107", "Control108", "Control109", "Control110", + "Control111", "Control112", "Control113", "Control114", + "Control115", "Control116", "Control117", "Control118", + "Control119", "AllSndOff", "Reset Ctrl", "Local Ctrl", + "AllNoteOff", "OmniModOff", "OmniModeOn", "MonoModeOn", + "PolyModeOn" + }; + for (unsigned int i = 0; i < sizeof(ctxt)/sizeof(*ctxt); ++i) + addItem(QString(ctxt[i])); + } + diff --git a/attic/muse_qt4_evolution/midiplugins/filter/ctrlcombo.h b/attic/muse_qt4_evolution/midiplugins/filter/ctrlcombo.h new file mode 100644 index 00000000..53044b20 --- /dev/null +++ b/attic/muse_qt4_evolution/midiplugins/filter/ctrlcombo.h @@ -0,0 +1,24 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: ctrlcombo.h,v 1.2 2005/11/06 17:49:34 wschweer Exp $ +// +// (C) Copyright 1999/2000 Werner Schweer (ws@seh.de) +//========================================================= + +#ifndef __CTRLGRP_H__ +#define __CTRLGRP_H__ + +//--------------------------------------------------------- +// CtrlComboBox +//--------------------------------------------------------- + +class CtrlComboBox : public QComboBox { + Q_OBJECT + public: + CtrlComboBox(QWidget* parent = 0); + }; + + +#endif + diff --git a/attic/muse_qt4_evolution/midiplugins/filter/filter.cpp b/attic/muse_qt4_evolution/midiplugins/filter/filter.cpp new file mode 100644 index 00000000..ac99449e --- /dev/null +++ b/attic/muse_qt4_evolution/midiplugins/filter/filter.cpp @@ -0,0 +1,167 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: filter.cpp,v 1.10 2005/11/06 17:49:34 wschweer Exp $ +// +// filter - simple midi filter +// +// (C) Copyright 2005 Werner Schweer (ws@seh.de) +//========================================================= + +#include "filtergui.h" +#include "filter.h" +#include "midi.h" + +//--------------------------------------------------------- +// Filter +//--------------------------------------------------------- + +Filter::Filter(const char* name, const MempiHost* h) + : Mempi(name, h) + { + data.type = 0; // allow any events + for (int i = 0; i < 4; ++i) + data.ctrl[i] = -1; + gui = 0; + } + +//--------------------------------------------------------- +// Filter +//--------------------------------------------------------- + +Filter::~Filter() + { + if (gui) + delete gui; + } + +//--------------------------------------------------------- +// init +//--------------------------------------------------------- + +bool Filter::init() + { + gui = new FilterGui(this, 0); + gui->setWindowTitle("MusE: "+QString(name())); + gui->show(); + return false; + } + +//--------------------------------------------------------- +// getGeometry +//--------------------------------------------------------- + +void Filter::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 Filter::setGeometry(int x, int y, int w, int h) + { + gui->resize(QSize(w, h)); + gui->move(QPoint(x, y)); + } + +//--------------------------------------------------------- +// process +//--------------------------------------------------------- + +void Filter::process(unsigned, unsigned, MidiEventList* il, MidiEventList* ol) + { + for (iMidiEvent i = il->begin(); i != il->end(); ++i) { + if (!filterEvent(*i)) + ol->insert(*i); + } + } + +//--------------------------------------------------------- +// filterEvent +// return true if event filtered +//--------------------------------------------------------- + +bool Filter::filterEvent(const MidiEvent& event) + { + switch(event.type()) { + case ME_NOTEON: + case ME_NOTEOFF: + if (data.type & MIDI_FILTER_NOTEON) + return true; + break; + case ME_POLYAFTER: + if (data.type & MIDI_FILTER_POLYP) + return true; + break; + case ME_CONTROLLER: + if (data.type & MIDI_FILTER_CTRL) + return true; + for (int i = 0; i < 4; ++i) { + if (data.ctrl[i] == event.dataA()) + return true; + } + break; + case ME_PROGRAM: + if (data.type & MIDI_FILTER_PROGRAM) + return true; + break; + case ME_AFTERTOUCH: + if (data.type & MIDI_FILTER_AT) + return true; + break; + case ME_PITCHBEND: + if (data.type & MIDI_FILTER_PITCH) + return true; + break; + case ME_SYSEX: + if (data.type & MIDI_FILTER_SYSEX) + return true; + break; + default: + break; + } + return false; + } + +void Filter::getInitData(int* n, const unsigned char** p) const + { + *n = sizeof(data); + *p = (unsigned char*)&data; + } + +void Filter::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 Filter(name, h); + } + +extern "C" { + static MEMPI descriptor = { + "Filter", + "MusE Simple Midi Filter", + "0.1", // filter version string + MEMPI_FILTER, // plugin type + MEMPI_MAJOR_VERSION, MEMPI_MINOR_VERSION, + instantiate + }; + + const MEMPI* mempi_descriptor() { return &descriptor; } + } + diff --git a/attic/muse_qt4_evolution/midiplugins/filter/filter.h b/attic/muse_qt4_evolution/midiplugins/filter/filter.h new file mode 100644 index 00000000..c8a357b4 --- /dev/null +++ b/attic/muse_qt4_evolution/midiplugins/filter/filter.h @@ -0,0 +1,51 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: filter.h,v 1.4 2005/06/12 08:18:37 wschweer Exp $ +// +// filter - simple midi filter +// +// (C) Copyright 2005 Werner Schweer (ws@seh.de) +//========================================================= + +#ifndef __FILTER_H__ +#define __FILTER_H__ + +#include "../libmidiplugin/mempi.h" + +//--------------------------------------------------------- +// filter - simple midi filter +//--------------------------------------------------------- + +class Filter : public Mempi { + struct initData { + int type; + int ctrl[4]; + } data; + FilterGui* gui; + + bool filterEvent(const MidiEvent& event); + virtual void process(unsigned, unsigned, MidiEventList*, MidiEventList*); + + public: + Filter(const char* name, const MempiHost*); + ~Filter(); + virtual bool init(); + + int midiType() const { return data.type; } + void setMidiType(int t) { data.type = t; } + int midiCtrl(int i) const { return data.ctrl[i]; } + void setMidiCtrl(int i, int val) { data.ctrl[i] = val; } + + 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/attic/muse_qt4_evolution/midiplugins/filter/filtergui.cpp b/attic/muse_qt4_evolution/midiplugins/filter/filtergui.cpp new file mode 100644 index 00000000..306ae392 --- /dev/null +++ b/attic/muse_qt4_evolution/midiplugins/filter/filtergui.cpp @@ -0,0 +1,187 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: filtergui.cpp,v 1.4 2005/11/06 17:49:34 wschweer Exp $ +// +// (C) Copyright 2005 Werner Schweer (ws@seh.de) +//========================================================= + +#include "filtergui.h" +#include "filter.h" +#include "ctrlcombo.h" + +//--------------------------------------------------------- +// MidiFilterConfig +//--------------------------------------------------------- + +FilterGui::FilterGui(Filter* f, QWidget* parent) + : QDialog(parent) + { + setupUi(this); + filter = f; + connect(rf1, SIGNAL(toggled(bool)), SLOT(rf1Toggled(bool))); + connect(rf2, SIGNAL(toggled(bool)), SLOT(rf2Toggled(bool))); + connect(rf3, SIGNAL(toggled(bool)), SLOT(rf3Toggled(bool))); + connect(rf4, SIGNAL(toggled(bool)), SLOT(rf4Toggled(bool))); + connect(rf5, SIGNAL(toggled(bool)), SLOT(rf5Toggled(bool))); + connect(rf6, SIGNAL(toggled(bool)), SLOT(rf6Toggled(bool))); + connect(rf7, SIGNAL(toggled(bool)), SLOT(rf7Toggled(bool))); + connect(cb1, SIGNAL(activated(int)), SLOT(cb1Activated(int))); + connect(cb2, SIGNAL(activated(int)), SLOT(cb2Activated(int))); + connect(cb3, SIGNAL(activated(int)), SLOT(cb3Activated(int))); + connect(cb4, SIGNAL(activated(int)), SLOT(cb4Activated(int))); + } + +//--------------------------------------------------------- +// init +//--------------------------------------------------------- + +void FilterGui::init() + { + int midiType = filter->midiType(); + rf1->setChecked(midiType & MIDI_FILTER_NOTEON); + rf2->setChecked(midiType & MIDI_FILTER_POLYP); + rf3->setChecked(midiType & MIDI_FILTER_CTRL); + rf4->setChecked(midiType & MIDI_FILTER_PROGRAM); + rf5->setChecked(midiType & MIDI_FILTER_AT); + rf6->setChecked(midiType & MIDI_FILTER_PITCH); + rf7->setChecked(midiType & MIDI_FILTER_SYSEX); + cb1->setCurrentIndex(filter->midiCtrl(0) + 1); + cb2->setCurrentIndex(filter->midiCtrl(1) + 1); + cb3->setCurrentIndex(filter->midiCtrl(2) + 1); + cb4->setCurrentIndex(filter->midiCtrl(3) + 1); + } + +//--------------------------------------------------------- +// cb1Activated +//--------------------------------------------------------- + +void FilterGui::cb1Activated(int idx) + { + filter->setMidiCtrl(0, idx - 1); + } + +//--------------------------------------------------------- +// cb2Activated +//--------------------------------------------------------- + +void FilterGui::cb2Activated(int idx) + { + filter->setMidiCtrl(1, idx - 1); + } + +//--------------------------------------------------------- +// cb3Activated +//--------------------------------------------------------- + +void FilterGui::cb3Activated(int idx) + { + filter->setMidiCtrl(2, idx - 1); + } + +//--------------------------------------------------------- +// cb4Activated +//--------------------------------------------------------- + +void FilterGui::cb4Activated(int idx) + { + filter->setMidiCtrl(3, idx - 1); + } + +//--------------------------------------------------------- +// rf1Toggled +//--------------------------------------------------------- + +void FilterGui::rf1Toggled(bool) + { + int midiType = filter->midiType(); + if (rf1->isChecked()) + midiType |= MIDI_FILTER_NOTEON; + else + midiType &= ~MIDI_FILTER_NOTEON; + filter->setMidiType(midiType); + } + +//--------------------------------------------------------- +// rf2Toggled +//--------------------------------------------------------- + +void FilterGui::rf2Toggled(bool) + { + int midiType = filter->midiType(); + if (rf2->isChecked()) + midiType |= MIDI_FILTER_POLYP; + else + midiType &= ~MIDI_FILTER_POLYP; + filter->setMidiType(midiType); + } + +//--------------------------------------------------------- +// rf3Toggled +//--------------------------------------------------------- + +void FilterGui::rf3Toggled(bool) + { + int midiType = filter->midiType(); + if (rf3->isChecked()) + midiType |= MIDI_FILTER_CTRL; + else + midiType &= ~MIDI_FILTER_CTRL; + filter->setMidiType(midiType); + } + +//--------------------------------------------------------- +// rf4Toggled +//--------------------------------------------------------- + +void FilterGui::rf4Toggled(bool) + { + int midiType = filter->midiType(); + if (rf4->isChecked()) + midiType |= MIDI_FILTER_PROGRAM; + else + midiType &= ~MIDI_FILTER_PROGRAM; + filter->setMidiType(midiType); + } + +//--------------------------------------------------------- +// rf5Toggled +//--------------------------------------------------------- + +void FilterGui::rf5Toggled(bool) + { + int midiType = filter->midiType(); + if (rf5->isChecked()) + midiType |= MIDI_FILTER_AT; + else + midiType &= ~MIDI_FILTER_AT; + filter->setMidiType(midiType); + } + +//--------------------------------------------------------- +// rf6Toggled +//--------------------------------------------------------- + +void FilterGui::rf6Toggled(bool) + { + int midiType = filter->midiType(); + if (rf1->isChecked()) + midiType |= MIDI_FILTER_PITCH; + else + midiType &= ~MIDI_FILTER_PITCH; + filter->setMidiType(midiType); + } + +//--------------------------------------------------------- +// rf7Toggled +//--------------------------------------------------------- + +void FilterGui::rf7Toggled(bool) + { + int midiType = filter->midiType(); + if (rf7->isChecked()) + midiType |= MIDI_FILTER_SYSEX; + else + midiType &= ~MIDI_FILTER_SYSEX; + filter->setMidiType(midiType); + } diff --git a/attic/muse_qt4_evolution/midiplugins/filter/filtergui.h b/attic/muse_qt4_evolution/midiplugins/filter/filtergui.h new file mode 100644 index 00000000..701bfec9 --- /dev/null +++ b/attic/muse_qt4_evolution/midiplugins/filter/filtergui.h @@ -0,0 +1,57 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: filtergui.h,v 1.4 2005/11/06 17:49:34 wschweer Exp $ +// +// (C) Copyright 2005 Werner Schweer (ws@seh.de) +//========================================================= + +#ifndef __FILTERGUI_H__ +#define __FILTERGUI_H__ + +#include "ui_filtergui.h" + +class Filter; + +enum { + MIDI_FILTER_NOTEON = 1, + MIDI_FILTER_POLYP = 2, + MIDI_FILTER_CTRL = 4, + MIDI_FILTER_PROGRAM = 8, + MIDI_FILTER_AT = 16, + MIDI_FILTER_PITCH = 32, + MIDI_FILTER_SYSEX = 64 + }; + +//--------------------------------------------------------- +// FilterGui +//--------------------------------------------------------- + +class FilterGui : public QDialog, public Ui::FilterBase { + Q_OBJECT + + Filter* filter; + + signals: + void hideWindow(); + + private slots: + void rf1Toggled(bool); + void rf2Toggled(bool); + void rf3Toggled(bool); + void rf4Toggled(bool); + void rf5Toggled(bool); + void rf6Toggled(bool); + void rf7Toggled(bool); + void cb1Activated(int); + void cb2Activated(int); + void cb3Activated(int); + void cb4Activated(int); + + public: + FilterGui(Filter*, QWidget* parent=0); + void init(); + }; + +#endif + diff --git a/attic/muse_qt4_evolution/midiplugins/filter/filtergui.ui b/attic/muse_qt4_evolution/midiplugins/filter/filtergui.ui new file mode 100644 index 00000000..8e1693f2 --- /dev/null +++ b/attic/muse_qt4_evolution/midiplugins/filter/filtergui.ui @@ -0,0 +1,269 @@ +<ui version="4.0" > + <author></author> + <comment></comment> + <exportmacro></exportmacro> + <class>FilterBase</class> + <widget class="QDialog" name="FilterBase" > + <property name="geometry" > + <rect> + <x>0</x> + <y>0</y> + <width>388</width> + <height>213</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 Input Filter</string> + </property> + <layout class="QHBoxLayout" > + <property name="margin" > + <number>6</number> + </property> + <property name="spacing" > + <number>2</number> + </property> + <item> + <widget class="QGroupBox" name="GroupBoxx" > + <property name="sizePolicy" > + <sizepolicy> + <hsizetype>5</hsizetype> + <vsizetype>5</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="title" > + <string>Event Filter</string> + </property> + <layout class="QVBoxLayout" > + <property name="margin" > + <number>6</number> + </property> + <property name="spacing" > + <number>2</number> + </property> + <item> + <widget class="QCheckBox" name="rf1" > + <property name="sizePolicy" > + <sizepolicy> + <hsizetype>5</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text" > + <string>Note On</string> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="rf2" > + <property name="sizePolicy" > + <sizepolicy> + <hsizetype>5</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text" > + <string>Poly Pressure</string> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="rf3" > + <property name="sizePolicy" > + <sizepolicy> + <hsizetype>5</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text" > + <string>Controller</string> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="rf4" > + <property name="sizePolicy" > + <sizepolicy> + <hsizetype>1</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text" > + <string>Program Change</string> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="rf5" > + <property name="sizePolicy" > + <sizepolicy> + <hsizetype>5</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text" > + <string>After Touch</string> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="rf6" > + <property name="sizePolicy" > + <sizepolicy> + <hsizetype>5</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text" > + <string>Pitch Bend</string> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="rf7" > + <property name="sizePolicy" > + <sizepolicy> + <hsizetype>5</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text" > + <string>Sysex</string> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item> + <widget class="QGroupBox" name="GroupBox4" > + <property name="sizePolicy" > + <sizepolicy> + <hsizetype>5</hsizetype> + <vsizetype>5</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="title" > + <string>Controller Filter</string> + </property> + <layout class="QVBoxLayout" > + <property name="margin" > + <number>6</number> + </property> + <property name="spacing" > + <number>2</number> + </property> + <item> + <widget class="CtrlComboBox" name="cb1" > + <property name="sizePolicy" > + <sizepolicy> + <hsizetype>5</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + </widget> + </item> + <item> + <widget class="CtrlComboBox" name="cb2" > + <property name="sizePolicy" > + <sizepolicy> + <hsizetype>5</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + </widget> + </item> + <item> + <widget class="CtrlComboBox" name="cb3" > + <property name="sizePolicy" > + <sizepolicy> + <hsizetype>5</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + </widget> + </item> + <item> + <widget class="CtrlComboBox" name="cb4" > + <property name="sizePolicy" > + <sizepolicy> + <hsizetype>5</hsizetype> + <vsizetype>5</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + </widget> + </item> + <item> + <spacer> + <property name="orientation" > + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" > + <size> + <width>20</width> + <height>40</height> + </size> + </property> + </spacer> + </item> + </layout> + </widget> + </item> + </layout> + </widget> + <layoutdefault spacing="6" margin="11" /> + <pixmapfunction></pixmapfunction> + <customwidgets> + <customwidget> + <class>CtrlComboBox</class> + <extends>QComboBox</extends> + <header>ctrlcombo.h</header> + <container>0</container> + <pixmap></pixmap> + </customwidget> + </customwidgets> + <tabstops> + <tabstop>rf1</tabstop> + <tabstop>rf2</tabstop> + <tabstop>rf3</tabstop> + <tabstop>rf4</tabstop> + <tabstop>rf5</tabstop> + <tabstop>rf6</tabstop> + <tabstop>rf7</tabstop> + </tabstops> + <resources/> + <connections/> +</ui> diff --git a/attic/muse_qt4_evolution/midiplugins/libmidiplugin/CMakeLists.txt b/attic/muse_qt4_evolution/midiplugins/libmidiplugin/CMakeLists.txt new file mode 100644 index 00000000..5988205f --- /dev/null +++ b/attic/muse_qt4_evolution/midiplugins/libmidiplugin/CMakeLists.txt @@ -0,0 +1,26 @@ +#============================================================================= +# 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. +#============================================================================= + +add_library ( midiplugin mempi.cpp ) + +set_target_properties( midiplugin + PROPERTIES COMPILE_FLAGS "-include ${PROJECT_BINARY_DIR}/all.h" + ) + diff --git a/attic/muse_qt4_evolution/midiplugins/libmidiplugin/evdata.h b/attic/muse_qt4_evolution/midiplugins/libmidiplugin/evdata.h new file mode 100644 index 00000000..8247b6e0 --- /dev/null +++ b/attic/muse_qt4_evolution/midiplugins/libmidiplugin/evdata.h @@ -0,0 +1,64 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: evdata.h,v 1.2 2005/05/11 14:18:39 wschweer Exp $ +// +// (C) Copyright 1999-2003 Werner Schweer (ws@seh.de) +//========================================================= + +#ifndef __EVDATA_H__ +#define __EVDATA_H__ + +//--------------------------------------------------------- +// EvData +// variable len event data (sysex, meta etc.) +//--------------------------------------------------------- + +class EvData { + int* refCount; + + public: + unsigned char* data; + int dataLen; + + EvData() { + data = 0; + dataLen = 0; + refCount = new int(1); + } + EvData(const EvData& ed) { + data = ed.data; + dataLen = ed.dataLen; + refCount = ed.refCount; + (*refCount)++; + } + + EvData& operator=(const EvData& ed) { + if (data == ed.data) + return *this; + if (--(*refCount) == 0) { + delete refCount; + delete[] data; + } + data = ed.data; + dataLen = ed.dataLen; + refCount = ed.refCount; + (*refCount)++; + return *this; + } + + ~EvData() { + if (--(*refCount) == 0) { + delete[] data; + delete refCount; + } + } + void setData(const unsigned char* p, int l) { + data = new unsigned char[l]; + memcpy(data, p, l); + dataLen = l; + } + }; + +#endif + diff --git a/attic/muse_qt4_evolution/midiplugins/libmidiplugin/mempi.cpp b/attic/muse_qt4_evolution/midiplugins/libmidiplugin/mempi.cpp new file mode 100644 index 00000000..91171c3b --- /dev/null +++ b/attic/muse_qt4_evolution/midiplugins/libmidiplugin/mempi.cpp @@ -0,0 +1,81 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: mempi.cpp,v 1.4 2005/05/24 15:27:48 wschweer Exp $ +// (C) Copyright 2005 Werner Schweer (ws@seh.de) +//========================================================= + +#include "mempi.h" + +static const int FIFO_SIZE = 128; + +//--------------------------------------------------------- +// MidiEvent +//--------------------------------------------------------- + +MidiEvent::MidiEvent(unsigned t, int tpe, const unsigned char* data, int len) + { + _time = t; + edata.setData(data, len); + _type = tpe; + } + +//--------------------------------------------------------- +// operator < +//--------------------------------------------------------- + +bool MidiEvent::operator<(const MidiEvent& e) const + { + if (time() != e.time()) + return time() < e.time(); + + // play note off events first to prevent overlapping + // notes + + if (channel() == e.channel()) + return type() == 0x80 + || (type() == 0x90 && dataB() == 0); + + int map[16] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 10, 11, 12, 13, 14, 15 }; + return map[channel()] < map[e.channel()]; + } + +//--------------------------------------------------------- +// MempiP +// Mempi private data structure +//--------------------------------------------------------- + +struct MempiP { + int dummy; + }; + +//--------------------------------------------------------- +// Mempi +//--------------------------------------------------------- + +Mempi::Mempi(const char* n, const MempiHost* h) + { + _name = strdup(n); + host = h; + d = new MempiP; + } + +Mempi::~Mempi() + { + delete _name; + delete d; + } + +//--------------------------------------------------------- +// getGeometry +// dummy +//--------------------------------------------------------- + +void Mempi::getGeometry(int* x, int* y, int* w, int* h) const + { + x = 0; + y = 0; + w = 0; + h = 0; + } + diff --git a/attic/muse_qt4_evolution/midiplugins/libmidiplugin/mempi.h b/attic/muse_qt4_evolution/midiplugins/libmidiplugin/mempi.h new file mode 100644 index 00000000..a5f114b6 --- /dev/null +++ b/attic/muse_qt4_evolution/midiplugins/libmidiplugin/mempi.h @@ -0,0 +1,97 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: mempi.h,v 1.10 2005/07/16 09:31:50 wschweer Exp $ +// (C) Copyright 2005 Werner Schweer (ws@seh.de) +//========================================================= + +// +// MusE experimental midi plugin interface +// + +#ifndef __MEMPI_H__ +#define __MEMPI_H__ + +#define MEMPI_MAJOR_VERSION 1 +#define MEMPI_MINOR_VERSION 1 + +#include <set> +#include "evdata.h" +#include "memory.h" +#include "midievent.h" + +class MempiP; + +//--------------------------------------------------------- +// MempiHost +// Host Infos +//--------------------------------------------------------- + +struct MempiHost { + virtual int division() const; // midi division + virtual int tempo(unsigned tick) const; + virtual unsigned tick2frame(unsigned tick) const; + virtual unsigned frame2tick(unsigned frame) const; + virtual void bar(int tick, int* bar, int* beat, unsigned* rest) const; + virtual unsigned bar2tick(int bar, int beat, int tick) const; + virtual ~MempiHost() {} + }; + +//--------------------------------------------------------- +// Mempi +// Instance class +// MusE experimental midi plugin interface +// Instance virtual interface class +//--------------------------------------------------------- + +class Mempi { + MempiP* d; + const char* _name; // mempi instance name + + protected: + const MempiHost* host; + + public: + // modul interface + Mempi(const char* name, const MempiHost*); + virtual ~Mempi(); + virtual bool init() { return false; } + const char* name() const { return _name; } + + // process interface + virtual void process(unsigned, unsigned, MidiEventList*, MidiEventList*) = 0; + + // session interface + virtual void getInitData(int*, const unsigned char**) const {} + virtual void setInitData(int, const unsigned char*) {} + + // GUI interface routines + virtual bool hasGui() const { return false; } + virtual bool guiVisible() const { return false; } + virtual void showGui(bool) {} + virtual void getGeometry(int* x, int* y, int* w, int* h) const; + virtual void setGeometry(int, int, int, int) {} + }; + +//--------------------------------------------------------- +// MEMPI +// Class descriptor +//--------------------------------------------------------- + +enum MempiType { MEMPI_FILTER = 0, MEMPI_GENERATOR = 1 }; + +struct MEMPI { + const char* name; + const char* description; + const char* version; + MempiType type; + int majorMempiVersion, minorMempiVersion; + Mempi* (*instantiate)(const char* name, const MempiHost*); + }; + +extern "C" { + const MEMPI* mempi_descriptor(); + } + +#endif + diff --git a/attic/muse_qt4_evolution/midiplugins/libmidiplugin/midievent.cpp b/attic/muse_qt4_evolution/midiplugins/libmidiplugin/midievent.cpp new file mode 100644 index 00000000..972bc8a2 --- /dev/null +++ b/attic/muse_qt4_evolution/midiplugins/libmidiplugin/midievent.cpp @@ -0,0 +1,21 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: mpevent.cpp,v 1.1 2005/05/08 17:01:30 wschweer Exp $ +// +// (C) Copyright 2002-2004 Werner Schweer (ws@seh.de) +//========================================================= + +#include "midievent.h" + +//--------------------------------------------------------- +// MEvent +//--------------------------------------------------------- + +MEvent::MEvent(unsigned t, int tpe, const unsigned char* data, int len) + { + _time = t; + edata.setData(data, len); + _type = tpe; + } + diff --git a/attic/muse_qt4_evolution/midiplugins/libmidiplugin/midievent.h b/attic/muse_qt4_evolution/midiplugins/libmidiplugin/midievent.h new file mode 100644 index 00000000..a21bec88 --- /dev/null +++ b/attic/muse_qt4_evolution/midiplugins/libmidiplugin/midievent.h @@ -0,0 +1,87 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: mpevent.h,v 1.3 2005/06/06 14:24:53 wschweer Exp $ +// +// (C) Copyright 1999-2002 Werner Schweer (ws@seh.de) +//========================================================= + +#ifndef __MIDIEVENT_H__ +#define __MIDIEVENT_H__ + +#include <set> +#include "evdata.h" +#include <ext/mt_allocator.h> + +class Event; +class EvData; + +//--------------------------------------------------------- +// MidiEvent +//--------------------------------------------------------- + +class MidiEvent { + unsigned _time; + EvData edata; + unsigned char _channel, _type; + int _a, _b; + + public: + MidiEvent() {} + MidiEvent(unsigned tm, int c, int t, int a, int b) + : _time(tm), _channel(c & 0xf), _type(t), _a(a), _b(b) {} + MidiEvent(unsigned t, int type, const unsigned char* data, int len); + MidiEvent(unsigned t, int tpe, EvData d) : _time(t), edata(d), _type(tpe) {} + MidiEvent(unsigned t, int channel, const Event& e); + + ~MidiEvent() {} + + MidiEvent& operator=(const MidiEvent& ed) { + _time = ed._time; + edata = ed.edata; + _channel = ed._channel; + _type = ed._type; + _a = ed._a; + _b = ed._b; + return *this; + } + + int channel() const { return _channel; } + int type() const { return _type; } + int dataA() const { return _a; } + int dataB() const { return _b; } + unsigned time() const { return _time; } + + void setChannel(int val) { _channel = val; } + void setType(int val) { _type = val; } + void setA(int val) { _a = val; } + void setB(int val) { _b = val; } + void setTime(unsigned val) { _time = val; } + + const EvData& eventData() const { return edata; } + unsigned char* data() const { return edata.data; } + int len() const { return edata.dataLen; } + void setData(const EvData& e) { edata = e; } + void setData(const unsigned char* p, int len) { edata.setData(p, len); } + void dump() const; + bool isNote() const { return _type == 0x90; } + bool isNoteOff() const { return (_type == 0x80)||(_type == 0x90 && _b == 0); } + bool operator<(const MidiEvent&) const; + }; + +//--------------------------------------------------------- +// MidiEventList +//--------------------------------------------------------- + +// typedef std::multiset<MidiEvent, std::less<MidiEvent>, +// __gnu_cxx::__mt_alloc<MidiEvent> > MPEL; + +struct MidiEventList : public std::multiset<MidiEvent, std::less<MidiEvent> > + { + }; + +typedef MidiEventList::iterator iMidiEvent; +typedef MidiEventList::const_iterator ciMidiEvent; + +#endif + diff --git a/attic/muse_qt4_evolution/midiplugins/metronom/CMakeLists.txt b/attic/muse_qt4_evolution/midiplugins/metronom/CMakeLists.txt new file mode 100644 index 00000000..5153e6d4 --- /dev/null +++ b/attic/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/attic/muse_qt4_evolution/midiplugins/metronom/metronom.cpp b/attic/muse_qt4_evolution/midiplugins/metronom/metronom.cpp new file mode 100644 index 00000000..ece1e466 --- /dev/null +++ b/attic/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/attic/muse_qt4_evolution/midiplugins/metronom/metronom.h b/attic/muse_qt4_evolution/midiplugins/metronom/metronom.h new file mode 100644 index 00000000..3d570613 --- /dev/null +++ b/attic/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/attic/muse_qt4_evolution/midiplugins/metronom/metronomgui.cpp b/attic/muse_qt4_evolution/midiplugins/metronom/metronomgui.cpp new file mode 100644 index 00000000..e6705f7c --- /dev/null +++ b/attic/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/attic/muse_qt4_evolution/midiplugins/metronom/metronomgui.h b/attic/muse_qt4_evolution/midiplugins/metronom/metronomgui.h new file mode 100644 index 00000000..cceea61d --- /dev/null +++ b/attic/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/attic/muse_qt4_evolution/midiplugins/metronom/metronomgui.ui b/attic/muse_qt4_evolution/midiplugins/metronom/metronomgui.ui new file mode 100644 index 00000000..188735d4 --- /dev/null +++ b/attic/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> diff --git a/attic/muse_qt4_evolution/midiplugins/splitlayer/CMakeLists.txt b/attic/muse_qt4_evolution/midiplugins/splitlayer/CMakeLists.txt new file mode 100644 index 00000000..b6803d8b --- /dev/null +++ b/attic/muse_qt4_evolution/midiplugins/splitlayer/CMakeLists.txt @@ -0,0 +1,45 @@ +#============================================================================= +# 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 ( splitlayer_mocs splitlayergui.h ) +## QT4_WRAP_UI ( splitlayer_uis splitlayergui.ui ) + +add_library ( splitlayer SHARED + splitlayer.cpp + splitlayergui.cpp + splitlayergui.h + ${splitlayer_mocs} + ) +target_link_libraries( splitlayer + midiplugin + ${QT_LIBRARIES} + ) + +# - tell cmake to name target splitlayer.so instead of +# libsplitlayer.so +# - use precompiled header files +# +set_target_properties ( splitlayer + PROPERTIES PREFIX "" + COMPILE_FLAGS "-include ${PROJECT_BINARY_DIR}/all-pic.h" + ) + +install_targets ( /${CMAKE_INSTALL_LIBDIR}/${MusE_INSTALL_NAME}/midiplugins/ splitlayer ) + diff --git a/attic/muse_qt4_evolution/midiplugins/splitlayer/splitlayer.cpp b/attic/muse_qt4_evolution/midiplugins/splitlayer/splitlayer.cpp new file mode 100644 index 00000000..7ea4ba3e --- /dev/null +++ b/attic/muse_qt4_evolution/midiplugins/splitlayer/splitlayer.cpp @@ -0,0 +1,209 @@ +//============================================================================= +// MusE +// Linux Music Editor +// $Id:$ +// +// Copyright (C) 2006 by Werner Schweer +// +// 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. +//============================================================================= + +#include "splitlayergui.h" +#include "splitlayer.h" +#include "midi.h" +#include "midievent.h" + +//--------------------------------------------------------- +// SplitLayer +//--------------------------------------------------------- + +SplitLayer::SplitLayer(const char* name, const MempiHost* h) + : Mempi(name, h) + { + gui = 0; + } + +//--------------------------------------------------------- +// SplitLayer +//--------------------------------------------------------- + +SplitLayer::~SplitLayer() + { + if (gui) + delete gui; + } + +//--------------------------------------------------------- +// init +//--------------------------------------------------------- + +bool SplitLayer::init() + { + data.startVelo[0] = 0; + data.endVelo[0] = 128; + data.startPitch[0] = 0; + data.endPitch[0] = 128; + data.pitchOffset[0] = 0; + data.veloOffset[0] = 0; + for (int i = 1; i < MIDI_CHANNELS; ++i) { + data.startVelo[i] = 0; + data.endVelo[i] = 0; + data.startPitch[i] = 0; + data.endPitch[i] = 0; + data.pitchOffset[i] = 0; + data.veloOffset[i] = 0; + } + memset(notes, 0, 128 * sizeof(int)); + learnMode = false; + gui = new SplitLayerGui(this, 0); + gui->hide(); + gui->setWindowTitle(QString(name())); + gui->init(); + return false; + } + +//--------------------------------------------------------- +// getGeometry +//--------------------------------------------------------- + +void SplitLayer::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 SplitLayer::setGeometry(int x, int y, int w, int h) + { + gui->resize(QSize(w, h)); + gui->move(QPoint(x, y)); + } + +//--------------------------------------------------------- +// process +//--------------------------------------------------------- + +void SplitLayer::process(unsigned, unsigned, MidiEventList* il, MidiEventList* ol) + { + for (iMidiEvent i = il->begin(); i != il->end(); ++i) { + if (i->type() != ME_NOTEON && i->type() != ME_NOTEOFF) { + ol->insert(*i); + continue; + } + int pitch = i->dataA(); + int velo = i->dataB(); + if (learnMode) { + if (learnStartPitch) + data.startPitch[learnChannel] = pitch; + else + data.endPitch[learnChannel] = pitch; + learnMode = false; + gui->sendResetLearnMode(); + return; + } + if (i->type() == ME_NOTEON && velo) { + for (int ch = 0; ch < MIDI_CHANNELS; ++ch) { + MidiEvent event(*i); + if (pitch >= data.startPitch[ch] + && pitch <= data.endPitch[ch] + && velo >= data.startVelo[ch] + && velo <= data.endVelo[ch]) { + notes[pitch] |= (1 << ch); + event.setChannel(ch); + int p = pitch; + int v = velo; + p += data.pitchOffset[ch]; + if (p > 127) + p = 127; + else if (p < 0) + p = 0; + v += data.veloOffset[ch]; + if (v > 127) + v = 127; + else if (v < 0) + v = 0; + event.setA(p); + event.setB(v); + ol->insert(event); + } + } + } + else { + for (int ch = 0; ch < MIDI_CHANNELS; ++ch) { + if (notes[pitch] & (1 << ch)) { + MidiEvent event(*i); + event.setChannel(ch); + int p = pitch + data.pitchOffset[ch]; + if (p < 0) + p = 0; + else if (p > 127) + p = 127; + event.setA(p); + ol->insert(event); + } + } + notes[pitch] = 0; + } + } + } + +//--------------------------------------------------------- +// getInitData +//--------------------------------------------------------- + +void SplitLayer::getInitData(int* n, const unsigned char** p) const + { + *n = sizeof(data); + *p = (unsigned char*)&data; + } + +//--------------------------------------------------------- +// setInitData +//--------------------------------------------------------- + +void SplitLayer::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 SplitLayer(name, h); + } + +extern "C" { + static MEMPI descriptor = { + "SplitLayer", + "MusE Midi Splits and Layers", + "0.1", // version string + MEMPI_FILTER, + MEMPI_MAJOR_VERSION, MEMPI_MINOR_VERSION, + instantiate + }; + + const MEMPI* mempi_descriptor() { return &descriptor; } + } + diff --git a/attic/muse_qt4_evolution/midiplugins/splitlayer/splitlayer.h b/attic/muse_qt4_evolution/midiplugins/splitlayer/splitlayer.h new file mode 100644 index 00000000..7c213c01 --- /dev/null +++ b/attic/muse_qt4_evolution/midiplugins/splitlayer/splitlayer.h @@ -0,0 +1,69 @@ +//============================================================================= +// MusE +// Linux Music Editor +// $Id:$ +// +// Copyright (C) 2006 by Werner Schweer +// +// 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. +//============================================================================= + +#ifndef __METRONOM_H__ +#define __METRONOM_H__ + +#include "../libmidiplugin/mempi.h" + +static const int MIDI_CHANNELS = 16; + +//--------------------------------------------------------- +// SplitLayer - splits and layers for midi input +//--------------------------------------------------------- + +class SplitLayer : public Mempi { + + protected: + struct InitData { + int startVelo[MIDI_CHANNELS]; + int endVelo[MIDI_CHANNELS]; + int startPitch[MIDI_CHANNELS]; + int endPitch[MIDI_CHANNELS]; + int pitchOffset[MIDI_CHANNELS]; + int veloOffset[MIDI_CHANNELS]; + } data; + int notes[128]; // bitmapped note-on/channel values + bool learnMode; + int learnChannel; + bool learnStartPitch; + + SplitLayerGui* gui; + friend class SplitLayerGui; + + virtual void process(unsigned, unsigned, MidiEventList*, MidiEventList*); + + public: + SplitLayer(const char* name, const MempiHost*); + ~SplitLayer(); + 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/attic/muse_qt4_evolution/midiplugins/splitlayer/splitlayergui.cpp b/attic/muse_qt4_evolution/midiplugins/splitlayer/splitlayergui.cpp new file mode 100644 index 00000000..b5d2bdb4 --- /dev/null +++ b/attic/muse_qt4_evolution/midiplugins/splitlayer/splitlayergui.cpp @@ -0,0 +1,263 @@ +//============================================================================= +// MusE +// Linux Music Editor +// $Id:$ +// +// Copyright (C) 2006 by Werner Schweer +// +// 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. +//============================================================================= + +#include "splitlayergui.h" +#include "splitlayer.h" +#include "gui.h" + +//--------------------------------------------------------- +// SplitLayerGui +//--------------------------------------------------------- + +SplitLayerGui::SplitLayerGui(SplitLayer* f, QWidget* parent) + : QWidget(parent) + { + sl = f; + QGridLayout* grid = new QGridLayout; + grid->setSpacing(1); + setLayout(grid); + QSignalMapper* m1 = new QSignalMapper(this); + QSignalMapper* m2 = new QSignalMapper(this); + QSignalMapper* m3 = new QSignalMapper(this); + QSignalMapper* m4 = new QSignalMapper(this); + QSignalMapper* m5 = new QSignalMapper(this); + QSignalMapper* m6 = new QSignalMapper(this); + connect(m1, SIGNAL(mapped(int)), SLOT(startPitchChanged(int))); + connect(m2, SIGNAL(mapped(int)), SLOT(endPitchChanged(int))); + connect(m3, SIGNAL(mapped(int)), SLOT(pitchOffsetChanged(int))); + connect(m4, SIGNAL(mapped(int)), SLOT(startVeloChanged(int))); + connect(m5, SIGNAL(mapped(int)), SLOT(endVeloChanged(int))); + connect(m6, SIGNAL(mapped(int)), SLOT(veloOffsetChanged(int))); + for (int i = 0; i < MIDI_CHANNELS; ++i) { + QLabel* l = new QLabel(QString("Ch %1").arg(i+1)); + grid->addWidget(l, i, 0); + + p1[i] = new Awl::PitchEdit(0); + p1[i]->setToolTip(tr("start pitch for split")); + connect(p1[i], SIGNAL(valueChanged(int)), m1, SLOT(map())); + m1->setMapping(p1[i], i); + + a1[i] = new QAction(this); + a1[i]->setToolTip(tr("enable learn mode for start pitch")); + a1[i]->setCheckable(true); + QIcon icon; + icon.addFile(":/xpm/recordOn.svg", ICON_SIZE, QIcon::Normal, QIcon::On); + icon.addFile(":/xpm/recordOff.svg", ICON_SIZE, QIcon::Normal, QIcon::Off); + a1[i]->setIcon(icon); + a1[i]->setData(i); + QToolButton* rb1 = new QToolButton; + rb1->setDefaultAction(a1[i]); + connect(rb1, SIGNAL(triggered(QAction*)), SLOT(learnStartPitch(QAction*))); + + p2[i] = new Awl::PitchEdit(0); + p2[i]->setToolTip(tr("end pitch for split")); + connect(p2[i], SIGNAL(valueChanged(int)), m2, SLOT(map())); + m2->setMapping(p2[i], i); + + a2[i] = new QAction(this); + a2[i]->setToolTip(tr("enable learn mode for end pitch")); + a2[i]->setCheckable(true); + a2[i]->setIcon(icon); + a2[i]->setData(i); + QToolButton* rb2 = new QToolButton; + rb2->setDefaultAction(a2[i]); + connect(rb2, SIGNAL(triggered(QAction*)), SLOT(learnEndPitch(QAction*))); + + p3[i] = new Awl::PitchEdit(0); + p3[i]->setToolTip(tr("pitch offset for split")); + p3[i]->setDeltaMode(true); + connect(p3[i], SIGNAL(valueChanged(int)), m3, SLOT(map())); + m3->setMapping(p3[i], i); + + p4[i] = new QSpinBox; + p4[i]->setRange(0, 127); + p4[i]->setToolTip(tr("start velocity for split")); + connect(p4[i], SIGNAL(valueChanged(int)), m4, SLOT(map())); + m4->setMapping(p4[i], i); + + p5[i] = new QSpinBox; + p5[i]->setRange(0, 127); + p5[i]->setToolTip(tr("end velocity for split")); + connect(p5[i], SIGNAL(valueChanged(int)), m5, SLOT(map())); + m5->setMapping(p5[i], i); + + p6[i] = new QSpinBox; + p6[i]->setRange(-127, 127); + p6[i]->setToolTip(tr("velocity offset for split")); + connect(p6[i], SIGNAL(valueChanged(int)), m6, SLOT(map())); + m6->setMapping(p6[i], i); + + grid->addWidget(p1[i], i, 1); + grid->addWidget(rb1, i, 2); + grid->addWidget(p2[i], i, 3); + grid->addWidget(rb2, i, 4); + grid->addWidget(p3[i], i, 5); + grid->addWidget(p4[i], i, 7); + grid->addWidget(p5[i], i, 8); + grid->addWidget(p6[i], i, 9); + } + QFrame* fr = new QFrame; + fr->setFrameStyle(QFrame::VLine | QFrame::Raised); + fr->setLineWidth(4); + grid->addWidget(fr, 0, 6, MIDI_CHANNELS, 1); + + int filedes[2]; // 0 - reading 1 - writing + if (pipe(filedes) == -1) { + perror("SplitLayerGui:creating pipe"); + exit(-1); + } + fd2 = filedes[0]; + fd1 = filedes[1]; + + QSocketNotifier* socket = new QSocketNotifier(fd2, + QSocketNotifier::Read, this); + connect(socket, SIGNAL(activated(int)), SLOT(resetLearnMode(int))); + init(); + } + +//--------------------------------------------------------- +// init +//--------------------------------------------------------- + +void SplitLayerGui::init() + { + for (int i = 0; i < MIDI_CHANNELS; ++i) { + p1[i]->setValue(sl->data.startPitch[i]); + p2[i]->setValue(sl->data.endPitch[i]); + p3[i]->setValue(sl->data.pitchOffset[i]); + p4[i]->setValue(sl->data.startVelo[i]); + p5[i]->setValue(sl->data.endVelo[i]); + p6[i]->setValue(sl->data.veloOffset[i]); + } + } + +//--------------------------------------------------------- +// learnStartPitch +//--------------------------------------------------------- + +void SplitLayerGui::learnStartPitch(QAction* a) + { + sl->learnChannel = a->data().toInt(); + sl->learnStartPitch = true; + sl->learnMode = true; + for (int i = 0; i < MIDI_CHANNELS; ++i) { + if (a != a1[i]) + a1[i]->setChecked(false); + if (a != a2[i]) + a2[i]->setChecked(false); + } + } + +//--------------------------------------------------------- +// learnEndPitch +//--------------------------------------------------------- + +void SplitLayerGui::learnEndPitch(QAction* a) + { + sl->learnChannel = a->data().toInt(); + sl->learnStartPitch = false; + sl->learnMode = true; + for (int i = 0; i < MIDI_CHANNELS; ++i) { + if (a != a1[i]) + a1[i]->setChecked(false); + if (a != a2[i]) + a2[i]->setChecked(false); + } + } + +//--------------------------------------------------------- +// startPitchChanged +//--------------------------------------------------------- + +void SplitLayerGui::startPitchChanged(int n) + { + sl->data.startPitch[n] = p1[n]->value(); + } + +//--------------------------------------------------------- +// endPitchChanged +//--------------------------------------------------------- + +void SplitLayerGui::endPitchChanged(int n) + { + sl->data.endPitch[n] = p2[n]->value(); + } + +//--------------------------------------------------------- +// pitchOffsetChanged +//--------------------------------------------------------- + +void SplitLayerGui::pitchOffsetChanged(int n) + { + sl->data.pitchOffset[n] = p3[n]->value(); + } + +//--------------------------------------------------------- +// startVeloChanged +//--------------------------------------------------------- + +void SplitLayerGui::startVeloChanged(int n) + { + sl->data.startVelo[n] = p4[n]->value(); + } + +//--------------------------------------------------------- +// endVeloChanged +//--------------------------------------------------------- + +void SplitLayerGui::endVeloChanged(int n) + { + sl->data.endVelo[n] = p5[n]->value(); + } + +//--------------------------------------------------------- +// veloOffsetChanged +//--------------------------------------------------------- + +void SplitLayerGui::veloOffsetChanged(int n) + { + sl->data.veloOffset[n] = p6[n]->value(); + } + +//--------------------------------------------------------- +// resetLearnMode +//--------------------------------------------------------- + +void SplitLayerGui::resetLearnMode(int fd) + { + char buffer[16]; + read(fd, buffer, 16); + + for (int i = 0; i < MIDI_CHANNELS; ++i) { + a1[i]->setChecked(false); + a2[i]->setChecked(false); + } + init(); + } + +//--------------------------------------------------------- +// sendResetLearnMode +//--------------------------------------------------------- + +void SplitLayerGui::sendResetLearnMode() + { + write(fd1, "X", 1); + } + diff --git a/attic/muse_qt4_evolution/midiplugins/splitlayer/splitlayergui.h b/attic/muse_qt4_evolution/midiplugins/splitlayer/splitlayergui.h new file mode 100644 index 00000000..4f2006ca --- /dev/null +++ b/attic/muse_qt4_evolution/midiplugins/splitlayer/splitlayergui.h @@ -0,0 +1,65 @@ +//============================================================================= +// MusE +// Linux Music Editor +// $Id:$ +// +// Copyright (C) 2006 by Werner Schweer +// +// 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. +//============================================================================= + +#ifndef __SPLITLAYERGUI_H__ +#define __SPLITLAYERGUI_H__ + +#include "awl/pitchedit.h" + +class SplitLayer; + +//--------------------------------------------------------- +// SplitLayerGui +//--------------------------------------------------------- + +class SplitLayerGui : public QWidget { + Q_OBJECT + SplitLayer* sl; + + Awl::PitchEdit* p1[16]; + Awl::PitchEdit* p2[16]; + Awl::PitchEdit* p3[16]; + QSpinBox* p4[16]; + QSpinBox* p5[16]; + QSpinBox* p6[16]; + + QAction* a1[16]; + QAction* a2[16]; + int fd1, fd2; + + private slots: + void learnStartPitch(QAction*); + void learnEndPitch(QAction*); + void startPitchChanged(int); + void endPitchChanged(int); + void pitchOffsetChanged(int); + void resetLearnMode(int); + void startVeloChanged(int); + void endVeloChanged(int); + void veloOffsetChanged(int); + + public: + SplitLayerGui(SplitLayer*, QWidget* parent=0); + void init(); + void sendResetLearnMode(); + }; + +#endif + diff --git a/attic/muse_qt4_evolution/midiplugins/transform/CMakeLists.txt b/attic/muse_qt4_evolution/midiplugins/transform/CMakeLists.txt new file mode 100644 index 00000000..1ac2652c --- /dev/null +++ b/attic/muse_qt4_evolution/midiplugins/transform/CMakeLists.txt @@ -0,0 +1,45 @@ +#============================================================================= +# 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 ( transform_mocs transform.h ) +QT4_WRAP_UI ( transform_uis transform.ui ) + +add_library ( transform SHARED + transform.cpp + ${transform_mocs} + ${transform_uis} + ) + +target_link_libraries( transform + midiplugin + ${QT_LIBRARIES} + ) + +# - tell cmake to name target transform.so instead of +# libtransform.so +# - use precompiled header files +# +set_target_properties ( transform + PROPERTIES PREFIX "" + COMPILE_FLAGS "-include ${PROJECT_BINARY_DIR}/all-pic.h" + ) + +install_targets ( /${CMAKE_INSTALL_LIBDIR}/${MusE_INSTALL_NAME}/midiplugins/ transform ) + diff --git a/attic/muse_qt4_evolution/midiplugins/transform/transform.cpp b/attic/muse_qt4_evolution/midiplugins/transform/transform.cpp new file mode 100644 index 00000000..1376d2fc --- /dev/null +++ b/attic/muse_qt4_evolution/midiplugins/transform/transform.cpp @@ -0,0 +1,904 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: transform.cpp,v 1.8 2005/11/17 18:19:30 wschweer Exp $ +// +// (C) Copyright 2001-2005 Werner Schweer (ws@seh.de) +//========================================================= + +#include "midievent.h" +#include "transform.h" + +static int eventTypeTable[] = { + 1, 6, 4, 7, 8, 10, 11 + }; +static int procVal2Map[] = { 0, 1, 2, 3, 4, 5, 6, 7, 10, 11 }; + +struct TDict { + TransformFunction id; + const QString text; + TDict(TransformFunction f, const QString& s) : id(f), text(s) {} + }; + +static const TDict oplist[] = { + TDict(Trans, QString("Transform")), + TDict(Delete, QString("Filter")) + }; + +static const char* vall[] = { + "c","c#","d","d#","e","f","f#","g","g#","a","a#","h" + }; +static const char* valu[] = { + "C","C#","D","D#","E","F","F#","G","G#","A","A#","H" + }; + +//--------------------------------------------------------- +// pitch2string +//--------------------------------------------------------- + +static QString pitch2string(int v) + { + if (v < 0 || v > 127) + return QString("----"); + int octave = (v / 12) - 2; + QString o; + o.sprintf("%d", octave); + int i = v % 12; + QString s(octave < 0 ? valu[i] : vall[i]); + return s + o; + } +//--------------------------------------------------------- +// Transform +//--------------------------------------------------------- + +Transform::Transform(const char* name, const MempiHost* h) + : Mempi(name, h) + { + } + +bool Transform::init() + { + gui = new TransformDialog(this, 0); + gui->setWindowTitle(QString(name())); + gui->show(); + + data.selEventOp = All; + data.selType = 0x90; + data.selVal1 = Ignore; + data.selVal1a = 0; + data.selVal1b = 0; + data.selVal2 = Ignore; + data.selVal2a = 0; + data.selVal2b = 0; + data.procEvent = Keep; + data.eventType = 0x90; + data.procVal1 = Keep; + data.procVal1a = 0; + data.procVal1b = 0; + data.procVal2 = Keep; + data.procVal2a = 0; + data.procVal2b = 0; + data.funcOp = Trans; + data.quantVal = host->division(); + data.selChannel = Ignore; + data.selChannela = 0; + data.selChannelb = 0; + data.procChannel = Keep; + data.procChannela = 0; + data.procChannelb = 0; + return false; + } + +//--------------------------------------------------------- +// filterValOp +//--------------------------------------------------------- + +static bool filterValOp(ValOp op, int val, int val1, int val2) + { + switch (op) { + case Ignore: + break; + case Equal: + if (val != val1) + return true; + break; + case Unequal: + if (val == val1) + return true; + break; + case Higher: + if (val <= val1) + return true; + break; + case Lower: + if (val >= val1) + return true; + break; + case Inside: + if ((val < val1) || (val >= val2)) + return true; + break; + case Outside: + if ((val >= val1) && (val < val2)) + return true; + break; + } + return false; + } + +//--------------------------------------------------------- +// apply +// apply Select filter +// return 0 - not applied +// 1 - drop event +// 2 - event changed +//--------------------------------------------------------- + +void Transform::process(unsigned, unsigned, MidiEventList* il, MidiEventList* ol) + { + for (iMidiEvent i = il->begin(); i != il->end(); ++i) { + MidiEvent event(*i); + if (filterEvent(event) == 1) + continue; + ol->insert(event); + } + } + +//--------------------------------------------------------- +// filterEvent +//--------------------------------------------------------- + +int Transform::filterEvent(MidiEvent& event) + { + switch (data.selEventOp) { + case Equal: + switch(event.type()) { + case 0x90: + case 0x80: + if (data.selType != 0x90) + return 0; + break; + default: + if (event.type() != data.selType) + return 0; + break; + } + break; + case Unequal: + switch(event.type()) { + case 0x90: + case 0x80: + if (data.selType == 0x90) + return 0; + break; + default: + if (event.type() == data.selType) + return 0; + break; + } + break; + default: + break; + } + if (filterValOp(data.selVal1, event.dataA(), data.selVal1a, data.selVal1b)) + return 0; + if (filterValOp(data.selVal2, event.dataB(), data.selVal2a, data.selVal2b)) + return 0; + if (filterValOp(data.selChannel, event.channel(), data.selChannela, data.selChannelb)) + return 0; + + if (data.funcOp == Delete) + return 1; // discard event + + // transform event + if (data.procEvent != Keep) + event.setType(data.eventType); + + //--------------------------------------------------- + // transform value A + //--------------------------------------------------- + + int val = event.dataA(); + switch (data.procVal1) { + case Keep: + break; + case Plus: + val += data.procVal1a; + break; + case Minus: + val -= data.procVal1a; + break; + case Multiply: + val = int(val * (data.procVal1a/100.0) + .5); + break; + case Divide: + val = int(val / (data.procVal1a/100.0) + .5); + break; + case Fix: + val = data.procVal1a; + break; + case Value: + val = data.procVal2a; + break; + case Invert: + val = 127 - val; + break; + case ScaleMap: + printf("scale map not implemented\n"); + break; + case Flip: + val = data.procVal1a - val; + break; + case Dynamic: // "crescendo" + printf("transform not implemented\n"); + break; + case Random: + { + int range = data.procVal1b - data.procVal1a; + if (range > 0) + val = (rand() % range) + data.procVal1a; + else if (range < 0) + val = (rand() % -range) + data.procVal1b; + else + val = data.procVal1a; + } + break; + } + if (val < 0) + val = 0; + if (val > 127) + val = 127; + event.setA(val); + + //--------------------------------------------------- + // transform value B + //--------------------------------------------------- + + val = event.dataB(); + switch (data.procVal2) { + case Plus: + val += data.procVal2a; + break; + case Minus: + val -= data.procVal2a; + break; + case Multiply: + val = int(val * (data.procVal2a/100.0) + .5); + break; + case Divide: + val = int(val / (data.procVal2a/100.0) + .5); + break; + case Fix: + val = data.procVal2a; + break; + case Value: + val = data.procVal1a; + break; + case Invert: + val = 127 - val; + break; + case Dynamic: + printf("transform not implemented\n"); + break; + case Random: + { + int range = data.procVal2b - data.procVal2a; + if (range > 0) + val = (rand() % range) + data.procVal2a; + else if (range < 0) + val = (rand() % -range) + data.procVal2b; + else + val = data.procVal2a; + } + break; + case ScaleMap: + case Keep: + case Flip: + break; + } + if (val < 0) + val = 0; + if (val > 127) + val = 127; + event.setB(val); + + //--------------------------------------------------- + // transform channel + //--------------------------------------------------- + + val = event.channel(); + switch (data.procChannel) { + case Plus: + val += data.procChannela; + break; + case Minus: + val -= data.procChannela; + break; + case Multiply: + val = int(val * (data.procChannela/100.0) + .5); + break; + case Divide: + val = int(val / (data.procChannela/100.0) + .5); + break; + case Fix: + val = data.procChannela; + break; + case Value: + val = data.procChannela; + break; + case Invert: + val = 16 - val; + break; + case Dynamic: + printf("transform not implemented\n"); + break; + case Random: + { + int range = data.procChannelb - data.procChannela; + if (range > 0) + val = (rand() % range) + data.procChannela; + else if (range < 0) + val = (rand() % -range) + data.procChannelb; + else + val = data.procChannela; + } + break; + case ScaleMap: + case Keep: + case Flip: + break; + } + if (val < 0) + val = 0; + if (val > 15) + val = 15; + event.setChannel(val); + return 2; + } + +//--------------------------------------------------------- +// getGeometry +//--------------------------------------------------------- + +void Transform::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 Transform::setGeometry(int x, int y, int w, int h) + { + gui->resize(QSize(w, h)); + gui->move(QPoint(x, y)); + } + +//--------------------------------------------------------- +// TransformDialog +// Widgets: +// selEventOp selType +// selVal1Op selVal1a selVal1b +// selVal2Op selVal2a selVal2b +// +// procEventOp procType +// procVal1Op procVal1a procVal1b +// procVal2Op procVal2a procVal2b +// funcOp funcQuantVal +// buttonNew buttonDelete +// +// selChannelOp selChannelVala selChannelValb +// procChannelOp procChannelVala procChannelValb +//--------------------------------------------------------- + +TransformDialog::TransformDialog(Transform* tf, QWidget* parent) + : QDialog(parent) + { + setupUi(this); + cmt = tf; + + for (unsigned i = 0; i < sizeof(oplist)/sizeof(*oplist); ++i) + funcOp->addItem(oplist[i].text, i); + + connect(selEventOp, SIGNAL(activated(int)), SLOT(selEventOpSel(int))); + connect(selType, SIGNAL(activated(int)), SLOT(selTypeSel(int))); + connect(selVal1Op, SIGNAL(activated(int)), SLOT(selVal1OpSel(int))); + connect(selVal2Op, SIGNAL(activated(int)), SLOT(selVal2OpSel(int))); + connect(procEventOp, SIGNAL(activated(int)), SLOT(procEventOpSel(int))); + connect(procType, SIGNAL(activated(int)), SLOT(procEventTypeSel(int))); + connect(procVal1Op, SIGNAL(activated(int)), SLOT(procVal1OpSel(int))); + connect(procVal2Op, SIGNAL(activated(int)), SLOT(procVal2OpSel(int))); + connect(funcOp, SIGNAL(activated(int)), SLOT(funcOpSel(int))); + connect(selVal1a, SIGNAL(valueChanged(int)), SLOT(selVal1aChanged(int))); + connect(selVal1b, SIGNAL(valueChanged(int)), SLOT(selVal1bChanged(int))); + connect(selVal2a, SIGNAL(valueChanged(int)), SLOT(selVal2aChanged(int))); + connect(selVal2b, SIGNAL(valueChanged(int)), SLOT(selVal2bChanged(int))); + connect(procVal1a, SIGNAL(valueChanged(int)), SLOT(procVal1aChanged(int))); + connect(procVal1b, SIGNAL(valueChanged(int)), SLOT(procVal1bChanged(int))); + connect(procVal2a, SIGNAL(valueChanged(int)), SLOT(procVal2aChanged(int))); + connect(procVal2b, SIGNAL(valueChanged(int)), SLOT(procVal2bChanged(int))); + connect(selChannelOp, SIGNAL(activated(int)), SLOT(selChannelOpSel(int))); + connect(selChannelVala, SIGNAL(valueChanged(int)), SLOT(selChannelValaChanged(int))); + connect(selChannelValb, SIGNAL(valueChanged(int)), SLOT(selChannelValbChanged(int))); + connect(procChannelOp, SIGNAL(activated(int)), SLOT(procChannelOpSel(int))); + connect(procChannelVala, SIGNAL(valueChanged(int)), SLOT(procChannelValaChanged(int))); + connect(procChannelValb, SIGNAL(valueChanged(int)), SLOT(procChannelValbChanged(int))); + } + +//--------------------------------------------------------- +// init +//--------------------------------------------------------- + +void TransformDialog::init() + { + selEventOp->setCurrentIndex(cmt->data.selEventOp); + selEventOpSel(cmt->data.selEventOp); + + for (unsigned i = 0; i < sizeof(eventTypeTable)/sizeof(*eventTypeTable); ++i) { + if (eventTypeTable[i] == cmt->data.selType) { + selType->setCurrentIndex(i); + break; + } + } + + selVal1Op->setCurrentIndex(cmt->data.selVal1); + selVal1OpSel(cmt->data.selVal1); + + selVal2Op->setCurrentIndex(cmt->data.selVal2); + selVal2OpSel(cmt->data.selVal2); + + selChannelOp->setCurrentIndex(cmt->data.selChannel); + selChannelOpSel(cmt->data.selChannel); + + { + unsigned i; + for (i = 0; i < sizeof(oplist)/sizeof(*oplist); ++i) { + if (oplist[i].id == cmt->data.funcOp) { + funcOp->setCurrentIndex(i); + break; + } + } + if (i == sizeof(oplist)/sizeof(*oplist)) + printf("internal error: bad OpCode\n"); + funcOpSel(i); + } + + procEventOp->setCurrentIndex(cmt->data.procEvent); + procEventOpSel(cmt->data.procEvent); + + procVal1Op->setCurrentIndex(cmt->data.procVal1); + procVal1OpSel(cmt->data.procVal1); + + for (unsigned i = 0; i < sizeof(procVal2Map)/sizeof(*procVal2Map); ++i) { + if (procVal2Map[i] == cmt->data.procVal2) { + procVal2Op->setCurrentIndex(i); + break; + } + } + + selVal1a->setValue(cmt->data.selVal1a); + selVal1b->setValue(cmt->data.selVal1b); + selVal1aChanged(cmt->data.selVal1a); + selVal1bChanged(cmt->data.selVal1b); + + selVal2a->setValue(cmt->data.selVal2a); + selVal2b->setValue(cmt->data.selVal2b); + + selChannelVala->setValue(cmt->data.selChannela); + selChannelValb->setValue(cmt->data.selChannelb); + + procVal1a->setValue(cmt->data.procVal1a); + procVal1b->setValue(cmt->data.procVal1b); + + procVal2a->setValue(cmt->data.procVal2a); + procVal2b->setValue(cmt->data.procVal2b); + + procChannelVala->setValue(cmt->data.procChannela); + procChannelValb->setValue(cmt->data.procChannelb); + } + +//--------------------------------------------------------- +// setValOp +//--------------------------------------------------------- + +void TransformDialog::setValOp(QWidget* a, QWidget* b, ValOp op) + { + switch (op) { + case Ignore: + a->setEnabled(false); + b->setEnabled(false); + break; + case Equal: + case Unequal: + case Higher: + case Lower: + a->setEnabled(true); + b->setEnabled(false); + break; + case Inside: + case Outside: + a->setEnabled(true); + b->setEnabled(true); + break; + } + } + +//--------------------------------------------------------- +// selEventOpSel +//--------------------------------------------------------- + +void TransformDialog::selEventOpSel(int val) + { + selType->setEnabled(val != All); + cmt->data.selEventOp = ValOp(val); + selVal1aChanged(cmt->data.selVal1a); + selVal1bChanged(cmt->data.selVal1b); + } + +//--------------------------------------------------------- +// selTypeSel +//--------------------------------------------------------- + +void TransformDialog::selTypeSel(int val) + { + cmt->data.selType = eventTypeTable[val]; + selVal1aChanged(cmt->data.selVal1a); + selVal1bChanged(cmt->data.selVal1b); + } + +//--------------------------------------------------------- +// selVal1OpSel +//--------------------------------------------------------- + +void TransformDialog::selVal1OpSel(int val) + { + setValOp(selVal1a, selVal1b, ValOp(val)); + cmt->data.selVal1 = ValOp(val); + } + +//--------------------------------------------------------- +// selVal2OpSel +//--------------------------------------------------------- + +void TransformDialog::selVal2OpSel(int val) + { + setValOp(selVal2a, selVal2b, ValOp(val)); + cmt->data.selVal2 = ValOp(val); + } + +//--------------------------------------------------------- +// procEventOpSel +//--------------------------------------------------------- + +void TransformDialog::procEventOpSel(int val) + { + TransformOperator op = val == 0 ? Keep : Fix; + procType->setEnabled(op == Fix); + cmt->data.procEvent = op; + } + +//--------------------------------------------------------- +// procEventTypeSel +//--------------------------------------------------------- + +void TransformDialog::procEventTypeSel(int val) + { + cmt->data.eventType = eventTypeTable[val]; + } + +//--------------------------------------------------------- +// procVal1OpSel +//--------------------------------------------------------- + +void TransformDialog::procVal1OpSel(int val) + { + cmt->data.procVal1 = TransformOperator(val); + switch(TransformOperator(val)) { + case Keep: + case Invert: + procVal1a->setEnabled(false); + procVal1b->setEnabled(false); + break; + case Multiply: + case Divide: + procVal1a->setEnabled(true); + procVal1b->setEnabled(false); + break; + case Plus: + case Minus: + case Fix: + case Value: + case Flip: + procVal1a->setEnabled(true); + procVal1b->setEnabled(false); + break; + case Random: + case ScaleMap: + case Dynamic: + procVal1a->setEnabled(true); + procVal1b->setEnabled(true); + break; + } + } + +//--------------------------------------------------------- +// procVal2OpSel +//--------------------------------------------------------- + +void TransformDialog::procVal2OpSel(int val) + { + TransformOperator op = TransformOperator(procVal2Map[val]); + cmt->data.procVal2 = op; + + switch (op) { + case Keep: + case Invert: + procVal2a->setEnabled(false); + procVal2b->setEnabled(false); + break; + case Multiply: + case Divide: + procVal2a->setEnabled(true); + procVal2b->setEnabled(false); + break; + case Plus: + case Minus: + case Fix: + case Value: + procVal2a->setEnabled(true); + procVal2b->setEnabled(false); + break; + case Random: + case Dynamic: + procVal2a->setEnabled(true); + procVal2b->setEnabled(true); + break; + default: + break; + } + } + +//--------------------------------------------------------- +// funcOpSel +//--------------------------------------------------------- + +void TransformDialog::funcOpSel(int val) + { + TransformFunction op = oplist[val].id; + + bool isFuncOp(op == Trans); + + procEventOp->setEnabled(isFuncOp); + procType->setEnabled(isFuncOp); + procVal1Op->setEnabled(isFuncOp); + procVal1a->setEnabled(isFuncOp); + procVal1b->setEnabled(isFuncOp); + procVal2Op->setEnabled(isFuncOp); + procVal2a->setEnabled(isFuncOp); + procVal2b->setEnabled(isFuncOp); + procChannelOp->setEnabled(isFuncOp); + procChannelVala->setEnabled(isFuncOp); + procChannelValb->setEnabled(isFuncOp); + if (isFuncOp) { + procEventOpSel(cmt->data.procEvent); + procVal1OpSel(cmt->data.procVal1); + procVal2OpSel(cmt->data.procVal2); + procChannelOpSel(cmt->data.procChannel); + } + cmt->data.funcOp = op; + } + +//--------------------------------------------------------- +// selVal1aChanged +//--------------------------------------------------------- + +void TransformDialog::selVal1aChanged(int val) + { + cmt->data.selVal1a = val; + if ((cmt->data.selEventOp != All) + && (cmt->data.selType == 0x90)) { + selVal1a->setSuffix(" - " + pitch2string(val)); + } + else + selVal1a->setSuffix(QString("")); + } + +//--------------------------------------------------------- +// selVal1bChanged +//--------------------------------------------------------- + +void TransformDialog::selVal1bChanged(int val) + { + cmt->data.selVal1b = val; + if ((cmt->data.selEventOp != All) + && (cmt->data.selType == 0x90)) { + selVal1b->setSuffix(" - " + pitch2string(val)); + } + else + selVal1b->setSuffix(QString("")); + } + +//--------------------------------------------------------- +// selVal2aChanged +//--------------------------------------------------------- + +void TransformDialog::selVal2aChanged(int val) + { + cmt->data.selVal2a = val; + } + +//--------------------------------------------------------- +// selVal2bChanged +//--------------------------------------------------------- + +void TransformDialog::selVal2bChanged(int val) + { + cmt->data.selVal2b = val; + } + +//--------------------------------------------------------- +// procVal1aChanged +//--------------------------------------------------------- + +void TransformDialog::procVal1aChanged(int val) + { + cmt->data.procVal1a = val; + } + +//--------------------------------------------------------- +// procVal1bChanged +//--------------------------------------------------------- + +void TransformDialog::procVal1bChanged(int val) + { + cmt->data.procVal1b = val; + } + +//--------------------------------------------------------- +// procVal2aChanged +//--------------------------------------------------------- + +void TransformDialog::procVal2aChanged(int val) + { + cmt->data.procVal2a = val; + } + +//--------------------------------------------------------- +// procVal2bChanged +//--------------------------------------------------------- + +void TransformDialog::procVal2bChanged(int val) + { + cmt->data.procVal2b = val; + } + +//--------------------------------------------------------- +// selChannelOpSel +//--------------------------------------------------------- + +void TransformDialog::selChannelOpSel(int val) + { + setValOp(selChannelVala, selChannelValb, ValOp(val)); + cmt->data.selChannel = ValOp(val); + } + +//--------------------------------------------------------- +// selChannelValaChanged +//--------------------------------------------------------- + +void TransformDialog::selChannelValaChanged(int val) + { + cmt->data.selChannela = val; + } + +//--------------------------------------------------------- +// selChannelValbChanged +//--------------------------------------------------------- + +void TransformDialog::selChannelValbChanged(int val) + { + cmt->data.selChannelb = val; + } + +//--------------------------------------------------------- +// procChannelOpSel +//--------------------------------------------------------- + +void TransformDialog::procChannelOpSel(int val) + { + cmt->data.procChannel = TransformOperator(val); + switch(TransformOperator(val)) { + case Keep: + case Invert: + procChannelVala->setEnabled(false); + procChannelValb->setEnabled(false); + break; + case Multiply: + case Divide: + procChannelVala->setEnabled(true); + procChannelValb->setEnabled(false); + break; + case Plus: + case Minus: + case Fix: + case Value: + case Flip: + procChannelVala->setEnabled(true); + procChannelValb->setEnabled(false); + break; + case Random: + case ScaleMap: + case Dynamic: + procChannelVala->setEnabled(true); + procChannelValb->setEnabled(true); + break; + } + } + +//--------------------------------------------------------- +// procChannelValaChanged +//--------------------------------------------------------- + +void TransformDialog::procChannelValaChanged(int val) + { + cmt->data.procChannela = val; + } + +//--------------------------------------------------------- +// procChannelValbChanged +//--------------------------------------------------------- + +void TransformDialog::procChannelValbChanged(int val) + { + cmt->data.procChannelb = val; + } + +//--------------------------------------------------------- +// getInitData +//--------------------------------------------------------- + +void Transform::getInitData(int* n, const unsigned char** p) const + { + *n = sizeof(data); + *p = (unsigned char*)&data; + } + +//--------------------------------------------------------- +// setInitData +//--------------------------------------------------------- + +void Transform::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 Transform(name, h); + } + +extern "C" { + static MEMPI descriptor = { + "Transformator", + "MusE Midi Event Transformator", + "0.1", // version string + MEMPI_FILTER, + MEMPI_MAJOR_VERSION, MEMPI_MINOR_VERSION, + instantiate + }; + + const MEMPI* mempi_descriptor() { return &descriptor; } + } + diff --git a/attic/muse_qt4_evolution/midiplugins/transform/transform.h b/attic/muse_qt4_evolution/midiplugins/transform/transform.h new file mode 100644 index 00000000..6f68698d --- /dev/null +++ b/attic/muse_qt4_evolution/midiplugins/transform/transform.h @@ -0,0 +1,126 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: transform.h,v 1.5 2005/10/05 17:02:03 lunar_shuttle Exp $ +// +// (C) Copyright 2005 Werner Schweer (ws@seh.de) +//========================================================= + +#ifndef __TRANSFORM_H__ +#define __TRANSFORM_H__ + +#include "../libmidiplugin/mempi.h" +#include "ui_transform.h" + +class Transform; + +namespace AL { + class Xml; + }; +using AL::Xml; + +enum ValOp { + All=0, Ignore=0, Equal=1, Unequal=2, Higher=3, Lower=4, + Inside=5, Outside=6 + }; + +enum TransformFunction { + Select, Quantize, Delete, Trans, Insert, Copy, Extract + }; + +enum TransformOperator { + Keep, Plus, Minus, Multiply, Divide, Fix, Value, Invert, + ScaleMap, Flip, Dynamic, Random + }; + +//--------------------------------------------------------- +// TransformDialog +//--------------------------------------------------------- + +class TransformDialog : public QDialog, public Ui::TransformDialogBase { + Q_OBJECT + Transform* cmt; + + void setValOp(QWidget* a, QWidget* b, ValOp op); + + signals: + void hideWindow(); + + private slots: + void selEventOpSel(int); + void selTypeSel(int); + void selVal1OpSel(int); + void selVal2OpSel(int); + void procEventOpSel(int); + void procEventTypeSel(int); + void procVal1OpSel(int); + void procVal2OpSel(int); + void funcOpSel(int); + void selVal1aChanged(int); + void selVal1bChanged(int); + void selVal2aChanged(int); + void selVal2bChanged(int); + void procVal1aChanged(int); + void procVal1bChanged(int); + void procVal2aChanged(int); + void procVal2bChanged(int); + void selChannelOpSel(int); + void selChannelValaChanged(int); + void selChannelValbChanged(int); + void procChannelOpSel(int); + void procChannelValaChanged(int); + void procChannelValbChanged(int); + + public: + TransformDialog(Transform*, QWidget* parent); + void init(); + }; + +//--------------------------------------------------------- +// Transform +//--------------------------------------------------------- + +class Transform : public Mempi { + int filterEvent(MidiEvent& event); + + public: + struct initData { + ValOp selEventOp; + int selType; + + ValOp selVal1; + int selVal1a, selVal1b; + ValOp selVal2; + int selVal2a, selVal2b; + ValOp selChannel; + int selChannela, selChannelb; + + TransformOperator procEvent; + int eventType; + TransformOperator procVal1; + int procVal1a, procVal1b; + TransformOperator procVal2; + int procVal2a, procVal2b; + TransformOperator procChannel; + int procChannela, procChannelb; + + TransformFunction funcOp; + int quantVal; + } data; + + TransformDialog* gui; + virtual void process(unsigned, unsigned, MidiEventList*, MidiEventList*); + + Transform(const char* name, const MempiHost*); + 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/attic/muse_qt4_evolution/midiplugins/transform/transform.ui b/attic/muse_qt4_evolution/midiplugins/transform/transform.ui new file mode 100644 index 00000000..c23cf343 --- /dev/null +++ b/attic/muse_qt4_evolution/midiplugins/transform/transform.ui @@ -0,0 +1,616 @@ +<ui version="4.0" > + <author></author> + <comment></comment> + <exportmacro></exportmacro> + <class>TransformDialogBase</class> + <widget class="QDialog" name="TransformDialogBase" > + <property name="geometry" > + <rect> + <x>0</x> + <y>0</y> + <width>630</width> + <height>418</height> + </rect> + </property> + <property name="windowTitle" > + <string>MusE: Midi Input Transformator</string> + </property> + <property name="sizeGripEnabled" > + <bool>true</bool> + </property> + <layout class="QVBoxLayout" > + <property name="margin" > + <number>11</number> + </property> + <property name="spacing" > + <number>6</number> + </property> + <item> + <widget class="QGroupBox" name="GroupBox3" > + <property name="title" > + <string>Filter</string> + </property> + <layout class="QGridLayout" > + <property name="margin" > + <number>11</number> + </property> + <property name="spacing" > + <number>6</number> + </property> + <item row="1" column="0" > + <widget class="QComboBox" name="selEventOp" > + <item> + <property name="text" > + <string>All</string> + </property> + </item> + <item> + <property name="text" > + <string>Equal</string> + </property> + </item> + <item> + <property name="text" > + <string>Unequal</string> + </property> + </item> + </widget> + </item> + <item row="2" column="0" > + <widget class="QComboBox" name="selType" > + <item> + <property name="text" > + <string>Note</string> + </property> + </item> + <item> + <property name="text" > + <string>Poly Pressure</string> + </property> + </item> + <item> + <property name="text" > + <string>Control Change</string> + </property> + </item> + <item> + <property name="text" > + <string>Aftertouch</string> + </property> + </item> + <item> + <property name="text" > + <string>Pitch Bend</string> + </property> + </item> + <item> + <property name="text" > + <string>NRPN</string> + </property> + </item> + <item> + <property name="text" > + <string>RPN</string> + </property> + </item> + </widget> + </item> + <item row="0" column="2" > + <widget class="QLabel" name="TextLabel3" > + <property name="text" > + <string>Value 2</string> + </property> + </widget> + </item> + <item row="0" column="1" > + <widget class="QLabel" name="TextLabel2" > + <property name="text" > + <string>Value 1</string> + </property> + </widget> + </item> + <item row="0" column="0" > + <widget class="QLabel" name="TextLabel1" > + <property name="text" > + <string>Event Type</string> + </property> + </widget> + </item> + <item row="1" column="1" > + <widget class="QComboBox" name="selVal1Op" > + <item> + <property name="text" > + <string>Ignore</string> + </property> + </item> + <item> + <property name="text" > + <string>Equal</string> + </property> + </item> + <item> + <property name="text" > + <string>Unequal</string> + </property> + </item> + <item> + <property name="text" > + <string>Higher</string> + </property> + </item> + <item> + <property name="text" > + <string>Lower</string> + </property> + </item> + <item> + <property name="text" > + <string>Inside</string> + </property> + </item> + <item> + <property name="text" > + <string>Outside</string> + </property> + </item> + </widget> + </item> + <item row="3" column="1" > + <widget class="QSpinBox" name="selVal1b" > + <property name="maximum" > + <number>127</number> + </property> + </widget> + </item> + <item row="3" column="2" > + <widget class="QSpinBox" name="selVal2b" > + <property name="maximum" > + <number>127</number> + </property> + </widget> + </item> + <item row="2" column="1" > + <widget class="QSpinBox" name="selVal1a" > + <property name="maximum" > + <number>127</number> + </property> + </widget> + </item> + <item row="1" column="2" > + <widget class="QComboBox" name="selVal2Op" > + <item> + <property name="text" > + <string>Ignore</string> + </property> + </item> + <item> + <property name="text" > + <string>Equal</string> + </property> + </item> + <item> + <property name="text" > + <string>Unequal</string> + </property> + </item> + <item> + <property name="text" > + <string>Higher</string> + </property> + </item> + <item> + <property name="text" > + <string>Lower</string> + </property> + </item> + <item> + <property name="text" > + <string>Inside</string> + </property> + </item> + <item> + <property name="text" > + <string>Outside</string> + </property> + </item> + </widget> + </item> + <item row="1" column="3" > + <widget class="QComboBox" name="selChannelOp" > + <item> + <property name="text" > + <string>Ignore</string> + </property> + </item> + <item> + <property name="text" > + <string>Equal</string> + </property> + </item> + <item> + <property name="text" > + <string>Unequal</string> + </property> + </item> + <item> + <property name="text" > + <string>Higher</string> + </property> + </item> + <item> + <property name="text" > + <string>Lower</string> + </property> + </item> + <item> + <property name="text" > + <string>Inside</string> + </property> + </item> + <item> + <property name="text" > + <string>Outside</string> + </property> + </item> + </widget> + </item> + <item row="0" column="3" > + <widget class="QLabel" name="TextLabel2_2" > + <property name="text" > + <string>Channel</string> + </property> + </widget> + </item> + <item row="2" column="2" > + <widget class="QSpinBox" name="selVal2a" > + <property name="maximum" > + <number>127</number> + </property> + </widget> + </item> + <item row="2" column="3" > + <widget class="QSpinBox" name="selChannelVala" > + <property name="maximum" > + <number>127</number> + </property> + </widget> + </item> + <item row="3" column="3" > + <widget class="QSpinBox" name="selChannelValb" > + <property name="maximum" > + <number>127</number> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item> + <widget class="QGroupBox" name="GroupBox5" > + <property name="title" > + <string>Processing</string> + </property> + <layout class="QGridLayout" > + <property name="margin" > + <number>11</number> + </property> + <property name="spacing" > + <number>6</number> + </property> + <item row="0" column="0" > + <widget class="QLabel" name="TextLabel5" > + <property name="text" > + <string>Event Type</string> + </property> + </widget> + </item> + <item row="1" column="0" > + <widget class="QComboBox" name="procEventOp" > + <item> + <property name="text" > + <string>Keep</string> + </property> + </item> + <item> + <property name="text" > + <string>Fix</string> + </property> + </item> + </widget> + </item> + <item row="2" column="0" > + <widget class="QComboBox" name="procType" > + <item> + <property name="text" > + <string>Note</string> + </property> + </item> + <item> + <property name="text" > + <string>Poly Pressure</string> + </property> + </item> + <item> + <property name="text" > + <string>Control Change</string> + </property> + </item> + <item> + <property name="text" > + <string>Aftertouch</string> + </property> + </item> + <item> + <property name="text" > + <string>Pitch Bend</string> + </property> + </item> + <item> + <property name="text" > + <string>NRPN</string> + </property> + </item> + <item> + <property name="text" > + <string>RPN</string> + </property> + </item> + </widget> + </item> + <item row="1" column="1" > + <widget class="QComboBox" name="procVal1Op" > + <item> + <property name="text" > + <string>Keep</string> + </property> + </item> + <item> + <property name="text" > + <string>Plus</string> + </property> + </item> + <item> + <property name="text" > + <string>Minus</string> + </property> + </item> + <item> + <property name="text" > + <string>Multiply</string> + </property> + </item> + <item> + <property name="text" > + <string>Divide</string> + </property> + </item> + <item> + <property name="text" > + <string>Fix</string> + </property> + </item> + <item> + <property name="text" > + <string>Value 2</string> + </property> + </item> + <item> + <property name="text" > + <string>Invert</string> + </property> + </item> + <item> + <property name="text" > + <string>ScaleMap</string> + </property> + </item> + <item> + <property name="text" > + <string>Flip</string> + </property> + </item> + <item> + <property name="text" > + <string>Dyn</string> + </property> + </item> + <item> + <property name="text" > + <string>Random</string> + </property> + </item> + </widget> + </item> + <item row="0" column="1" > + <widget class="QLabel" name="TextLabel6" > + <property name="text" > + <string>Value 1</string> + </property> + </widget> + </item> + <item row="0" column="2" > + <widget class="QLabel" name="TextLabel7" > + <property name="text" > + <string>Value 2</string> + </property> + </widget> + </item> + <item row="3" column="1" > + <widget class="QSpinBox" name="procVal1b" > + <property name="maximum" > + <number>9999</number> + </property> + </widget> + </item> + <item row="3" column="2" > + <widget class="QSpinBox" name="procVal2b" > + <property name="maximum" > + <number>9999</number> + </property> + </widget> + </item> + <item row="3" column="3" > + <widget class="QSpinBox" name="procChannelValb" > + <property name="maximum" > + <number>127</number> + </property> + </widget> + </item> + <item row="1" column="2" > + <widget class="QComboBox" name="procVal2Op" > + <item> + <property name="text" > + <string>Keep</string> + </property> + </item> + <item> + <property name="text" > + <string>Plus</string> + </property> + </item> + <item> + <property name="text" > + <string>Minus</string> + </property> + </item> + <item> + <property name="text" > + <string>Multiply</string> + </property> + </item> + <item> + <property name="text" > + <string>Divide</string> + </property> + </item> + <item> + <property name="text" > + <string>Fix</string> + </property> + </item> + <item> + <property name="text" > + <string>Value 1</string> + </property> + </item> + <item> + <property name="text" > + <string>Invert</string> + </property> + </item> + <item> + <property name="text" > + <string>Dyn</string> + </property> + </item> + <item> + <property name="text" > + <string>Random</string> + </property> + </item> + </widget> + </item> + <item row="1" column="3" > + <widget class="QComboBox" name="procChannelOp" > + <item> + <property name="text" > + <string>Keep</string> + </property> + </item> + <item> + <property name="text" > + <string>Plus</string> + </property> + </item> + <item> + <property name="text" > + <string>Minus</string> + </property> + </item> + <item> + <property name="text" > + <string>Multiply</string> + </property> + </item> + <item> + <property name="text" > + <string>Divide</string> + </property> + </item> + <item> + <property name="text" > + <string>Fix</string> + </property> + </item> + <item> + <property name="text" > + <string>Value 1</string> + </property> + </item> + <item> + <property name="text" > + <string>Invert</string> + </property> + </item> + <item> + <property name="text" > + <string>Dyn</string> + </property> + </item> + <item> + <property name="text" > + <string>Random</string> + </property> + </item> + </widget> + </item> + <item row="0" column="3" > + <widget class="QLabel" name="TextLabel2_2_2" > + <property name="text" > + <string>Channel</string> + </property> + </widget> + </item> + <item row="3" column="0" > + <widget class="QComboBox" name="funcOp" /> + </item> + <item row="2" column="1" > + <widget class="QSpinBox" name="procVal1a" /> + </item> + <item row="2" column="2" > + <widget class="QSpinBox" name="procVal2a" /> + </item> + <item row="2" column="3" > + <widget class="QSpinBox" name="procChannelVala" /> + </item> + </layout> + </widget> + </item> + </layout> + </widget> + <layoutdefault spacing="6" margin="11" /> + <pixmapfunction>qPixmapFromMimeSource</pixmapfunction> + <tabstops> + <tabstop>selEventOp</tabstop> + <tabstop>selType</tabstop> + <tabstop>selVal1Op</tabstop> + <tabstop>selVal1a</tabstop> + <tabstop>selVal1b</tabstop> + <tabstop>selVal2Op</tabstop> + <tabstop>selVal2a</tabstop> + <tabstop>selVal2b</tabstop> + <tabstop>selChannelOp</tabstop> + <tabstop>selChannelVala</tabstop> + <tabstop>selChannelValb</tabstop> + <tabstop>procEventOp</tabstop> + <tabstop>procType</tabstop> + <tabstop>procVal1Op</tabstop> + <tabstop>procVal1b</tabstop> + <tabstop>procVal2Op</tabstop> + <tabstop>procVal2b</tabstop> + <tabstop>procChannelOp</tabstop> + <tabstop>procChannelValb</tabstop> + </tabstops> + <resources/> + <connections/> +</ui> diff --git a/attic/muse_qt4_evolution/midiplugins/trigg/CMakeLists.txt b/attic/muse_qt4_evolution/midiplugins/trigg/CMakeLists.txt new file mode 100644 index 00000000..397ccf81 --- /dev/null +++ b/attic/muse_qt4_evolution/midiplugins/trigg/CMakeLists.txt @@ -0,0 +1,47 @@ +#============================================================================= +# 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 ( trigg_mocs trigggui.h ) +QT4_WRAP_UI ( trigg_uis trigggui.ui ) + +add_library ( trigg SHARED + trigg.cpp + trigggui.cpp + trigggui.h + ${trigg_mocs} + ${trigg_uis} + ) + +target_link_libraries( trigg + midiplugin awl + ${QT_LIBRARIES} + ) + +# - tell cmake to name target name.so instead of +# libname.so +# - use precompiled header files +# +set_target_properties ( trigg + PROPERTIES PREFIX "" + COMPILE_FLAGS "-include ${PROJECT_BINARY_DIR}/all-pic.h" + ) + +install_targets ( /${CMAKE_INSTALL_LIBDIR}/${MusE_INSTALL_NAME}/midiplugins/ trigg ) + diff --git a/attic/muse_qt4_evolution/midiplugins/trigg/trigg.cpp b/attic/muse_qt4_evolution/midiplugins/trigg/trigg.cpp new file mode 100644 index 00000000..fb3703cb --- /dev/null +++ b/attic/muse_qt4_evolution/midiplugins/trigg/trigg.cpp @@ -0,0 +1,131 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: filter.cpp,v 1.10 2005/11/06 17:49:34 wschweer Exp $ +// +// filter - simple midi filter +// +// (C) Copyright 2005 Werner Schweer (ws@seh.de) +//========================================================= + +#include "trigggui.h" +#include "trigg.h" +#include "midi.h" +#include "midievent.h" + +//--------------------------------------------------------- +// Trigg +//--------------------------------------------------------- + +Trigg::Trigg(const char* name, const MempiHost* h) + : Mempi(name, h) + { + data.note=30; // allow any events + data.velocity=127; + gui = 0; + } + +//--------------------------------------------------------- +// Trigg +//--------------------------------------------------------- + +Trigg::~Trigg() + { + if (gui) + delete gui; + } + +//--------------------------------------------------------- +// init +//--------------------------------------------------------- + +bool Trigg::init() + { + gui = new TriggGui(this, 0); + gui->setWindowTitle("MusE: "+QString(name())); + gui->show(); + return false; + } + +//--------------------------------------------------------- +// getGeometry +//--------------------------------------------------------- + +void Trigg::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 Trigg::setGeometry(int x, int y, int w, int h) + { + gui->resize(QSize(w, h)); + gui->move(QPoint(x, y)); + } + +//--------------------------------------------------------- +// process +//--------------------------------------------------------- + +void Trigg::process(unsigned , unsigned , MidiEventList* il, MidiEventList* ol) + { + + for (iMidiEvent i = il->begin(); i != il->end(); ++i) { + MidiEvent temp=*i; + if (temp.isNote() || temp.isNoteOff()) + { + // for each event modify note and velocity + printf("a=%d b=%d isNote=%d isNoteOff=%d\n",temp.dataA(),temp.dataB(),temp.isNote(),temp.isNoteOff()); + temp.setA(data.note); + if (!temp.isNoteOff()) + temp.setB(data.velocity); + printf("AFTER a=%d b=%d\n",temp.dataA(),temp.dataB()); + } + ol->insert(temp); + } + } + +void Trigg::getInitData(int* n, const unsigned char** p) const + { + *n = sizeof(data); + *p = (unsigned char*)&data; + printf("::getInitData note=%d vel=%d\n",data.note,data.velocity); + } + +void Trigg::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 Trigg(name, h); + } + +extern "C" { + static MEMPI descriptor = { + "Trigg", + "Any note triggers a specified note with specified velocity", + "1.0", // filter version string + MEMPI_FILTER, // plugin type + MEMPI_MAJOR_VERSION, MEMPI_MINOR_VERSION, + instantiate + }; + + const MEMPI* mempi_descriptor() { return &descriptor; } + } + diff --git a/attic/muse_qt4_evolution/midiplugins/trigg/trigg.h b/attic/muse_qt4_evolution/midiplugins/trigg/trigg.h new file mode 100644 index 00000000..c29a06a0 --- /dev/null +++ b/attic/muse_qt4_evolution/midiplugins/trigg/trigg.h @@ -0,0 +1,49 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: filter.h,v 1.4 2005/06/12 08:18:37 wschweer Exp $ +// +// filter - simple midi filter +// +// (C) Copyright 2005 Werner Schweer (ws@seh.de) +//========================================================= + +#ifndef __TRIGG_H__ +#define __TRIGG_H__ + +#include "../libmidiplugin/mempi.h" + +//--------------------------------------------------------- +// filter - simple midi filter +//--------------------------------------------------------- +class Trigg : public Mempi { + struct initData { + int note; + int velocity; + } data; + friend class TriggGui; + + TriggGui* gui; + + virtual void process(unsigned, unsigned, MidiEventList*, MidiEventList*); + + public: + Trigg(const char* name, const MempiHost*); + ~Trigg(); + virtual bool init(); + + void setNote(int t) { data.note = t; } + void setVelocity(int t) { data.velocity = t; } + + 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/attic/muse_qt4_evolution/midiplugins/trigg/trigggui.cpp b/attic/muse_qt4_evolution/midiplugins/trigg/trigggui.cpp new file mode 100644 index 00000000..0fd3c4c6 --- /dev/null +++ b/attic/muse_qt4_evolution/midiplugins/trigg/trigggui.cpp @@ -0,0 +1,56 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: filtergui.cpp,v 1.4 2005/11/06 17:49:34 wschweer Exp $ +// +// (C) Copyright 2005 Werner Schweer (ws@seh.de) +//========================================================= + +#include "trigggui.h" +#include "trigg.h" + +//--------------------------------------------------------- +// MidiTriggConfig +//--------------------------------------------------------- + +TriggGui::TriggGui(Trigg* f, QWidget* parent) + : QDialog(parent) + { + setupUi(this); + filter = f; + + connect(noteEntry, SIGNAL(valueChanged(int)), SLOT(setNote(int))); + connect(velocityEntry, SIGNAL(valueChanged(int)), SLOT(setVelocity(int))); + } + +//--------------------------------------------------------- +// init +//--------------------------------------------------------- +void TriggGui::init() + { + Trigg::initData *data; + int n; + filter->getInitData(&n,(const unsigned char **)&data); + printf("::init note=%d vel=%d\n",data->note,data->velocity); + noteEntry->setValue(data->note); + velocityEntry->setValue(data->velocity); + } + +//--------------------------------------------------------- +// setNote +//--------------------------------------------------------- +void TriggGui::setNote(int value) + { + printf("TriggGui::setNote %d\n",value); + filter->setNote(value); + } + +//--------------------------------------------------------- +// setVelocity +//--------------------------------------------------------- +void TriggGui::setVelocity(int value) + { + printf("TriggGui::setVelocity %d\n",value); + filter->setVelocity(value); + } + diff --git a/attic/muse_qt4_evolution/midiplugins/trigg/trigggui.h b/attic/muse_qt4_evolution/midiplugins/trigg/trigggui.h new file mode 100644 index 00000000..f4c597fa --- /dev/null +++ b/attic/muse_qt4_evolution/midiplugins/trigg/trigggui.h @@ -0,0 +1,48 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: filtergui.h,v 1.4 2005/11/06 17:49:34 wschweer Exp $ +// +// (C) Copyright 2005 Werner Schweer (ws@seh.de) +//========================================================= + +#ifndef __FILTERGUI_H__ +#define __FILTERGUI_H__ + +#include "ui_trigggui.h" + +class Trigg; + +enum { + MIDI_FILTER_NOTEON = 1, + MIDI_FILTER_POLYP = 2, + MIDI_FILTER_CTRL = 4, + MIDI_FILTER_PROGRAM = 8, + MIDI_FILTER_AT = 16, + MIDI_FILTER_PITCH = 32, + MIDI_FILTER_SYSEX = 64 + }; + +//--------------------------------------------------------- +// TriggGui +//--------------------------------------------------------- + +class TriggGui : public QDialog, public Ui::TriggBase { + Q_OBJECT + + Trigg* filter; + + signals: + void hideWindow(); + + private slots: + void setNote(int ); + void setVelocity(int ); + + public: + TriggGui(Trigg*, QWidget* parent=0); + void init(); + }; + +#endif + diff --git a/attic/muse_qt4_evolution/midiplugins/trigg/trigggui.ui b/attic/muse_qt4_evolution/midiplugins/trigg/trigggui.ui new file mode 100644 index 00000000..5c096e24 --- /dev/null +++ b/attic/muse_qt4_evolution/midiplugins/trigg/trigggui.ui @@ -0,0 +1,109 @@ +<ui version="4.0" > + <author></author> + <comment></comment> + <exportmacro></exportmacro> + <class>TriggBase</class> + <widget class="QDialog" name="TriggBase" > + <property name="geometry" > + <rect> + <x>0</x> + <y>0</y> + <width>233</width> + <height>125</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 Input Trigg</string> + </property> + <layout class="QGridLayout" > + <property name="margin" > + <number>9</number> + </property> + <property name="spacing" > + <number>6</number> + </property> + <item row="0" column="0" > + <widget class="QGroupBox" name="GroupBoxx" > + <property name="sizePolicy" > + <sizepolicy> + <hsizetype>5</hsizetype> + <vsizetype>5</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="title" > + <string>Trigg</string> + </property> + <layout class="QGridLayout" > + <property name="margin" > + <number>9</number> + </property> + <property name="spacing" > + <number>6</number> + </property> + <item row="0" column="0" > + <layout class="QGridLayout" > + <property name="margin" > + <number>0</number> + </property> + <property name="spacing" > + <number>6</number> + </property> + <item row="1" column="1" > + <widget class="QLabel" name="label_2" > + <property name="text" > + <string>Velocity</string> + </property> + </widget> + </item> + <item row="0" column="0" > + <widget class="QSpinBox" name="noteEntry" > + <property name="maximum" > + <number>127</number> + </property> + <property name="value" > + <number>30</number> + </property> + </widget> + </item> + <item row="1" column="0" > + <widget class="QSpinBox" name="velocityEntry" > + <property name="maximum" > + <number>127</number> + </property> + <property name="minimum" > + <number>0</number> + </property> + <property name="value" > + <number>127</number> + </property> + </widget> + </item> + <item row="0" column="1" > + <widget class="QLabel" name="label" > + <property name="text" > + <string>Note</string> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </widget> + </item> + </layout> + </widget> + <layoutdefault spacing="6" margin="11" /> + <pixmapfunction></pixmapfunction> + <resources/> + <connections/> +</ui> |