Classic Computer Magazine Archive CREATIVE COMPUTING VOL. 10, NO. 2 / FEBRUARY 1984 / PAGE 138

Audio-Animation; synchronized sight and sound for Atari computers. (computer program) Kent A. Multer.

Audio-Animation provides a vivid demonstration of the graphic and musical talents of the Atari computer. I run it on a system with 32K and a disk, but it should also run on a 24K disk system or with 8K and cassette.

The main graphics routine is based on the familiar dancing line algorithm. It draws webs of colored lines on the screen, and stores their endpoint coordinates in an array so that it can erase old lines as well as draw new ones. I have spiced up the algorithm in several ways.

First, I made it select new colors at random, instead of just using the four standard colors over and over again. If you watch the program for a while, you will probably be pleasantly surprised to see what a great variety of colors that Atari can produce: salmon pink, olive green, and charcoal gray to name but a few.

I have also written a routine that selects musical tones to correspond to the colors on the screen. Obviously, the problem of selecting pleasant sounds, or ones that are a "good match" with the colors, is a very subjective matter, so we can't expect the computer to have the aesthetic sense of a Van Gogh or a Bach. However, the results are quite good for a simple program.

There are four colors on the screen, so one sound channel is assigned to each color register. The pitch of each channel is selected by the color number, and the loudness of the tone is selected by the brightness.

The program shifts randomly among five different harmonic modes, sets of notes that are related in some way. The five modes are defined by the five rows of the matrix FRQ and by the DATA statements that load it. The modes are:

* 0-Harmonic sequence. Note 2 is twice the frequency of note 1. Note 3 is 3 times note 1, etc.

* 1-Chromatic sequence. Consecutive notes are one semitone apart.

* 2-Parallel thirds. These correspond to every other note of the C major scale.

* 3-Diatonic sequence. A simple C major scale.

* 4-C major chord, C, E, and G, in all octaves.

You will note that in all harmonic modes, color number 0 produces a pitch of 0 for the sound channel. Color 0 refers to white, black, and six shades of gray. A pitch of 0 has the effect of turning the sound channel off (apparently because it produces a note that is too high to hear). Thus the neutral colors (the grays) are accompanied by the neutral sound--silence.

In selecting the loudnesses of the other colors, I decided to make the lightest and darkest colors produce the quietest notes. My reasoning was that the lightest colors are almost white, and the darkest ones are almost black. Therefore, the ones in the middle must be the most colorful (you might say loudest) colors, so they should produce the loudest sounds.

When switching to a new color, instead of a sudden flash, the program does a smooth fade by stepping through all intermediate values of color and brightness. The musical tone changes in step with the color. The speed of the fades is set by the delay factor that the program asks you to type in. Zero is the fastest. Using larger delay factors shows down the fades to that you can observe them more closely.

To do the fades, the program stores the current colors and brightnesses in the arrays CHROM and LUM, respectively. This means that if you see (or hear) something that you really like, you can stop the program by hitting BREAK or SYSTE, RESET and print out the numbers in the array so you can use them in your own programs.

When you look at the program, you may wonder what line 1070 is for.

It prevents the computer from going into "attract mode." This term is a carry-over from the arcade game world, and refers to what a game does when it is sitting around not being played.) After about nine minutes of running without any keys being pressed, the computer begins randomly switching all the colors every few seconds. This is supposed to save you from burning an image into the screen of your TV set if you should happen to walk away and forget to turn it off.

However, our program is already changing the colors every few seconds, so we don't need any h elp, thank you. Location 77 is used as a timer for attract mode, so by frequently resetting it to 0, we can prevent attract mode from messing up our display when we leave it running for a long time.

You may wish to modify this program, and try out your own ideas about how to generate pleasing combinations of colors and sounds. I trust that you will find Audio-Animation to be an eye-and ear-catching demonstration of the power of your computer.