Re: MIDI, snd-serial-u16550 and dropped notes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Ok, let's try problem 2: something is causing corrupted MIDI messages.

Using the snd-serial-u16550 driver I have two MIDI inputs.  Every now
and then (after 5-15 minutes of playing) I get a dropped or corrupted
message.  I managed to capture this using both a logic analyzer on the
serial data and software logging of the ALSA ports.

The stimulus, applied to both input ports with a slight time delay,
was a note on, followed by a note off (of a different note).  (plus
normal playing before and after)
Port 1: (hex) 93 53 40 93 54 00
Port 2: (hex)  93 53 40 93 54 00
The serial protocol inserts port flags (F5 nn) between bytes to tag
the port, so the serial stream becomes
F5 01 93 F5 02 93 F5 01 53 F5 02 53 F5 01 40 F5 02 40 F5 01 93 F5 02
93 F5 01 54 F5 02 54 F5 01 00 F5 02 00

The snd-serial-u16550 driver turns this back into two ALSA ports.

One program, reading one port, received two events, 93 53 40 and 93 54 00
The other program, reading the other port, received one event, 93 53 54

So it appears as if something caused the system to drop the two bytes
in the middle of the MIDI stream, but only after they'd been parsed
into separate ports and before they'd been parsed into sequencer
events.  Does this make any sense?

Data before and after this event is fine.  There is fair amount of
other activity within the ALSA system going on at the same time, and
the "other" program is similar to a MIDI filter, passing data to the
first program through other ALSA ports.

For ALSA input (on either program) I'm using something like:

snd_seq_nonblock(pSeq, 1);
nppD = snd_seq_poll_descriptors_count(pSeq, POLLIN);
ppD = alloca(sizeof(*ppD) * nppD);
while (1)
{
   snd_seq_poll_descriptors(pSeq, ppD, nppD, POLLIN);
   if (poll(ppD, nppD, -1) < 0)
      printf("error 1\n");
   do
   {
      snd_seq_event *pEvent;

      status = snd_seq_event_input(pSeq, &pEvent);
      if (status < 0)
      {
	 printf("error 2\n");
      }
      else if (pEvent)
      {
	//log message
      }
   } while (status > 0);
}

I am getting errors at error 2, showing "Resource temporarily
unavailable", any time there is idle space between events.

Stats are same as before:
kernel 2.6.35-24 (Ubuntu 10.10)
ALSA 1.0.23
snd-serial-u16550 port=0x3f8 irq=4 adaptor=4 speed=115200 ins=3 outs=3

John

------------------------------------------------------------------------------
Free Software Download: Index, Search & Analyze Logs and other IT data in 
Real-Time with Splunk. Collect, index and harness all the fast moving IT data 
generated by your applications, servers and devices whether physical, virtual
or in the cloud. Deliver compliance at lower cost and gain new business 
insights. http://p.sf.net/sfu/splunk-dev2dev 
_______________________________________________
Alsa-user mailing list
Alsa-user@xxxxxxxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/alsa-user


[Index of Archives]     [ALSA Devel]     [Linux Audio Users]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]

  Powered by Linux