Midi info

I have a simple midi player that works on the Sega Genesis.
It’s written in C and can play most of the downloadable
midi files available all over the internet. I haven’t
attempted to handle proper voicing–ie when midi calls for
rich string, I ignore it and all voices sound the same. The
source is 577 lines of C code and might be a good starting
point for a midi player.

My experience with linux c source is that for some reason
there are 10x as many lines of code to do something as
their need to be. Case in point is the sendfax program.
Very huge, bloated, cryptic, spread over dozens of source
files. My fax program is tiny and fits in 1 single source
file.

A midi stream is actually very simple. There are packets
of information, and between each packet is a timestamp,
which indicates the amount of time to wait before going
to the next packet. Frequently this time stamp is a delta
of zero, meaning a group of packets should be processed
all at once.

Each midi channel can have up to 16 different voices. Each
voice can have as many chords playing together as desired.
Notes are done by key down events and key up events. The
key events have a rate associated with them, so you can
specify louder or softer notes that way. The keys
correspond to a piano–12 notes per octave. Keys are
represented by a 7 bit number. I think #64 is middle C on
the piano.

There are lots of other packet types, such as load a
different instrument, or display some text in sync with
the music (for karoake stuff). The free DL’able midi
files frequently have lyric information built in.

Let me know if anyone is interested. If so email me
at dash at xdr.com directly, I may not always read the
@Dave_Ashley email, which is just for sdl mailing list
stuff.

-Dave