

Appendix C

Converting MIDI Files

                Information needed to properly transfer from 
		one sequencer file format to another using 
		Standard MIDI files.
                                               
Macintosh is a registered trademark of Apple Computer, Inc.
IBM is a registered trademark of International Business Machines, Inc.


WHAT ARE MIDI FILES?
             
MIDI is a standard that has been agreed to by many manfucturers.  You 
can interconnect most keyboards and other instruments using MIDI and 
they will "talk" to each other, "understanding" the same language.
But when a sequencer records MIDI information on a computer, there are 
many things it needs to keep track of in addition to the MIDI events, such 
as when the events should be played back, how they are organized into 
tracks, what the tempo of the song is, which tracks you want muted or 
protected, etc.  Different sequencers need to store different amounts and 
kinds of information, so each sequencer uses a different file format.  You 
can not take a file created with one brand of sequencer and read it into 
another because each sequencer expects the information in the file to be 
organized differently.

So it used to be that, if you wanted to transfer a song between two 
different sequencers, the only way you could do it was to run each 
sequencer on a separate computer, connect the two computers with MIDI 
cables, and simply play the song in one sequencer while recording it in real 
time on the other sequencer.  Even if you have the two computers handy, 
this can be a time-consuming procedure.
MIDI Files make transferring songs between many sequencers much 
simpler.  You simply save the song to disk as a MIDI File in one sequencer, 
and load the song in MIDI File format into the other sequencer.

An important point needs to be made here:  MIDI Files are intended as a 
sequencer interchange format only.  That is, they are specifically designed 
for the purpose of moving information from one sequencer to another.  
Thus they deal only with the most common types of information that are 
likely to be used by most sequencers, such as MIDI data, tempos, etc.  They 
do not deal with types of information which tend to be specific to the design 
of a particular sequencer, such as the way tracks are numbered, mute 
settings, loops, synchronization type, etc.

It is not intended that MIDI Files be used as the native method of storage in 
a particular program, except perhaps some programs whose main function 
is to create data for use by other programs rather than for later use by 
that same program.  Many sequencers use the terms Import and Export to 
refer to saving and loading MIDI Files.  This program simply calls it Saving 
and Loading MIDI Files, as opposed to Song Files, since the term Import 
has another meaning - Importing a single Track from another Song File.


MIDI FILE FORMATS

MIDI Files come in three possible formats:  format 0, 1, or 2.

Format 0 is one single track representing the whole song.  This is the 
simplest form of interchange.  It is analogous to interconnecting two 
computers by MIDI cables and playing the whole song from one sequencer 
into the other and saving it as one track. Assuming the receiving sequencer 
has unmix-by-channel capabilities, that track can then be split into multiple 
tracks.

Format 0 = Single Track                                            

Format 1 is multiple tracks intended to play at the same time.  This format 
most closely matches linear (not pattern-oriented) multi-track 
sequencers.  In the interconnected-computers analogy, this is like playing 
each track soloed in the sending sequencer and recording it as a separate 
track in the receiving sequencer.

Format1 = track 1 Track 2 Track 3, etc.

                                         
Format 2 is single-track patterns intended to play one after the other. This 
format is intended for pattern-oriented sequencers.

Format 2 |Track 1|Track2|Track3	, etc.

Almost all programs that support MIDI Files support at least format 0. 
Many multi-track sequencers (even some pattern-oriented sequencers that 
have multiple tracks in each pattern) also support format 1. Few if any 
sequencers to date support format 2.

MidiTrack ST and MidiMover support both format 0 and format 1.


WHAT IS INCLUDED IN A MIDI FILE?
             
A format 0 file contains all the information in one track.  

A format 1 file contains all tempo/meter information (plus SMPTE start time, if 
applicable) in the first track, and all MIDI information in one or more 
tracks that follow.

At the beginning of a MIDI File is a number called division which indicates 
how many ticks per quarter note are used when representing the time at 
which each MIDI event is sent.  Barefoot Software Sequencers use 96 or 192 
ticks per quarter note, and write MIDI Files with the division value 
according to the setting of Tick Resolution in the Options menu.  As long as you send 
MIDI Files between sequencers that have the same division value, you will 
not lose any resolution in the transfer.  If you send a MIDI File between 
sequencers that have different division values, then only the resolution of 
the lower-resolution sequencer will be maintained.

