summaryrefslogtreecommitdiff
path: root/muse2
diff options
context:
space:
mode:
Diffstat (limited to 'muse2')
-rw-r--r--muse2/muse/helper.cpp2
-rw-r--r--muse2/muse/instruments/editinstrument.cpp399
-rw-r--r--muse2/muse/instruments/editinstrument.h27
-rw-r--r--muse2/muse/instruments/editinstrumentbase.ui592
-rw-r--r--muse2/muse/instruments/minstrument.cpp147
-rw-r--r--muse2/muse/instruments/minstrument.h18
-rw-r--r--muse2/muse/midiedit/dlist.cpp76
-rw-r--r--muse2/muse/midiedit/dlist.h5
8 files changed, 1200 insertions, 66 deletions
diff --git a/muse2/muse/helper.cpp b/muse2/muse/helper.cpp
index 7d07a6ce..ce96d6fe 100644
--- a/muse2/muse/helper.cpp
+++ b/muse2/muse/helper.cpp
@@ -250,7 +250,7 @@ void write_new_style_drummap(int level, Xml& xml, const char* tagname,
// channel and port are ignored as well, as they're not used
// in new-style-drum-mode
- xml.tag(level--, "/entry");
+ xml.tag(--level, "/entry");
}
}
diff --git a/muse2/muse/instruments/editinstrument.cpp b/muse2/muse/instruments/editinstrument.cpp
index b90b872e..8a8b4be0 100644
--- a/muse2/muse/instruments/editinstrument.cpp
+++ b/muse2/muse/instruments/editinstrument.cpp
@@ -32,6 +32,9 @@
#include <QMessageBox>
#include <QLineEdit>
#include <QWhatsThis>
+#include <QStringListModel>
+#include <QScrollBar>
+#include <list>
#include "editinstrument.h"
#include "minstrument.h"
@@ -42,10 +45,15 @@
#include "gconfig.h"
#include "icons.h"
+#include "dlist.h"
+#include "drummap.h"
+#include "header.h"
+#include "drumedit.h" // FINDMICHJETZT only needed for COL_FOO. fix that!
+
namespace MusEGui {
enum {
- COL_NAME = 0, COL_TYPE,
+ COL_CNAME = 0, COL_TYPE,
COL_HNUM, COL_LNUM, COL_MIN, COL_MAX, COL_DEF
};
@@ -72,10 +80,10 @@ EditInstrument::EditInstrument(QWidget* parent, Qt::WFlags fl)
// populate instrument list
// Populate common controller list.
for(int i = 0; i < 128; ++i)
- {
- QListWidgetItem *lci = new QListWidgetItem(MusECore::midiCtrlName(i));
- listController->addItem(lci);
- }
+ {
+ QListWidgetItem *lci = new QListWidgetItem(MusECore::midiCtrlName(i));
+ listController->addItem(lci);
+ }
oldMidiInstrument = 0;
oldPatchItem = 0;
for (MusECore::iMidiInstrument i = MusECore::midiInstruments.begin(); i != MusECore::midiInstruments.end(); ++i) {
@@ -105,8 +113,66 @@ EditInstrument::EditInstrument(QWidget* parent, Qt::WFlags fl)
// workingInstrument.assign( *wip );
+ dlist_header = new Header(dlistContainer, "header");
+ dlist_header->setFixedHeight(31);
+ dlist_header->setColumnLabel(tr("Name"), COL_NAME, 120);
+ dlist_header->setColumnLabel(tr("Vol"), COL_VOLUME);
+ dlist_header->setColumnLabel(tr("Quant"), COL_QUANT, 30);
+ dlist_header->setColumnLabel(tr("E-Note"), COL_INPUTTRIGGER, 50);
+ dlist_header->setColumnLabel(tr("Len"), COL_NOTELENGTH);
+ dlist_header->setColumnLabel(tr("A-Note"), COL_NOTE, 50);
+ dlist_header->setColumnLabel(tr("LV1"), COL_LEVEL1);
+ dlist_header->setColumnLabel(tr("LV2"), COL_LEVEL2);
+ dlist_header->setColumnLabel(tr("LV3"), COL_LEVEL3);
+ dlist_header->setColumnLabel(tr("LV4"), COL_LEVEL4);
+ dlist_header->hideSection(COL_OUTPORT);
+ dlist_header->hideSection(COL_OUTCHANNEL);
+ dlist_header->hideSection(COL_HIDE);
+ dlist_header->hideSection(COL_MUTE);
+ dlist_header->hide();
+
+
+ connect(patchFromBox, SIGNAL(valueChanged(int)), this, SLOT(patchCollectionSpinboxChanged(int)));
+ connect(patchToBox, SIGNAL(valueChanged(int)), this, SLOT(patchCollectionSpinboxChanged(int)));
+ connect(lbankFromBox, SIGNAL(valueChanged(int)), this, SLOT(patchCollectionSpinboxChanged(int)));
+ connect(lbankToBox, SIGNAL(valueChanged(int)), this, SLOT(patchCollectionSpinboxChanged(int)));
+ connect(hbankFromBox, SIGNAL(valueChanged(int)), this, SLOT(patchCollectionSpinboxChanged(int)));
+ connect(hbankToBox, SIGNAL(valueChanged(int)), this, SLOT(patchCollectionSpinboxChanged(int)));
+ connect(patchCheckbox, SIGNAL(toggled(bool)), this, SLOT(patchCollectionCheckboxChanged(bool)));
+ connect(lbankCheckbox, SIGNAL(toggled(bool)), this, SLOT(patchCollectionCheckboxChanged(bool)));
+ connect(hbankCheckbox, SIGNAL(toggled(bool)), this, SLOT(patchCollectionCheckboxChanged(bool)));
+
+ connect(addCollBtn, SIGNAL(clicked()), this, SLOT(addPatchCollection()));
+ connect(rmCollBtn, SIGNAL(clicked()), this, SLOT(delPatchCollection()));
+ connect(copyCollBtn, SIGNAL(clicked()), this, SLOT(copyPatchCollection()));
+ connect(collUpBtn, SIGNAL(clicked()), this, SLOT(patchCollectionUp()));
+ connect(collDownBtn, SIGNAL(clicked()), this, SLOT(patchCollectionDown()));
+
+ connect(patchCollections, SIGNAL(activated(const QModelIndex&)), this, SLOT(patchActivated(const QModelIndex&)));
+ connect(patchCollections, SIGNAL(clicked (const QModelIndex&)), this, SLOT(patchActivated(const QModelIndex&)));
+
+ patch_coll_model=new QStringListModel();
+ patchCollections->setModel(patch_coll_model);
+ patchCollections->setEditTriggers(QAbstractItemView::NoEditTriggers);
+
connect(instrumentList, SIGNAL(itemSelectionChanged()), SLOT(instrumentChanged()));
connect(patchView, SIGNAL(itemSelectionChanged()), SLOT(patchChanged()));
+
+ dlist_vscroll = new QScrollBar(Qt::Vertical, this);
+ dlist_vscroll->setMaximum(128*TH);
+ dlist_vscroll->hide();
+
+ dlist_grid = new QGridLayout(dlistContainer);
+ dlist_grid->setContentsMargins(0, 0, 0, 0);
+ dlist_grid->setSpacing(0);
+ dlist_grid->setRowStretch(1, 100);
+ dlist_grid->setColumnStretch(0, 100);
+ dlist_grid->addWidget(dlist_header, 0, 0);
+ dlist_grid->addWidget(dlist_vscroll, 1,1);
+
+ dlist=NULL;
+
+
//instrumentChanged();
changeInstrument();
@@ -151,6 +217,306 @@ EditInstrument::EditInstrument(QWidget* parent, Qt::WFlags fl)
//connect(newSysex, SIGNAL(clicked()), SLOT(newSysexClicked()));
}
+
+void EditInstrument::patchCollectionSpinboxChanged(int)
+{
+ if (patchFromBox->value() > patchToBox->value())
+ patchToBox->setValue(patchFromBox->value());
+
+ if (lbankFromBox->value() > lbankToBox->value())
+ lbankToBox->setValue(lbankFromBox->value());
+
+ if (hbankFromBox->value() > hbankToBox->value())
+ hbankToBox->setValue(hbankFromBox->value());
+
+ storePatchCollection();
+}
+
+void EditInstrument::patchCollectionCheckboxChanged(bool)
+{
+ storePatchCollection();
+}
+
+void EditInstrument::storePatchCollection()
+{
+ using MusECore::patch_drummap_mapping_t;
+
+ int idx=patchCollections->currentIndex().row();
+ std::list<patch_drummap_mapping_t>* pdm = workingInstrument.get_patch_drummap_mapping();
+ if (idx>=0 && (unsigned)idx<pdm->size())
+ {
+ std::list<patch_drummap_mapping_t>::iterator it=pdm->begin();
+ advance(it,idx);
+
+ if (patchCheckbox->isChecked())
+ {
+ it->affected_patches.first_program=patchFromBox->value()-1;
+ it->affected_patches.last_program=patchToBox->value()-1;
+ }
+ else
+ {
+ it->affected_patches.first_program=0;
+ it->affected_patches.last_program=127;
+ }
+
+ if (lbankCheckbox->isChecked())
+ {
+ it->affected_patches.first_lbank=lbankFromBox->value()-1;
+ it->affected_patches.last_lbank=lbankToBox->value()-1;
+ }
+ else
+ {
+ it->affected_patches.first_lbank=0;
+ it->affected_patches.last_lbank=127;
+ }
+
+ if (hbankCheckbox->isChecked())
+ {
+ it->affected_patches.first_hbank=hbankFromBox->value()-1;
+ it->affected_patches.last_hbank=hbankToBox->value()-1;
+ }
+ else
+ {
+ it->affected_patches.first_hbank=0;
+ it->affected_patches.last_hbank=127;
+ }
+
+ workingInstrument.setDirty(true);
+ repopulatePatchCollections();
+ }
+}
+
+void EditInstrument::fetchPatchCollection()
+{
+ using MusECore::patch_drummap_mapping_t;
+
+ int idx=patchCollections->currentIndex().row();
+ std::list<patch_drummap_mapping_t>* pdm = workingInstrument.get_patch_drummap_mapping();
+ if (idx>=0 && (unsigned)idx<pdm->size())
+ {
+ std::list<patch_drummap_mapping_t>::iterator it=pdm->begin();
+ advance(it,idx);
+
+ patchFromBox->blockSignals(true);
+ patchToBox->blockSignals(true);
+ lbankFromBox->blockSignals(true);
+ lbankToBox->blockSignals(true);
+ hbankFromBox->blockSignals(true);
+ hbankToBox->blockSignals(true);
+
+ patchFromBox->setValue(it->affected_patches.first_program+1);
+ patchToBox->setValue(it->affected_patches.last_program+1);
+
+ lbankFromBox->setValue(it->affected_patches.first_lbank+1);
+ lbankToBox->setValue(it->affected_patches.last_lbank+1);
+
+ hbankFromBox->setValue(it->affected_patches.first_hbank+1);
+ hbankToBox->setValue(it->affected_patches.last_hbank+1);
+
+ patchFromBox->blockSignals(false);
+ patchToBox->blockSignals(false);
+ lbankFromBox->blockSignals(false);
+ lbankToBox->blockSignals(false);
+ hbankFromBox->blockSignals(false);
+ hbankToBox->blockSignals(false);
+
+
+ patchCheckbox->setChecked(it->affected_patches.first_program>0 || it->affected_patches.last_program < 127);
+ lbankCheckbox->setChecked(it->affected_patches.first_lbank>0 || it->affected_patches.last_lbank < 127);
+ hbankCheckbox->setChecked(it->affected_patches.first_hbank>0 || it->affected_patches.last_hbank < 127);
+ }
+}
+
+void EditInstrument::patchActivated(const QModelIndex& idx)
+{
+ using MusECore::patch_drummap_mapping_t;
+
+ if (idx.row()>=0)
+ {
+ using MusECore::DrumMap;
+
+ std::list<patch_drummap_mapping_t>* tmp = workingInstrument.get_patch_drummap_mapping();
+ std::list<patch_drummap_mapping_t>::iterator it=tmp->begin();
+ if ((unsigned)idx.row()>=tmp->size())
+ printf("THIS SHOULD NEVER HAPPEN: idx.row()>=tmp->size() in EditInstrument::patchActivated()\n");
+
+ advance(it, idx.row());
+ DrumMap* dm=it->drummap;
+
+
+ if (dlist)
+ {
+ dlist->hide();
+ delete dlist;
+ dlist=NULL;
+ }
+
+ dlist=new DList(dlist_header,dlistContainer,1,dm);
+
+ dlist->setYPos(dlist_vscroll->value());
+
+ connect(dlist_vscroll, SIGNAL(valueChanged(int)), dlist, SLOT(setYPos(int)));
+ dlist_grid->addWidget(dlist, 1, 0);
+
+
+ dlist_header->show();
+ dlist->show();
+ dlist_vscroll->show();
+
+ collUpBtn->setEnabled(idx.row()>0);
+ collDownBtn->setEnabled(idx.row()<patch_coll_model->rowCount()-1);
+ rmCollBtn->setEnabled(true);
+ copyCollBtn->setEnabled(true);
+ patchCollectionContainer->setEnabled(true);
+
+ fetchPatchCollection();
+ }
+}
+
+void EditInstrument::addPatchCollection()
+{
+ using MusECore::patch_drummap_mapping_t;
+
+ int idx=patchCollections->currentIndex().row();
+
+ std::list<patch_drummap_mapping_t>* tmp = workingInstrument.get_patch_drummap_mapping();
+ std::list<patch_drummap_mapping_t>::iterator it=tmp->begin();
+ advance(it,idx+1);
+ tmp->insert(it,patch_drummap_mapping_t());
+
+ repopulatePatchCollections();
+ patchCollections->setCurrentIndex(patch_coll_model->index(idx+1));
+ patchActivated(patchCollections->currentIndex());
+
+ workingInstrument.setDirty(true);
+}
+
+void EditInstrument::delPatchCollection()
+{
+ using MusECore::patch_drummap_mapping_t;
+
+ int idx=patchCollections->currentIndex().row();
+ if (idx>=0)
+ {
+ if (dlist)
+ {
+ dlist->hide();
+ delete dlist;
+ dlist=NULL;
+ }
+
+ dlist_header->hide();
+ dlist_vscroll->hide();
+
+ rmCollBtn->setEnabled(false);
+ copyCollBtn->setEnabled(false);
+ patchCollectionContainer->setEnabled(false);
+ collUpBtn->setEnabled(false);
+ collDownBtn->setEnabled(false);
+
+ std::list<patch_drummap_mapping_t>* tmp = workingInstrument.get_patch_drummap_mapping();
+ std::list<patch_drummap_mapping_t>::iterator it=tmp->begin();
+ advance(it,idx);
+ tmp->erase(it);
+
+ repopulatePatchCollections();
+
+ patchActivated(patchCollections->currentIndex());
+ workingInstrument.setDirty(true);
+ }
+}
+
+void EditInstrument::copyPatchCollection()
+{
+ using MusECore::patch_drummap_mapping_t;
+
+ int idx=patchCollections->currentIndex().row();
+
+ std::list<patch_drummap_mapping_t>* tmp = workingInstrument.get_patch_drummap_mapping();
+ std::list<patch_drummap_mapping_t>::iterator it=tmp->begin();
+ advance(it,idx);
+ patch_drummap_mapping_t tmp2(*it);
+ it++;
+ tmp->insert(it,tmp2);
+
+ patch_coll_model->insertRow(idx+1);
+ patch_coll_model->setData(patch_coll_model->index(idx+1), patch_coll_model->index(idx).data());
+ patchCollections->setCurrentIndex(patch_coll_model->index(idx+1));
+ patchActivated(patchCollections->currentIndex());
+ workingInstrument.setDirty(true);
+}
+
+void EditInstrument::patchCollectionUp()
+{
+ using MusECore::patch_drummap_mapping_t;
+
+ std::list<patch_drummap_mapping_t>* pdm = workingInstrument.get_patch_drummap_mapping();
+ int idx=patchCollections->currentIndex().row();
+
+ if (idx>=1)
+ {
+ std::list<patch_drummap_mapping_t>::iterator it=pdm->begin();
+ advance(it,idx-1);
+ std::list<patch_drummap_mapping_t>::iterator it2=it;
+ it2++;
+
+ //it2 is the element to move, it is the element to put before.
+
+ pdm->insert(it,*it2);
+ pdm->erase(it2);
+
+ repopulatePatchCollections();
+
+ patchCollections->setCurrentIndex(patch_coll_model->index(idx-1));
+ patchActivated(patchCollections->currentIndex());
+
+ workingInstrument.setDirty(true);
+ }
+}
+
+void EditInstrument::patchCollectionDown()
+{
+ using MusECore::patch_drummap_mapping_t;
+
+ std::list<patch_drummap_mapping_t>* pdm = workingInstrument.get_patch_drummap_mapping();
+ int idx=patchCollections->currentIndex().row();
+
+ if ((unsigned)idx<pdm->size()-1)
+ {
+ std::list<patch_drummap_mapping_t>::iterator it=pdm->begin();
+ advance(it,idx);
+ std::list<patch_drummap_mapping_t>::iterator it2=it;
+ it2++; it2++;
+
+ //it is the element to move, it2 is the element to put before (might be end())
+
+ pdm->insert(it2,*it);
+ pdm->erase(it);
+
+ repopulatePatchCollections();
+
+ patchCollections->setCurrentIndex(patch_coll_model->index(idx+1));
+ patchActivated(patchCollections->currentIndex());
+
+ workingInstrument.setDirty(true);
+ }
+}
+
+void EditInstrument::repopulatePatchCollections()
+{
+ using MusECore::patch_drummap_mapping_t;
+
+ int idx=patchCollections->currentIndex().row();
+ QStringList strlist;
+
+ std::list<patch_drummap_mapping_t>* pdm = workingInstrument.get_patch_drummap_mapping();
+ for (std::list<patch_drummap_mapping_t>::iterator it=pdm->begin(); it!=pdm->end(); it++)
+ strlist << it->affected_patches.to_string();
+
+ patch_coll_model->setStringList(strlist);
+ patchCollections->setCurrentIndex(patch_coll_model->index(idx));
+}
+
//---------------------------------------------------------
// helpWhatsThis
//---------------------------------------------------------
@@ -1014,6 +1380,25 @@ void EditInstrument::changeInstrument()
*/
+
+ repopulatePatchCollections();
+ if (dlist)
+ {
+ dlist->hide();
+ delete dlist;
+ dlist=NULL;
+ }
+
+ dlist_header->hide();
+ dlist_vscroll->hide();
+
+ rmCollBtn->setEnabled(false);
+ copyCollBtn->setEnabled(false);
+ patchCollectionContainer->setEnabled(false);
+ collUpBtn->setEnabled(false);
+ collDownBtn->setEnabled(false);
+
+
}
//---------------------------------------------------------
@@ -1801,9 +2186,9 @@ void EditInstrument::ctrlNameReturn()
}
c->setName(ctrlName->text());
- item->setText(COL_NAME, ctrlName->text());
+ item->setText(COL_CNAME, ctrlName->text());
//c->setName(s);
- //item->setText(COL_NAME, s);
+ //item->setText(COL_CNAME, s);
workingInstrument.setDirty(true);
}
diff --git a/muse2/muse/instruments/editinstrument.h b/muse2/muse/instruments/editinstrument.h
index ba53aae1..ab5edf39 100644
--- a/muse2/muse/instruments/editinstrument.h
+++ b/muse2/muse/instruments/editinstrument.h
@@ -31,9 +31,14 @@
class QDialog;
class QMenu;
class QCloseEvent;
+class QGridLayout;
+class QStringListModel;
namespace MusEGui {
+class Header;
+class DList;
+
//---------------------------------------------------------
// EditInstrument
//---------------------------------------------------------
@@ -44,6 +49,15 @@ class EditInstrument : public QMainWindow, public Ui::EditInstrumentBase {
MusECore::MidiInstrument workingInstrument;
QListWidgetItem* oldMidiInstrument;
QTreeWidgetItem* oldPatchItem;
+
+ Header* dlist_header;
+ DList* dlist;
+ QScrollBar* dlist_vscroll;
+ QGridLayout* dlist_grid;
+ QStringListModel* patch_coll_model;
+
+
+
void closeEvent(QCloseEvent*);
int checkDirty(MusECore::MidiInstrument*, bool isClose = false);
bool fileSave(MusECore::MidiInstrument*, const QString&);
@@ -61,7 +75,6 @@ class EditInstrument : public QMainWindow, public Ui::EditInstrumentBase {
void setDefaultPatchControls(int);
QString getPatchName(int);
void deleteInstrument(QListWidgetItem*);
- ///QMenu* patchpopup;
private slots:
virtual void fileNew();
@@ -99,6 +112,18 @@ class EditInstrument : public QMainWindow, public Ui::EditInstrumentBase {
//void newSysexClicked();
void ctrlNullParamHChanged(int);
void ctrlNullParamLChanged(int);
+
+ void patchCollectionSpinboxChanged(int);
+ void patchCollectionCheckboxChanged(bool);
+ void patchActivated(const QModelIndex&);
+ void addPatchCollection();
+ void delPatchCollection();
+ void copyPatchCollection();
+ void patchCollectionUp();
+ void patchCollectionDown();
+ void repopulatePatchCollections();
+ void storePatchCollection();
+ void fetchPatchCollection();
public:
EditInstrument(QWidget* parent = 0, Qt::WFlags fl = Qt::Window);
diff --git a/muse2/muse/instruments/editinstrumentbase.ui b/muse2/muse/instruments/editinstrumentbase.ui
index 3337cfc0..5295abb2 100644
--- a/muse2/muse/instruments/editinstrumentbase.ui
+++ b/muse2/muse/instruments/editinstrumentbase.ui
@@ -1370,6 +1370,404 @@ Typically, set to 127/127, or an unused
</item>
</layout>
</widget>
+ <widget class="QWidget" name="drumTab">
+ <attribute name="title">
+ <string>Drummaps</string>
+ </attribute>
+ <layout class="QHBoxLayout" name="horizontalLayout_4">
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_3">
+ <item>
+ <layout class="QVBoxLayout" name="verticalLayout_2">
+ <item>
+ <widget class="QLabel" name="label">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Patch Collections:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QListView" name="patchCollections">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Expanding">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <property name="spacing">
+ <number>0</number>
+ </property>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QPushButton" name="addCollBtn">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Minimum" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>&amp;Add</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="copyCollBtn">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Minimum" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>&amp;Copy</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="rmCollBtn">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Minimum" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>&amp;Remove</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_2">
+ <item>
+ <widget class="QPushButton" name="collUpBtn">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Minimum" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>&amp;Up</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="collDownBtn">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Minimum" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>&amp;Down</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <widget class="QWidget" name="patchCollectionContainer" native="true">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <layout class="QGridLayout" name="gridLayout_">
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <item row="0" column="0">
+ <layout class="QGridLayout" name="gridLayout_2">
+ <item row="0" column="0">
+ <widget class="QCheckBox" name="patchCheckbox">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Patch:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QLabel" name="label_5">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>from</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="2">
+ <widget class="QSpinBox" name="patchFromBox">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimum">
+ <number>1</number>
+ </property>
+ <property name="maximum">
+ <number>128</number>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="3">
+ <widget class="QLabel" name="label_8">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>to</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="4">
+ <widget class="QSpinBox" name="patchToBox">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimum">
+ <number>1</number>
+ </property>
+ <property name="maximum">
+ <number>128</number>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QCheckBox" name="hbankCheckbox">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Bank Hi:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QLabel" name="label_6">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>from</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="2">
+ <widget class="QSpinBox" name="hbankFromBox">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimum">
+ <number>1</number>
+ </property>
+ <property name="maximum">
+ <number>128</number>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="3">
+ <widget class="QLabel" name="label_9">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>to</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="4">
+ <widget class="QSpinBox" name="hbankToBox">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimum">
+ <number>1</number>
+ </property>
+ <property name="maximum">
+ <number>128</number>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0">
+ <widget class="QCheckBox" name="lbankCheckbox">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Bank Lo:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1">
+ <widget class="QLabel" name="label_7">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>from</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="2">
+ <widget class="QSpinBox" name="lbankFromBox">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimum">
+ <number>1</number>
+ </property>
+ <property name="maximum">
+ <number>128</number>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="3">
+ <widget class="QLabel" name="label_10">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>to</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="4">
+ <widget class="QSpinBox" name="lbankToBox">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimum">
+ <number>1</number>
+ </property>
+ <property name="maximum">
+ <number>128</number>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <widget class="QWidget" name="dlistContainer" native="true"/>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
</widget>
</widget>
</item>
@@ -1396,7 +1794,7 @@ Typically, set to 127/127, or an unused
<x>0</x>
<y>0</y>
<width>802</width>
- <height>21</height>
+ <height>25</height>
</rect>
</property>
<property name="defaultUp">
@@ -1645,5 +2043,197 @@ Typically, set to 127/127, or an unused
</hint>
</hints>
</connection>
+ <connection>
+ <sender>patchCheckbox</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>label_5</receiver>
+ <slot>setEnabled(bool)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>214</x>
+ <y>411</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>289</x>
+ <y>412</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>patchCheckbox</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>patchFromBox</receiver>
+ <slot>setEnabled(bool)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>214</x>
+ <y>411</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>343</x>
+ <y>412</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>patchCheckbox</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>label_8</receiver>
+ <slot>setEnabled(bool)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>214</x>
+ <y>411</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>390</x>
+ <y>412</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>patchCheckbox</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>patchToBox</receiver>
+ <slot>setEnabled(bool)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>214</x>
+ <y>411</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>436</x>
+ <y>412</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>lbankCheckbox</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>lbankFromBox</receiver>
+ <slot>setEnabled(bool)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>221</x>
+ <y>469</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>343</x>
+ <y>470</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>lbankCheckbox</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>lbankToBox</receiver>
+ <slot>setEnabled(bool)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>221</x>
+ <y>469</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>436</x>
+ <y>470</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>lbankCheckbox</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>label_7</receiver>
+ <slot>setEnabled(bool)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>221</x>
+ <y>469</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>289</x>
+ <y>470</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>lbankCheckbox</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>label_10</receiver>
+ <slot>setEnabled(bool)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>221</x>
+ <y>469</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>390</x>
+ <y>470</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>hbankCheckbox</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>hbankFromBox</receiver>
+ <slot>setEnabled(bool)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>220</x>
+ <y>440</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>343</x>
+ <y>441</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>hbankCheckbox</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>hbankToBox</receiver>
+ <slot>setEnabled(bool)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>220</x>
+ <y>440</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>436</x>
+ <y>441</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>hbankCheckbox</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>label_6</receiver>
+ <slot>setEnabled(bool)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>220</x>
+ <y>440</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>289</x>
+ <y>441</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>hbankCheckbox</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>label_9</receiver>
+ <slot>setEnabled(bool)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>220</x>
+ <y>440</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>390</x>
+ <y>441</y>
+ </hint>
+ </hints>
+ </connection>
</connections>
</ui>
diff --git a/muse2/muse/instruments/minstrument.cpp b/muse2/muse/instruments/minstrument.cpp
index 3906c399..bd4b3bd4 100644
--- a/muse2/muse/instruments/minstrument.cpp
+++ b/muse2/muse/instruments/minstrument.cpp
@@ -410,17 +410,9 @@ MidiInstrument::~MidiInstrument()
if (_initScript)
delete _initScript;
- clear_delete_patch_drummap_mapping();
+ patch_drummap_mapping.clear();
}
-void MidiInstrument::clear_delete_patch_drummap_mapping()
-{
- for (std::list<patch_drummap_mapping_t>::iterator it = patch_drummap_mapping.begin();
- it!=patch_drummap_mapping.end(); it++)
- delete[] it->drummap;
-
- patch_drummap_mapping.clear();
-}
/*
@@ -529,16 +521,7 @@ MidiInstrument& MidiInstrument::assign(const MidiInstrument& ins)
_name = ins._name;
_filePath = ins._filePath;
- clear_delete_patch_drummap_mapping();
- // do a deep copy
- for (std::list<patch_drummap_mapping_t>::const_iterator it = ins.patch_drummap_mapping.begin();
- it!=ins.patch_drummap_mapping.end(); it++)
- {
- patch_drummap_mapping_t temp = *it;
- temp.drummap=new DrumMap[128];
- for (int i=0;i<128;i++)
- temp.drummap[i]=it->drummap[i];
- }
+ patch_drummap_mapping=ins.patch_drummap_mapping;
@@ -761,7 +744,7 @@ void MidiInstrument::readMidiState(Xml& xml)
void MidiInstrument::readDrummaps(Xml& xml)
{
- clear_delete_patch_drummap_mapping();
+ patch_drummap_mapping.clear();
for (;;)
{
@@ -796,7 +779,7 @@ patch_drummap_mapping_t MidiInstrument::readDrummapsEntry(Xml& xml)
{
using std::list;
- list<patch_collection_t> collection;
+ patch_collection_t collection;
DrumMap* drummap=new DrumMap[128];
for (int i=0;i<128;i++)
drummap[i]=iNewDrumMap[i];
@@ -813,7 +796,7 @@ patch_drummap_mapping_t MidiInstrument::readDrummapsEntry(Xml& xml)
case Xml::TagStart:
if (tag == "patch_collection")
- collection.push_back(readDrummapsEntryPatchCollection(xml));
+ collection=readDrummapsEntryPatchCollection(xml);
else if (tag == "drummap")
read_new_style_drummap(xml, "drummap", drummap);
else
@@ -875,6 +858,43 @@ patch_collection_t MidiInstrument::readDrummapsEntryPatchCollection(Xml& xml)
" not returning anything. expect undefined behaviour or even crashes.\n");
}
+void MidiInstrument::writeDrummaps(int level, Xml& xml) const
+{
+ xml.tag(level++, "Drummaps");
+
+ for (std::list<patch_drummap_mapping_t>::const_iterator it=patch_drummap_mapping.begin();
+ it!=patch_drummap_mapping.end(); it++)
+ {
+ xml.tag(level++, "entry");
+
+ const patch_collection_t* ap = &it->affected_patches;
+ QString tmp="<patch_collection ";
+ if (ap->first_program==ap->last_program)
+ tmp+="prog=\""+QString::number(ap->first_program)+"\" ";
+ else if (! (ap->first_program==0 && ap->last_program>=127))
+ tmp+="prog=\""+QString::number(ap->first_program)+"-"+QString::number(ap->last_program)+"\" ";
+
+ if (ap->first_lbank==ap->last_lbank)
+ tmp+="lbank=\""+QString::number(ap->first_lbank)+"\" ";
+ else if (! (ap->first_lbank==0 && ap->last_lbank>=127))
+ tmp+="lbank=\""+QString::number(ap->first_lbank)+"-"+QString::number(ap->last_lbank)+"\" ";
+
+ if (ap->first_hbank==ap->last_hbank)
+ tmp+="hbank=\""+QString::number(ap->first_hbank)+"\" ";
+ else if (! (ap->first_hbank==0 && ap->last_hbank>=127))
+ tmp+="hbank=\""+QString::number(ap->first_hbank)+"-"+QString::number(ap->last_hbank)+"\" ";
+
+ tmp+="/>\n";
+
+ xml.nput(level, tmp.toAscii().data());
+
+ write_new_style_drummap(level, xml, "drummap", it->drummap);
+
+ xml.etag(--level, "entry");
+ }
+
+ xml.etag(--level, "Drummaps");
+}
//---------------------------------------------------------
// read
@@ -1018,6 +1038,9 @@ void MidiInstrument::write(int level, Xml& xml)
//(*ic)->write(xml);
ic->second->write(level, xml);
//xml.etag("MidiInstrument");
+
+ writeDrummaps(level, xml);
+
level--;
xml.etag(level, "MidiInstrument");
//xml.etag("muse");
@@ -1136,16 +1159,13 @@ const DrumMap* MidiInstrument::drummap_for_patch(int patch) const
for (list<patch_drummap_mapping_t>::const_iterator it=patch_drummap_mapping.begin();
it!=patch_drummap_mapping.end(); it++)
{
- for (list<patch_collection_t>::const_iterator it2=it->affected_patches.begin();
- it2!=it->affected_patches.end(); it2++)
+ const patch_collection_t* ap = &it->affected_patches;
+ // if the entry matches our patch
+ if ( (program >= ap->first_program && program <= ap->last_program) &&
+ (hbank >= ap->first_hbank && hbank <= ap->last_hbank) &&
+ (lbank >= ap->first_lbank && lbank <= ap->last_lbank) )
{
- // if the entry matches our patch
- if ( (program >= it2->first_program && program <= it2->last_program) &&
- (hbank >= it2->first_hbank && hbank <= it2->last_hbank) &&
- (lbank >= it2->first_lbank && lbank <= it2->last_lbank) )
- {
- return it->drummap;
- }
+ return it->drummap;
}
}
@@ -1160,5 +1180,70 @@ patch_drummap_mapping_t::patch_drummap_mapping_t()
drummap[i]=iNewDrumMap[i];
}
+patch_drummap_mapping_t::patch_drummap_mapping_t(const patch_drummap_mapping_t& that)
+{
+ drummap=new DrumMap[128];
+ for (int i=0;i<128;i++)
+ drummap[i]=that.drummap[i];
+
+ affected_patches=that.affected_patches;
+}
+
+patch_drummap_mapping_t& patch_drummap_mapping_t::operator=(const patch_drummap_mapping_t& that)
+{
+ if (drummap)
+ delete [] drummap;
+
+ drummap=new DrumMap[128];
+ for (int i=0;i<128;i++)
+ drummap[i]=that.drummap[i];
+
+ affected_patches=that.affected_patches;
+
+ return *this;
+}
+
+patch_drummap_mapping_t::~patch_drummap_mapping_t()
+{
+ delete [] drummap;
+}
+
+QString patch_collection_t::to_string()
+{
+ QString tmp;
+
+ if (first_program==0 && last_program>=127 &&
+ first_lbank==0 && last_lbank>=127 &&
+ first_hbank==0 && last_hbank>=127)
+ tmp="default";
+ else
+ {
+ tmp+="prog: ";
+ if (first_program==last_program)
+ tmp+=QString::number(first_program+1);
+ else if (! (first_program==0 && last_program>=127))
+ tmp+=QString::number(first_program+1)+"-"+QString::number(last_program+1);
+ else
+ tmp+="*";
+
+ tmp+=" bank=";
+ if (first_lbank==last_lbank)
+ tmp+=QString::number(first_lbank+1);
+ else if (! (first_lbank==0 && last_lbank>=127))
+ tmp+=QString::number(first_lbank+1)+"-"+QString::number(last_lbank+1);
+ else
+ tmp+="*";
+
+ tmp+="/";
+ if (first_hbank==last_hbank)
+ tmp+=QString::number(first_hbank+1);
+ else if (! (first_hbank==0 && last_hbank>=127))
+ tmp+=QString::number(first_hbank+1)+"-"+QString::number(last_hbank+1);
+ else
+ tmp+="*";
+
+ }
+ return tmp;
+}
} // namespace MusECore
diff --git a/muse2/muse/instruments/minstrument.h b/muse2/muse/instruments/minstrument.h
index 9a65598b..f793a7b6 100644
--- a/muse2/muse/instruments/minstrument.h
+++ b/muse2/muse/instruments/minstrument.h
@@ -27,8 +27,7 @@
#include "globaldefs.h"
#include <list>
#include <vector>
-
-class QString;
+#include <QString>
namespace MusEGui {
class PopupMenu;
@@ -101,21 +100,26 @@ struct patch_collection_t
first_hbank=h1;
last_hbank=h2;
}
-
+
+ QString to_string();
};
struct patch_drummap_mapping_t
{
- std::list<patch_collection_t> affected_patches;
+ patch_collection_t affected_patches;
DrumMap* drummap;
- patch_drummap_mapping_t(const std::list<patch_collection_t>& a, DrumMap* d)
+ patch_drummap_mapping_t(const patch_collection_t& a, DrumMap* d)
{
affected_patches=a;
drummap=d;
}
+ patch_drummap_mapping_t(const patch_drummap_mapping_t& that);
patch_drummap_mapping_t();
+ ~patch_drummap_mapping_t();
+
+ patch_drummap_mapping_t& operator=(const patch_drummap_mapping_t& that);
};
//---------------------------------------------------------
@@ -143,8 +147,7 @@ class MidiInstrument {
QString _name;
QString _filePath;
- void clear_delete_patch_drummap_mapping();
-
+ void writeDrummaps(int level, Xml& xml) const;
void readDrummaps(Xml& xml);
patch_drummap_mapping_t readDrummapsEntry(Xml& xml);
patch_collection_t readDrummapsEntryPatchCollection(Xml& xml);
@@ -195,6 +198,7 @@ class MidiInstrument {
void write(int level, Xml&);
PatchGroupList* groups() { return &pg; }
+ std::list<patch_drummap_mapping_t>* get_patch_drummap_mapping() { return &patch_drummap_mapping; }
};
//---------------------------------------------------------
diff --git a/muse2/muse/midiedit/dlist.cpp b/muse2/muse/midiedit/dlist.cpp
index fc6384f7..ad0d05dd 100644
--- a/muse2/muse/midiedit/dlist.cpp
+++ b/muse2/muse/midiedit/dlist.cpp
@@ -395,6 +395,8 @@ void DList::viewMousePressEvent(QMouseEvent* ev)
}
else
{
+ if (dcanvas)
+ {
//Check if there is any other drumMap with the same inmap value (there should be one (and only one):-)
//If so, switch the inmap between the instruments
for (QSet<MusECore::Track*>::iterator it = dcanvas->get_instrument_map()[instrument].tracks.begin(); it!=dcanvas->get_instrument_map()[instrument].tracks.end(); it++)
@@ -408,6 +410,16 @@ void DList::viewMousePressEvent(QMouseEvent* ev)
// does this for us.
// updating ourDrumMap is unneccessary because the song->update(SC_DRUMMAP)
// does this for us.
+ }
+ else
+ {
+ for (int i=0;i<128;i++)
+ if (ourDrumMap[i].enote==val)
+ {
+ ourDrumMap[i].enote=dm->enote;
+ break;
+ }
+ }
}
dm->enote = val;
@@ -510,14 +522,14 @@ void DList::viewMousePressEvent(QMouseEvent* ev)
if (velo > 127 ) velo = 127;
emit keyPressed(instrument, velo); //Mapping done on other side, send index
}
- else if (button == Qt::MidButton) // hide that instrument
+ else if (button == Qt::MidButton && dcanvas) // hide that instrument
{
QSet<MusECore::Track*>* group = &dcanvas->get_instrument_map()[instrument].tracks;
int pitch = dcanvas->get_instrument_map()[instrument].pitch;
for (QSet<MusECore::Track*>::iterator track=group->begin(); track!=group->end(); track++)
dynamic_cast<MusECore::MidiTrack*>(*track)->drummap_hidden()[pitch] = true;
}
- else if (button == Qt::RightButton)
+ else if (button == Qt::RightButton && dcanvas)
{
bool hidden=false;
bool shown=false;
@@ -555,7 +567,7 @@ void DList::viewMousePressEvent(QMouseEvent* ev)
break;
}
- if (!old_style_drummap_mode && dm_old != *dm) //something changed and we're in new style mode?
+ if (!old_style_drummap_mode && dm_old != *dm && dcanvas) //something changed and we're in new style mode?
dcanvas->propagate_drummap_change(instrument, (dm_old.enote != dm->enote));
MusEGlobal::song->update(SC_DRUMMAP);
@@ -834,7 +846,7 @@ void DList::returnPressed()
break;
}
- if (editEntryOld != *editEntry)
+ if (editEntryOld != *editEntry && dcanvas)
dcanvas->propagate_drummap_change(editEntry-ourDrumMap, false);
selectedColumn = -1;
@@ -895,6 +907,8 @@ void DList::pitchEdited()
}
else
{
+ if (dcanvas)
+ {
//Check if there is any other drumMap with the same inmap value (there should be one (and only one):-)
//If so, switch the inmap between the instruments
for (QSet<MusECore::Track*>::iterator it = dcanvas->get_instrument_map()[instrument].tracks.begin(); it!=dcanvas->get_instrument_map()[instrument].tracks.end(); it++)
@@ -908,6 +922,16 @@ void DList::pitchEdited()
// does this for us.
// updating ourDrumMap is unneccessary because the song->update(SC_DRUMMAP)
// does this for us.
+ }
+ else
+ {
+ for (int i=0;i<128;i++)
+ if (ourDrumMap[i].enote==val)
+ {
+ ourDrumMap[i].enote=editEntry->enote;
+ break;
+ }
+ }
}
editEntry->enote = val;
break;
@@ -917,7 +941,7 @@ void DList::pitchEdited()
break;
}
- if (editEntryOld != *editEntry)
+ if (editEntryOld != *editEntry && dcanvas)
dcanvas->propagate_drummap_change(editEntry-ourDrumMap, (editEntryOld.enote!=editEntry->enote));
selectedColumn = -1;
@@ -960,19 +984,12 @@ void DList::songChanged(int flags)
// DList
//---------------------------------------------------------
-DList::DList(QHeaderView* h, QWidget* parent, int ymag, DrumCanvas* dcanvas_, bool oldstyle)
- : MusEGui::View(parent, 1, ymag)
- {
+void DList::init(QHeaderView* h, QWidget* parent)
+{
setBg(Qt::white);
-
- dcanvas=dcanvas_;
- ourDrumMap=dcanvas->getOurDrumMap();
- ourDrumMapSize=dcanvas->getOurDrumMapSize();
- old_style_drummap_mode=oldstyle;
- connect(dcanvas, SIGNAL(ourDrumMapChanged(bool)), SLOT(ourDrumMapChanged(bool)));
-
- if (!h){
- h = new QHeaderView(Qt::Horizontal, parent);}
+ if (!h)
+ h = new QHeaderView(Qt::Horizontal, parent);
+
header = h;
//ORCAN- CHECK if really needed: header->setTracking(true);
connect(header, SIGNAL(sectionResized(int,int,int)),
@@ -983,6 +1000,7 @@ DList::DList(QHeaderView* h, QWidget* parent, int ymag, DrumCanvas* dcanvas_, bo
editor = 0;
pitch_editor = 0;
editEntry = 0;
+
if (ourDrumMapSize!=0)
{
// always select a drum instrument
@@ -994,6 +1012,30 @@ DList::DList(QHeaderView* h, QWidget* parent, int ymag, DrumCanvas* dcanvas_, bo
}
selectedColumn = -1;
+
+}
+
+DList::DList(QHeaderView* h, QWidget* parent, int ymag, DrumCanvas* dcanvas_, bool oldstyle)
+ : MusEGui::View(parent, 1, ymag)
+ {
+ dcanvas=dcanvas_;
+ ourDrumMap=dcanvas->getOurDrumMap();
+ ourDrumMapSize=dcanvas->getOurDrumMapSize();
+ old_style_drummap_mode=oldstyle;
+ connect(dcanvas, SIGNAL(ourDrumMapChanged(bool)), SLOT(ourDrumMapChanged(bool)));
+
+ init(h, parent);
+ }
+
+DList::DList(QHeaderView* h, QWidget* parent, int ymag, MusECore::DrumMap* dm, int dmSize)
+ : MusEGui::View(parent, 1, ymag)
+ {
+ dcanvas=NULL;
+ ourDrumMap=dm;
+ ourDrumMapSize=dmSize;
+ old_style_drummap_mode=false;
+
+ init(h, parent);
}
//---------------------------------------------------------
diff --git a/muse2/muse/midiedit/dlist.h b/muse2/muse/midiedit/dlist.h
index 35a67023..cfa10c96 100644
--- a/muse2/muse/midiedit/dlist.h
+++ b/muse2/muse/midiedit/dlist.h
@@ -120,6 +120,8 @@ class DList : public View {
int x2col(int x) const;
void devicesPopupMenu(MusECore::DrumMap* t, int x, int y, bool changeAll);
+ void init(QHeaderView*, QWidget*);
+
//void setCurDrumInstrument(int n);
private slots:
@@ -144,7 +146,8 @@ class DList : public View {
void lineEdit(int line, int section);
void pitchEdit(int line, int section);
void setCurDrumInstrument(int n);
- DList(QHeaderView*, QWidget* parent, int ymag, MusEGui::DrumCanvas* dcanvas, bool oldstyle);
+ DList(QHeaderView*, QWidget* parent, int ymag, DrumCanvas* dcanvas, bool oldstyle);
+ DList(QHeaderView* h, QWidget* parent, int ymag, MusECore::DrumMap* dm, int dmSize=128);
~DList();
int getSelectedInstrument();