Re: [linux-audio-dev] high level midi api

New Message Reply About this list Date view Thread view Subject view Author view Other groups

Subject: Re: [linux-audio-dev] high level midi api
From: Paul Davis (pbd_AT_Op.Net)
Date: Sun Oct 28 2001 - 23:54:01 EET


>- the midi driver accessed through rawmidi does not supprot scheduling,
>i.e. it has read() and write() that have to be called at the right time and
>the bytes are sent immediately.

correct, modulo stupid h/w design issues (like the 2 byte FIFO on the
SB series) that thwart such delivery.

>- the alsa sequencer handles the scheduling of midi events and calls write()
>on rawmidi ports at the time they are to be sent.

wrong. the ALSA sequencer (currently) lives in kernel space, and
delivers data via a callback registered when the relevant client
connected to the sequencer. in this case, the callback would be
registered by the specific device driver for the MIDI interface, and
the callback can be called directly within kernel space without any
access to write(2). if its a user client that the data is destined
for, the sequencer has to callback across the user/kernel boundary,
which is handled by alsa-lib on behalf of the application.

>if the above is correct however, than how should any timing a midi interface
>have be supported through rawmidi?

it cannot be. you cannot do timing support with a raw midi data stream
because there is no place to store the timestamp. At the very least,
you need to wrap it up as:

    struct foo {
       timestamp_t timestamp;
       midibyte_t data;
       unsigned long len;
    }

or something similar. the sequencer provides more flexible and more
specific wrapping of data into "events".

>and should synchronisation be in a sequencer device or in the application?
>low latency patches and scheduler improvements should make accurate
>timing possible from user space.

yes, several of my MIDI apps use the RTC in user space to provide
excellent timing (though never perfect, because the RTC has no
interval corresponding to a multiple of the MIDI data rate).

there has been some talk on the alsa-devel list about the possibility
of moving the sequencer into user-space, but nothing has been done
about it yet.

--p


New Message Reply About this list Date view Thread view Subject view Author view Other groups

This archive was generated by hypermail 2b28 : Sun Oct 28 2001 - 23:52:06 EET