diff options
author | Tim E. Real <termtech@rogers.com> | 2012-11-13 08:36:20 +0000 |
---|---|---|
committer | Tim E. Real <termtech@rogers.com> | 2012-11-13 08:36:20 +0000 |
commit | a247e60904516800a3874688e368979b9b1e7bf8 (patch) | |
tree | 0df00fdfbc69e919234a4ad65369c4787c934d9c /muse2/muse | |
parent | 33250e6a085d51efab1b061e13bd635c804209d0 (diff) |
Added aftertouch controller to fluidsynth, and aftertouch/poly-aftertouch to DSSI.
Diffstat (limited to 'muse2/muse')
-rw-r--r-- | muse2/muse/dssihost.cpp | 62 | ||||
-rw-r--r-- | muse2/muse/midiport.cpp | 4 |
2 files changed, 64 insertions, 2 deletions
diff --git a/muse2/muse/dssihost.cpp b/muse2/muse/dssihost.cpp index c76631e4..70db2a47 100644 --- a/muse2/muse/dssihost.cpp +++ b/muse2/muse/dssihost.cpp @@ -1112,6 +1112,32 @@ bool DssiSynthIF::processEvent(const MusECore::MidiPlayEvent& e, snd_seq_event_t return true; } + if(a == MusECore::CTRL_AFTERTOUCH) + { + #ifdef DSSI_DEBUG + fprintf(stderr, "DssiSynthIF::processEvent midi event is MusECore::ME_CONTROLLER, dataA is MusECore::CTRL_AFTERTOUCH\n"); + #endif + + snd_seq_ev_clear(event); + event->queue = SND_SEQ_QUEUE_DIRECT; + snd_seq_ev_set_chanpress(event, chn, b); + // Event pointer filled. Return true. + return true; + } + + if((a | 0xff) == MusECore::CTRL_POLYAFTER) + { + #ifdef DSSI_DEBUG + fprintf(stderr, "DssiSynthIF::processEvent midi event is MusECore::ME_CONTROLLER, dataA is MusECore::CTRL_POLYAFTER\n"); + #endif + + snd_seq_ev_clear(event); + event->queue = SND_SEQ_QUEUE_DIRECT; + snd_seq_ev_set_keypress(event, chn, a & 0x7f, b & 0x7f); + // Event pointer filled. Return true. + return true; + } + const LADSPA_Descriptor* ld = dssi->LADSPA_Plugin; MusECore::ciMidiCtl2LadspaPort ip = synth->midiCtl2PortMap.find(a); @@ -1219,6 +1245,11 @@ bool DssiSynthIF::processEvent(const MusECore::MidiPlayEvent& e, snd_seq_event_t event->queue = SND_SEQ_QUEUE_DIRECT; snd_seq_ev_set_chanpress(event, chn, a); break; + case MusECore::ME_POLYAFTER: + snd_seq_ev_clear(event); + event->queue = SND_SEQ_QUEUE_DIRECT; + snd_seq_ev_set_keypress(event, chn, a & 0x7f, b & 0x7f); + break; case MusECore::ME_SYSEX: { #ifdef DSSI_DEBUG @@ -1615,6 +1646,19 @@ MusECore::iMPEvent DssiSynthIF::getData(MusECore::MidiPort* /*mp*/, MusECore::MP if(!mp->setHwCtrlState(start_event->channel(), MusECore::CTRL_PITCH, da)) continue; } + else if(start_event->type() == MusECore::ME_AFTERTOUCH) + { + int da = mp->limitValToInstrCtlRange(MusECore::CTRL_AFTERTOUCH, start_event->dataA()); + if(!mp->setHwCtrlState(start_event->channel(), MusECore::CTRL_AFTERTOUCH, da)) + continue; + } + else if(start_event->type() == MusECore::ME_POLYAFTER) + { + int ctl = (MusECore::CTRL_POLYAFTER & ~0xff) | (start_event->dataA() & 0x7f); + int db = mp->limitValToInstrCtlRange(ctl, start_event->dataB()); + if(!mp->setHwCtrlState(start_event->channel(), ctl , db)) + continue; + } else if(start_event->type() == MusECore::ME_PROGRAM) { if(!mp->setHwCtrlState(start_event->channel(), MusECore::CTRL_PROGRAM, start_event->dataA())) @@ -2160,7 +2204,23 @@ void DssiSynthIF::populatePatchPopup(MusEGui::PopupMenu* menu, int /*ch*/, bool int DssiSynthIF::getControllerInfo(int id, const char** name, int* ctrl, int* min, int* max, int* initval) { int controlPorts = synth->_controlInPorts; - if(id >= controlPorts) + if(id == controlPorts || id == controlPorts + 1) + { + // + // It is unknown at this point whether or not a synth recognizes aftertouch and poly aftertouch + // (channel and key pressure) midi messages, so add support for them now (as controllers). + // + if(id == controlPorts) + *ctrl = MusECore::CTRL_POLYAFTER; + else if(id == controlPorts + 1) + *ctrl = MusECore::CTRL_AFTERTOUCH; + *min = 0; + *max = 127; + *initval = MusECore::CTRL_VAL_UNKNOWN; + *name = midiCtrlName(*ctrl).toLatin1().constData(); + return ++id; + } + else if(id >= controlPorts + 2) return 0; const DSSI_Descriptor* dssi = synth->dssi; diff --git a/muse2/muse/midiport.cpp b/muse2/muse/midiport.cpp index 61e7ab50..e4759d31 100644 --- a/muse2/muse/midiport.cpp +++ b/muse2/muse/midiport.cpp @@ -794,7 +794,9 @@ int MidiPort::limitValToInstrCtlRange(int ctl, int val) return val; MidiControllerList* cl = _instrument->controller(); - + + // FIXME: This might be optimized by calling midiController instead, + // and simply asking if it's a drum controller. Saves one list iteration. // Is it a drum controller? MidiController *mc = drumController(ctl); if(!mc) |