Hi All,
Just pushed new commit, fixing stuck notes. To prove that this patch
should work right, I'll try to explain my steps. May be these results
are completely wrong, but here is the explanation:
(IMPORTANT: this results are not related to physical midi inputs - when
playing on external midi devices, ME_NOTEON and ME_NOTEOFF are sent right).
1. stuckNotes. I checked the code and decided that this mechanism is
used for shutting down notes that were not explicitly shut off by note
offs messages or by some other means. So the only message that should be
recorded for future post is ME_NOTEOFF (0x80 in midi specs).
2. The code from midi.cpp made something strange for adding events to
stuck notes array. According to midi specs, not only ME_NOTEON, but also
ME_NOTEOFF can have velocity value. For ME_NOTEOFF velocity describes
how quickly the note should be released (127 - fast release, 0 - long
release). For reference: in MusE all noteoffs from virtual instruments
are sent with velocity value = 0.
3. From dssihost.cpp I knew that ME_NOTEON message is used in rather
interesting way: if supplied velocity value is zero, ME_NOTEOFF message
is sent instead of ME_NOTEON. lv2host.cpp has the same issue until I
rewrote midi handling code and removed this check. That's why some
instruments were stuck on some notes after this change (ME_NOTEOFF was
not sent at all).
4. Again about stuck notes. It seems, that velocity for ME_NOTEOFF
message is supported by the code. When ME_NOTEOFF is received by midi
engine, but before it's send to actual midi device, velocity value is
remembered in event's _veloOff variable. When stuck notes array is
filled, this value is used as midi event velocity. But (and this is a
mystery for me) this velocity value was also used for deciding if
ME_NOTEON (if _veloOff = 0) or ME_NOTEOFF (if _veloOff > 0) was inserted
to stuck notes. The problem was that stuckNotes was filled with
ME_NOTEON and velocity = 0. It was ok for this code (from dssihost.cpp):
if(b)
snd_seq_ev_set_noteon(event, chn, a, b);
else
snd_seq_ev_set_noteoff(event, chn, a, 0);
where b is the velocity.
But not ok when this check was not used. As for me, the above code seems
like a hack.
After forcing ME_NOTEOFF for stuckNotes all things went in a normal way.
To be sure I added code for dumping midi messages sent to lv2 synths to
check if it works right. And it did. Every ME_NOTEON message was closed
with corresponding ME_NOTEOFF. I also added velocity to noteoff message
in lv2 host code to satisfy midi specs.
P.S. midi_engine_fixes branch also have this problem, but because of
older version of lv2host.cpp (which handles ME_NOTEON with velocity=0 as
ME_NOTEOFF) everything worked right.
Regards,
Andrew
--
Regards,
Andrew
------------------------------------------------------------------------------
_______________________________________________
Lmuse-developer mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/lmuse-developer