summaryrefslogtreecommitdiff
path: root/muse2/muse
diff options
context:
space:
mode:
authorTim E. Real <termtech@rogers.com>2012-10-28 01:34:16 +0000
committerTim E. Real <termtech@rogers.com>2012-10-28 01:34:16 +0000
commitb45ce65ca39817a0678f2172410b71433f79f736 (patch)
tree4a193aaa1ba899f17e298826ae4b44a15a763b7a /muse2/muse
parentb1776f093d4b87ad2635990f429f4503157f6288 (diff)
Improved: Eliminated copious unrequired "controller" sections from songs and templates.
Eliminated ALL "controller" and "midiport" sections from built-in templates. For template "synth.med", changed synth ports to 198 and 199. Improved: Templates, use your chosen default output port/channel from the midi ports setup dialog.
Diffstat (limited to 'muse2/muse')
-rw-r--r--muse2/muse/conf.cpp17
-rw-r--r--muse2/muse/midictrl.cpp18
-rw-r--r--muse2/muse/midictrl.h9
-rw-r--r--muse2/muse/midiport.cpp32
-rw-r--r--muse2/muse/midiport.h2
-rw-r--r--muse2/muse/track.cpp47
6 files changed, 102 insertions, 23 deletions
diff --git a/muse2/muse/conf.cpp b/muse2/muse/conf.cpp
index 54a02265..ea2390c3 100644
--- a/muse2/muse/conf.cpp
+++ b/muse2/muse/conf.cpp
@@ -1167,18 +1167,31 @@ static void writeSeqConfiguration(int level, Xml& xml, bool writePortInfo)
for (int k = 0; k < MIDI_CHANNELS; ++k) {
int min = k << 24;
int max = min + 0x100000;
- xml.tag(level++, "channel idx=\"%d\"", k);
+ bool found = false;
iMidiCtrlValList s = vll->lower_bound(min);
iMidiCtrlValList e = vll->lower_bound(max);
if (s != e) {
for (iMidiCtrlValList i = s; i != e; ++i) {
+ int ctl = i->second->num();
+ if(mport->drumController(ctl)) // Including internals like polyaftertouch
+ ctl |= 0xff;
+ // Don't bother saving these empty controllers since they are already always added!
+ if(defaultManagedMidiController.find(ctl) != defaultManagedMidiController.end()
+ && i->second->hwVal() == CTRL_VAL_UNKNOWN)
+ continue;
+ if(!found)
+ {
+ xml.tag(level++, "channel idx=\"%d\"", k);
+ found = true;
+ }
xml.tag(level++, "controller id=\"%d\"", i->second->num());
if (i->second->hwVal() != CTRL_VAL_UNKNOWN)
xml.intTag(level, "val", i->second->hwVal());
xml.etag(level--, "controller");
}
}
- xml.etag(level--, "channel");
+ if(found)
+ xml.etag(level--, "channel");
}
xml.etag(level--, "midiport");
}
diff --git a/muse2/muse/midictrl.cpp b/muse2/muse/midictrl.cpp
index b87ea8d1..56b1b2a8 100644
--- a/muse2/muse/midictrl.cpp
+++ b/muse2/muse/midictrl.cpp
@@ -81,12 +81,15 @@ 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);
-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);
+MidiController pitchCtrl("PitchBend", CTRL_PITCH, -8192, +8191, 0);
+MidiController programCtrl("Program", CTRL_PROGRAM, 0, 0xffffff, 0);
+MidiController mastervolCtrl("MasterVolume", CTRL_MASTER_VOLUME, 0, 0x3fff, 0x3000);
+MidiController volumeCtrl("MainVolume", CTRL_VOLUME, 0, 127, 100);
+MidiController panCtrl("Pan", CTRL_PANPOT, -64, 63, 0);
+MidiController reverbSendCtrl("ReverbSend", CTRL_REVERB_SEND, 0, 127, 0);
+MidiController chorusSendCtrl("ChorusSend", CTRL_CHORUS_SEND, 0, 127, 0);
+MidiController variationSendCtrl("VariationSend", CTRL_VARIATION_SEND, 0, 127, 0);
//---------------------------------------------------------
// ctrlType2Int
@@ -151,6 +154,9 @@ void initMidiController()
defaultMidiController.add(&mastervolCtrl);
defaultMidiController.add(&volumeCtrl);
defaultMidiController.add(&panCtrl);
+ defaultMidiController.add(&reverbSendCtrl);
+ defaultMidiController.add(&chorusSendCtrl);
+ defaultMidiController.add(&variationSendCtrl);
}
//---------------------------------------------------------
diff --git a/muse2/muse/midictrl.h b/muse2/muse/midictrl.h
index 5ff3f129..d4cd1079 100644
--- a/muse2/muse/midictrl.h
+++ b/muse2/muse/midictrl.h
@@ -256,7 +256,14 @@ extern MidiController::ControllerType ctrlType2Int(const QString& s);
extern QString midiCtrlName(int ctrl, bool fullyQualified = false);
extern QString midiCtrlNumString(int ctrl, bool fullyQualified = false);
extern MidiController veloCtrl;
-
+extern MidiController pitchCtrl;
+extern MidiController programCtrl;
+extern MidiController mastervolCtrl;
+extern MidiController volumeCtrl;
+extern MidiController panCtrl;
+extern MidiController reverbSendCtrl;
+extern MidiController chorusSendCtrl;
+extern MidiController variationSendCtrl;
typedef std::map<int, int, std::less<int> > MidiCtl2LadspaPortMap;
typedef MidiCtl2LadspaPortMap::iterator iMidiCtl2LadspaPort;
diff --git a/muse2/muse/midiport.cpp b/muse2/muse/midiport.cpp
index 4365d698..f7a3d5e3 100644
--- a/muse2/muse/midiport.cpp
+++ b/muse2/muse/midiport.cpp
@@ -50,14 +50,32 @@ MusECore::MidiPort midiPorts[MIDI_PORTS];
namespace MusECore {
+
+MidiControllerList defaultManagedMidiController;
+
//---------------------------------------------------------
// initMidiPorts
//---------------------------------------------------------
void initMidiPorts()
{
+ defaultManagedMidiController.add(&pitchCtrl);
+ defaultManagedMidiController.add(&programCtrl);
+ defaultManagedMidiController.add(&volumeCtrl);
+ defaultManagedMidiController.add(&panCtrl);
+ defaultManagedMidiController.add(&reverbSendCtrl);
+ defaultManagedMidiController.add(&chorusSendCtrl);
+ defaultManagedMidiController.add(&variationSendCtrl);
+
for (int i = 0; i < MIDI_PORTS; ++i) {
MidiPort* port = &MusEGlobal::midiPorts[i];
+
+ //
+ // create minimum set of managed controllers
+ // to make midi mixer operational
+ //
+ port->addDefaultControllers();
+
///port->setInstrument(genericMidiInstrument);
port->setInstrument(registerMidiInstrument("GM")); // Changed by Tim.
port->syncInfo().setPort(i);
@@ -81,12 +99,6 @@ MidiPort::MidiPort()
_instrument = 0;
_controller = new MidiCtrlValListList();
_foundInSongFile = false;
-
- //
- // create minimum set of managed controllers
- // to make midi mixer operational
- //
- addDefaultControllers();
}
//---------------------------------------------------------
@@ -739,9 +751,8 @@ MidiCtrlValList* MidiPort::addManagedController(int channel, int ctrl)
void MidiPort::addDefaultControllers()
{
for (int i = 0; i < MIDI_CHANNELS; ++i) {
- addManagedController(i, CTRL_PROGRAM);
- addManagedController(i, CTRL_VOLUME);
- addManagedController(i, CTRL_PANPOT);
+ for(ciMidiController imc = defaultManagedMidiController.begin(); imc != defaultManagedMidiController.end(); ++imc)
+ addManagedController(i, imc->second->num());
_automationType[i] = AUTO_READ;
}
}
@@ -1074,7 +1085,8 @@ MidiController* MidiPort::drumController(int ctl)
if(((ctl - CTRL_RPN_OFFSET >= 0) && (ctl - CTRL_RPN_OFFSET <= 0xffff)) ||
((ctl - CTRL_NRPN_OFFSET >= 0) && (ctl - CTRL_NRPN_OFFSET <= 0xffff)) ||
((ctl - CTRL_RPN14_OFFSET >= 0) && (ctl - CTRL_RPN14_OFFSET <= 0xffff)) ||
- ((ctl - CTRL_NRPN14_OFFSET >= 0) && (ctl - CTRL_NRPN14_OFFSET <= 0xffff)))
+ ((ctl - CTRL_NRPN14_OFFSET >= 0) && (ctl - CTRL_NRPN14_OFFSET <= 0xffff)) ||
+ ((ctl - CTRL_INTERNAL_OFFSET >= 0) && (ctl - CTRL_INTERNAL_OFFSET <= 0xffff))) // Include internals
{
// Does the instrument have a drum controller to match this controller's number?
iMidiController imc = cl->find(ctl | 0xff);
diff --git a/muse2/muse/midiport.h b/muse2/muse/midiport.h
index 6f92cb02..3a1feba6 100644
--- a/muse2/muse/midiport.h
+++ b/muse2/muse/midiport.h
@@ -37,6 +37,7 @@ class MidiDevice;
class Part;
//class MidiSyncInfo;
class MidiController;
+class MidiControllerList;
class MidiCtrlValListList;
class MidiCtrlValList;
class MidiInstrument;
@@ -164,6 +165,7 @@ extern void setPortExclusiveDefOutChan(int /*port*/, int /*chan*/);
#endif
extern QMenu* midiPortsPopup(QWidget* parent = 0, int checkPort = -1);
+extern MidiControllerList defaultManagedMidiController;
} // namespace MusECore
diff --git a/muse2/muse/track.cpp b/muse2/muse/track.cpp
index 0fa419c6..b18a9410 100644
--- a/muse2/muse/track.cpp
+++ b/muse2/muse/track.cpp
@@ -1037,10 +1037,49 @@ void MidiTrack::read(Xml& xml)
if(p)
parts()->add(p);
}
- else if (tag == "device")
- setOutPort(xml.parseInt());
- else if (tag == "channel")
- setOutChannel(xml.parseInt());
+ // TODO: These two device and channel sections will need to change
+ // if and when multiple output routes are supported.
+ // For now just look for the first default (there's only one)...
+ else if (tag == "device") {
+ int port = xml.parseInt();
+ if(port == -1)
+ {
+ for(int i = 0; i < MIDI_PORTS; ++i)
+ {
+ if(MusEGlobal::midiPorts[i].defaultOutChannels())
+ {
+ port = i;
+ break;
+ }
+ }
+ }
+ if(port == -1)
+ port = 0;
+ setOutPort(port);
+ }
+ else if (tag == "channel") {
+ int chan = xml.parseInt();
+ if(chan == -1)
+ {
+ for(int i = 0; i < MIDI_PORTS; ++i)
+ {
+ int defchans = MusEGlobal::midiPorts[i].defaultOutChannels();
+ for(int c = 0; c < MIDI_CHANNELS; ++c)
+ {
+ if(defchans & (1 << c))
+ {
+ chan = c;
+ break;
+ }
+ }
+ if(chan != -1)
+ break;
+ }
+ }
+ if(chan == -1)
+ chan = 0;
+ setOutChannel(chan);
+ }
else if (tag == "inportMap")
portmask = xml.parseUInt(); // Obsolete but support old files.
else if (tag == "inchannelMap")