summaryrefslogtreecommitdiff
path: root/muse2
diff options
context:
space:
mode:
Diffstat (limited to 'muse2')
-rw-r--r--muse2/ChangeLog3
-rw-r--r--muse2/muse/widgets/mtrackinfo.cpp184
-rw-r--r--muse2/muse/widgets/mtrackinfo.h2
3 files changed, 186 insertions, 3 deletions
diff --git a/muse2/ChangeLog b/muse2/ChangeLog
index 3d7c1513..f3dabe74 100644
--- a/muse2/ChangeLog
+++ b/muse2/ChangeLog
@@ -1,3 +1,6 @@
+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'.
20.10.2012:
- In MidiEventBase::read() Repair controllers saved with lo byte 0xff. (Tim)
No such control. It was supposed to be 0x00. It's an error caused by a previous bug, fixed now.
diff --git a/muse2/muse/widgets/mtrackinfo.cpp b/muse2/muse/widgets/mtrackinfo.cpp
index 23c7bf34..80b9a76a 100644
--- a/muse2/muse/widgets/mtrackinfo.cpp
+++ b/muse2/muse/widgets/mtrackinfo.cpp
@@ -206,8 +206,8 @@ MidiTrackInfo::MidiTrackInfo(QWidget* parent, MusECore::Track* sel_track) : QWid
connect(iHBank, SIGNAL(valueChanged(int)), SLOT(iProgHBankChanged()));
connect(iLBank, SIGNAL(valueChanged(int)), SLOT(iProgLBankChanged()));
connect(iProgram, SIGNAL(valueChanged(int)), SLOT(iProgramChanged()));
- connect(iHBank, SIGNAL(ctrlDoubleClicked()), SLOT(iProgramDoubleClicked()));
- connect(iLBank, SIGNAL(ctrlDoubleClicked()), SLOT(iProgramDoubleClicked()));
+ connect(iHBank, SIGNAL(ctrlDoubleClicked()), SLOT(iProgHBankDoubleCLicked()));
+ connect(iLBank, SIGNAL(ctrlDoubleClicked()), SLOT(iProgLBankDoubleCLicked()));
connect(iProgram, SIGNAL(ctrlDoubleClicked()), SLOT(iProgramDoubleClicked()));
connect(iLautst, SIGNAL(valueChanged(int)), SLOT(iLautstChanged(int)));
connect(iLautst, SIGNAL(ctrlDoubleClicked()), SLOT(iLautstDoubleClicked()));
@@ -1190,6 +1190,184 @@ void MidiTrackInfo::recEchoToggled(bool v)
}
//---------------------------------------------------------
+// iProgHBankDoubleCLicked
+//---------------------------------------------------------
+
+void MidiTrackInfo::iProgHBankDoubleCLicked()
+{
+ if(!selected)
+ return;
+ MusECore::MidiTrack* track = (MusECore::MidiTrack*)selected;
+ int port = track->outPort();
+ int chan = track->outChannel();
+ MusECore::MidiPort* mp = &MusEGlobal::midiPorts[port];
+ MusECore::MidiController* mctl = mp->midiController(MusECore::CTRL_PROGRAM);
+
+ if(!track || !mctl)
+ return;
+
+ int lastv = mp->lastValidHWCtrlState(chan, MusECore::CTRL_PROGRAM);
+ int curv = mp->hwCtrlState(chan, MusECore::CTRL_PROGRAM);
+
+ if(curv == MusECore::CTRL_VAL_UNKNOWN)
+ {
+ // If no value has ever been set yet, use the current knob value
+ // (or the controller's initial value?) to 'turn on' the controller.
+ if(lastv == MusECore::CTRL_VAL_UNKNOWN)
+ {
+ int kiv = mctl->initVal();
+ //int kiv = lrint(_knob->value());
+ if(kiv == MusECore::CTRL_VAL_UNKNOWN)
+ kiv = 0;
+ //else
+ //{
+ //if(kiv < mctrl->minVal())
+ // kiv = mctrl->minVal();
+ //if(kiv > mctrl->maxVal())
+ // kiv = mctrl->maxVal();
+ //kiv += mctrl->bias();
+ //}
+
+ //MusECore::MidiPlayEvent ev(0, port, chan, MusECore::ME_CONTROLLER, num, kiv);
+ MusECore::MidiPlayEvent ev(0, port, chan, MusECore::ME_CONTROLLER, MusECore::CTRL_PROGRAM, kiv);
+ MusEGlobal::audio->msgPlayMidiEvent(&ev);
+ }
+ else
+ {
+ // TODO
+// int hbank = (lastv >> 16) & 0xff;
+// if(hbank == 0xff)
+// lastv &= 0xffff;
+// else
+// lastv |= 0xff0000;
+
+ MusECore::MidiPlayEvent ev(0, port, chan, MusECore::ME_CONTROLLER, MusECore::CTRL_PROGRAM, lastv);
+ MusEGlobal::audio->msgPlayMidiEvent(&ev);
+ }
+ }
+ else
+ {
+ // TODO
+// int lasthb = 0xff;
+// if(lastv != MusECore::CTRL_VAL_UNKNOWN)
+// lasthb = (lastv >> 16) & 0xff;
+//
+// int hbank = (curv >> 16) & 0xff;
+// if(hbank == 0xff)
+// {
+// curv &= 0xffff;
+// if(lasthb != 0xff)
+// curv |= lasthb;
+// }
+// else
+// curv |= 0xff0000;
+
+ if(mp->hwCtrlState(chan, MusECore::CTRL_PROGRAM) != MusECore::CTRL_VAL_UNKNOWN)
+ MusEGlobal::audio->msgSetHwCtrlState(mp, chan, MusECore::CTRL_PROGRAM, MusECore::CTRL_VAL_UNKNOWN);
+// MusECore::MidiPlayEvent ev(0, port, chan, MusECore::ME_CONTROLLER, MusECore::CTRL_PROGRAM, curv);
+// MusEGlobal::audio->msgPlayMidiEvent(&ev);
+ }
+
+ MusEGlobal::song->update(SC_MIDI_CONTROLLER);
+}
+
+//---------------------------------------------------------
+// iProgLBankDoubleCLicked
+//---------------------------------------------------------
+
+void MidiTrackInfo::iProgLBankDoubleCLicked()
+{
+ if(!selected)
+ return;
+ MusECore::MidiTrack* track = (MusECore::MidiTrack*)selected;
+ int port = track->outPort();
+ int chan = track->outChannel();
+ MusECore::MidiPort* mp = &MusEGlobal::midiPorts[port];
+ MusECore::MidiController* mctl = mp->midiController(MusECore::CTRL_PROGRAM);
+
+ if(!track || !mctl)
+ return;
+
+ int lastv = mp->lastValidHWCtrlState(chan, MusECore::CTRL_PROGRAM);
+ int curv = mp->hwCtrlState(chan, MusECore::CTRL_PROGRAM);
+
+ if(curv == MusECore::CTRL_VAL_UNKNOWN)
+ {
+ // If no value has ever been set yet, use the current knob value
+ // (or the controller's initial value?) to 'turn on' the controller.
+ if(lastv == MusECore::CTRL_VAL_UNKNOWN)
+ {
+ int kiv = mctl->initVal();
+ //int kiv = lrint(_knob->value());
+ if(kiv == MusECore::CTRL_VAL_UNKNOWN)
+ kiv = 0xff0000;
+ //else
+ //{
+ //if(kiv < mctrl->minVal())
+ // kiv = mctrl->minVal();
+ //if(kiv > mctrl->maxVal())
+ // kiv = mctrl->maxVal();
+ //kiv += mctrl->bias();
+ //}
+
+ //MusECore::MidiPlayEvent ev(0, port, chan, MusECore::ME_CONTROLLER, num, kiv);
+ MusECore::MidiPlayEvent ev(0, port, chan, MusECore::ME_CONTROLLER, MusECore::CTRL_PROGRAM, kiv);
+ MusEGlobal::audio->msgPlayMidiEvent(&ev);
+ }
+ else
+ {
+// TODO
+// int lbank = (lastv >> 8) & 0xff;
+// if(lbank == 0xff)
+// lastv &= 0xff00ff;
+// else
+// {
+// lastv |= 0xffff00;
+// //int hbank = (lastv >> 16) & 0xff;
+// //if(hbank != 0xff)
+// // lastv |= 0xff0000;
+// }
+
+ MusECore::MidiPlayEvent ev(0, port, chan, MusECore::ME_CONTROLLER, MusECore::CTRL_PROGRAM, lastv);
+ MusEGlobal::audio->msgPlayMidiEvent(&ev);
+ }
+ }
+ else
+ {
+// TODO
+// //int lasthb = 0xff;
+// int lastlb = 0xff;
+// if(lastv != MusECore::CTRL_VAL_UNKNOWN)
+// {
+// //lasthb = (lastv >> 16) & 0xff;
+// lastlb = (lastv >> 8) & 0xff;
+// }
+//
+// int lbank = (curv >> 8) & 0xff;
+// if(lbank == 0xff)
+// {
+// curv &= 0xff00ff;
+// if(lastlb != 0xff)
+// curv |= lastlb;
+// }
+// else
+// {
+// curv |= 0xffff00;
+// //int hbank = (curv >> 16) & 0xff;
+// //if(hbank != 0xff)
+// // curv |= 0xff0000;
+// }
+
+ if(mp->hwCtrlState(chan, MusECore::CTRL_PROGRAM) != MusECore::CTRL_VAL_UNKNOWN)
+ MusEGlobal::audio->msgSetHwCtrlState(mp, chan, MusECore::CTRL_PROGRAM, MusECore::CTRL_VAL_UNKNOWN);
+// MusECore::MidiPlayEvent ev(0, port, chan, MusECore::ME_CONTROLLER, MusECore::CTRL_PROGRAM, curv);
+// MusEGlobal::audio->msgPlayMidiEvent(&ev);
+ }
+
+ MusEGlobal::song->update(SC_MIDI_CONTROLLER);
+}
+
+//---------------------------------------------------------
// iProgramDoubleClicked
//---------------------------------------------------------
@@ -1218,7 +1396,7 @@ void MidiTrackInfo::iProgramDoubleClicked()
int kiv = mctl->initVal();
//int kiv = lrint(_knob->value());
if(kiv == MusECore::CTRL_VAL_UNKNOWN)
- kiv = 0;
+ kiv = 0xffff00;
//else
//{
//if(kiv < mctrl->minVal())
diff --git a/muse2/muse/widgets/mtrackinfo.h b/muse2/muse/widgets/mtrackinfo.h
index fd21f066..d6b3f32a 100644
--- a/muse2/muse/widgets/mtrackinfo.h
+++ b/muse2/muse/widgets/mtrackinfo.h
@@ -51,7 +51,9 @@ class MidiTrackInfo : public QWidget, public Ui::MidiTrackInfoBase
void iOutputChannelChanged(int);
void iOutputPortChanged(int);
void iProgHBankChanged();
+ void iProgHBankDoubleCLicked();
void iProgLBankChanged();
+ void iProgLBankDoubleCLicked();
void iProgramChanged();
void iProgramDoubleClicked();
void iLautstChanged(int);