[LAD] Sending huge SysEx files via ALSA

Clemens Ladisch clemens at ladisch.de
Mon Jul 27 08:35:02 UTC 2009


Christoph Eckert wrote:
> I'm currently playing with some code that sends SysEx data to ALSA using 
> RtMidi¹. I get an error reported by the latter one as soon as the size of the 
> message exceeds 16355 bytes.

This probably exceeds ALSA's sequencer buffer size.

> Can anyone comment whether this is a limitation in ALSA, and in case it is if 
> there are coding workarounds?

You could increase the sequencer kernel buffer size by calling
snd_seq_client_pool_set_output_pool().  For the RawMIDI buffer, there
is no programmatic way to change the buffer size; you'd have to change
the output_buffer_size parameter of the snd-seq-midi module.

> AFAIR ALSA splits incoming SysEx-events into chunks of 256 bytes if
> necessary.

This is the RawMIDI->sequencer event converter, which has its own
buffer.

> But I obviously overlooked that sending is much harder when I played
> with SysEx data the last time :) .

ALSA's sequencer API (and RtMidi) have been designed for 'real-time'
events that are so small that they do not need much buffering, and that
are scheduled to be sent at some specific time.

When you want to send SysEx messages, you should split them into small
chunks that are scheduled at proper times so that the MIDI bandwidth
is not exceeded.  (aplaymidi does something like this if you give it
a .mid file with huge SysExes.)

However, for this it would be easier to use the RawMIDI API, or a tool
like amidi.


Best regards,
Clemens



More information about the Linux-audio-dev mailing list