Hi again; don't worry about MIDI timing info and variable lengths, it is
much more simple than that. As far as I remember, the main blocks of the
file are:
1. Header, fixed for all files. About 15 or 20 bytes long.
2. Song information. About 3000 bytes. It is divided into ten zones,
one for each song. It contains the song name, tracks initial assignments
(initial program, channel, and all those parameters you can adjust when
EDITing in SEQ mode, page 1: Send C/D, Tune, adjust, velocity window, key
window, etc...). There is something duplicate about MIDI
channels which I did not clear completely yet. They appear on two different
zones, and the one I had to edit with SNGs created from SMFs was just
one of them.
3. Pointer zone. More about this later. Length: 17 tracks x 10 songs x 2 bytes
(yes, 17 tracks: 16 + tempo track). I have to check whether that 2 is
really 2 bytes or four, I don't remember well. Basically, each two (four?)
bytes point
to the beginning of every track of the sequencer. With this zone, you can
tell all tracks from zone 4 apart. That is, you know all track length in
bytes and where it starts in zone 4.
4. All sequencer events. Length: 0 to ca. 128KB. They are stored in this
order:
Song 0: all events from track 1, then all events from track 2, ...
... all events from track 16, all tempo events.
Song 1: Parallel to song 0
...
Song 9: Parallel to song 0.
Each event is coded with four bytes. Events are all MIDI events, new bar,
and track end. Nothing with MIDI clock or tempo here. The tempo track
contains just "new bar" events and "tempo change" events.
Zones 1, 2 and 3 are always present in a SNG file. Zone 4 has a variable
length: 0 to 4 x number of events in the sequencer memory. If you delete
all songs and you then save a SNG file, you'll get only zones 1, 2 and
3 saved. My guess
is that the X3 has 128 KB for sequencer data, so zones 1, 2, 3 and 4 will
sum up to those 128 KB. By the way, I also guess that the SNG file is
a DIRECT dump of the sequencer's memory data into disk. As you'll see in
the future, the codification leaves only 7 bits for data such as Note
Velocity... and the X3 specs say that velocity is rounded up to an even
number, 0 to 126... that is what you get by using just seven bits and
left-shifting the result: bin 11111110 = dec 126, as you all know.
Well, that was all I could tell you from my memory. More about this will
be posted soon (or I will look for an FTP to leave it there). I made all
this out by starting with empty songs, then adding one event and studying
the outcoming SNG files. With a bit of patience, I made out all the data
I needed for the moment. I will recover all this info and continue
investigating about it.
I hope we keep in touch ! Bye
Roberto Saralegui
_________________________
you can e-mail me at: robertico at europe dot com.