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: martijn sipkema (msipkema_AT_sipkema-digital.com)
Date: Mon Oct 29 2001 - 11:44:17 EET


> >- 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.

ok, but the callback is called at the time the event is to be sent right?
so it wouldn't be possible to send some data to an interface early and
have the interface transmit them at the correct time?

> >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".

i know. i would like to have a high level midi api that uses events and
a timestamp. but no support for tempo, mtc, midiclock, etc. only one
time (like openml's ust). and that the scheduling of the events can be
done in the driver. and some way to deal with streams of midi data
(sysex) should be provided.

> >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.

i think the sequencer should be in user space (and in the application). all
the application needs is.
- a function to receive midi events with an accurate (<< 1 ms) timestamp.
- a function to send midi events with a timestamp, the driver transmits
the event at the specified time. events have to be sent in the correct
order.
- functions for flushing and draining.
- maybe a function for 'out of band' events. (for midi through).
- some way to send/receive sysex.
- and a way to get the time (the same used for stamping/scheduling).

i think this would (with low-latency patches) allow for a sequencer to
be built in user space, which is better than in the kernel.

--martijn


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

This archive was generated by hypermail 2b28 : Mon Oct 29 2001 - 10:41:47 EET