diff options
-rw-r--r-- | muse/muse/ctrl/configmidictrl.cpp | 3 | ||||
-rw-r--r-- | muse/muse/instruments/editinstrument.cpp | 136 | ||||
-rw-r--r-- | muse/muse/instruments/editinstrument.h | 3 | ||||
-rw-r--r-- | muse/muse/instruments/editinstrument.ui | 1205 | ||||
-rw-r--r-- | muse/muse/instruments/minstrument.cpp | 3 | ||||
-rw-r--r-- | muse/muse/instruments/minstrument.h | 21 | ||||
-rw-r--r-- | muse/muse/midictrl.cpp | 29 | ||||
-rw-r--r-- | muse/muse/midictrl.h | 13 | ||||
-rw-r--r-- | muse/muse/muse.cpp | 28 | ||||
-rw-r--r-- | muse/muse/song.cpp | 1 | ||||
-rw-r--r-- | muse/muse/synth.cpp | 1 |
11 files changed, 801 insertions, 642 deletions
diff --git a/muse/muse/ctrl/configmidictrl.cpp b/muse/muse/ctrl/configmidictrl.cpp index f5d2247d..6f9187c9 100644 --- a/muse/muse/ctrl/configmidictrl.cpp +++ b/muse/muse/ctrl/configmidictrl.cpp @@ -50,6 +50,7 @@ ConfigMidiCtrl::ConfigMidiCtrl(MidiTrack* t) if (track->type() == Track::MIDI) { MidiTrack* mc = (MidiTrack*)track; portName->setText(track->name()); + instrumentName->setText(mc->instrument()->iname()); // // populate popup with all controllers available for // current instrument @@ -69,6 +70,7 @@ ConfigMidiCtrl::ConfigMidiCtrl(MidiTrack* t) delete cn; buttonAdd->setEnabled(false); buttonRemove->setEnabled(false); + connect(buttonAdd, SIGNAL(clicked()), SLOT(addClicked())); connect(buttonRemove, SIGNAL(clicked()), SLOT(removeClicked())); connect(availableController, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)), SLOT(availableSelected(QListWidgetItem*))); @@ -190,7 +192,6 @@ void ConfigMidiCtrl::done(int code) void ConfigMidiCtrl::defineClicked() { - printf("define clicked\n"); DefineMidiCtrl dc(track, this); if (dc.exec()) QDialog::done(0); diff --git a/muse/muse/instruments/editinstrument.cpp b/muse/muse/instruments/editinstrument.cpp index c0a1c736..de4bdc4c 100644 --- a/muse/muse/instruments/editinstrument.cpp +++ b/muse/muse/instruments/editinstrument.cpp @@ -20,6 +20,8 @@ #include "editinstrument.h" #include "minstrument.h" +#include "ctrl.h" +#include "midictrl.h" //--------------------------------------------------------- // EditInstrument @@ -30,14 +32,23 @@ EditInstrument::EditInstrument(QWidget* parent) { setupUi(this); // populate instrument list - for (iMidiInstrument i = midiInstruments.begin(); i != midiInstruments.end(); ++i) - instrumentList->addItem((*i)->iname()); + for (iMidiInstrument i = midiInstruments.begin(); i != midiInstruments.end(); ++i) { + QListWidgetItem* item = new QListWidgetItem((*i)->iname()); + QVariant v = qVariantFromValue((void*)(*i)); + item->setData(Qt::UserRole, v); + instrumentList->addItem(item); + } instrumentList->setItemSelected(instrumentList->item(0), true); connect(instrumentList, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)), SLOT(instrumentChanged(QListWidgetItem*))); connect(patchView, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)), SLOT(patchChanged(QTreeWidgetItem*))); instrumentChanged(instrumentList->item(0)); + connect(listController, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)), + SLOT(controllerChanged(QListWidgetItem*))); + connect(instrumentName, SIGNAL(textChanged(const QString&)), SLOT(instrumentNameChanged(const QString&))); + connect(fileSaveAsAction, SIGNAL(triggered()), SLOT(fileSaveAs())); + connect(fileSaveAction, SIGNAL(triggered()), SLOT(fileSave())); } //--------------------------------------------------------- @@ -46,60 +57,111 @@ EditInstrument::EditInstrument(QWidget* parent) void EditInstrument::instrumentChanged(QListWidgetItem* sel) { - if (sel == 0) - return; - QString iname = sel->text(); - iMidiInstrument i = midiInstruments.begin(); - for (; i != midiInstruments.end(); ++i) { - if ((*i)->iname() == iname) - break; - } patchView->clear(); - if (i == midiInstruments.end()) + listController->clear(); + + if (sel == 0) return; // populate patch list - std::vector<PatchGroup>* pg = (*i)->groups(); + + MidiInstrument* instrument = (MidiInstrument*)sel->data(Qt::UserRole).value<void*>(); + instrumentName->setText(instrument->iname()); + std::vector<PatchGroup>* pg = instrument->groups(); for (std::vector<PatchGroup>::iterator g = pg->begin(); g != pg->end(); ++g) { QTreeWidgetItem* item = new QTreeWidgetItem; item->setText(0, g->name); + QVariant v = QVariant::fromValue((void*)0); + item->setData(0, Qt::UserRole, v); patchView->addTopLevelItem(item); for (iPatch p = g->patches.begin(); p != g->patches.end(); ++p) { + Patch* patch = *p; QTreeWidgetItem* sitem = new QTreeWidgetItem; - sitem->setText(0, (*p)->name); + sitem->setText(0, patch->name); + QVariant v = QVariant::fromValue((void*)(patch)); + sitem->setData(0, Qt::UserRole, v); item->addChild(sitem); } } + MidiControllerList* cl = instrument->controller(); + for (iMidiController ic = cl->begin(); ic != cl->end(); ++ic) { + MidiController* c = *ic; + QListWidgetItem* item = new QListWidgetItem(c->name()); + QVariant v = qVariantFromValue((void*)(c)); + item->setData(Qt::UserRole, v); + listController->addItem(item); + } + listController->setItemSelected(listController->item(0), true); + controllerChanged(listController->item(0)); } //--------------------------------------------------------- -// patchChanged +// controllerChanged //--------------------------------------------------------- -void EditInstrument::patchChanged(QTreeWidgetItem* sel) +void EditInstrument::controllerChanged(QListWidgetItem* sel) { - if (sel == 0) { - textLabelPatchName->setText(""); + if (sel == 0 || sel->data(Qt::UserRole).value<void*>() == 0) { + // patchNameEdit->setText(""); return; } - textLabelPatchName->setText(sel->text(0)); + MidiController* c = (MidiController*)sel->data(Qt::UserRole).value<void*>(); + entryName->setText(c->name()); + MidiController::ControllerType type = c->type(); + switch(type) { + case MidiController::Controller7: + spinBoxHCtrlNo->setEnabled(false); + break; + case MidiController::Controller14: + case MidiController::RPN: + case MidiController::NRPN: + case MidiController::RPN14: + case MidiController::NRPN14: + spinBoxHCtrlNo->setEnabled(true); + break; + case MidiController::Pitch: + case MidiController::Program: + case MidiController::Velo: + break; + } + + int ctrlH = (c->num() >> 8) & 0x7f; + int ctrlL = c->num() & 0x7f; + spinBoxType->setCurrentIndex(int(type)); + spinBoxHCtrlNo->setValue(ctrlH); + spinBoxLCtrlNo->setValue(ctrlL); + spinBoxMin->setValue(c->minVal()); + spinBoxMax->setValue(c->maxVal()); + spinBoxDefault->setValue(c->initVal()); } //--------------------------------------------------------- -// fileNew +// patchChanged //--------------------------------------------------------- -void EditInstrument::fileNew() +void EditInstrument::patchChanged(QTreeWidgetItem* sel) { - + if (sel == 0 || sel->data(0, Qt::UserRole).value<void*>() == 0) { + patchNameEdit->setText(""); + return; + } + Patch* p = (Patch*)sel->data(0, Qt::UserRole).value<void*>(); + patchNameEdit->setText(p->name); + spinBoxHBank->setValue(p->hbank); + spinBoxLBank->setValue(p->lbank); + spinBoxProgram->setValue(p->prog); + checkBoxDrum->setChecked(p->drumMap); + checkBoxGM->setChecked(p->typ & 1); + checkBoxGS->setChecked(p->typ & 2); + checkBoxXG->setChecked(p->typ & 4); } //--------------------------------------------------------- -// fileOpen +// fileNew //--------------------------------------------------------- -void EditInstrument::fileOpen() +void EditInstrument::fileNew() { - printf("fileOpen\n"); + } //--------------------------------------------------------- @@ -117,7 +179,16 @@ void EditInstrument::fileSave() void EditInstrument::fileSaveAs() { - + QListWidgetItem* item = instrumentList->currentItem(); + if (item == 0) + return; + MidiInstrument* instrument = (MidiInstrument*)item->data(Qt::UserRole).value<void*>(); + QString path = QDir::homePath() + "/MusE/instruments"; + path += QString("/%1.idf").arg(instrument->iname()); + QString s = QFileDialog::getSaveFileName(this, + tr("MusE: Save Instrument Definition"), + path, + tr("Instrument Definition (*.idf)")); } //--------------------------------------------------------- @@ -126,6 +197,21 @@ void EditInstrument::fileSaveAs() void EditInstrument::fileExit() { + } + +//--------------------------------------------------------- +// instrumentNameChanged +//--------------------------------------------------------- +void EditInstrument::instrumentNameChanged(const QString& s) + { + QListWidgetItem* item = instrumentList->currentItem(); + if (item == 0) + return; + if (s != item->text()) { + item->setText(s); + MidiInstrument* instrument = (MidiInstrument*)item->data(Qt::UserRole).value<void*>(); + instrument->setDirty(true); + } } diff --git a/muse/muse/instruments/editinstrument.h b/muse/muse/instruments/editinstrument.h index 54f6f5e5..2714814a 100644 --- a/muse/muse/instruments/editinstrument.h +++ b/muse/muse/instruments/editinstrument.h @@ -32,12 +32,13 @@ class EditInstrument : public QMainWindow, public Ui::EditInstrumentBase { private slots: virtual void fileNew(); - virtual void fileOpen(); virtual void fileSave(); virtual void fileSaveAs(); virtual void fileExit(); void instrumentChanged(QListWidgetItem*); void patchChanged(QTreeWidgetItem*); + void controllerChanged(QListWidgetItem* sel); + void instrumentNameChanged(const QString&); public: EditInstrument(QWidget* parent = 0); diff --git a/muse/muse/instruments/editinstrument.ui b/muse/muse/instruments/editinstrument.ui index 648981dc..c8f1916b 100644 --- a/muse/muse/instruments/editinstrument.ui +++ b/muse/muse/instruments/editinstrument.ui @@ -1,662 +1,681 @@ <ui version="4.0" > - <author></author> - <comment></comment> - <exportmacro></exportmacro> <class>EditInstrumentBase</class> <widget class="QMainWindow" name="EditInstrumentBase" > <property name="geometry" > <rect> <x>0</x> <y>0</y> - <width>750</width> - <height>644</height> + <width>819</width> + <height>505</height> </rect> </property> <property name="windowTitle" > <string>MusE: Instrument Editor</string> </property> <widget class="QWidget" name="widget" > - <widget class="QSplitter" name="splitter" > - <property name="orientation" > - <enum>Qt::Horizontal</enum> + <layout class="QVBoxLayout" > + <property name="margin" > + <number>9</number> </property> - <widget class="QListWidget" name="instrumentList" /> - <widget class="QTabWidget" name="tabWidget3" > - <widget class="QWidget" name="tab" > - <attribute name="title" > - <string>Patches</string> - </attribute> - <layout class="QVBoxLayout" > - <property name="margin" > - <number>9</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <widget class="QSplitter" name="" > - <property name="orientation" > - <enum>Qt::Horizontal</enum> - </property> - <widget class="QTreeWidget" name="patchView" > - <property name="sizePolicy" > - <sizepolicy> - <hsizetype>7</hsizetype> - <vsizetype>7</vsizetype> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="rootIsDecorated" > - <bool>true</bool> - </property> - <column> - <property name="text" > - <string>Patch/Group</string> - </property> - </column> - </widget> - <widget class="QWidget" name="" > - <layout class="QGridLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item row="0" column="1" colspan="2" > - <widget class="QLineEdit" name="patchNameEdit" /> - </item> - <item row="0" column="0" > - <widget class="QLabel" name="textLabelPatchName" > - <property name="text" > - <string>Patch Name:</string> - </property> - </widget> - </item> - <item row="3" column="0" > - <widget class="QLabel" name="textLabel4_3" > - <property name="text" > - <string>Program:</string> - </property> - </widget> - </item> - <item row="6" column="0" colspan="3" > - <layout class="QHBoxLayout" > - <property name="margin" > - <number>5</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <widget class="QToolButton" name="patchDelete" > - <property name="sizePolicy" > - <sizepolicy> - <hsizetype>5</hsizetype> - <vsizetype>0</vsizetype> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text" > - <string>&Delete</string> - </property> - <property name="shortcut" > - <string>Alt+D</string> - </property> - </widget> - </item> - <item> - <widget class="QToolButton" name="patchNew" > - <property name="sizePolicy" > - <sizepolicy> - <hsizetype>5</hsizetype> - <vsizetype>1</vsizetype> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text" > - <string>&New Patch</string> - </property> - <property name="shortcut" > - <string>Alt+N</string> - </property> - </widget> - </item> - <item> - <widget class="QToolButton" name="patchNewGroup" > - <property name="text" > - <string>New Group</string> - </property> - </widget> - </item> - <item> - <spacer> - <property name="orientation" > - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeType" > - <enum>QSizePolicy::Expanding</enum> - </property> - <property name="sizeHint" > - <size> - <width>240</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - </layout> - </item> - <item row="2" column="2" > - <spacer> - <property name="orientation" > - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeType" > - <enum>QSizePolicy::Expanding</enum> - </property> - <property name="sizeHint" > - <size> - <width>280</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item row="3" column="2" > - <spacer> - <property name="orientation" > - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeType" > - <enum>QSizePolicy::Expanding</enum> - </property> - <property name="sizeHint" > - <size> - <width>280</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item row="1" column="2" > - <spacer> - <property name="orientation" > - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeType" > - <enum>QSizePolicy::Expanding</enum> - </property> - <property name="sizeHint" > - <size> - <width>280</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item row="2" column="1" > - <widget class="QSpinBox" name="spinBoxLBank" > - <property name="specialValueText" > - <string>d.c.</string> - </property> - <property name="maximum" > - <number>127</number> - </property> - <property name="minimum" > - <number>-1</number> - </property> - <property name="value" > - <number>-1</number> - </property> - </widget> - </item> - <item row="1" column="0" > - <widget class="QLabel" name="textLabel2_2" > - <property name="text" > - <string>High Bank:</string> - </property> - </widget> - </item> - <item row="2" column="0" > - <widget class="QLabel" name="textLabel3_2" > - <property name="text" > - <string>Low Bank:</string> - </property> - </widget> - </item> - <item row="5" column="2" > - <spacer> - <property name="orientation" > - <enum>Qt::Vertical</enum> - </property> - <property name="sizeType" > - <enum>QSizePolicy::Expanding</enum> - </property> - <property name="sizeHint" > - <size> - <width>20</width> - <height>90</height> - </size> - </property> - </spacer> - </item> - <item row="1" column="1" > - <widget class="QSpinBox" name="spinBoxHBank" > - <property name="specialValueText" > - <string>d.c.</string> - </property> - <property name="maximum" > - <number>127</number> - </property> - <property name="minimum" > - <number>-1</number> - </property> - <property name="value" > - <number>-1</number> - </property> - </widget> - </item> - <item row="3" column="1" > - <widget class="QSpinBox" name="spinBoxProgram" /> - </item> - <item row="4" column="0" colspan="3" > - <layout class="QHBoxLayout" > - <property name="margin" > - <number>6</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <widget class="QCheckBox" name="checkBoxDrum" > - <property name="text" > - <string>Drum</string> - </property> - </widget> - </item> - <item> - <widget class="QCheckBox" name="checkBoxGM" > - <property name="text" > - <string>GM</string> - </property> - </widget> - </item> - <item> - <widget class="QCheckBox" name="checkBoxGS" > - <property name="text" > - <string>GS</string> - </property> - </widget> - </item> - <item> - <widget class="QCheckBox" name="checkBoxXG" > - <property name="text" > - <string>XG</string> - </property> - </widget> - </item> - </layout> - </item> - </layout> - </widget> - </widget> - </item> - </layout> - </widget> - <widget class="QWidget" name="tab" > - <attribute name="title" > - <string>Controller</string> - </attribute> - <layout class="QGridLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item row="0" column="0" > - <widget class="QLabel" name="textLabel1" > - <property name="sizePolicy" > - <sizepolicy> - <hsizetype>5</hsizetype> - <vsizetype>0</vsizetype> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text" > - <string>Predefined Controller:</string> - </property> - </widget> - </item> - <item rowspan="2" row="1" column="0" > - <widget class="QListWidget" name="listController" > - <property name="whatsThis" > - <string>This is a list of commonly used midi controllers. -Note that in MusE pitch and program changes are -handled like normal controllers.</string> - </property> - </widget> - </item> - <item row="2" column="1" > - <widget class="QGroupBox" name="GroupBox1" > - <property name="sizePolicy" > - <sizepolicy> - <hsizetype>1</hsizetype> - <vsizetype>5</vsizetype> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="title" > - <string>Properties</string> - </property> - <layout class="QGridLayout" > + <property name="spacing" > + <number>6</number> + </property> + <item> + <widget class="QSplitter" name="splitter_2" > + <property name="orientation" > + <enum>Qt::Horizontal</enum> + </property> + <widget class="QListWidget" name="instrumentList" /> + <widget class="QWidget" name="layoutWidget" > + <layout class="QVBoxLayout" > + <property name="margin" > + <number>0</number> + </property> + <property name="spacing" > + <number>6</number> + </property> + <item> + <layout class="QHBoxLayout" > <property name="margin" > - <number>10</number> + <number>0</number> </property> <property name="spacing" > <number>6</number> </property> - <item row="0" column="0" > - <widget class="QLabel" name="TextLabel1_3" > + <item> + <widget class="QLabel" name="label" > <property name="text" > - <string>Name</string> + <string>Instrument Name:</string> </property> </widget> </item> - <item row="1" column="0" > - <widget class="QLabel" name="TextLabel2_4" > - <property name="text" > - <string>Type</string> - </property> - </widget> + <item> + <widget class="QLineEdit" name="instrumentName" /> </item> - <item row="1" column="1" > - <layout class="QHBoxLayout" > + </layout> + </item> + <item> + <widget class="QTabWidget" name="tabWidget3" > + <property name="currentIndex" > + <number>1</number> + </property> + <widget class="QWidget" name="tab" > + <attribute name="title" > + <string>Patches</string> + </attribute> + <layout class="QVBoxLayout" > <property name="margin" > - <number>2</number> + <number>9</number> </property> <property name="spacing" > <number>6</number> </property> <item> - <widget class="QComboBox" name="spinBoxType" > - <item> - <property name="text" > - <string>Control7</string> - </property> - </item> - <item> - <property name="text" > - <string>Control14</string> - </property> - </item> - <item> - <property name="text" > - <string>RPN</string> - </property> - </item> - <item> - <property name="text" > - <string>NRPN</string> - </property> - </item> - <item> - <property name="text" > - <string>Pitch</string> + <widget class="QSplitter" name="splitter" > + <property name="orientation" > + <enum>Qt::Horizontal</enum> + </property> + <widget class="QTreeWidget" name="patchView" > + <property name="sizePolicy" > + <sizepolicy> + <hsizetype>7</hsizetype> + <vsizetype>7</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> </property> - </item> - <item> - <property name="text" > - <string>Program</string> + <property name="rootIsDecorated" > + <bool>true</bool> </property> - </item> + <column> + <property name="text" > + <string>Patch/Group</string> + </property> + </column> + </widget> + <widget class="QWidget" name="layoutWidget" > + <layout class="QGridLayout" > + <property name="margin" > + <number>0</number> + </property> + <property name="spacing" > + <number>6</number> + </property> + <item row="0" column="1" colspan="2" > + <widget class="QLineEdit" name="patchNameEdit" /> + </item> + <item row="0" column="0" > + <widget class="QLabel" name="textLabelPatchName" > + <property name="text" > + <string>Patch Name:</string> + </property> + </widget> + </item> + <item row="3" column="0" > + <widget class="QLabel" name="textLabel4_3" > + <property name="text" > + <string>Program:</string> + </property> + </widget> + </item> + <item row="6" column="0" colspan="3" > + <layout class="QHBoxLayout" > + <property name="margin" > + <number>5</number> + </property> + <property name="spacing" > + <number>6</number> + </property> + <item> + <widget class="QToolButton" name="patchDelete" > + <property name="sizePolicy" > + <sizepolicy> + <hsizetype>5</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text" > + <string>&Delete</string> + </property> + <property name="shortcut" > + <string>Alt+D</string> + </property> + </widget> + </item> + <item> + <widget class="QToolButton" name="patchNew" > + <property name="sizePolicy" > + <sizepolicy> + <hsizetype>5</hsizetype> + <vsizetype>1</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text" > + <string>&New Patch</string> + </property> + <property name="shortcut" > + <string>Alt+N</string> + </property> + </widget> + </item> + <item> + <widget class="QToolButton" name="patchNewGroup" > + <property name="text" > + <string>New Group</string> + </property> + </widget> + </item> + <item> + <spacer> + <property name="orientation" > + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeType" > + <enum>QSizePolicy::Expanding</enum> + </property> + <property name="sizeHint" > + <size> + <width>240</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + </layout> + </item> + <item row="2" column="2" > + <spacer> + <property name="orientation" > + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeType" > + <enum>QSizePolicy::Expanding</enum> + </property> + <property name="sizeHint" > + <size> + <width>280</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item row="3" column="2" > + <spacer> + <property name="orientation" > + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeType" > + <enum>QSizePolicy::Expanding</enum> + </property> + <property name="sizeHint" > + <size> + <width>280</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item row="1" column="2" > + <spacer> + <property name="orientation" > + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeType" > + <enum>QSizePolicy::Expanding</enum> + </property> + <property name="sizeHint" > + <size> + <width>280</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item row="2" column="1" > + <widget class="QSpinBox" name="spinBoxLBank" > + <property name="specialValueText" > + <string>d.c.</string> + </property> + <property name="maximum" > + <number>127</number> + </property> + <property name="minimum" > + <number>-1</number> + </property> + <property name="value" > + <number>-1</number> + </property> + </widget> + </item> + <item row="1" column="0" > + <widget class="QLabel" name="textLabel2_2" > + <property name="text" > + <string>High Bank:</string> + </property> + </widget> + </item> + <item row="2" column="0" > + <widget class="QLabel" name="textLabel3_2" > + <property name="text" > + <string>Low Bank:</string> + </property> + </widget> + </item> + <item row="5" column="2" > + <spacer> + <property name="orientation" > + <enum>Qt::Vertical</enum> + </property> + <property name="sizeType" > + <enum>QSizePolicy::Expanding</enum> + </property> + <property name="sizeHint" > + <size> + <width>20</width> + <height>90</height> + </size> + </property> + </spacer> + </item> + <item row="1" column="1" > + <widget class="QSpinBox" name="spinBoxHBank" > + <property name="specialValueText" > + <string>d.c.</string> + </property> + <property name="maximum" > + <number>127</number> + </property> + <property name="minimum" > + <number>-1</number> + </property> + <property name="value" > + <number>-1</number> + </property> + </widget> + </item> + <item row="3" column="1" > + <widget class="QSpinBox" name="spinBoxProgram" /> + </item> + <item row="4" column="0" colspan="3" > + <layout class="QHBoxLayout" > + <property name="margin" > + <number>6</number> + </property> + <property name="spacing" > + <number>6</number> + </property> + <item> + <widget class="QCheckBox" name="checkBoxDrum" > + <property name="text" > + <string>Drum</string> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="checkBoxGM" > + <property name="text" > + <string>GM</string> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="checkBoxGS" > + <property name="text" > + <string>GS</string> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="checkBoxXG" > + <property name="text" > + <string>XG</string> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </widget> </widget> </item> - <item> - <widget class="QLabel" name="TextLabel3_2" > - <property name="text" > - <string>H-Ctrl</string> + </layout> + </widget> + <widget class="QWidget" name="tab" > + <attribute name="title" > + <string>Controller</string> + </attribute> + <layout class="QGridLayout" > + <property name="margin" > + <number>9</number> + </property> + <property name="spacing" > + <number>6</number> + </property> + <item row="0" column="0" > + <widget class="QLabel" name="textLabel1" > + <property name="sizePolicy" > + <sizepolicy> + <hsizetype>5</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> </property> - <property name="indent" > - <number>10</number> + <property name="text" > + <string>Controller List:</string> </property> </widget> </item> - <item> - <widget class="QSpinBox" name="spinBoxHCtrlNo" > - <property name="toolTip" > - <string>Midi Controller Number High Byte</string> + <item rowspan="2" row="0" column="1" > + <spacer> + <property name="orientation" > + <enum>Qt::Vertical</enum> </property> - <property name="maximum" > - <number>127</number> + <property name="sizeHint" > + <size> + <width>20</width> + <height>111</height> + </size> </property> - <property name="minimum" > - <number>0</number> - </property> - <property name="value" > - <number>1</number> - </property> - </widget> + </spacer> </item> - <item> - <widget class="QLabel" name="TextLabel2_3_2" > - <property name="text" > - <string>L-Ctrl</string> - </property> - <property name="indent" > - <number>10</number> + <item rowspan="2" row="1" column="0" > + <widget class="QListWidget" name="listController" > + <property name="whatsThis" > + <string>This is a list of commonly used midi controllers. +Note that in MusE pitch and program changes are +handled like normal controllers.</string> </property> </widget> </item> - <item> - <widget class="QSpinBox" name="spinBoxLCtrlNo" > - <property name="toolTip" > - <string>Midi Controller Number Low Byte</string> - </property> - <property name="maximum" > - <number>127</number> - </property> - <property name="minimum" > - <number>0</number> + <item row="2" column="1" > + <widget class="QGroupBox" name="GroupBox1" > + <property name="sizePolicy" > + <sizepolicy> + <hsizetype>1</hsizetype> + <vsizetype>5</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> </property> - <property name="value" > - <number>1</number> + <property name="title" > + <string>Properties</string> </property> + <layout class="QGridLayout" > + <property name="margin" > + <number>10</number> + </property> + <property name="spacing" > + <number>6</number> + </property> + <item row="0" column="0" > + <widget class="QLabel" name="TextLabel1_3" > + <property name="text" > + <string>Name</string> + </property> + </widget> + </item> + <item row="1" column="0" > + <widget class="QLabel" name="TextLabel2_4" > + <property name="text" > + <string>Type</string> + </property> + </widget> + </item> + <item row="1" column="1" > + <layout class="QHBoxLayout" > + <property name="margin" > + <number>2</number> + </property> + <property name="spacing" > + <number>6</number> + </property> + <item> + <widget class="QComboBox" name="spinBoxType" > + <item> + <property name="text" > + <string>Controller-7Bit</string> + </property> + </item> + <item> + <property name="text" > + <string>Controller-14Bit</string> + </property> + </item> + <item> + <property name="text" > + <string>RPN-7Bit</string> + </property> + </item> + <item> + <property name="text" > + <string>NRPN-7Bit</string> + </property> + </item> + <item> + <property name="text" > + <string>RPN-14Bit</string> + </property> + </item> + <item> + <property name="text" > + <string>NRPN-14Bit</string> + </property> + </item> + <item> + <property name="text" > + <string>Pitch</string> + </property> + </item> + <item> + <property name="text" > + <string>Program</string> + </property> + </item> + </widget> + </item> + <item> + <widget class="QLabel" name="TextLabel3_2" > + <property name="text" > + <string>H-Ctrl</string> + </property> + <property name="indent" > + <number>10</number> + </property> + </widget> + </item> + <item> + <widget class="QSpinBox" name="spinBoxHCtrlNo" > + <property name="toolTip" > + <string>Midi Controller Number High Byte</string> + </property> + <property name="maximum" > + <number>127</number> + </property> + <property name="minimum" > + <number>0</number> + </property> + <property name="value" > + <number>1</number> + </property> + </widget> + </item> + <item> + <widget class="QLabel" name="TextLabel2_3_2" > + <property name="text" > + <string>L-Ctrl</string> + </property> + <property name="indent" > + <number>10</number> + </property> + </widget> + </item> + <item> + <widget class="QSpinBox" name="spinBoxLCtrlNo" > + <property name="toolTip" > + <string>Midi Controller Number Low Byte</string> + </property> + <property name="maximum" > + <number>127</number> + </property> + <property name="minimum" > + <number>0</number> + </property> + <property name="value" > + <number>1</number> + </property> + </widget> + </item> + </layout> + </item> + <item row="0" column="1" > + <widget class="QLineEdit" name="entryName" /> + </item> + <item row="2" column="0" > + <widget class="QLabel" name="textLabel4_2" > + <property name="text" > + <string>Range</string> + </property> + </widget> + </item> + <item row="2" column="1" > + <layout class="QHBoxLayout" > + <property name="margin" > + <number>0</number> + </property> + <property name="spacing" > + <number>6</number> + </property> + <item> + <widget class="QLabel" name="TextLabel1_2_2" > + <property name="text" > + <string>Min</string> + </property> + <property name="indent" > + <number>10</number> + </property> + </widget> + </item> + <item> + <widget class="QSpinBox" name="spinBoxMin" > + <property name="maximum" > + <number>16384</number> + </property> + <property name="minimum" > + <number>-16385</number> + </property> + </widget> + </item> + <item> + <widget class="QLabel" name="TextLabel2_2_2" > + <property name="text" > + <string>Max</string> + </property> + <property name="indent" > + <number>10</number> + </property> + </widget> + </item> + <item> + <widget class="QSpinBox" name="spinBoxMax" > + <property name="maximum" > + <number>16384</number> + </property> + <property name="minimum" > + <number>-16385</number> + </property> + <property name="value" > + <number>127</number> + </property> + </widget> + </item> + <item> + <widget class="QLabel" name="textLabel1_3" > + <property name="text" > + <string>Default</string> + </property> + </widget> + </item> + <item> + <widget class="QSpinBox" name="spinBoxDefault" /> + </item> + </layout> + </item> + </layout> </widget> </item> </layout> - </item> - <item row="0" column="1" > - <widget class="QLineEdit" name="entryName" /> - </item> - <item row="2" column="0" > - <widget class="QLabel" name="textLabel4_2" > - <property name="text" > - <string>Range</string> - </property> - </widget> - </item> - <item row="2" column="1" > - <layout class="QHBoxLayout" > + </widget> + <widget class="QWidget" name="TabPage" > + <attribute name="title" > + <string>SysEx</string> + </attribute> + <layout class="QGridLayout" > <property name="margin" > <number>0</number> </property> <property name="spacing" > <number>6</number> </property> - <item> - <widget class="QLabel" name="TextLabel1_2_2" > - <property name="text" > - <string>Min</string> + <item row="2" column="1" > + <spacer> + <property name="orientation" > + <enum>Qt::Vertical</enum> </property> - <property name="indent" > - <number>10</number> + <property name="sizeType" > + <enum>QSizePolicy::Expanding</enum> </property> - </widget> - </item> - <item> - <widget class="QSpinBox" name="spinBoxMin" > - <property name="maximum" > - <number>16384</number> - </property> - <property name="minimum" > - <number>-16385</number> + <property name="sizeHint" > + <size> + <width>20</width> + <height>130</height> + </size> </property> - </widget> + </spacer> </item> - <item> - <widget class="QLabel" name="TextLabel2_2_2" > - <property name="text" > - <string>Max</string> - </property> - <property name="indent" > - <number>10</number> + <item rowspan="3" row="0" column="0" > + <widget class="QListWidget" name="listBox2" > + <property name="sizePolicy" > + <sizepolicy> + <hsizetype>1</hsizetype> + <vsizetype>7</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> </property> </widget> </item> - <item> - <widget class="QSpinBox" name="spinBoxMax" > - <property name="maximum" > - <number>16384</number> - </property> - <property name="minimum" > - <number>-16385</number> - </property> - <property name="value" > - <number>127</number> - </property> - </widget> + <item row="1" column="1" > + <widget class="QTextEdit" name="initSysEx" /> </item> - <item> - <widget class="QLabel" name="textLabel1_3" > + <item row="0" column="1" > + <widget class="QLabel" name="textLabel1_2" > <property name="text" > - <string>Default</string> + <string>Hex Entry:</string> </property> </widget> </item> - <item> - <widget class="QSpinBox" name="spinBoxDefault" /> - </item> </layout> - </item> - </layout> - </widget> - </item> - <item rowspan="2" row="0" column="1" > - <widget class="QTreeWidget" name="viewController" > - <property name="toolTip" > - <string>list of defined controllers</string> - </property> - <property name="whatsThis" > - <string>This is the MusE list of defined controllers.</string> - </property> - <property name="frameShape" > - <enum>QFrame::StyledPanel</enum> - </property> - <property name="frameShadow" > - <enum>QFrame::Sunken</enum> - </property> - <column> - <property name="text" > - <string>Name </string> - </property> - </column> - <column> - <property name="text" > - <string>Type </string> - </property> - </column> - <column> - <property name="text" > - <string>H-Ctrl</string> - </property> - </column> - <column> - <property name="text" > - <string>L-Ctrl</string> - </property> - </column> - <column> - <property name="text" > - <string>Min Val</string> - </property> - </column> - <column> - <property name="text" > - <string>Max Val</string> - </property> - </column> - </widget> - </item> - </layout> - </widget> - <widget class="QWidget" name="TabPage" > - <attribute name="title" > - <string>SysEx</string> - </attribute> - <layout class="QGridLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item row="2" column="1" > - <spacer> - <property name="orientation" > - <enum>Qt::Vertical</enum> - </property> - <property name="sizeType" > - <enum>QSizePolicy::Expanding</enum> - </property> - <property name="sizeHint" > - <size> - <width>20</width> - <height>130</height> - </size> - </property> - </spacer> - </item> - <item rowspan="3" row="0" column="0" > - <widget class="QListWidget" name="listBox2" > - <property name="sizePolicy" > - <sizepolicy> - <hsizetype>1</hsizetype> - <vsizetype>7</vsizetype> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - </widget> - </item> - <item row="1" column="1" > - <widget class="QTextEdit" name="initSysEx" /> - </item> - <item row="0" column="1" > - <widget class="QLabel" name="textLabel1_2" > - <property name="text" > - <string>Hex Entry:</string> - </property> - </widget> - </item> - </layout> + </widget> + </widget> + </item> + </layout> + </widget> </widget> - </widget> - </widget> + </item> + </layout> </widget> <widget class="QMenuBar" name="MenuBar" > <property name="geometry" > <rect> <x>0</x> <y>0</y> - <width>750</width> - <height>35</height> + <width>819</width> + <height>32</height> </rect> </property> <property name="defaultUp" > @@ -665,17 +684,16 @@ handled like normal controllers.</string> <widget class="QMenu" name="fileMenu" > <property name="geometry" > <rect> - <x>0</x> - <y>0</y> - <width>155</width> - <height>213</height> + <x>434</x> + <y>167</y> + <width>146</width> + <height>166</height> </rect> </property> <property name="title" > <string>&File</string> </property> <addaction name="fileNewAction" /> - <addaction name="fileOpenAction" /> <addaction name="fileSaveAction" /> <addaction name="fileSaveAsAction" /> <addaction name="separator" /> @@ -726,6 +744,9 @@ handled like normal controllers.</string> </property> </action> <action name="fileSaveAsAction" > + <property name="icon" > + <iconset resource="../muse.qrc" >:/xpm/fileopen.png</iconset> + </property> <property name="text" > <string>Save &As...</string> </property> @@ -749,8 +770,8 @@ handled like normal controllers.</string> </action> </widget> <layoutdefault spacing="6" margin="11" /> - <pixmapfunction></pixmapfunction> - <includes/> - <resources/> + <resources> + <include location="../muse.qrc" /> + </resources> <connections/> </ui> diff --git a/muse/muse/instruments/minstrument.cpp b/muse/muse/instruments/minstrument.cpp index c6281552..dfd4a8be 100644 --- a/muse/muse/instruments/minstrument.cpp +++ b/muse/muse/instruments/minstrument.cpp @@ -80,6 +80,7 @@ static void loadIDF(QFileInfo* fi) if (e.tagName() == "MidiInstrument") { MidiInstrument* i = new MidiInstrument(); i->read(n); + i->setFilePath(fi->filePath()); midiInstruments.push_back(i); } } @@ -173,6 +174,8 @@ void MidiInstrument::init() // MidiController* prog = new MidiController("Program", CTRL_PROGRAM, 0, 0x7fffff, 0); _controller->push_back(prog); + _dirty = false; + _readonly = false; } MidiInstrument::MidiInstrument() diff --git a/muse/muse/instruments/minstrument.h b/muse/muse/instruments/minstrument.h index 64f86393..f8e7f99b 100644 --- a/muse/muse/instruments/minstrument.h +++ b/muse/muse/instruments/minstrument.h @@ -73,6 +73,8 @@ class MidiInstrument { std::vector<PatchGroup> pg; MidiControllerList* _controller; std::vector<SysEx> sysex; + bool _dirty; + bool _readonly; void init(); @@ -82,17 +84,24 @@ class MidiInstrument { EventList* _midiState; char* _initScript; QString _name; + QString _filePath; public: MidiInstrument(); virtual ~MidiInstrument(); MidiInstrument(const QString& txt); - const QString& iname() const { return _name; } - void setIName(const QString& txt) { _name = txt; } - - EventList* midiInit() const { return _midiInit; } - EventList* midiReset() const { return _midiReset; } - EventList* midiState() const { return _midiState; } + const QString& iname() const { return _name; } + void setIName(const QString& txt) { _name = txt; } + QString filePath() const { return _filePath; } + void setFilePath(const QString& s) { _filePath = s; } + bool dirty() const { return _dirty; } + void setDirty(bool v) { _dirty = v; } + bool readonly() const { return _readonly; } + void setReadonly(bool v) { _readonly = v; } + + EventList* midiInit() const { return _midiInit; } + EventList* midiReset() const { return _midiReset; } + EventList* midiState() const { return _midiState; } const char* initScript() const { return _initScript; } MidiControllerList* controller() const { return _controller; } diff --git a/muse/muse/midictrl.cpp b/muse/muse/midictrl.cpp index fc6fd665..fff81bf5 100644 --- a/muse/muse/midictrl.cpp +++ b/muse/muse/midictrl.cpp @@ -206,23 +206,23 @@ MidiController::MidiController(const QString& s, int n, int min, int max, int in MidiController::ControllerType midiControllerType(int num) { - if (num < 0x10000) - return MidiController::Controller7; - if (num < 0x20000) - return MidiController::Controller14; - if (num < 0x30000) - return MidiController::RPN; - if (num < 0x40000) - return MidiController::NRPN; if (num == CTRL_PITCH) return MidiController::Pitch; if (num == CTRL_PROGRAM) return MidiController::Program; if (num == CTRL_VELOCITY || num == CTRL_SVELOCITY) return MidiController::Velo; - if (num < 0x60000) + if (num < CTRL_14_OFFSET) + return MidiController::Controller7; + if (num < CTRL_RPN_OFFSET) + return MidiController::Controller14; + if (num < CTRL_NRPN_OFFSET) + return MidiController::RPN; + if (num < CTRL_RPN14_OFFSET) + return MidiController::NRPN; + if (num < CTRL_NRPN14_OFFSET) return MidiController::RPN14; - if (num < 0x70000) + if (num < CTRL_NONE_OFFSET) return MidiController::NRPN14; return MidiController::Controller7; } @@ -321,3 +321,12 @@ void MidiController::read(QDomNode node) return; } +//--------------------------------------------------------- +// type +//--------------------------------------------------------- + +MidiController::ControllerType MidiController::type() const + { + return midiControllerType(num()); + } + diff --git a/muse/muse/midictrl.h b/muse/muse/midictrl.h index f728d58f..895695e0 100644 --- a/muse/muse/midictrl.h +++ b/muse/muse/midictrl.h @@ -125,12 +125,13 @@ class MidiController { void setNum(int v) { _num = v; } void write(Xml& xml) const; void read(QDomNode); - int minVal() const { return _minVal; } - int maxVal() const { return _maxVal; } + int minVal() const { return _minVal; } + int maxVal() const { return _maxVal; } int initVal() const { return _initVal; } - void setInitVal(int val) { _initVal = val; } - void setMinVal(int val) { _minVal = val; } - void setMaxVal(int val) { _maxVal = val; } + void setInitVal(int val) { _initVal = val; } + void setMinVal(int val) { _minVal = val; } + void setMaxVal(int val) { _maxVal = val; } + ControllerType type() const; }; //--------------------------------------------------------- @@ -151,8 +152,8 @@ typedef MidiControllerList MidiControllerList; extern MidiControllerList defaultMidiController; extern void initMidiController(); -extern MidiController::ControllerType midiControllerType(int num); +extern MidiController::ControllerType midiControllerType(int num); extern void configMidiController(); extern const QString& int2ctrlType(int n); extern MidiController::ControllerType ctrlType2Int(const QString& s); diff --git a/muse/muse/muse.cpp b/muse/muse/muse.cpp index cbc802e9..4471ce5b 100644 --- a/muse/muse/muse.cpp +++ b/muse/muse/muse.cpp @@ -2974,6 +2974,34 @@ int main(int argc, char* argv[]) } } + // check for instruments directory: + + pd.setPath(QDir::homePath() + "/MusE/instruments"); + if (!pd.exists()) { + // ask user to create a new instruments directory + QString title(QT_TR_NOOP("MusE: create instruments directory")); + + QString s; + s = "The MusE instruments directory\n%1\ndoes not exists"; + s = s.arg(pd.path()); + + int rv = QMessageBox::question(0, + title, + s, + "Create", + "Abort", + QString(), + 0, 1); + if (rv == 0) { + if (!pd.mkpath(pd.path())) { + // TODO: tell user why this has happened + QMessageBox::critical(0, + title, + "Creating instruments directory failed"); + } + } + } + QString path; // project path relativ to config.projectPath if (argc >= 2) path = argv[optind]; // start with first name on command line diff --git a/muse/muse/song.cpp b/muse/muse/song.cpp index 1ad7fde7..17d03fe3 100644 --- a/muse/muse/song.cpp +++ b/muse/muse/song.cpp @@ -1527,4 +1527,3 @@ void Song::routeChanged(QAction* a) audio->msgRoute(a->isChecked(), a->data().value<Route>()); } - diff --git a/muse/muse/synth.cpp b/muse/muse/synth.cpp index fae15e2f..7c6de9f1 100644 --- a/muse/muse/synth.cpp +++ b/muse/muse/synth.cpp @@ -187,6 +187,7 @@ SynthI::SynthI() _sif = 0; // setVolume(1.0); // setPan(0.0); + setReadonly(true); // midi instrument cannot be edited } //--------------------------------------------------------- |