home *** CD-ROM | disk | FTP | other *** search
/ The Hacker's Encyclopedia 1998 / hackers_encyclopedia.iso / etc / misc / music.doc < prev    next >
Encoding:
Text File  |  2003-06-11  |  9.6 KB  |  190 lines

  1.                     ANSI Music - The Technical Details
  2.  
  3. ANSI is an acronym for "American National Standards Institute" and 
  4. actually has little to do with this "ANSI music" stuff. However, the 
  5. American National Standards Institute defined a set of codes for 
  6. terminals to provide a standard for cursor control. This was expanded to 
  7. include graphics modes and color with the release of the ANSI.SYS device 
  8. driver. It wasn't actually ANSI who expanded the set of codes to include 
  9. the graphics, which are specific to IBM compatible computers with 
  10. certain video adapters, but the name ANSI stuck. The original purpose of 
  11. ANSI cursor control was to give mainframes a way to control the cursor 
  12. on various terminals connected to them. The purpose of the ANSI.SYS 
  13. driver was to give programs a simple and compatible way of controlling 
  14. the video screen. However, it seems that the only real use for ANSI has 
  15. been to give BBS's the ability to control the screen colors and cursor 
  16. positioning. This even led to a new artform, but let's not even think 
  17. about that. It's too much like Art Deco. In CGA color, no less.
  18.         The ANSI.SYS driver also includes provisions for redefining keys 
  19. on the keyboard. This can be used for character translation or to create 
  20. simple macros. It has even been used to create trojan text files that 
  21. redefined your keys to destroy data (i.e. your enter key becomes "DEL 
  22. *.* <return> Y <return>"). Watch out for this kind of thing. It's not 
  23. hard to do.
  24.  
  25.         Now I said that the actual "ANSI" organization had little to do 
  26. with "ANSI music." The reason that the music codes were given the name 
  27. "ANSI" is because they start with the same escape sequences. All ANSI 
  28. codes start with <esc>[ as do the music codes. What I mean by <esc>[ is 
  29. the escape character (27 decimal, 1E hex) and the open-bracket 
  30. character. Now, on to the REAL details of ANSI music.
  31.  
  32.         As I just got through saying, ANSI music starts with the 
  33. characters <esc><open-bracket>. An ANSI music sequence ends with the 
  34. character <control-N> (14 decimal, 0E hex). In between, the commands are 
  35. exactly the same as those used for the "PLAY" command in BASIC. Now you 
  36. can just look up the PLAY command and you know most everything you need 
  37. to know about ANSI music. But for those of you still confused, I'll 
  38. summarize the PLAY commands and give a few examples and pointers. Here 
  39. we go:
  40.  
  41. The PLAY commands are pretty simple. This info was taken from the Tandy 
  42. BASIC reference manual, but the Tandy-specific commands are not 
  43. recognized by ANSI music and will be left out. Here we go again:
  44.  
  45. A - G    Plays the notes corresponding to the notes A-G on the musical
  46.          scale. A # or + after the note makes it sharp, and a - makes
  47.          it flat.
  48.  
  49. Ln       Sets the duration of the notes that follow. n is a number from
  50.          1 to 64. 1 is a whole note, 2 is a half note, 4 is a quarter
  51.          note, 8 is an eighth note, etc.
  52.  
  53. On       Sets the current octave. There are 7 octaves, 0 through 6. The
  54.          default octave is 4. Each octave starts with C and ends with B.
  55.          Octave 3 starts with middle C.
  56.  
  57. Nn       Plays a note. n is in the range 0 to 84. Instead of specifying
  58.          the note's letter and octave, you may specify the note's number.
  59.          Note zero is a rest.
  60.  
  61. Pn       Plays a rest (if that's the right terminology). n is the same as
  62.          for the L command, but specifies the length of the rest.
  63.  
  64. .        Plays the note as a dotted note. You music buffs know that means
  65.          that the note is one half it's length longer when dotted. Place
  66.          the dot after the note, not before it. More than one dot may be 
  67.          used after a note, and dots may be specified for rests.
  68.  
  69. MF, MB   I'm not sure these options work. Music Foreground and Music
  70.          Background. Supposedly these options will let you specify
  71.          MF and have the computer stop whatever it's doing and play
  72.          the note, while MB lets the computer do whatever it was doing
  73.          and play the note at the same time, kind of lo-tech multitasking.
  74.          The default (for BASIC anyway, and it seems for ANSI-music) is
  75.          Music Background.
  76.  
  77. MN       "Music Normal." Each note plays 7/8 of the duration set by the
  78.          L command.
  79.  
  80. ML       "Music Legato." Each note plays the full duration as set by the
  81.          L command.
  82.  
  83. MS       "Music Staccato." Each note plays 3/4 of the duration set by the
  84.          L command.
  85.  
  86.         That's it for the basic set of commands. There are other options 
  87. in BASIC that are unusuable in the ANSI music, such as the X command 
  88. which lets you include a variable name in the play command, where a 
  89. string variable name is given and the string contains a series of play 
  90. commands. Another command which is usable only on a Tandy or other 
  91. computer with the TI sound chip (the PCjr, for instance) is the V 
  92. command, for setting the volume of the sound. Now for some examples.
  93.  
  94. <esc>[cdefgab<control-n>  plays the notes "cdefgab" (the entire octave) on
  95.                           the default octave 4.
  96.  
  97. <esc>[l4al2cl8e<control-n>  plays a quarter-note A, a half note C, and an
  98.                             eighth-note E. Not too musical, but an
  99.                             example nonetheless.
  100.  
  101.         I'm not one for giving too many examples, I think that's plenty 
  102. for you to get the basic idea. Try it in BASIC before you try it as an 
  103. ANSI code in a message/picture. Just type PLAY "ABCDE" <return> and put 
  104. whatever you like in the quotes. That's the easiest way to work out the 
  105. notes and get the timing right before you blast it up to your favorite 
  106. BBS.
  107.  
  108.                      USING ANSI-MUSIC WITH WWIV 4.10
  109.  
  110.         You have two options. Use the full-screen editor known as FSED13 
  111. (the full-screen editor used by most WWIV systems, if not all of them) 
  112. or use the //UPLOAD command at the main menu to upload your creations. I 
  113. prefer the FSED method, since it allows for musical macros and other 
  114. annoying tricks like that. To use the //UPLOAD method, you must first 
  115. create your message with music and all with some off-line text editor 
  116. that lets you put the escape character in a file by hitting <esc> or 
  117. <control-[>. You'll end up with something that looks like an arrow 
  118. pointing to the beginning of the line if you did it right. Then put an 
  119. open-bracket, the series of PLAY commands, and the <control-n>. You'll 
  120. notice that the <control-n> character is in fact... TWO CONNECTED 
  121. MUSICAL NOTES! Pretty witty of the designer, eh? Anyway, place this file 
  122. in your upload directory, call your favorite WWIV system, type //UPLOAD 
  123. at the main menu, and upload the file you created like you would any 
  124. other uploadable file. Your next message (posted or e-mailed) will 
  125. contain that text, and the codes for the music.
  126.         To use FSED13, it's a bit easier. The backslash key will let you 
  127. enter the hex value of any character, and it'll send that character in 
  128. the message without interpreting it in any way. Therefore, an escape can 
  129. be created by typing \1b and a control-N is \0e. That way you can,
  130. without ever logging off the system, type:
  131.  
  132. \1b[cdefgab\0e
  133.  
  134. and it'll send the notes "cdefgab" as music. Incidentally, you don't 
  135. actually see the \1b on the screen, but if you hit backslash, it should 
  136. let you type the two hex digits without displaying them. That's how you 
  137. know if it's working properly. And that's all there is to the FSED method.
  138.  
  139.         On my comm program, the music codes are not hidden, and I have 
  140. to manually add normal ANSI codes to hide them. The ANSI code for 
  141. "invisible" is:
  142.  
  143. <esc>[8m    The "m" has to be lowercase.
  144.  
  145.         Using FSED, that can be entered as \1b[8m
  146.  
  147. The command for "Normal text" is <esc>[0m (\1b[0m for you FSED users).
  148.  
  149.         So, using FSED, you would probably do something like this:
  150.  
  151. \1b[8m\1b[cdefgab\0e\1b[0m
  152.  
  153. If you don't use the ANSI hide and unhide commands, you will see a bunch 
  154. of your notes on the screen, which looks mighty ugly.
  155.  
  156.                   *********** Closing Comments ***********
  157.  
  158.         I only know of two major comm programs that support ANSI music: 
  159. TeliMate and Qmodem. I personally prefer TeliMate. If we (the collective 
  160. we, that is) spread the use of ANSI music, hopefully the makers of other 
  161. comm programs will incorporate this feature. If the makers of Telix and 
  162. Procomm included this, that would cover 95% of IBM compatible BBS'ers. A 
  163. new version of Telix is due out in a few months and I'm hoping this new 
  164. version will add ANSI music. I gave up Procomm years ago, so I don't 
  165. really know when a new version of that's due out, but it still seems to 
  166. be the most common terminal program around. Still, TeliMate is gaining 
  167. popularity for its mouse support and multitasking ablility (I wrote most 
  168. of this document while downloading a 371k file at 1200 baud), and Qmodem 
  169. is pretty popular already.
  170.  
  171.         If I was inaccurate, unclear, or otherwise confusing or wrong, 
  172. or if you simply have comments, I can be reached through your local 
  173. WWIVnet board by e-mailing 1@4353. I am the sysop of the Non-Smurf WWIV, 
  174. a not-too-spectacular but loads of fun BBS in Greenfield, MA. 
  175. 413-772-2716. If you can't possibly reach me by WWIVnet and really want 
  176. to tell me something, my address is:
  177.  
  178. Mike Barnard
  179. 24 Temple Ave.
  180. Greenfield, MA 01301
  181.  
  182.         That's all for today, boys and girls. Please distribute this 
  183. file as widely as possible, upload it to as many BBS's as you can 
  184. possibly call, and help spread ANSI music mania. Hell, go as far as to 
  185. make it a trendy element of pop-culture that never loses it's appeal, 
  186. like the Rolling Stones or bright neon signs. So long, and have fun.
  187.  
  188.  
  189.  
  190.