New Monmouth, NJ
Would you like to teach your VIC to sing in three-part harmony? Here's a program, called the Harmonizer, that makes training your VIC easy.
Believe it or not, it's the data statements that make this program so friendly. In fact, they were given prime consideration in the design. The data statements tell the Harmonizer how to play your song. These statements change with each song, although the rest of the program stays pretty much the same. The data statements contain three kinds of information: voice commands, notes, and separators. These are described separately below.
Voice Commands: The VIC has three voices – Soprano, Alto, and Tenor. The voice command tells which voice we want to play the following notes. A voice command consists of the letter "V" followed by an "S", "A", or "T" for Soprano, Alto, or Tenor, respectively. The "VS" on line 10 is a voice command meaning soprano.
Notes: In a data statement, a note consists of an "A", "B", "C", "D", "E", "F", "G", or "R", followed by a number from 1 to 9. The letters "A" to "G" are the standard music names for notes. The "R" (for rest) means silence. The number following the letter tells how many counts the note or rest lasts. A count is not always the same as a musical beat; the shortest note in a song has a value of one count. This eliminates the need for a notation involving fractions.
Separators: Separators are just commas and spaces. You can put them in the data strings wherever you want. You might find them useful to keep track of musical groupings, to make your data more readable.
Other Data Features: An "X" indicates the end of your data, to save you the trouble of counting notes. It makes no difference what order you put the voices in, and you can change voices whenever you want. So, you could build up a complete tune a short phrase at a time using one or all voices, and check it as you go by listening, instead of listing.
When the Harmonizer is started, it seems to pause at first because it is reading the input data, sorting the notes by voices, and determining the internal note codes. Suddenly, it prints out how many notes were found for each voice, and plays the music. When it finishes, it prints out how much memory was free, and silences all the voices.
The first time you try it, remember to turn up the TV volume. For a quick test, you may want to leave out the data statements 12 to 20, 24 to 32, and 36 to 44. Also, you can leave out some of the REM statements to save space.
The key to understanding how it works inside is to study the two-dimensional array, "N%". The "N" stands for note and the "%" means integer. The N% array is like a table containing three rows and 81 columns of integers. The rows are numbered 0, 1, and 2; one row for each voice. Each row has 81 columns, numbered 0 to 80. Columns 1 to 80 store each voice's notes in an internal form in sequential order. See line 480. Both the pitch and duration are packed into a single integer. So, you have a maximum of 80 notes per voice. If you get more memory, you can have a larger array just by changing the 80 in line 130. Column 0 keeps track of how many notes each voice actually uses in a particular piece.
When playing begins (around line 500), two other one-dimensional arrays are also used to keep track of where the Harmonizer is. The SP% (for stack pointer) array keeps track of the column of the current note for a given voice. Likewise, the TM% (for timer) array keeps track of how long, in counts, the current note for a given voice has been playing.
All input comes from the subroutine at line 800, which gets a single character from the data statements and returns it in the variable "C$". This routine lets you use arbitrary length data strings and also takes care of the separators.
Once you have the standard program working, you will probably want to make changes. One of the first might be to add sharps and flats. These may be added using lines 350 to 410 as a guide. I've used the graphics on the front of the keys for this purpose; the one on the right means sharp, and the one on the left means flat. I've left this feature out of the article listing mainly so I could type it. Look at your VIC keyboard and imagine trying to figure out the difference between my hand-drawn C sharp and D sharp!
Other minor changes I might suggest would be to vary the tempo (line 680) or make the tune repeat (change line 740 to GOTO 510). A finishing touch would be to paint a picture on the screen to match the tune.
The Harmonizer was designed to be friendly; it's easy to use and modify. It works well. If you like music, I think you'll like the Harmonizer.