alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
* BUG: ALSA snd-virmidi: snd-virmidi is not MIDI 1.0 specification compliant
@ 2020-03-15 11:57 Andreas Steinmetz
  2020-03-16  9:00 ` Takashi Iwai
  0 siblings, 1 reply; 2+ messages in thread
From: Andreas Steinmetz @ 2020-03-15 11:57 UTC (permalink / raw)
  To: alsa-devel; +Cc: tiwai

snd-virmidi, as of kernel 5.4.23, does not adhere to the MIDI
specification:

From MIDI 1.0 Detailed Specification, Document Version 4.2, Appendix A-
1 (RUNNING STATUS), Page A-2:

"3. Buffer is cleared when a System Exclusive or Common status message
is received."

snd-virmidi does not clear the running status in case of a SysEx
message.

How to test:

Load snd-virmidi module and get the card number of the module.
In the following 5 is assumed as the card number and device 1 is used.

You need two shells, in shell 1 do:

aconnect 'Virtual Raw MIDI 5-1':0 'Virtual Raw MIDI 5-1':0
amidi -p hw:VirMIDI,1 -d

Now, in shell 2 do:

amidi -p hw:VirMIDI,1 -S '80 01 02 F0 01 F7 80 02 03'

This sends a note off, followed by a SysEx, followed by another note
off. The result in shell 1 is:

80 01 02
F0 01 F7
02
03

So snd-virmidi did not clear the running status. The correct result
would be:

80 01 02
F0 01 F7
80 02 03



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: BUG: ALSA snd-virmidi: snd-virmidi is not MIDI 1.0 specification compliant
  2020-03-15 11:57 BUG: ALSA snd-virmidi: snd-virmidi is not MIDI 1.0 specification compliant Andreas Steinmetz
@ 2020-03-16  9:00 ` Takashi Iwai
  0 siblings, 0 replies; 2+ messages in thread
From: Takashi Iwai @ 2020-03-16  9:00 UTC (permalink / raw)
  To: Andreas Steinmetz; +Cc: alsa-devel

On Sun, 15 Mar 2020 12:57:13 +0100,
Andreas Steinmetz wrote:
> 
> snd-virmidi, as of kernel 5.4.23, does not adhere to the MIDI
> specification:
> 
> >From MIDI 1.0 Detailed Specification, Document Version 4.2, Appendix A-
> 1 (RUNNING STATUS), Page A-2:
> 
> "3. Buffer is cleared when a System Exclusive or Common status message
> is received."
> 
> snd-virmidi does not clear the running status in case of a SysEx
> message.
> 
> How to test:
> 
> Load snd-virmidi module and get the card number of the module.
> In the following 5 is assumed as the card number and device 1 is used.
> 
> You need two shells, in shell 1 do:
> 
> aconnect 'Virtual Raw MIDI 5-1':0 'Virtual Raw MIDI 5-1':0
> amidi -p hw:VirMIDI,1 -d
> 
> Now, in shell 2 do:
> 
> amidi -p hw:VirMIDI,1 -S '80 01 02 F0 01 F7 80 02 03'
> 
> This sends a note off, followed by a SysEx, followed by another note
> off. The result in shell 1 is:
> 
> 80 01 02
> F0 01 F7
> 02
> 03
> 
> So snd-virmidi did not clear the running status. The correct result
> would be:
> 
> 80 01 02
> F0 01 F7
> 80 02 03

Thanks for the report.  Indeed it's a very old bug.
The fix is simple as below.

Since there is a similar bug in OSS emulation layer, too, I'm going to
submit a proper patch set including this.


Takashi

--- a/sound/core/seq/seq_virmidi.c
+++ b/sound/core/seq/seq_virmidi.c
@@ -81,6 +81,7 @@ static int snd_virmidi_dev_receive_event(struct snd_virmidi_dev *rdev,
 			if ((ev->flags & SNDRV_SEQ_EVENT_LENGTH_MASK) != SNDRV_SEQ_EVENT_LENGTH_VARIABLE)
 				continue;
 			snd_seq_dump_var_event(ev, (snd_seq_dump_func_t)snd_rawmidi_receive, vmidi->substream);
+			snd_midi_event_reset_decode(vmidi->parser);
 		} else {
 			len = snd_midi_event_decode(vmidi->parser, msg, sizeof(msg), ev);
 			if (len > 0)

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-03-16  9:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-15 11:57 BUG: ALSA snd-virmidi: snd-virmidi is not MIDI 1.0 specification compliant Andreas Steinmetz
2020-03-16  9:00 ` Takashi Iwai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).