[alsa-devel] How to get correct midi timings from ALSA using the library only

Carlo Florendo subscribermail at gmail.com
Tue Jul 24 11:01:19 CEST 2007


(1) I've written a command line MIDI sequencer for lightweight systems and 
am successful in making it work using the ALSA queue API.  However, one 
drawback of the API is its lack of callback functions.  I wish to be able 
to track events as they are drained by the queue.

(2) I know and have successfully worked on a work around whereby the 
application itself subscribes to the output port so as to see events as 
they are played.

However, I wish to be able to make the sequencer or player work without the 
use of the ALSA queue nor the workaround in (2).

Here's the pseudo-code of the relevant MIDI player routine:

for (i = 0; i < number_of_events; i++)

This routine gives a non-bearable latency on 2.4 kernels but not so much on 
2.6 kernels.

How could I get the app to <u|nano>sleep() in the most accurate way in 
userspace without using the ALSA queue nor the extra subscription to an 
output port?   Or, is there a drain or output routine that supports 
callbacks?  If so, I will be grateful if you could point them out.  I seem 
not to find any output callback routine under the docs.

Thank you very much.

Best Regards,


Carlo Florendo
Softare Engineer/Network Co-Administrator
Astra Philippines Inc.
UP-Ayala Technopark, Diliman 1101, Quezon City

The Astra Group of Companies
5-3-11 Sekido, Tama City
Tokyo 206-0011, Japan

More information about the Alsa-devel mailing list