summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim E. Real <termtech@rogers.com>2012-10-22 06:54:39 +0000
committerTim E. Real <termtech@rogers.com>2012-10-22 06:54:39 +0000
commitb6cb5a7a97c4959ddd6ef4fabdf0ddf0b3604d1b (patch)
treecb957648f670b4f7697eddbe37adcda8b620fb6d
parentbb2ae55efec337e3b372937582dcd154fb36e9e9 (diff)
Fixed regression: Re-add default managed controllers to midi ports at Song::clear.
W.I.P. Preparations for Aftertouch and Poly Aftertouch graph editing.
-rw-r--r--muse2/ChangeLog3
-rw-r--r--muse2/muse/ctrl/ctrlpanel.cpp46
-rw-r--r--muse2/muse/driver/alsamidi.cpp10
-rw-r--r--muse2/muse/driver/jackmidi.cpp9
-rw-r--r--muse2/muse/helper.cpp29
-rw-r--r--muse2/muse/midictrl.cpp47
-rw-r--r--muse2/muse/midictrl.h6
-rw-r--r--muse2/muse/midiedit/drumedit.cpp30
-rw-r--r--muse2/muse/midiedit/pianoroll.cpp30
-rw-r--r--muse2/muse/midiport.cpp43
-rw-r--r--muse2/muse/midiport.h4
-rw-r--r--muse2/muse/song.cpp4
12 files changed, 210 insertions, 51 deletions
diff --git a/muse2/ChangeLog b/muse2/ChangeLog
index f3dabe74..dca54595 100644
--- a/muse2/ChangeLog
+++ b/muse2/ChangeLog
@@ -1,3 +1,6 @@
+22.10.2012:
+ - Oops, fixed regression: Re-add default managed controllers to midi ports at Song::clear. (Tim)
+ - W.I.P. Preparations for Aftertouch and Poly Aftertouch (channel and key pressure) graph editing. (Tim)
21.10.2012:
- Slight changes to midi track info hbank/lbank/program dblclick on/off behaviour. (Tim)
TODO Need to improve by having separate 'last valid hbank/lbank/program' instead of single 'last valid value'.
diff --git a/muse2/muse/ctrl/ctrlpanel.cpp b/muse2/muse/ctrl/ctrlpanel.cpp
index cb14200e..c6adc778 100644
--- a/muse2/muse/ctrl/ctrlpanel.cpp
+++ b/muse2/muse/ctrl/ctrlpanel.cpp
@@ -253,6 +253,14 @@ void CtrlPanel::labelDoubleClicked()
int curv = mp->hwCtrlState(chan, _dnum);
+// if(_dnum == MusECore::CTRL_AFTERTOUCH)
+// {
+// // Auto bias...
+// ival += _ctrl->bias();
+// MusECore::MidiPlayEvent ev(0, outport, chan, MusECore::ME_AFTERTOUCH, ival, 0);
+// MusEGlobal::audio->msgPlayMidiEvent(&ev);
+// }
+// else
if(_dnum == MusECore::CTRL_PROGRAM)
{
if(curv == MusECore::CTRL_VAL_UNKNOWN || ((curv & 0xffffff) == 0xffffff))
@@ -348,6 +356,14 @@ void CtrlPanel::ctrlChanged(double val)
MusECore::MidiPort* mp = &MusEGlobal::midiPorts[outport];
int curval = mp->hwCtrlState(chan, _dnum);
+// if(_dnum == MusECore::CTRL_AFTERTOUCH)
+// {
+// // Auto bias...
+// ival += _ctrl->bias();
+// MusECore::MidiPlayEvent ev(0, outport, chan, MusECore::ME_AFTERTOUCH, ival, 0);
+// MusEGlobal::audio->msgPlayMidiEvent(&ev);
+// }
+// else
if(_dnum == MusECore::CTRL_PROGRAM)
{
--ival;
@@ -562,15 +578,29 @@ void CtrlPanel::ctrlPopupTriggered(QAction* act)
MusECore::MidiControllerList* mcl = instr->controller();
MusECore::MidiCtrlValListList* cll = port->controller();
- int min = channel << 24;
- int max = min + 0x1000000;
+ const int min = channel << 24;
+ const int max = min + 0x1000000;
+
+ const int add_ins_def = max + 1;
+ const int add_other = max + 2;
+ const int edit_ins = max + 3;
+
+ const int velo = max + 0x101;
+ const int polyafter = max + 0x102;
+ const int after = max + 0x103;
int rv = act->data().toInt();
- if (rv == max) { // special case velocity
+ if (rv == velo) { // special case velocity
emit controllerChanged(MusECore::CTRL_VELOCITY);
}
- else if (rv == max + 1) { // add new instrument controller
+ else if (rv == polyafter) { // special case
+ emit controllerChanged(MusECore::CTRL_POLYAFTER);
+ }
+ else if (rv == after) { // special case
+ emit controllerChanged(MusECore::CTRL_AFTERTOUCH);
+ }
+ else if (rv == add_ins_def) { // add new instrument controller
PopupMenu * ctrlSubPop = new PopupMenu(this, true); // true = enable stay open
ctrlSubPop->addAction(new MenuTitleItem(tr("Instrument-defined"), ctrlSubPop));
@@ -599,14 +629,14 @@ void CtrlPanel::ctrlPopupTriggered(QAction* act)
// Don't allow editing instrument if it's a synth
if(!port->device() || port->device()->deviceType() != MusECore::MidiDevice::SYNTH_MIDI)
- ctrlSubPop->addAction(QIcon(*midi_edit_instrumentIcon), tr("Edit instrument ..."))->setData(max + 2);
+ ctrlSubPop->addAction(QIcon(*midi_edit_instrumentIcon), tr("Edit instrument ..."))->setData(edit_ins);
QAction *act2 = ctrlSubPop->exec(selCtrl->mapToGlobal(QPoint(0,0)));
if (act2)
{
int rv2 = act2->data().toInt();
- if (rv2 == max + 2) // edit instrument
+ if (rv2 == edit_ins) // edit instrument
MusEGlobal::muse->startEditInstrument();
else // select new instrument control
{
@@ -639,10 +669,10 @@ void CtrlPanel::ctrlPopupTriggered(QAction* act)
delete ctrlSubPop;
}
- //else if (rv == max + 2) // edit instrument
+ //else if (rv == edit_ins) // edit instrument
// MusEGlobal::muse->startEditInstrument();
- else if (rv == max + 3) { // add new other controller
+ else if (rv == add_other) { // add new other controller
PopupMenu* ctrlSubPop = new PopupMenu(this, true); // true = enable stay open
ctrlSubPop->addAction(new MenuTitleItem(tr("Common Controls"), ctrlSubPop));
diff --git a/muse2/muse/driver/alsamidi.cpp b/muse2/muse/driver/alsamidi.cpp
index d8b3a947..978cca98 100644
--- a/muse2/muse/driver/alsamidi.cpp
+++ b/muse2/muse/driver/alsamidi.cpp
@@ -386,7 +386,7 @@ bool MidiAlsaDevice::putMidiEvent(const MidiPlayEvent& e)
snd_seq_ev_set_pitchbend(&event, chn, a);
break;
case ME_POLYAFTER:
- // chnEvent2(chn, 0xa0, a, b);
+ snd_seq_ev_set_keypress(&event, chn, a, b);
break;
case ME_AFTERTOUCH:
snd_seq_ev_set_chanpress(&event, chn, a);
@@ -1278,7 +1278,6 @@ void alsaProcessMidiInput()
switch(ev->type)
{
case SND_SEQ_EVENT_NOTEON:
- case SND_SEQ_EVENT_KEYPRESS:
event.setChannel(ev->data.note.channel);
event.setType(ME_NOTEON);
event.setA(ev->data.note.note);
@@ -1292,6 +1291,13 @@ void alsaProcessMidiInput()
event.setB(ev->data.note.velocity);
break;
+ case SND_SEQ_EVENT_KEYPRESS:
+ event.setChannel(ev->data.note.channel);
+ event.setType(ME_POLYAFTER);
+ event.setA(ev->data.note.note);
+ event.setB(ev->data.note.velocity);
+ break;
+
case SND_SEQ_EVENT_CHANPRESS:
event.setChannel(ev->data.control.channel);
event.setType(ME_AFTERTOUCH);
diff --git a/muse2/muse/driver/jackmidi.cpp b/muse2/muse/driver/jackmidi.cpp
index 6b1506e1..a088290a 100644
--- a/muse2/muse/driver/jackmidi.cpp
+++ b/muse2/muse/driver/jackmidi.cpp
@@ -466,6 +466,7 @@ void MidiJackDevice::eventReceived(jack_midi_event_t* ev)
case ME_NOTEON:
case ME_NOTEOFF:
case ME_CONTROLLER:
+ case ME_POLYAFTER:
event.setA(*(ev->buffer + 1));
event.setB(*(ev->buffer + 2));
break;
@@ -845,7 +846,13 @@ bool MidiJackDevice::processEvent(const MidiPlayEvent& event)
}
}
- if(a == CTRL_PITCH)
+ if(a == CTRL_AFTERTOUCH)
+ {
+ //printf("MidiJackDevice::processEvent CTRL_AFTERTOUCH v:%d time:%d type:%d ch:%d A:%d B:%d\n", v, event.time(), event.type(), event.channel(), event.dataA(), event.dataB());
+ if(!queueEvent(MidiPlayEvent(t, port, chn, ME_AFTERTOUCH, b & 0x7f, 0)))
+ return false;
+ }
+ else if(a == CTRL_PITCH)
{
int v = b + 8192;
//printf("MidiJackDevice::processEvent CTRL_PITCH v:%d time:%d type:%d ch:%d A:%d B:%d\n", v, event.time(), event.type(), event.channel(), event.dataA(), event.dataB());
diff --git a/muse2/muse/helper.cpp b/muse2/muse/helper.cpp
index 21986831..986d38aa 100644
--- a/muse2/muse/helper.cpp
+++ b/muse2/muse/helper.cpp
@@ -893,8 +893,15 @@ int populateMidiCtrlMenu(PopupMenu* menu, MusECore::PartList* part_list, MusECor
MusECore::MidiControllerList* mcl = instr->controller();
MusECore::MidiCtrlValListList* cll = port->controller();
- int min = channel << 24;
- int max = min + 0x1000000;
+ const int min = channel << 24;
+ const int max = min + 0x1000000;
+
+ const int add_ins_def = max + 1;
+ const int add_other = max + 2;
+
+ const int velo = max + 0x101;
+// const int polyafter = max + 0x102;
+// const int after = max + 0x103;
int est_width = 0;
@@ -1007,7 +1014,7 @@ int populateMidiCtrlMenu(PopupMenu* menu, MusECore::PartList* part_list, MusECor
fmw = menu->fontMetrics().width(stext);
if(fmw > est_width)
est_width = fmw;
- menu->addAction(QIcon(*configureIcon), stext)->setData(max + 1);
+ menu->addAction(QIcon(*configureIcon), stext)->setData(add_ins_def);
menu->addSeparator();
@@ -1021,7 +1028,19 @@ int populateMidiCtrlMenu(PopupMenu* menu, MusECore::PartList* part_list, MusECor
fmw = menu->fontMetrics().width(stext);
if(fmw > est_width)
est_width = fmw;
- menu->addAction(stext)->setData(max);
+ menu->addAction(stext)->setData(velo);
+
+// stext = QWidget::tr("PolyAftertouch");
+// fmw = menu->fontMetrics().width(stext);
+// if(fmw > est_width)
+// est_width = fmw;
+// menu->addAction(stext)->setData(polyafter);
+//
+// stext = QWidget::tr("Aftertouch");
+// fmw = menu->fontMetrics().width(stext);
+// if(fmw > est_width)
+// est_width = fmw;
+// menu->addAction(stext)->setData(after);
// Add global default controllers (all controllers not found in instrument).
for (isList i = sList.begin(); i != sList.end(); ++i)
@@ -1047,7 +1066,7 @@ int populateMidiCtrlMenu(PopupMenu* menu, MusECore::PartList* part_list, MusECor
fmw = menu->fontMetrics().width(stext);
if(fmw > est_width)
est_width = fmw;
- menu->addAction(QIcon(*configureIcon), stext)->setData(max + 3);
+ menu->addAction(QIcon(*configureIcon), stext)->setData(add_other);
est_width += 60; // Add about 60 for the coloured lights on the left.
diff --git a/muse2/muse/midictrl.cpp b/muse2/muse/midictrl.cpp
index 63ce6fe6..2cf4f790 100644
--- a/muse2/muse/midictrl.cpp
+++ b/muse2/muse/midictrl.cpp
@@ -81,13 +81,14 @@ MidiControllerList defaultMidiController;
//
// some global controller which are always available:
//
-MidiController veloCtrl("Velocity", CTRL_VELOCITY, 0, 127, 0);
-static MidiController pitchCtrl("PitchBend", CTRL_PITCH, -8192, +8191, 0);
-static MidiController programCtrl("Program", CTRL_PROGRAM, 0, 0xffffff, 0);
-// Removed p3.3.37 Re-added p4.0.15
-static MidiController mastervolCtrl("MasterVolume", CTRL_MASTER_VOLUME, 0, 0x3fff, 0x3000);
-static MidiController volumeCtrl("MainVolume", CTRL_VOLUME, 0, 127, 100);
-static MidiController panCtrl("Pan", CTRL_PANPOT, -64, 63, 0);
+MidiController veloCtrl("Velocity", CTRL_VELOCITY, 0, 127, 0);
+static MidiController pitchCtrl("PitchBend", CTRL_PITCH, -8192, +8191, 0);
+static MidiController programCtrl("Program", CTRL_PROGRAM, 0, 0xffffff, 0);
+static MidiController mastervolCtrl("MasterVolume", CTRL_MASTER_VOLUME, 0, 0x3fff, 0x3000);
+static MidiController volumeCtrl("MainVolume", CTRL_VOLUME, 0, 127, 100);
+static MidiController panCtrl("Pan", CTRL_PANPOT, -64, 63, 0);
+static MidiController polyAfterCtrl("PolyAftertouch", CTRL_POLYAFTER, 0, 127, 0);
+static MidiController afterCtrl("Aftertouch", CTRL_AFTERTOUCH, 0, 127, 0);
//---------------------------------------------------------
@@ -107,6 +108,8 @@ static struct {
{ MidiController::NRPN14, QString("NRPN14") },
{ MidiController::Pitch, QString("Pitch") },
{ MidiController::Program, QString("Program") },
+ { MidiController::PolyAftertouch, QString("PolyAftertouch") },
+ { MidiController::Aftertouch, QString("Aftertouch") },
{ MidiController::Controller7, QString("Control") }, // alias
};
@@ -146,6 +149,8 @@ const QString& int2ctrlType(int n)
void initMidiController()
{
defaultMidiController.add(&veloCtrl);
+ defaultMidiController.add(&polyAfterCtrl);
+ defaultMidiController.add(&afterCtrl);
defaultMidiController.add(&pitchCtrl);
defaultMidiController.add(&programCtrl);
defaultMidiController.add(&mastervolCtrl);
@@ -178,10 +183,10 @@ QString midiCtrlNumString(int ctrl, bool fullyQualified)
case MidiController::NRPN:
return s1 + QString("N") + s2;
case MidiController::Pitch: // Don't show internal controller numbers.
- return QString();
case MidiController::Program:
- return QString();
case MidiController::Velo:
+ case MidiController::PolyAftertouch:
+ case MidiController::Aftertouch:
return QString();
case MidiController::RPN14:
return s1 + QString("RF") + s2;
@@ -221,6 +226,10 @@ QString midiCtrlName(int ctrl, bool fullyQualified)
return QString("Program");
case MidiController::Velo:
return QString("Velocity");
+ case MidiController::PolyAftertouch:
+ return QString("PolyAftertouch");
+ case MidiController::Aftertouch:
+ return QString("Aftertouch");
case MidiController::RPN14:
return s1 + QString("RF") + s2;
case MidiController::NRPN14:
@@ -298,6 +307,10 @@ MidiController::ControllerType midiControllerType(int num)
return MidiController::Program;
if (num == CTRL_VELOCITY)
return MidiController::Velo;
+ if (num == CTRL_POLYAFTER)
+ return MidiController::PolyAftertouch;
+ if (num == CTRL_AFTERTOUCH)
+ return MidiController::Aftertouch;
if (num < CTRL_NRPN14_OFFSET)
return MidiController::RPN14;
if (num < CTRL_NONE_OFFSET)
@@ -328,6 +341,10 @@ int midiCtrlTerms2Number(int type_num, int ctrl)
return CTRL_PROGRAM;
case MidiController::Velo:
return CTRL_VELOCITY;
+ case MidiController::PolyAftertouch:
+ return CTRL_POLYAFTER;
+ case MidiController::Aftertouch:
+ return CTRL_AFTERTOUCH;
case MidiController::RPN14:
return CTRL_RPN14_OFFSET + ctrl;
case MidiController::NRPN14:
@@ -378,6 +395,8 @@ void MidiController::updateBias()
mx = 8191;
break;
//case Velo: // cannot happen
+ //case PolyAfter:
+ //case After:
default:
b = 64;
mn = 0;
@@ -413,7 +432,7 @@ void MidiController::updateBias()
void MidiController::write(int level, Xml& xml) const
{
ControllerType t = midiControllerType(_num);
- if(t == Velo)
+ if(t == Velo || t == PolyAftertouch || t == Aftertouch)
return;
QString type(int2ctrlType(t));
@@ -458,6 +477,8 @@ void MidiController::write(int level, Xml& xml) const
break;
case Program:
case Velo: // Cannot happen
+ case PolyAftertouch:
+ case Aftertouch:
break;
}
@@ -579,6 +600,8 @@ void MidiController::read(Xml& xml)
_num = CTRL_PROGRAM;
break;
case Velo: // cannot happen
+ case PolyAftertouch:
+ case Aftertouch:
break;
}
if (_minVal == NOT_SET)
@@ -617,6 +640,10 @@ int MidiController::genNum(MidiController::ControllerType t, int h, int l)
return CTRL_PITCH;
case Program:
return CTRL_PROGRAM;
+ case PolyAftertouch:
+ return CTRL_POLYAFTER;
+ case Aftertouch:
+ return CTRL_AFTERTOUCH;
default:
return -1;
}
diff --git a/muse2/muse/midictrl.h b/muse2/muse/midictrl.h
index 4c9a4097..5e197dc0 100644
--- a/muse2/muse/midictrl.h
+++ b/muse2/muse/midictrl.h
@@ -84,6 +84,8 @@ const int CTRL_PITCH = CTRL_INTERNAL_OFFSET;
const int CTRL_PROGRAM = CTRL_INTERNAL_OFFSET + 1;
const int CTRL_VELOCITY = CTRL_INTERNAL_OFFSET + 2;
const int CTRL_MASTER_VOLUME = CTRL_INTERNAL_OFFSET + 3;
+const int CTRL_POLYAFTER = CTRL_INTERNAL_OFFSET + 4;
+const int CTRL_AFTERTOUCH = CTRL_INTERNAL_OFFSET + 5;
const int CTRL_VAL_UNKNOWN = 0x10000000; // used as unknown hwVal
@@ -113,7 +115,9 @@ class MidiController {
NRPN14, // non registered parameter 0x60000 -
Pitch, // num value = CTRL_PITCH
Program, // num value = CTRL_PROGRAM
- Velo // not assigned
+ Velo, // not assigned
+ PolyAftertouch, // num value = CTRL_POLYAFTER
+ Aftertouch // num value = CTRL_AFTERTOUCH
};
private:
QString _name;
diff --git a/muse2/muse/midiedit/drumedit.cpp b/muse2/muse/midiedit/drumedit.cpp
index 7a86f010..238b37fd 100644
--- a/muse2/muse/midiedit/drumedit.cpp
+++ b/muse2/muse/midiedit/drumedit.cpp
@@ -1245,15 +1245,29 @@ void DrumEdit::ctrlPopupTriggered(QAction* act)
MusECore::MidiControllerList* mcl = instr->controller();
MusECore::MidiCtrlValListList* cll = port->controller();
- int min = channel << 24;
- int max = min + 0x1000000;
+ const int min = channel << 24;
+ const int max = min + 0x1000000;
+
+ const int add_ins_def = max + 1;
+ const int add_other = max + 2;
+ const int edit_ins = max + 3;
+
+ const int velo = max + 0x101;
+ const int polyafter = max + 0x102;
+ const int after = max + 0x103;
int rv = act->data().toInt();
- if (rv == max) { // special case velocity
+ if (rv == velo) { // special case velocity
newCtlNum = MusECore::CTRL_VELOCITY;
}
- else if (rv == max + 1) { // add new instrument controller
+ else if (rv == polyafter) { // special case
+ newCtlNum = MusECore::CTRL_POLYAFTER;
+ }
+ else if (rv == after) { // special case
+ newCtlNum = MusECore::CTRL_AFTERTOUCH;
+ }
+ else if (rv == add_ins_def) { // add new instrument controller
PopupMenu * ctrlSubPop = new PopupMenu(this, true); // true = enable stay open
ctrlSubPop->addAction(new MenuTitleItem(tr("Instrument-defined"), ctrlSubPop));
@@ -1282,14 +1296,14 @@ void DrumEdit::ctrlPopupTriggered(QAction* act)
// Don't allow editing instrument if it's a synth
if(!port->device() || port->device()->deviceType() != MusECore::MidiDevice::SYNTH_MIDI)
- ctrlSubPop->addAction(QIcon(*midi_edit_instrumentIcon), tr("Edit instrument ..."))->setData(max + 2);
+ ctrlSubPop->addAction(QIcon(*midi_edit_instrumentIcon), tr("Edit instrument ..."))->setData(edit_ins);
QAction *act2 = ctrlSubPop->exec(ctrl->mapToGlobal(QPoint(0,0)));
if (act2)
{
int rv2 = act2->data().toInt();
- if (rv2 == max + 2) // edit instrument
+ if (rv2 == edit_ins) // edit instrument
MusEGlobal::muse->startEditInstrument();
else // select new instrument control
{
@@ -1322,10 +1336,10 @@ void DrumEdit::ctrlPopupTriggered(QAction* act)
delete ctrlSubPop;
}
- //else if (rv == max + 2) // edit instrument
+ //else if (rv == edit_ins) // edit instrument
// MusEGlobal::muse->startEditInstrument();
- else if (rv == max + 3) { // add new other controller
+ else if (rv == add_other) { // add new other controller
PopupMenu* ctrlSubPop = new PopupMenu(this, true); // true = enable stay open
ctrlSubPop->addAction(new MenuTitleItem(tr("Common Controls"), ctrlSubPop));
diff --git a/muse2/muse/midiedit/pianoroll.cpp b/muse2/muse/midiedit/pianoroll.cpp
index 44b0cc66..1701f537 100644
--- a/muse2/muse/midiedit/pianoroll.cpp
+++ b/muse2/muse/midiedit/pianoroll.cpp
@@ -818,15 +818,29 @@ void PianoRoll::ctrlPopupTriggered(QAction* act)
MusECore::MidiControllerList* mcl = instr->controller();
MusECore::MidiCtrlValListList* cll = port->controller();
- int min = channel << 24;
- int max = min + 0x1000000;
+ const int min = channel << 24;
+ const int max = min + 0x1000000;
+
+ const int add_ins_def = max + 1;
+ const int add_other = max + 2;
+ const int edit_ins = max + 3;
+
+ const int velo = max + 0x101;
+ const int polyafter = max + 0x102;
+ const int after = max + 0x103;
int rv = act->data().toInt();
- if (rv == max) { // special case velocity
+ if (rv == velo) { // special case velocity
newCtlNum = MusECore::CTRL_VELOCITY;
}
- else if (rv == max + 1) { // add new instrument controller
+ else if (rv == polyafter) { // special case
+ newCtlNum = MusECore::CTRL_POLYAFTER;
+ }
+ else if (rv == after) { // special case
+ newCtlNum = MusECore::CTRL_AFTERTOUCH;
+ }
+ else if (rv == add_ins_def) { // add new instrument controller
PopupMenu * ctrlSubPop = new PopupMenu(this, true); // true = enable stay open
ctrlSubPop->addAction(new MenuTitleItem(tr("Instrument-defined"), ctrlSubPop));
@@ -855,14 +869,14 @@ void PianoRoll::ctrlPopupTriggered(QAction* act)
// Don't allow editing instrument if it's a synth
if(!port->device() || port->device()->deviceType() != MusECore::MidiDevice::SYNTH_MIDI)
- ctrlSubPop->addAction(QIcon(*midi_edit_instrumentIcon), tr("Edit instrument ..."))->setData(max + 2);
+ ctrlSubPop->addAction(QIcon(*midi_edit_instrumentIcon), tr("Edit instrument ..."))->setData(edit_ins);
QAction *act2 = ctrlSubPop->exec(ctrl->mapToGlobal(QPoint(0,0)));
if (act2)
{
int rv2 = act2->data().toInt();
- if (rv2 == max + 2) // edit instrument
+ if (rv2 == edit_ins) // edit instrument
MusEGlobal::muse->startEditInstrument();
else // select new instrument control
{
@@ -895,10 +909,10 @@ void PianoRoll::ctrlPopupTriggered(QAction* act)
delete ctrlSubPop;
}
- //else if (rv == max + 2) // edit instrument
+ //else if (rv == edit_ins) // edit instrument
// MusEGlobal::muse->startEditInstrument();
- else if (rv == max + 3) { // add new other controller
+ else if (rv == add_other) { // add new other controller
PopupMenu* ctrlSubPop = new PopupMenu(this, true); // true = enable stay open
ctrlSubPop->addAction(new MenuTitleItem(tr("Common Controls"), ctrlSubPop));
diff --git a/muse2/muse/midiport.cpp b/muse2/muse/midiport.cpp
index c1288e6e..2f3898ff 100644
--- a/muse2/muse/midiport.cpp
+++ b/muse2/muse/midiport.cpp
@@ -86,12 +86,7 @@ MidiPort::MidiPort()
// create minimum set of managed controllers
// to make midi mixer operational
//
- for (int i = 0; i < MIDI_CHANNELS; ++i) {
- addManagedController(i, CTRL_PROGRAM);
- addManagedController(i, CTRL_VOLUME);
- addManagedController(i, CTRL_PANPOT);
- _automationType[i] = AUTO_READ;
- }
+ addDefaultControllers();
}
//---------------------------------------------------------
@@ -738,6 +733,22 @@ MidiCtrlValList* MidiPort::addManagedController(int channel, int ctrl)
}
//---------------------------------------------------------
+// addDefaultControllers
+//---------------------------------------------------------
+
+void MidiPort::addDefaultControllers()
+{
+ for (int i = 0; i < MIDI_CHANNELS; ++i) {
+ addManagedController(i, CTRL_PROGRAM);
+ addManagedController(i, CTRL_VOLUME);
+ addManagedController(i, CTRL_PANPOT);
+ addManagedController(i, CTRL_POLYAFTER);
+ addManagedController(i, CTRL_AFTERTOUCH);
+ _automationType[i] = AUTO_READ;
+ }
+}
+
+//---------------------------------------------------------
// limitValToInstrCtlRange
//---------------------------------------------------------
@@ -811,6 +822,24 @@ bool MidiPort::sendHwCtrlState(const MidiPlayEvent& ev, bool forceSend)
return false;
}
}
+// else
+// if (ev.type() == ME_POLYAFTER) // REMOVE Tim. Or keep?
+// {
+// int db = limitValToInstrCtlRange(CTRL_POLYAFTER, ev.dataB());
+// if(!setHwCtrlState(ev.channel(), CTRL_POLYAFTER, db)) {
+// if (!forceSend)
+// return false;
+// }
+// }
+// else
+// if (ev.type() == ME_AFTERTOUCH)
+// {
+// int da = limitValToInstrCtlRange(CTRL_AFTERTOUCH, ev.dataA());
+// if(!setHwCtrlState(ev.channel(), CTRL_AFTERTOUCH, da)) {
+// if (!forceSend)
+// return false;
+// }
+// }
else
if (ev.type() == ME_PITCHBEND)
{
@@ -1006,6 +1035,8 @@ MidiController* MidiPort::midiController(int num) const
case MidiController::RPN:
case MidiController::NRPN:
case MidiController::Controller7:
+ case MidiController::PolyAftertouch:
+ case MidiController::Aftertouch:
max = 127;
break;
case MidiController::Controller14:
diff --git a/muse2/muse/midiport.h b/muse2/muse/midiport.h
index 3acaa6ee..6f92cb02 100644
--- a/muse2/muse/midiport.h
+++ b/muse2/muse/midiport.h
@@ -77,7 +77,6 @@ class MidiPort {
MidiCtrlValListList* controller() { return _controller; }
int getCtrl(int ch, int tick, int ctrl) const;
int getCtrl(int ch, int tick, int ctrl, Part* part) const;
- // Removed by T356.
bool setControllerVal(int ch, int tick, int ctrl, int val, Part* part);
// Can be CTRL_VAL_UNKNOWN until a valid state is set
int lastValidHWCtrlState(int ch, int ctrl) const;
@@ -85,7 +84,8 @@ class MidiPort {
bool setHwCtrlState(int ch, int ctrl, int val);
bool setHwCtrlStates(int ch, int ctrl, int val, int lastval);
void deleteController(int ch, int tick, int ctrl, Part* part);
-
+ void addDefaultControllers();
+
bool guiVisible() const;
bool hasGui() const;
bool nativeGuiVisible() const;
diff --git a/muse2/muse/song.cpp b/muse2/muse/song.cpp
index 036892f0..542c6abc 100644
--- a/muse2/muse/song.cpp
+++ b/muse2/muse/song.cpp
@@ -2113,8 +2113,12 @@ void Song::clear(bool signal, bool clear_all)
// Clear all midi port controller values.
for(int i = 0; i < MIDI_PORTS; ++i)
+ {
// Remove the controllers AND the values so we start with a clean slate.
MusEGlobal::midiPorts[i].controller()->clearDelete(true);
+ // Don't forget to re-add the default managed controllers.
+ MusEGlobal::midiPorts[i].addDefaultControllers();
+ }
_masterFlag = true;
loopFlag = false;