TUCoPS :: Truly Miscellaneous :: ansimus.txt

Tech specs for ANSI music

                    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.

                     USING ANSI-MUSIC WITH WWIV 4.10

        You have two options. Use the full-screen editor known as FSED13 
(the full-screen editor used by most WWIV systems, if not all of them) 
or use the //UPLOAD command at the main menu to upload your creations. I 
prefer the FSED method, since it allows for musical macros and other 
annoying tricks like that. To use the //UPLOAD method, you must first 
create your message with music and all with some off-line text editor 
that lets you put the escape character in a file by hitting <esc> or 
<control-[>. You'll end up with something that looks like an arrow 
pointing to the beginning of the line if you did it right. Then put an 
open-bracket, the series of PLAY commands, and the <control-n>. You'll 
notice that the <control-n> character is in fact... TWO CONNECTED 
MUSICAL NOTES! Pretty witty of the designer, eh? Anyway, place this file 
in your upload directory, call your favorite WWIV system, type //UPLOAD 
at the main menu, and upload the file you created like you would any 
other uploadable file. Your next message (posted or e-mailed) will 
contain that text, and the codes for the music.
        To use FSED13, it's a bit easier. The backslash key will let you 
enter the hex value of any character, and it'll send that character in 
the message without interpreting it in any way. Therefore, an escape can 
be created by typing \1b and a control-N is \0e. That way you can,
without ever logging off the system, type:

\1b[cdefgab\0e

and it'll send the notes "cdefgab" as music. Incidentally, you don't 
actually see the \1b on the screen, but if you hit backslash, it should 
let you type the two hex digits without displaying them. That's how you 
know if it's working properly. And that's all there is to the FSED method.

        On my comm program, the music codes are not hidden, and I have 
to manually add normal ANSI codes to hide them. The ANSI code for 
"invisible" is:

<esc>[8m    The "m" has to be lowercase.

        Using FSED, that can be entered as \1b[8m

The command for "Normal text" is <esc>[0m (\1b[0m for you FSED users).

        So, using FSED, you would probably do something like this:

\1b[8m\1b[cdefgab\0e\1b[0m

If you don't use the ANSI hide and unhide commands, you will see a bunch 
of your notes on the screen, which looks mighty ugly.

                  *********** 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.

        If I was inaccurate, unclear, or otherwise confusing or wrong, 
or if you simply have comments, I can be reached through your local 
WWIVnet board by e-mailing 1@4353. I am the sysop of the Non-Smurf WWIV, 
a not-too-spectacular but loads of fun BBS in Greenfield, MA. 
413-772-2716. If you can't possibly reach me by WWIVnet and really want 
to tell me something, my address is:

Mike Barnard
24 Temple Ave.
Greenfield, MA 01301

        That's all for today, boys and girls. Please distribute this 
file as widely as possible, upload it to as many BBS's as you can 
possibly call, and help spread ANSI music mania. Hell, go as far as to 
make it a trendy element of pop-culture that never loses it's appeal, 
like the Rolling Stones or bright neon signs. So long, and have fun.
 
 
 

TUCoPS is optimized to look best in Firefox® on a widescreen monitor (1440x900 or better).
Site design & layout copyright © 1986-2024 AOH