Classic Computer Magazine Archive COMPUTE! ISSUE 43 / DECEMBER 1983 / PAGE 252


C, Regena

Computer Fun

The best news for TI owners this Christmas season is that Texas Instruments has reduced the price of its peripherals. One complaint about the TI-99/ 4A has been that the cost of the basic computer was quite reasonable, but if you wanted to add disk drives or a printer, the cost was out of sight. But that's not a valid complaint anymore. The peripheral expansion box with one disk drive, the disk controller card, and the 32K memory expansion card now have a total list price of $550 — I have seen advertisements of prices near $450.

The RS-232 interface card, needed to add a printer or a modem, lists for around $100. Therefore, since the computer itself sells for about $100, you can get a "complete system" for under $700. Although you can use other brands of printers and modems, the TI printer has been reduced to $500, and the TI modem to $100. All of this means that more TI owners will be getting the peripherals and discovering even more ways we can use our computers in our homes.

Computer Choreography

Since December is a festive time of year, the subject of this column is combining music with graphics to create a show I call "computer choreography." Two months ago I wrote about music on the TI-99/4A. This column is a continuation of that topic, with an explanation of one way to add graphics to the music. Remember, there are many ways to program — there's no one "correct" way. Your program is "correct" if it works the way you want it to when you run it. If it runs properly, you are successful.

Many programming books tell you to plan your program carefully by sketching a structure chart or writing different sections of coding. High school teachers often have students write out the program by hand before going to the computer. (Actually, often the real reason for this procedure is that the school doesn't have enough computers for the whole class.) If you are using a terminal or a mainframe computer and need to pay for computer time, you do need to plan carefully for efficiency. A home computer allows you to experiment to your heart's content — and even try out your program after every few lines if you wish. Although I usually do sketch out my graphics on graph paper, most of my programming is done by composing right at the console.

Choreography programs require a lot of experimentation, so it is almost better to compose at the console rather than plan each statement in order. Let's get right to an example. I chose a Christmas song that I would like to "play" on the computer. I looked up the music in a songbook then started translating notes. Each CALL SOUND statement contains a duration, a melody note and volume, and two accompaniment notes with their volumes. The duration is expressed in terms of a variable T, which is defined at the beginning of the program.

Try different values for T in line 110. For example, try T = 600. Then try T = 100. By programming the duration in terms of T, you only need to change line 110, not each of the CALL SOUND statements, to increase or decrease the speed of the song. Keep experimenting until you find the tempo you like.

You may write the three notes (frequencies) in the CALL SOUND statement in any order you wish. I usually write the melody note first so I can keep track of the tune. Also, if I later run out of memory I can more easily delete some of the accompaniment notes because I know the melody note is the first frequency.

Each frequency has a corresponding volume. I write the melody notes with a louder volume than the accompaniment notes in order to bring out the melody. Also, many times bass notes sound louder to us naturally, so we need to lower their volume.

By the way, our chart's lowest available note is low A on the bass clef (frequency 110), and you cannot use a frequency number less than 110. However, it is possible to get tones lower than low A. Comparing the tones to an electronic keyboard, Jerry Glaze of Las Vegas, Nevada, has come up with various numbers to get lower tones. He suggests you try this command to hear low G:

CALL SOUND(2000, 1475, 30, 1475, 30, 1475, 30, -4, 1)

He specifies three music frequencies of 1475 with a volume of 30, plus the noise parameter of -4 with a volume of 1. Now change each of the 1475 numbers to 1293 and you'll hear low F (one line below the bass clef). Continuing downward, Jerry suggests the following numbers: 1227 – E; 1105 – D; 990 – C. (You may wish to adjust the numbers slightly.)

Adding Graphics To Music

Now let's add graphics. The actual picture I plan on paper first. I sketch out the main picture on graph paper 24 squares by 32 squares to correspond to the 24 rows by 32 columns on the screen. Any pictures that do not fit into the full squares are redrawn on 8 by 8 squares for the high resolution graphics. Then add line 105 CALL CLEAR to clear the screen before running the program. Now we're ready to begin by inserting graphics commands among the present sound commands.

First, you need to define graphics characters for later pictures using CALL CHAR STATEMENTS. This is where you really need to experiment. Try adding the following lines:

122 CALL CHAR(128, "0101010303FF7F1F")
124 CALL CHAR(129, "0F0F1F3E38604")

Be sure those are zeros and not the letter O in the quotes of the character definitions. Now try running the program. It should sound the same as when you ran it without any graphics statements since the TI can play music while it is executing other commands. Depending on how long a note is held, you can define characters between sounds. In this case we were able to define two characters between the first note and the second. You may be able to define more characters, but if you put too many definitions between the sounds, there will be a gap between the notes — so you need to use fewer definitions or commands.

I stayed with just the two definitions between the first two notes. I decided to put the next definition after the third note. Add:

145 CALL CHAR(130, "008080C0C0FFFEFC")

Line 150 is the sound corresponding to the word "night" in the song "Silent Night," so right after the music is played, I change the screen color to black with


This chord has a rather long duration, so let's define two more characters. Add:

154 CALL CHAR (131, "F8F0F8F83C0C06")
156 CALL CHAR(132, "0002040810204")

Next I started drawing a star. In this case the screen is black and characters are naturally black with a transparent background, so any characters placed on the screen won't be seen until the color is changed. I didn't want the star to actually appear until after "holy night." To make the star, add the following statements:

162 CALL HCHAR(3, 25, 128)
164 CALL HCHAR(4, 25, 129)
166 CALL HCHAR(3, 26, 130)
168 CALL HCHAR(4, 26, 131)

and after "night" in line 190,

192 CALL COLOR(13, 16, 1)

You can use this technique of drawing invisibly by first defining the colors of the character with a CALL COLOR statement to match whatever colors are already on the screen; then placing the characters on the screen with CALL HCHAR and CALL VCHAR; then making the characters visible with another CALL COLOR statement defining the visible colors.

After you add a few more character definitions and some HCHAR commands to draw on the screen, then RESequence the program segment, this is how it will look.

The last line, 440 GOTO 440, keeps the picture on the screen until you press CLEAR (SHIFT C on the TI-99/4 or FCTN 4 on the TI-99/4A). I'm going to leave the rest of the song up to you. Since I'm not an artist, I often look at children's picture books or coloring books for picture ideas. For Christmas scenes, you can also try tracing Christmas stencils on graph paper then coloring the squares to plan your shapes. Computer choreography can be a lot of fun, and I know many people who have gotten interested in programming by first designing pictures with music.

A New Year's Present

I promised you a Christmas present, but I've decided to make it a New Year's present instead. I got my first computer for Christmas in 1980, and one of the first programs I wrote was the music for "Auld Lang Syne" with the screen showing 1980 turning into 1981. Each year I change the year and I change the graphics or music slightly. In 1981 I had TI Extended BASIC and made the number 1 out of sprites that moved off the screen to make room for 1982. This year I'm using the natural scrolling of PRINT statements to move 1983 off the screen while bringing in the new year.

I'm also including a TI Extended BASIC version (Program 3). To RUN it, you will need the TI Extended BASIC command module. It includes fireworks and champagne bubbles while the music is playing. In the character definitions, up to four characters may be defined in one command. Trailing REMark statements are allowed with the exclamation point, so the words (or syllables) to the music are written along with the CALL SOUND statements.

If you want to use these programs right at midnight, type RUN then press ENTER at 31 seconds before midnight for the regular TI BASIC program, or 25 seconds before midnight for the TI Extended BASIC program. The year 1984 will be in place exactly for the new year.

Have a happy holiday season!