From 9e597bbedcac417880ef2d5729e8d170f6d0fbc7 Mon Sep 17 00:00:00 2001 From: Robert Jonsson Date: Sun, 30 Dec 2007 21:55:11 +0000 Subject: added DrumGlue midi filter --- muse/midiplugins/CMakeLists.txt | 11 +- muse/midiplugins/drumglue/CMakeLists.txt | 50 ++++ muse/midiplugins/drumglue/drumglue.cpp | 250 ++++++++++++++++++ muse/midiplugins/drumglue/drumglue.h | 86 ++++++ muse/midiplugins/drumglue/drumgluegui.cpp | 68 +++++ muse/midiplugins/drumglue/drumgluegui.h | 41 +++ muse/midiplugins/drumglue/drumgluegui.ui | 91 +++++++ muse/midiplugins/drumglue/globalinstrumentview.cpp | 153 +++++++++++ muse/midiplugins/drumglue/globalinstrumentview.h | 41 +++ muse/midiplugins/drumglue/globalinstrumentview.ui | 102 +++++++ muse/midiplugins/drumglue/outputinstrumentview.cpp | 45 ++++ muse/midiplugins/drumglue/outputinstrumentview.h | 31 +++ muse/midiplugins/drumglue/outputinstrumentview.ui | 292 +++++++++++++++++++++ 13 files changed, 1260 insertions(+), 1 deletion(-) create mode 100644 muse/midiplugins/drumglue/CMakeLists.txt create mode 100644 muse/midiplugins/drumglue/drumglue.cpp create mode 100644 muse/midiplugins/drumglue/drumglue.h create mode 100644 muse/midiplugins/drumglue/drumgluegui.cpp create mode 100644 muse/midiplugins/drumglue/drumgluegui.h create mode 100644 muse/midiplugins/drumglue/drumgluegui.ui create mode 100644 muse/midiplugins/drumglue/globalinstrumentview.cpp create mode 100644 muse/midiplugins/drumglue/globalinstrumentview.h create mode 100644 muse/midiplugins/drumglue/globalinstrumentview.ui create mode 100644 muse/midiplugins/drumglue/outputinstrumentview.cpp create mode 100644 muse/midiplugins/drumglue/outputinstrumentview.h create mode 100644 muse/midiplugins/drumglue/outputinstrumentview.ui diff --git a/muse/midiplugins/CMakeLists.txt b/muse/midiplugins/CMakeLists.txt index db19dfa8..465e1983 100644 --- a/muse/midiplugins/CMakeLists.txt +++ b/muse/midiplugins/CMakeLists.txt @@ -18,7 +18,16 @@ # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. #============================================================================= -subdirs(libmidiplugin splitlayer filter metronom transform trigg dump ) +subdirs( + libmidiplugin + splitlayer + filter + metronom + transform + trigg + dump + drumglue + ) set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DQT_NO_DEBUG -DQT_PLUGIN -DQT_SHARED -fPIC" diff --git a/muse/midiplugins/drumglue/CMakeLists.txt b/muse/midiplugins/drumglue/CMakeLists.txt new file mode 100644 index 00000000..f824c54b --- /dev/null +++ b/muse/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/midiplugins/drumglue/drumglue.cpp b/muse/midiplugins/drumglue/drumglue.cpp new file mode 100644 index 00000000..7a9b6ed2 --- /dev/null +++ b/muse/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/midiplugins/drumglue/drumglue.h b/muse/midiplugins/drumglue/drumglue.h new file mode 100644 index 00000000..49a19b55 --- /dev/null +++ b/muse/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 + +#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 outputInstruments; + +// storage of runtime variables + int lastOutputIndex; + unsigned int outputTime; +}; + + + + +class DrumGlue : public Mempi { + friend class DrumGlueGui; + friend class GlobalInstrumentView; + friend class OutputInstrumentView; + + QList 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/midiplugins/drumglue/drumgluegui.cpp b/muse/midiplugins/drumglue/drumgluegui.cpp new file mode 100644 index 00000000..562adf2c --- /dev/null +++ b/muse/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/midiplugins/drumglue/drumgluegui.h b/muse/midiplugins/drumglue/drumgluegui.h new file mode 100644 index 00000000..cdbac7a3 --- /dev/null +++ b/muse/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/midiplugins/drumglue/drumgluegui.ui b/muse/midiplugins/drumglue/drumgluegui.ui new file mode 100644 index 00000000..ddd402c4 --- /dev/null +++ b/muse/midiplugins/drumglue/drumgluegui.ui @@ -0,0 +1,91 @@ + + DrumGlueBase + + + + 0 + 0 + 444 + 270 + + + + Drumglue - midi filter + + + + + + + + + + Add instrument + + + + + + + Remove current + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + Arial + 14 + 75 + true + + + + DrumGlue 0.1 + + + + + + + + + QTabWidget::North + + + QTabWidget::Rounded + + + 0 + + + Qt::ElideLeft + + + + Snare + + + + + + + + + + + diff --git a/muse/midiplugins/drumglue/globalinstrumentview.cpp b/muse/midiplugins/drumglue/globalinstrumentview.cpp new file mode 100644 index 00000000..5ca81054 --- /dev/null +++ b/muse/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::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::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::iterator iter = drumGlue->drumInstruments.begin(); + while(iter != drumGlue->drumInstruments.end()) { + if ((*iter)->name == instrumentName) { + (*iter)->inKey = inKeySpinBox->value(); + } + iter++; + } + +} diff --git a/muse/midiplugins/drumglue/globalinstrumentview.h b/muse/midiplugins/drumglue/globalinstrumentview.h new file mode 100644 index 00000000..f923ec49 --- /dev/null +++ b/muse/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/midiplugins/drumglue/globalinstrumentview.ui b/muse/midiplugins/drumglue/globalinstrumentview.ui new file mode 100644 index 00000000..e817906a --- /dev/null +++ b/muse/midiplugins/drumglue/globalinstrumentview.ui @@ -0,0 +1,102 @@ + + GlobalInstrumentViewBase + + + + 0 + 0 + 386 + 256 + + + + Form + + + + -1 + + + + + -1 + + + + + -1 + + + + + Midi input key: + + + + + + + 1 + + + 127 + + + + + + + Add output + + + + + + + Remove output + + + + + + + Edit output + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + Midi output definitions: + + + + + + + + + + + + + + + diff --git a/muse/midiplugins/drumglue/outputinstrumentview.cpp b/muse/midiplugins/drumglue/outputinstrumentview.cpp new file mode 100644 index 00000000..2e4c97ce --- /dev/null +++ b/muse/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 +//--------------------------------------------------------- +// 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/midiplugins/drumglue/outputinstrumentview.h b/muse/midiplugins/drumglue/outputinstrumentview.h new file mode 100644 index 00000000..b2b5dc12 --- /dev/null +++ b/muse/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/midiplugins/drumglue/outputinstrumentview.ui b/muse/midiplugins/drumglue/outputinstrumentview.ui new file mode 100644 index 00000000..250c2010 --- /dev/null +++ b/muse/midiplugins/drumglue/outputinstrumentview.ui @@ -0,0 +1,292 @@ + + OutputInstrumentViewBase + + + + 0 + 0 + 449 + 150 + + + + Dialog + + + + + + + + + + Midi output key: + + + + + + + 1 + + + 127 + + + + + + + If this instrument is to be used more often than others check this box. + + + + + + Prefer always + + + + + + + If this instrument is to be used more often when used often, check this checkbox. + + + + + + Prefer when fast + + + + + + + + + Qt::Horizontal + + + + + + + + + + 0 + 0 + + + + [low] + + + + + + + + 0 + 0 + + + + Qt::Vertical + + + + + + + + 0 + 0 + + + + Qt::Vertical + + + + + + + + 0 + 0 + + + + Qt::RightToLeft + + + [high] + + + + + + + + + + + + + + 24 + 0 + + + + QFrame::Box + + + 1 + + + + + + + 1 + + + 127 + + + Qt::Horizontal + + + + + + + + + use in range + + + + + + + + + + 24 + 0 + + + + QFrame::Box + + + 127 + + + + + + + 1 + + + 127 + + + 127 + + + Qt::Horizontal + + + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok + + + + + + + + + + + buttonBox + accepted() + OutputInstrumentViewBase + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + OutputInstrumentViewBase + reject() + + + 316 + 260 + + + 286 + 274 + + + + + highRangeSlider + valueChanged(int) + highRangeLabel + setNum(int) + + + 215 + 107 + + + 165 + 108 + + + + + lowRangeSlider + valueChanged(int) + lowRangeLabel + setNum(int) + + + 75 + 107 + + + 25 + 108 + + + + + -- cgit v1.2.3