For example, if you send data from a 24-tick sequencer into this sequencer, 
you can only end up with events at ticks such as .00, .04, .08, etc.  If you 
send data from this sequencer into a 24-tick sequencer, you will effectively 
be quantizing the whole sequence slightly, as the events will be placed on 
ticks which correspond to .00, .04, .08, etc.  (If the divisions of the two 
sequencers are not divisible by each other, such as going between a 96-tick 
and a 120-tick sequencer, some additional one-tick errors may occur in a 
back-and-forth conversion.  This will not be cumulative, however, if you 
write and read the MIDI File several times.)

In the first (tempo/meter) track of a format 1 MIDI File (or in the only 
track of a format 0 file), Barefoot Software Sequencers can write and 
read the following types of information:

	Song Name
	Tempo Changes
	Meter Changes (and Metronome Tick "time signature" denominator)
	SMPTE Start Time
         
A format 0 MIDI File will also contain MIDI Events in its only track. In 
any additional (MIDI) tracks of a format 1 MIDI File, Barefoot Software 
Sequencers will write and read:

	Track Name
	MIDI Events
        Output Port (for MidiPlexer users)
        
Note that in a format 0 file the name of the single track is not saved, and 
in a format 1 file the name of a tempo and/or meter track can not be 
saved.

Barefoot Software Sequencers will deal with differences in song/track 
name length and in tempo values as well as possible.  If a sequencer sends a 
song name longer than 32 characters, only the first 32 characters will be 
kept.  Similarly, only the first 16 characters of a track name can be used.  
The closest possible tempo value (in Ultra-Fine Tempo Resolution, if 
necessary) will be used when reading tempo values from a MIDI File.

SmpteTrack will save the Global SMPTE Start Time in a MIDI File and read 
it back. MIDI Files assume frames are broken into 100 subframes, whereas 
in reality (and in SmpteTrack) frames are divided into 80 bits.  Because of 
this discrepancy, a SMPTE Start Time written to a MIDI File and then read 
back may be off by one bit.  (This will not be cumulative, however, if you 
write and read the MIDI File several times.)
MIDI Files do not support a metronome-tick time signature numerator; 
they assume the metronome tick is only accented at the start of a new 
measure. When reading a MIDI File, the program will set the metronome-tick numerator to 60 to make the metronome accent this way.


SAVING MIDI FILES
             
You must first decide whether you want to write a format 0 or format 1 
file.  Use format 1 if you are sending the MIDI File to a multi-track 
sequencer and want to keep each Track separate and you know the 
program that will read the MIDI File can handle format 1.  Use format 0 if 
you are sending the MIDI File to a program that cannot handle format 1, 
or if you only have one MIDI track to send anyway.  (A few multi-track 
sequencers can only handle format 0.)

Make sure you have no Chains active.  If "loop" symbols appear on any 
track, indicating the Track is under Chain control, you will not be able to 
save a MIDI File.  You should Flatten any Chains into Linear Tracks and 
mute the Chains (the tracks they control will be muted automatically).   
The program will only save unmuted (turned ON) Tracks in a MIDI File.  
No muted Tracks are saved.

A format 0 file is saved if there is only one 
unmuted Track.

A format 1 file is saved if there are multiple unmuted 
Tracks.



To Prepare To Save A Format 0 MIDI File:

	Select Mix Tracks from the Edit menu.

	Use the Left button to select all the MIDI Tracks you want to save in 
        the MIDI File.

	Use the Right button to save the mix of all those Tracks to an empty 
        Track.

	Turn OFF (mute) all the Tracks you Mixed.

	Turn ON (unmute) the new Track which is a Mix of the other Tracks.
 

	Turn ON (unmute) the Tempo and Meter Track, if any.



To Prepare To Save A Format 1 MIDI File:

	Turn ON (unmute) all the MIDI Tracks (2 or more) you want to save.

	Turn ON (unmute) the Tempo and Meter Track, if any.


