summaryrefslogtreecommitdiff
path: root/muse2/muse/liste
diff options
context:
space:
mode:
authorTim E. Real <termtech@rogers.com>2012-11-03 12:05:56 +0000
committerTim E. Real <termtech@rogers.com>2012-11-03 12:05:56 +0000
commit31f618e5461553bd7836677f944acfa233e5ae3c (patch)
tree9ce5c671ed1a089bb2cd19692db5a9c45951b237 /muse2/muse/liste
parentb45ce65ca39817a0678f2172410b71433f79f736 (diff)
Improved: Instrument Editor, fFixed MANY bugs. Should be SOLID now.
Improved: Midi controller graph 'Ctrl' popup menus. Improved: Aftertouch and PolyAftertouch (channel/key pressure) are true MusE controllers now. TODO: Still W.I.P. See ChangeLog
Diffstat (limited to 'muse2/muse/liste')
-rw-r--r--muse2/muse/liste/editctrlbase.ui124
-rw-r--r--muse2/muse/liste/editevent.cpp148
2 files changed, 167 insertions, 105 deletions
diff --git a/muse2/muse/liste/editctrlbase.ui b/muse2/muse/liste/editctrlbase.ui
index 7b4d68ec..036b4525 100644
--- a/muse2/muse/liste/editctrlbase.ui
+++ b/muse2/muse/liste/editctrlbase.ui
@@ -500,23 +500,34 @@
</disabled>
</palette>
</property>
+ <property name="currentIndex">
+ <number>0</number>
+ </property>
<widget class="QWidget" name="WStackPage">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>140</width>
- <height>349</height>
- </rect>
- </property>
- <layout class="QGridLayout">
- <item row="3" column="0" colspan="2">
- <widget class="QSlider" name="valSlider">
- <property name="maximum">
- <number>127</number>
- </property>
+ <layout class="QGridLayout" name="gridLayout1">
+ <item row="0" column="1">
+ <spacer name="spacer2">
<property name="orientation">
- <enum>Qt::Horizontal</enum>
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Expanding</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="textLabel2">
+ <property name="text">
+ <string>Controller</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
</property>
</widget>
</item>
@@ -534,59 +545,52 @@
</widget>
</item>
<item row="2" column="0">
- <widget class="QLabel" name="textLabel4">
+ <widget class="QLabel" name="textLabel2_3">
<property name="text">
- <string>Value</string>
+ <string>Note</string>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
- <item row="1" column="0">
- <widget class="QLabel" name="textLabel2">
+ <item row="2" column="1">
+ <widget class="QSpinBox" name="noteSpinBox">
+ <property name="maximum">
+ <number>127</number>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="0">
+ <widget class="QLabel" name="textLabel4">
<property name="text">
- <string>Controller</string>
+ <string>Value</string>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
- <item row="2" column="1">
+ <item row="3" column="1">
<widget class="QSpinBox" name="valSpinBox">
<property name="maximum">
<number>127</number>
</property>
</widget>
</item>
- <item row="0" column="1">
- <spacer name="spacer2">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeType">
- <enum>QSizePolicy::Expanding</enum>
+ <item row="4" column="0" colspan="2">
+ <widget class="QSlider" name="valSlider">
+ <property name="maximum">
+ <number>127</number>
</property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>20</width>
- <height>40</height>
- </size>
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
</property>
- </spacer>
+ </widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="WStackPage2">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>100</width>
- <height>30</height>
- </rect>
- </property>
<layout class="QGridLayout">
<item row="2" column="0">
<widget class="QLabel" name="textLabel2_2">
@@ -759,8 +763,7 @@
</widget>
</item>
<item row="1" column="0" colspan="2">
- <widget class="QListWidget" name="ctrlList">
- </widget>
+ <widget class="QListWidget" name="ctrlList"/>
</item>
<item row="2" column="1">
<spacer name="spacer3">
@@ -802,44 +805,11 @@
<class>Awl::PosEdit</class>
<extends>QWidget</extends>
<header>awl/posedit.h</header>
- <container>0</container>
</customwidget>
</customwidgets>
<resources/>
<connections>
<connection>
- <sender>buttonOk</sender>
- <signal>clicked()</signal>
- <receiver>MyDialog</receiver>
- <slot>accept()</slot>
- <hints>
- <hint type="sourcelabel">
- <x>20</x>
- <y>20</y>
- </hint>
- <hint type="destinationlabel">
- <x>20</x>
- <y>20</y>
- </hint>
- </hints>
- </connection>
- <connection>
- <sender>buttonCancel</sender>
- <signal>clicked()</signal>
- <receiver>MyDialog</receiver>
- <slot>reject()</slot>
- <hints>
- <hint type="sourcelabel">
- <x>20</x>
- <y>20</y>
- </hint>
- <hint type="destinationlabel">
- <x>20</x>
- <y>20</y>
- </hint>
- </hints>
- </connection>
- <connection>
<sender>valSlider</sender>
<signal>valueChanged(int)</signal>
<receiver>valSpinBox</receiver>
diff --git a/muse2/muse/liste/editevent.cpp b/muse2/muse/liste/editevent.cpp
index 415c6385..fac6866d 100644
--- a/muse2/muse/liste/editevent.cpp
+++ b/muse2/muse/liste/editevent.cpp
@@ -27,6 +27,7 @@
#include <QGridLayout>
#include <QLabel>
#include <QListWidget>
+#include <QListWidgetItem>
#include <QMessageBox>
#include <QPushButton>
#include <QRadioButton>
@@ -602,22 +603,32 @@ EditCtrlDialog::EditCtrlDialog(int tick, const MusECore::Event& event,
{
setupUi(this);
widgetStack->setAutoFillBackground(true);
+
+ MusECore::MidiTrack* track = part->track();
+ int portn = track->outPort();
+ MusECore::MidiPort* port = &MusEGlobal::midiPorts[portn];
+ bool isDrum = track->type() == MusECore::Track::DRUM;
+ bool isNewDrum = track->type() == MusECore::Track::NEW_DRUM;
+ bool isMidi = track->type() == MusECore::Track::MIDI;
+ MusECore::MidiCtrlValListList* cll = port->controller();
+
val = 0;
num = 0;
+ int note = -1;
if (!event.empty()) {
num = event.dataA();
val = event.dataB();
+ if(port->drumController(num))
+ {
+ if(isDrum)
+ num = (num & ~0xff) | MusEGlobal::drumMap[num & 0xff].anote;
+ note = num & 0xff;
}
+ }
///pop = new QMenu(this);
//pop->setCheckable(false); //not necessary in Qt4
- MusECore::MidiTrack* track = part->track();
- int portn = track->outPort();
- MusECore::MidiPort* port = &MusEGlobal::midiPorts[portn];
- bool isDrum = track->isDrumTrack();
- MusECore::MidiCtrlValListList* cll = port->controller();
-
ctrlList->clear();
ctrlList->setSelectionMode(QAbstractItemView::SingleSelection);
@@ -630,14 +641,34 @@ EditCtrlDialog::EditCtrlDialog(int tick, const MusECore::Event& event,
for (MusECore::iMidiCtrlValList it = cll->begin(); it != cll->end(); ++it) {
MusECore::MidiCtrlValList* cl = it->second;
- int num = cl->num();
+ int clnum = cl->num();
// dont show drum specific controller if not a drum track
- if ((num & 0xff) == 0xff) {
- if (!isDrum)
- continue;
- }
- MusECore::MidiController* c = port->midiController(num);
+ //if ((num & 0xff) == 0xff) { // REMOVE Tim. Or keep.
+ // if (!isDrum)
+ // continue;
+ // }
+// int rnum = num;
+// if(port->drumController(num))
+// {
+// rnum |= 0xff;
+// if()
+// continue;
+// }
+
+
+// FIXME: TODO: Finish this stuff off. Use items' data member for control number.
+
+ MusECore::MidiController* c = port->midiController(clnum);
+ //int cnum = c->num();
+ //if(c->isPerNoteController())
+ //{
+ if(((isDrum || isNewDrum) && !(c->showInTracks() & MusECore::MidiController::ShowInDrum)) ||
+ (isMidi && !(c->showInTracks() & MusECore::MidiController::ShowInMidi)))
+ continue;
+ //}
+
+
{
isList i = sList.begin();
for (; i != sList.end(); ++i) {
@@ -674,10 +705,27 @@ EditCtrlDialog::EditCtrlDialog(int tick, const MusECore::Event& event,
{
widgetStack->setCurrentIndex(0);
valSlider->setValue(val - mc->bias());
+
+ if(mc->isPerNoteController())
+ {
+ noteSpinBox->setVisible(true);
+ noteSpinBox->setEnabled(true);
+ if(note != -1)
+ noteSpinBox->setValue(note);
+ }
+ else
+ {
+ noteSpinBox->setEnabled(false);
+ noteSpinBox->setVisible(false);
+ }
}
}
else
+ {
+ noteSpinBox->setEnabled(false);
+ noteSpinBox->setVisible(false);
ctrlListClicked(ctrlList->selectedItems()[0]);
+ }
connect(ctrlList, SIGNAL(itemClicked(QListWidgetItem*)), SLOT(ctrlListClicked(QListWidgetItem*)));
connect(buttonNewController, SIGNAL(clicked()), SLOT(newController()));
connect(hbank, SIGNAL(valueChanged(int)), SLOT(programChanged()));
@@ -703,36 +751,77 @@ void EditCtrlDialog::newController()
MusECore::MidiTrack* track = part->track();
int portn = track->outPort();
MusECore::MidiPort* port = &MusEGlobal::midiPorts[portn];
+ bool isDrum = track->type() == MusECore::Track::DRUM;
+ bool isNewDrum = track->type() == MusECore::Track::NEW_DRUM;
+ bool isMidi = track->type() == MusECore::Track::MIDI;
MusECore::MidiInstrument* instr = port->instrument();
MusECore::MidiControllerList* mcl = instr->controller();
MusECore::MidiCtrlValListList* cll = port->controller();
int channel = track->outChannel();
- int nn = 0;
+ //int nn = 0;
for (MusECore::iMidiController ci = mcl->begin(); ci != mcl->end(); ++ci)
{
- if(cll->find(channel, ci->second->num()) == cll->end())
- {
- QAction* act = pup->addAction(ci->second->name());
- act->setData(nn);
- ++nn;
- }
+
+ MusECore::MidiController* c = ci->second;
+ int num = c->num();
+ int show = c->showInTracks();
+
+ if(((isDrum || isNewDrum) && !(show & MusECore::MidiController::ShowInDrum)) ||
+ (isMidi && !(show & MusECore::MidiController::ShowInMidi)))
+ continue;
+ if(c->isPerNoteController())
+ {
+ if (isDrum)
+ num = (num & ~0xff) | MusEGlobal::drumMap[noteSpinBox->value()].anote;
+ else if ((isNewDrum || isMidi))
+ num = (num & ~0xff) | noteSpinBox->value();
+ else // dont show drum specific controller if not a drum track
+ continue;
+ }
+
+ // If it's not already in the parent menu...
+ if(cll->find(channel, num) == cll->end())
+ {
+ //ctrlSubPop->addAction(MusECore::midiCtrlNumString(num, true) + ci->second->name())->setData(num);
+ QAction* act = pup->addAction(MusECore::midiCtrlNumString(num, true) + c->name());
+ act->setData(num);
+ }
+
+// REMOVE Tim.
+// if(cll->find(channel, ci->second->num()) == cll->end())
+// {
+// QAction* act = pup->addAction(ci->second->name());
+// act->setData(nn);
+// ++nn;
+// }
}
- QAction* rv = pup->exec(buttonNewController->mapToGlobal(QPoint(0,0)));
- if (rv) {
- QString s = rv->text();
+
+// QAction* rv = pup->exec(buttonNewController->mapToGlobal(QPoint(0,0)));
+ QAction* act = pup->exec(buttonNewController->mapToGlobal(QPoint(0,0)));
+ if (act && act->data().toInt() != -1) {
+ //QString s = rv->text(); // REMOVE Tim.
+ int rv = act->data().toInt();
+ int num = rv;
+ if(port->drumController(rv))
+ num |= 0xff;
for (MusECore::iMidiController ci = mcl->begin(); ci != mcl->end(); ++ci) {
MusECore::MidiController* mc = ci->second;
- if (mc->name() == s) {
- if(cll->find(channel, mc->num()) == cll->end())
+ //if (mc->name() == s) { // REMOVE Tim.
+ if (mc->num() == num) {
+ //if(cll->find(channel, mc->num()) == cll->end()) // REMOVE Tim.
+ if(cll->find(channel, rv) == cll->end())
{
- MusECore::MidiCtrlValList* vl = new MusECore::MidiCtrlValList(mc->num());
+ //MusECore::MidiCtrlValList* vl = new MusECore::MidiCtrlValList(mc->num()); // REMOVE Tim.
+ MusECore::MidiCtrlValList* vl = new MusECore::MidiCtrlValList(rv);
cll->add(channel, vl);
}
int idx = 0;
for (; idx < ctrlList->count() ;++idx) { // p4.0.25 Fix segfault
- QString str = ctrlList->item(idx)->text();
- if (s == str)
+ //QString str = ctrlList->item(idx)->text(); // REMOVE Tim.
+ int item_data = ctrlList->item(idx)->data(Qt::UserRole).toInt();
+ //if (s == str)
+ if (item_data == num)
{
ctrlList->item(idx)->setSelected(true);
ctrlListClicked(ctrlList->item(idx));
@@ -740,7 +829,10 @@ void EditCtrlDialog::newController()
}
}
if (idx >= ctrlList->count()) { // p4.0.25 Fix segfault
- ctrlList->addItem(s);
+ //ctrlList->addItem(s); // REMOVE Tim.
+ QListWidgetItem* new_item = new QListWidgetItem(act->text(), ctrlList);
+ new_item->setData(Qt::UserRole, num);
+ //ctrlList->addItem(new_item);
ctrlList->item(idx)->setSelected(true);
ctrlListClicked(ctrlList->item(idx));
break;