summaryrefslogtreecommitdiff
path: root/muse2/muse/midiseq.cpp
diff options
context:
space:
mode:
authorTim E. Real <termtech@rogers.com>2011-04-28 06:14:25 +0000
committerTim E. Real <termtech@rogers.com>2011-04-28 06:14:25 +0000
commitdcef2c49e36e86036a4caa08a6bcc0580cc53da7 (patch)
tree3c8832519a9e41c5c14f8e740a49294ed0251e7c /muse2/muse/midiseq.cpp
parente2cec3f03fdee64da1c5080498476c1cdd43bbdb (diff)
Small scoreedit and dssi controls out fix. More separation of Alsa/Jack midi processing -
as a possible fix for crash report by Geoff B. Please see ChangeLog
Diffstat (limited to 'muse2/muse/midiseq.cpp')
-rw-r--r--muse2/muse/midiseq.cpp177
1 files changed, 100 insertions, 77 deletions
diff --git a/muse2/muse/midiseq.cpp b/muse2/muse/midiseq.cpp
index 5e42d547..aaf3f7dd 100644
--- a/muse2/muse/midiseq.cpp
+++ b/muse2/muse/midiseq.cpp
@@ -131,91 +131,114 @@ void MidiSeq::processMsg(const ThreadMsg* m)
//---------------------------------------------------------
void MidiSeq::processStop()
- {
- // p3.3.28
- playStateExt = false; // not playing
-
- //
- // stop stuck notes
- //
- for (iMidiDevice id = midiDevices.begin(); id != midiDevices.end(); ++id) {
- MidiDevice* md = *id;
- if (md->midiPort() == -1)
- continue;
- MPEventList* pel = md->playEvents();
- MPEventList* sel = md->stuckNotes();
- pel->clear();
- for (iMPEvent i = sel->begin(); i != sel->end(); ++i) {
- MidiPlayEvent ev = *i;
- ev.setTime(0);
- pel->add(ev);
- }
- sel->clear();
- //md->setNextPlayEvent(pel->begin()); // Removed p4.0.15
- }
- }
+{
+ // p3.3.28
+ // TODO Try to move this into Audio::stopRolling(). p4.0.22
+ playStateExt = false; // not playing
+
+ //
+ // clear Alsa midi device notes and stop stuck notes
+ // Jack midi devices are handled in Audio::stopRolling()
+ //
+ for(iMidiDevice id = midiDevices.begin(); id != midiDevices.end(); ++id)
+ {
+ MidiDevice* md = *id;
+ if(md->deviceType() == MidiDevice::JACK_MIDI) // p4.0.22
+ continue;
+ md->handleStop(); // p4.0.22
+ /*
+ if (md->midiPort() == -1)
+ continue;
+ MPEventList* pel = md->playEvents();
+ MPEventList* sel = md->stuckNotes();
+ pel->clear();
+ for(iMPEvent i = sel->begin(); i != sel->end(); ++i)
+ {
+ MidiPlayEvent ev = *i;
+ ev.setTime(0);
+ pel->add(ev);
+ }
+ sel->clear();
+ //md->setNextPlayEvent(pel->begin()); // Removed p4.0.15
+ */
+ }
+}
//---------------------------------------------------------
// processSeek
//---------------------------------------------------------
void MidiSeq::processSeek()
+{
+ int pos = audio->tickPos();
+
+ // TODO Try to move this into audio::seek(). p4.0.22
+ if (pos == 0 && !song->record())
+ audio->initDevices();
+
+ //---------------------------------------------------
+ // set all controller
+ //---------------------------------------------------
+
+ for (iMidiDevice i = midiDevices.begin(); i != midiDevices.end(); ++i)
+ {
+ MidiDevice* md = *i;
+ //
+ // Jack midi devices are handled in Audio::seek()
+ //
+ if(md->deviceType() == MidiDevice::JACK_MIDI) // p4.0.22
+ continue;
+ md->handleSeek(); // p4.0.22
+ /*
+ int port = md->midiPort();
+ if (port == -1)
+ continue;
+ MidiPort* mp = &midiPorts[port];
+ MidiCtrlValListList* cll = mp->controller();
+
+ MPEventList* el = md->playEvents();
+
+ if (audio->isPlaying())
+ {
+ // stop all notes
+ el->clear();
+ MPEventList* sel = dev->stuckNotes();
+ for (iMPEvent i = sel->begin(); i != sel->end(); ++i)
{
- int pos = audio->tickPos();
- if (pos == 0 && !song->record())
- audio->initDevices();
-
- //---------------------------------------------------
- // set all controller
- //---------------------------------------------------
-
- for (iMidiDevice i = midiDevices.begin(); i != midiDevices.end(); ++i) {
- MidiDevice* dev = *i;
- int port = dev->midiPort();
- if (port == -1)
- continue;
- MidiPort* mp = &midiPorts[port];
- MidiCtrlValListList* cll = mp->controller();
-
- MPEventList* el = dev->playEvents();
-
- if (audio->isPlaying()) {
- // stop all notes
- el->clear();
- MPEventList* sel = dev->stuckNotes();
- for (iMPEvent i = sel->begin(); i != sel->end(); ++i) {
- MidiPlayEvent ev = *i;
- ev.setTime(0);
- el->add(ev);
- }
- sel->clear();
- }
- //else
- // Removed p4.0.15 Device now leaves beginning pointing at next event,
- // immediately after playing some notes.
- // NOTE: This removal needs testing. I'm not sure about this.
- // el->erase(el->begin(), dev->nextPlayEvent());
-
- for (iMidiCtrlValList ivl = cll->begin(); ivl != cll->end(); ++ivl) {
- MidiCtrlValList* vl = ivl->second;
- //int val = vl->value(pos);
- //if (val != CTRL_VAL_UNKNOWN) {
- // int channel = ivl->first >> 24;
- // el->add(MidiPlayEvent(0, port, channel, ME_CONTROLLER, vl->num(), val));
- // }
- iMidiCtrlVal imcv = vl->iValue(pos);
- if(imcv != vl->end())
- {
- Part* p = imcv->second.part;
- unsigned t = (unsigned)imcv->first;
- // Do not add values that are outside of the part.
- if(p && t >= p->tick() && t < (p->tick() + p->lenTick()) )
- el->add(MidiPlayEvent(0, port, ivl->first >> 24, ME_CONTROLLER, vl->num(), imcv->second.val));
- }
- }
- //dev->setNextPlayEvent(el->begin()); // Removed p4.0.15
- }
+ MidiPlayEvent ev = *i;
+ ev.setTime(0);
+ el->add(ev);
+ }
+ sel->clear();
+ }
+ //else
+ // Removed p4.0.15 Device now leaves beginning pointing at next event,
+ // immediately after playing some notes.
+ // NOTE: This removal needs testing. I'm not sure about this.
+ //el->erase(el->begin(), dev->nextPlayEvent());
+
+ for (iMidiCtrlValList ivl = cll->begin(); ivl != cll->end(); ++ivl)
+ {
+ MidiCtrlValList* vl = ivl->second;
+ //int val = vl->value(pos);
+ //if (val != CTRL_VAL_UNKNOWN) {
+ // int channel = ivl->first >> 24;
+ // el->add(MidiPlayEvent(0, port, channel, ME_CONTROLLER, vl->num(), val));
+ // }
+ iMidiCtrlVal imcv = vl->iValue(pos);
+ if(imcv != vl->end())
+ {
+ Part* p = imcv->second.part;
+ unsigned t = (unsigned)imcv->first;
+ // Do not add values that are outside of the part.
+ if(p && t >= p->tick() && t < (p->tick() + p->lenTick()) )
+ el->add(MidiPlayEvent(0, port, ivl->first >> 24, ME_CONTROLLER, vl->num(), imcv->second.val));
}
+ }
+ //dev->setNextPlayEvent(el->begin()); // Removed p4.0.15
+ */
+ }
+}
//---------------------------------------------------------
// MidiSeq