To Save A MIDI File:

	Select Save SNG/MID File from the File menu with the Right mouse 
        button (or press Clr/Home and then press Alternate ).
	A file selector will appear, showing only files with the extension .MID (most         programs use the .MID extension for MIDI Files).

	Type in a name for the file you want to save.  This file name can be up 
        to 8 characters; the .MID extension will be automatically added to the 
        file name.  
        Don't type anything as an extension (3 characters after the 
        period) unless you fully understand how to use the Item Selector.
	Make sure to pick a file name that isn't used yet, unless you want to
        replace (without backup) an existing file.  The program will not 
        automatically back up a  file when you try to save to a file that 
        already exists; the file will be replaced without any warning message.

	When you're ready to save, Click OK or press Return.
	A message will appear, indicating whether a format 0 or format 1 file is 
        being written.

	The message will stay on the screen until the file has been saved (this 
        may take a minute or more for very large files - it's not just saving, 
        it's doing a lot of conversion calculations).




The MIDI tracks are saved in the order they appear on the screen.  All 
Tracks are saved with the Track MIDI Channel and Track Offset (Track 
Delay) incorporated into the MIDI File track, as if a Mix had been done of 
the Track to itself.  If you have a Track with events on different channels 
and you want to preserve those different channels on different events, 
make sure you don't have a Track MIDI Channel set for that Track before 
you save it to a MIDI File; otherwise all events on the Track will be on the 
Track MIDI Channel after it's been saved.

If you get a Memory Limit Exceeded warning, it means there wasn't 
enough memory to convert one or more Tracks.  The MIDI File will be 
saved, but some track(s) may not contain all the intended data.  It is 
suggested you Delete the File you just saved.  Less memory will be needed to 
save a format 1 file than a format 0 file (because it only needs to convert 
one Track at a time rather than the whole Song at once).


LOADING MIDI FILES
You don't need to know whether a file is format 0 or format 1 in order to 
load it.  In fact, you don't need to know what computer the file was sent from 
(if you got the file by modem) to load it.  MidiTrack ST and
MidiMover will automatically skip computer-specific headers (see 
Transferring Between Different Computers below) and will automatically 
expand a MIDI file into:

	*one tempo track, if there are any tempo changes in the song.
	*one meter track, if there are any meter changes in the song.
	*one or more MIDI tracks, in the order they were saved in the MIDI 
         File.

To Load A MIDI File:

	Select Load SNG/MID File from the File menu with the Right button
	(or press Clr/Home and then press Alternate L)
	A dialog box will appear, warning you that when you load in a MIDI 
        File, you will be erasing the song now in memory
	Click OK to continue
	A file selector will appear, showing only files with the extension
        .MID.
	(most programs use the .MID extension for MIDI Files)
	Click on the name of the MIDI File you wish to load
	Click OK
	A message will appear, indicating whether a format 0 or format 1 
        file is being read
	The message will stay on the screen until the file has been loaded 
        (this may take a minute or more for very large files)

All tracks not converted will be empty.  All Track MIDI Channels and 
Track Offsets (Track Delays) will be reset to their default values (dot and 
+0 respectively).  The Song Name and the Track Names of MIDI (not 
Tempo or Meter) tracks will be filled in, if possible. If the MIDI file had a 
time signature, it will be used; otherwise the song will be in Beats Mode.  If 
you're using SmpteTrack, the SMPTE Start Time will be filled in if present 
in the MIDI File.  All other settings will be obtained from your 
AUTOLOAD.SNG (if you are using one - the program effectively does a New 
Song operation just before reading the MIDI File) or will be set to factory 
default values (if you aren't using an AUTOLOAD.SNG).

If you get a Memory Limit Exceeded warning, it means there 
wasn't enough memory to convert one or more tracks.  The program 
needs to load each track from the MIDI File into memory as it's converting 
it.  Less memory will be needed to load a format 1 file than a format 0 file 
of the same size (because it only needs to convert one track at a time 
rather than the whole song at once).

If you try to load a file with is not a valid MIDI File, or is 
damaged, you may get a warning which says "Not a MIDI File."  (Be 
aware that some older versions of a few Macintosh programs wrote MIDI 
Files that don't conform to the current 1.0 spec.)  You will also get a 
warning if you:

(1)	try to load a format 2 file
(2)	try to load a format 1 file with more than 58 tracks 
        (60 tracks minus a possible tempo track and a possible meter track)
(3)	try to load a time-based file (such as a cue list) 
        rather than a tempo-based song.


TRANSFERRING BETWEEN DIFFERENT COMPUTERS

If you are transferring between different programs on the Atari ST, you can simply take the disk containing the MIDI File written by one program and load the MIDI File from the same disk into the other program.  (You can also transfer by modem, of course, just as you would 
any other ST file.)

If you are transferring between an IBM/clone and the Atari ST, you _may_ be able to transfer by disk, if you have a 3.5" drive on the IBM (or a 5.25" drive on the ST), and you format the disk on the IBM (or using a special formatting program on the ST; most ST formatting 
routines, including the one built into the Desktop and the ones built into 
Hybrid Arts programs, will not format disks that an IBM/clone computer 
can read directly).

In most cases, however, the easiest way to transfer MIDI Files 
between different computers is by modem (if the two computers are next to 
each other, and you know how to use a null-modem cable to interconnect 
them, you can transfer that way as well). If the other computer is 
anything but a Macintosh, the process is very simple; just transfer the 
MIDI File as you would any other data file, naming the file with a .MID 
extension at the other end.

Files on most personal computers used for MIDI are stored in 
the same manner:  a file simply contains the data it contains, and has a 
name! But on the Macintosh, files are stored in a more complex manner.  
Each file, in addition to having a name, has a type, an owner, and a 
resource fork, in addition to the data, which it stores in a part of the file 
called the data fork.

When Macintosh modem programs send files, they have an 
option called MacBinary.  This puts a 128-byte header on the file that is not 
part of the MIDI File data.  Most programs on computers other than the 
Macintosh will not recognize a MIDI File sent in MacBinary.
If you are sending a MIDI File from a Macintosh to the ST, 
and will be converting the file using MidiTrack ST or MidiMover, you have 
nothing to worry about, however!  MidiTrack ST and MidiMover 
automatically detect and skip this 128-byte header on MacBinary-sent files, 
and find and convert the MIDI File data with no problem!

(In fact, MidiMover could be used to convert MIDI Files in 
MacBinary form to MIDI Files in ST-compatible form for use with other 
programs which can't handle MacBinary files directly!

Going the other way is a bit trickier.  MIDI Files created on the 
ST can be sent to the Mac by modem, but they will generally be interpreted 
as being "Text" type files, and unreadable by any Macintosh MIDI 
program!  So, once the file is on the Macintosh, you have to change the file 
type to "Midi" (note that the "M" must be upper case but the "idi" must be 
lower case).
You can use a program such as ResEdit to do this (after 
selecting the file, use Get Info from the File menu to change the file type to 
"Midi", then save the file).


USES FOR MIDIMOVER
 
There are several things you can do with MidiMover.
The most obvious is to convert Song Files to/from MIDI Files if 
you're using EZ-Track Plus (which doesn't have the conversion built in).
You can also Auto-Score files which originate on other 
sequencers in EZ-Score Plus, by saving the files as MIDI Files in the other 
sequencer, using MidiMover to convert the MIDI File to Hybrid .SNG 
format, and then Auto-Scoring the .SNG file in EZ-Score Plus.  Format 1 is 
suggested for this application, to make it easier to put different parts on 
different staves/voices.
 
You can also take sequences created in (by?) Ludwig and, by 
using MidiMover to convert them to MIDI Files, give them to anyone using 
any MIDI-File-capable sequencer on any computer.
You can take files which originate with other programs that 
aren't sequencers but which generate some sort of MIDI data (like Ludwig does) and save them as MIDI Files, and use them with any Hybrid Arts 
program (sequencer or scoring program) that can handle .SNG files.
And you can even use MidiMover to convert between format 0 and format 1 files, or from MacBinary to ST-format files, if another MIDI program you use can't handle the type of MIDI file you're trying to load!  Just load the MIDI File and save it back out, using the instructions above.

Of course, if you have EditTrack or SmpteTrack, with MIDI 
File conversion built in, you can do all of these things too.  MidiMover 
simply makes the same capabilities avaiable in a smaller program, which 
can be freely distributed (so you can give MidiMover away to all your 
friends, so that they will be able to use the files you create with your 
Hybrid Arts programs!).
MidiMover is basically a version of MidiTrack ST with most of 
the features not needed for MIDI File conversion removed.  The screen 
layout and user interface is the same as that in all Hybrid Arts sequencers.
 
Note:

To save or load a Hybrid Arts format Song File, select Save 
SNG/MID File or Load SNG/MID File from the File menu with the Left 
button (or press Alternate S or Alternate L without pressing Clr/Home 
first). The mute indicators are up/down arrows next to the track names.  
Click on the arrow with the Left button to turn the track ON (unmute it); 
click with the Right button to turn the track OFF (mute it).
 