Hi,
(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++) { usleep(event[i].delta_time_in_microseconds); output_and_drain_event(event[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