summaryrefslogtreecommitdiff
path: root/muse2/muse/midictrl.cpp
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/midictrl.cpp
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/midictrl.cpp')
-rw-r--r--muse2/muse/midictrl.cpp55
1 files changed, 43 insertions, 12 deletions
diff --git a/muse2/muse/midictrl.cpp b/muse2/muse/midictrl.cpp
index 56b1b2a8..14dd666e 100644
--- a/muse2/muse/midictrl.cpp
+++ b/muse2/muse/midictrl.cpp
@@ -250,11 +250,12 @@ MidiController::MidiController()
_minVal = 0;
_maxVal = 127;
_initVal = 0;
+ _showInTracks = ShowInDrum | ShowInMidi;
updateBias();
}
-MidiController::MidiController(const QString& s, int n, int min, int max, int init)
- : _name(s), _num(n), _minVal(min), _maxVal(max), _initVal(init)
+MidiController::MidiController(const QString& s, int n, int min, int max, int init, int show_in_track)
+ : _name(s), _num(n), _minVal(min), _maxVal(max), _initVal(init), _showInTracks(show_in_track)
{
updateBias();
}
@@ -276,6 +277,7 @@ void MidiController::copy(const MidiController &mc)
_maxVal = mc._maxVal;
_initVal = mc._initVal;
_bias = mc._bias;
+ _showInTracks = mc._showInTracks;
}
//---------------------------------------------------------
@@ -308,7 +310,7 @@ MidiController::ControllerType midiControllerType(int num)
return MidiController::Program;
if (num == CTRL_VELOCITY)
return MidiController::Velo;
- if (num == CTRL_POLYAFTER)
+ if ((num | 0xff) == CTRL_POLYAFTER)
return MidiController::PolyAftertouch;
if (num == CTRL_AFTERTOUCH)
return MidiController::Aftertouch;
@@ -323,10 +325,10 @@ MidiController::ControllerType midiControllerType(int num)
// midiCtrlTerms2Number
//---------------------------------------------------------
-int midiCtrlTerms2Number(int type_num, int ctrl)
+int midiCtrlTerms2Number(MidiController::ControllerType type, int ctrl)
{
ctrl &= 0xffff;
- switch(type_num)
+ switch(type)
{
case MidiController::Controller7:
return ctrl & 0xff;
@@ -442,7 +444,7 @@ void MidiController::write(int level, Xml& xml) const
int l = _num & 0x7f;
QString sl;
- if ((_num & 0xff) == 0xff)
+ if (isPerNoteController())
sl = "pitch";
else
sl.setNum(l);
@@ -504,6 +506,10 @@ void MidiController::write(int level, Xml& xml) const
if(_initVal != CTRL_VAL_UNKNOWN)
xml.nput(" init=\"%d\"", _initVal);
}
+
+ if(_showInTracks != (ShowInDrum | ShowInMidi))
+ xml.nput(" showType=\"%d\"", _showInTracks);
+
xml.put(" />");
}
@@ -542,9 +548,7 @@ void MidiController::read(Xml& xml)
else if (tag == "h")
h = xml.s2().toInt(&ok, base);
else if (tag == "l") {
- // By T356 08/16/08. Changed wildcard to '*'.
- // Changed back to 'pitch' again.
- // Support instrument files with '*' as wildcard.
+ // Support instrument files with '*' or 'pitch' as wildcard.
if ((xml.s2() == "*") || (xml.s2() == "pitch"))
l = 0xff;
else
@@ -556,6 +560,8 @@ void MidiController::read(Xml& xml)
_maxVal = xml.s2().toInt(&ok, base);
else if (tag == "init")
_initVal = xml.s2().toInt(&ok, base);
+ else if (tag == "showType")
+ _showInTracks = xml.s2().toInt(&ok, base);
}
break;
case Xml::TagStart:
@@ -625,7 +631,6 @@ void MidiController::read(Xml& xml)
}
if (_minVal == NOT_SET)
_minVal = 0;
-
updateBias();
return;
}
@@ -641,10 +646,10 @@ void MidiController::read(Xml& xml)
int MidiController::genNum(MidiController::ControllerType t, int h, int l)
{
- int val = (h << 8) + l;
+ int val = (h << 8) | (l & 0xff);
switch(t) {
case Controller7:
- return l;
+ return l & 0xff;
case Controller14:
return val + CTRL_14_OFFSET;
case RPN:
@@ -881,4 +886,30 @@ MidiControllerList::MidiControllerList(const MidiControllerList& mcl) : std::map
}
}
+//---------------------------------------------------------
+// ctrlAvailable (static)
+// Check if either a per-note controller, or else a regular controller already exists.
+//---------------------------------------------------------
+
+bool MidiControllerList::ctrlAvailable(int find_num, MidiController* ignore_this)
+{
+ MusECore::ciMidiController imc;
+ for(imc = begin(); imc != end(); ++ imc)
+ {
+ // Ignore this controller.
+ if(ignore_this && imc->second == ignore_this)
+ continue;
+ int n = imc->second->num();
+ if(((find_num & 0xff) == 0xff) && ((n | 0xff) == find_num))
+ break;
+ if(imc->second->isPerNoteController() && ((find_num | 0xff) == n))
+ break;
+ if(find_num == n)
+ break;
+ }
+ return imc == end();
+}
+
+
+
} // namespace MusECore