diff options
author | Robert Jonsson <spamatica@gmail.com> | 2009-12-27 11:30:35 +0000 |
---|---|---|
committer | Robert Jonsson <spamatica@gmail.com> | 2009-12-27 11:30:35 +0000 |
commit | b703eab295330e6f81564fbb39a10a1a2fdd2f54 (patch) | |
tree | e46b5c9a6bc22fd661c15d1d2123f5bf631cef80 /muse_qt4_evolution/midiplugins/drumglue | |
parent | 5d5fa0fdf913907edbc3d2d29a7548f0cb658c94 (diff) |
moved old qt4 branch
Diffstat (limited to 'muse_qt4_evolution/midiplugins/drumglue')
12 files changed, 1250 insertions, 0 deletions
diff --git a/muse_qt4_evolution/midiplugins/drumglue/CMakeLists.txt b/muse_qt4_evolution/midiplugins/drumglue/CMakeLists.txt new file mode 100644 index 00000000..f824c54b --- /dev/null +++ b/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/muse_qt4_evolution/midiplugins/drumglue/drumglue.cpp b/muse_qt4_evolution/midiplugins/drumglue/drumglue.cpp new file mode 100644 index 00000000..7a9b6ed2 --- /dev/null +++ b/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/muse_qt4_evolution/midiplugins/drumglue/drumglue.h b/muse_qt4_evolution/midiplugins/drumglue/drumglue.h new file mode 100644 index 00000000..49a19b55 --- /dev/null +++ b/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/muse_qt4_evolution/midiplugins/drumglue/drumgluegui.cpp b/muse_qt4_evolution/midiplugins/drumglue/drumgluegui.cpp new file mode 100644 index 00000000..562adf2c --- /dev/null +++ b/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/muse_qt4_evolution/midiplugins/drumglue/drumgluegui.h b/muse_qt4_evolution/midiplugins/drumglue/drumgluegui.h new file mode 100644 index 00000000..cdbac7a3 --- /dev/null +++ b/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/muse_qt4_evolution/midiplugins/drumglue/drumgluegui.ui b/muse_qt4_evolution/midiplugins/drumglue/drumgluegui.ui new file mode 100644 index 00000000..ddd402c4 --- /dev/null +++ b/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/muse_qt4_evolution/midiplugins/drumglue/globalinstrumentview.cpp b/muse_qt4_evolution/midiplugins/drumglue/globalinstrumentview.cpp new file mode 100644 index 00000000..5ca81054 --- /dev/null +++ b/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/muse_qt4_evolution/midiplugins/drumglue/globalinstrumentview.h b/muse_qt4_evolution/midiplugins/drumglue/globalinstrumentview.h new file mode 100644 index 00000000..f923ec49 --- /dev/null +++ b/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/muse_qt4_evolution/midiplugins/drumglue/globalinstrumentview.ui b/muse_qt4_evolution/midiplugins/drumglue/globalinstrumentview.ui new file mode 100644 index 00000000..e817906a --- /dev/null +++ b/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/muse_qt4_evolution/midiplugins/drumglue/outputinstrumentview.cpp b/muse_qt4_evolution/midiplugins/drumglue/outputinstrumentview.cpp new file mode 100644 index 00000000..2e4c97ce --- /dev/null +++ b/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/muse_qt4_evolution/midiplugins/drumglue/outputinstrumentview.h b/muse_qt4_evolution/midiplugins/drumglue/outputinstrumentview.h new file mode 100644 index 00000000..b2b5dc12 --- /dev/null +++ b/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/muse_qt4_evolution/midiplugins/drumglue/outputinstrumentview.ui b/muse_qt4_evolution/midiplugins/drumglue/outputinstrumentview.ui new file mode 100644 index 00000000..250c2010 --- /dev/null +++ b/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> |