Hi, people.  This is a bit loosely related to the Music project.

Last week, someone unexpectedly gave me two MIDI synthetisers, a keyboard
controller, amplifiers, and cabling.  A nice gift indeed for me who
would not afford such expenses :-).  Playing with all this material,
stealing bits of time in between more serious projects, I found out that
if, on this Linux system, I write to `/dev/midi00', the bytes are made
available in real-time to the synthetisers.  So, if I only had a program
able to dispatch bits of a MIDI file to `/dev/midi00' at the proper time,
I could hear MIDI files with lower CPU overhead than with `timidity'.
So, I wrote a small program doing that for MIDI file formats 0 and 1.

Multi-processing is apparently not fully favourable to a MIDI sequencer,
and I understood that if I want some precision, I should work for it.
One avenue would have been to use special provisions for real-time in
the Linux scheduler, but it would also require installing the sequencer
program as `root' and some other fancy things, while I prefer simplicity.
Instead, I tried to evaluate lags and latencies on the fly, and correct
them appropriately.  The result is satisfying enough.  When the system gets
loaded, music rendering could sometimes be slightly jerky, but overall, the
beat stays precise.  I also avoided floating-point computations or anything
else that could yield accumulated rounding errors, and implemented regular
quantum warping of the time reference (:-), so to decrease the overflow
risk, while computing proper waits for very long delta times (like those
who could exist on the timing track of some lengthy musical pieces).

I'm not especially trying to make a "package" with the result, as it
is only a toy and a study tool.  There are also other free sequencers,
which I did not evaluate (I should most probably have done that first!) and
which are surely better in various ways.  Nevertheless, in the GPL spirit,
I'm willing to share this quick hack with anybody interested into using
or growing it into free tools.  I might also work on it too, who knows! :-)

-- 
François Pinard                            mailto:[EMAIL PROTECTED]
Join the free Translation Project!    http://www.iro.umontreal.ca/~pinard

Reply via email to