[linux-audio-dev] about MIDI timing...

Stephen Sinclair radarsat1 at gmail.com
Wed Oct 25 12:29:34 UTC 2006


> On the other hand, last night I observed how timidity++ works by using
> strace and I found no *sleep() (nanosleep, msleep and friends). Does it
> mean, major MIDI software synthesizers use non system sleep mechanism
> for the timing?

I believe Timidity++ just uses its synthesizer to convert the MIDI
information into an audio stream, which it then either writes to a
file or plays through the soundcard.  So it doesn't need precise
timing, since the audio callback it uses is already timed by the sound
system.

When dealing with real MIDI, timing is more critical, though usually
you simply use timestamps which tell the sound system when a MIDI
event should be played, instead of dealing with the timing yourself.
(At least I know this is the case with PortMidi, I've never programmed
with ALSA directly.)

By the way, there are more ways to time things than just *sleep().
For example, using sigalrm and setitimer.


> I also read that not all Linux kernel sound card driver
> enable the internal card timer, thus the software must rely on system
> timer. Is it correct?

Don't know anything about that.  I think all soundcards use an
built-in timer for playing their FIFO.  As for interrupting the
computer to tell it when it needs more data, I guess it's possible
that sometimes it uses the card's timer and sometimes uses the system
timer.  Someone more informed may have something to say.


Steve



More information about the Linux-audio-dev mailing list