                    ANSI Music - The Technical Details

ANSI is an acronym for "American National Standards Institute" and 
actually has little to do with this "ANSI music" stuff. However, the 
American National Standards Institute defined a set of codes for 
terminals to provide a standard for cursor control. This was expanded to 
include graphics modes and color with the release of the ANSI.SYS device 
driver. It wasn't actually ANSI who expanded the set of codes to include 
the graphics, which are specific to IBM compatible computers with 
certain video adapters, but the name ANSI stuck. The original purpose of 
ANSI cursor control was to give mainframes a way to control the cursor 
on various terminals connected to them. The purpose of the ANSI.SYS 
driver was to give programs a simple and compatible way of controlling 
the video screen. However, it seems that the only real use for ANSI has 
been to give BBS's the ability to control the screen colors and cursor 
positioning. This even led to a new artform, but let's not even think 
about that. It's too much like Art Deco. In CGA color, no less.
        The ANSI.SYS driver also includes provisions for redefining keys 
on the keyboard. This can be used for character translation or to create 
simple macros. It has even been used to create trojan text files that 
redefined your keys to destroy data (i.e. your enter key becomes "DEL 
*.* <return> Y <return>"). Watch out for this kind of thing. It's not 
hard to do.

        Now I said that the actual "ANSI" organization had little to do 
with "ANSI music." The reason that the music codes were given the name 
"ANSI" is because they start with the same escape sequences. All ANSI 
codes start with <esc>[ as do the music codes. What I mean by <esc>[ is 
the escape character (27 decimal, 1E hex) and the open-bracket 
character. Now, on to the REAL details of ANSI music.

        As I just got through saying, ANSI music starts with the 
characters <esc><open-bracket>. An ANSI music sequence ends with the 
character <control-N> (14 decimal, 0E hex). In between, the commands are 
exactly the same as those used for the "PLAY" command in BASIC. Now you 
can just look up the PLAY command and you know most everything you need 
to know about ANSI music. But for those of you still confused, I'll 
summarize the PLAY commands and give a few examples and pointers. Here 
we go:

The PLAY commands are pretty simple. This info was taken from the Tandy 
BASIC reference manual, but the Tandy-specific commands are not 
recognized by ANSI music and will be left out. Here we go again:

A - G    Plays the notes corresponding to the notes A-G on the musical
         scale. A # or + after the note makes it sharp, and a - makes
         it flat.

Ln       Sets the duration of the notes that follow. n is a number from
         1 to 64. 1 is a whole note, 2 is a half note, 4 is a quarter
         note, 8 is an eighth note, etc.

On       Sets the current octave. There are 7 octaves, 0 through 6. The
         default octave is 4. Each octave starts with C and ends with B.
         Octave 3 starts with middle C.

Nn       Plays a note. n is in the range 0 to 84. Instead of specifying
         the note's letter and octave, you may specify the note's number.
         Note zero is a rest.

Pn       Plays a rest (if that's the right terminology). n is the same as
         for the L command, but specifies the length of the rest.

.        Plays the note as a dotted note. You music buffs know that means
         that the note is one half it's length longer when dotted. Place
         the dot after the note, not before it. More than one dot may be 
         used after a note, and dots may be specified for rests.

MF, MB   I'm not sure these options work. Music Foreground and Music
         Background. Supposedly these options will let you specify
         MF and have the computer stop whatever it's doing and play
         the note, while MB lets the computer do whatever it was doing
         and play the note at the same time, kind of lo-tech multitasking.
         The default (for BASIC anyway, and it seems for ANSI-music) is
         Music Background.

MN       "Music Normal." Each note plays 7/8 of the duration set by the
         L command.

ML       "Music Legato." Each note plays the full duration as set by the
         L command.

MS       "Music Staccato." Each note plays 3/4 of the duration set by the
         L command.

        That's it for the basic set of commands. There are other options 
in BASIC that are unusuable in the ANSI music, such as the X command 
which lets you include a variable name in the play command, where a 
string variable name is given and the string contains a series of play 
commands. Another command which is usable only on a Tandy or other 
computer with the TI sound chip (the PCjr, for instance) is the V 
command, for setting the volume of the sound. Now for some examples.

<esc>[cdefgab<control-n>  plays the notes "cdefgab" (the entire octave) on
                          the default octave 4.

<esc>[l4al2cl8e<control-n>  plays a quarter-note A, a half note C, and an
                            eighth-note E. Not too musical, but an
                            example nonetheless.

        I'm not one for giving too many examples, I think that's plenty 
for you to get the basic idea. Try it in BASIC before you try it as an 
ANSI code in a message/picture. Just type PLAY "ABCDE" <return> and put 
whatever you like in the quotes. That's the easiest way to work out the 
notes and get the timing right before you blast it up to your favorite 
BBS.
                  *********** Closing Comments ***********

        I only know of two major comm programs that support ANSI music: 
TeliMate and Qmodem. I personally prefer TeliMate. If we (the collective 
we, that is) spread the use of ANSI music, hopefully the makers of other 
comm programs will incorporate this feature. If the makers of Telix and 
Procomm included this, that would cover 95% of IBM compatible BBS'ers. A 
new version of Telix is due out in a few months and I'm hoping this new 
version will add ANSI music. I gave up Procomm years ago, so I don't 
really know when a new version of that's due out, but it still seems to 
be the most common terminal program around. Still, TeliMate is gaining 
popularity for its mouse support and multitasking ablility (I wrote most 
of this document while downloading a 371k file at 1200 baud), and Qmodem 
is pretty popular already.