Classic Computer Magazine Archive ANTIC VOL. 9, NO. 2 / JUNE 1990

FEATURE APPLICATION

Antic Music Transposer

Instant key changes for any Antic Music Processor song

By Joe Cabuk

Want to sing along, but the song's just not in your key? Now you can easily change the key or range of songs entered in the Antic Music Processor with Transposer and Shifter, two BASIC utility programs for the ever-popular AMP. These programs run on Atari 8-bit computers with at least 48K memory and disk drive.

I have really enjoyed using Antic Music Processor(AMP) the Super Disk Bonus program by Steven Lashower from the December 1988 and June 1989 issues of Antic. Entering songs in AMP is very easy, and since the program first came out I have stored many of my favorite tunes on disk.

Once you've entered a song, you can easily change the tempo or volume at which the song plays, but to change the key or pitch you'd essentiaHy have to re-enter the song note by note. After using the Music Processor for a while, I decided to see if I could build a program to transpose the songs into new keys. Since the keys in music are all relative to each other, and the notes follow fixed patterns, I figured this task should be easy for the computer. Well, after some study in a few music texts, I was able to devise a scheme for transposing on the computer. The result was two programs, Transposer and Shifter. Transposer changes a song's key, while Shifter moves the pitch up or down an octave. Using these two tools, you can easily change the key or range of your AMP songs for a more pleasing sound, or to put a song in the perfect range for a sing-along.

Getting Started

For the Transposer, type in Listing 1, TRANSPOZ.BAS, check it with TYPO II, and SAVE a copy to disk before you RUN it. For the octave Shifter, type in Listing 2, SHIFTER.BAS, check it with TYPO II, and SAVE a copy to disk.

When you RUN Transposer, it prompts you for the filename of the song you wish to transpose. Then, follow the prompts to transpose your song. You won't need any more musical knowledge than is necessary to enter the songs into AMP, but you do need to know how many sharps or flats are in the current key of the song to be transposed. (To find the old key, load the song into AMP and look at the song in the Editor. The KEY indicator at the bottom of the screen notes the number of sharps or flats.) You can enter sharps as either # or S, flats as either b or F.

Loading and transposing a song can take a long time, so be patient. Then, after transposing the song, SAVE the new version. Be sure to use a new filename, I use the key as a filename extension, e.g. D:COMESAIL.C, to keep each version clearly identified. Now you can run AMP as usual, and proceed normally to load and play the transposed music.

If you find the song is pitched considerably too high or low. you can use the Shifter to move the tune up or down an octave. The Shifter works very much like the Transposer. RUN Shifter, then follow the prompts, and SAVE the shifted version. Again, I like to use extenders to keep the different versions straight. For shifted songs, I use "UP" or "DN" in addition to the key, as in D:COMESAIL.CDN.

Cracking the Code

Once I'd researched the musically technical problems of transposition music, the problem was to get the program to identify the notes stored by AMP. I used AtariWriter to pull a few song files onto the computer screen so I could look at the storage format. In the past, this technique has helped me learn how other programmers have stored data. Unfortunately, it didn't help much with AMP - all I got was a screen full of jumbled characters. (I later learned this was caused by the presence of "control characters" for up-down-left-nght.)

Next, I tried having the computer print out the ASCII characters for the data stored in the AMP song files. BINGO! Using this technique, I was able to locate the beginning and end of each voice, and the key-signature data. Steven Lashower had used the ASCII characters from zero through 64 to store the musical notes from C in the first octave through F in the sixth octave. In addition, he uses the letter T for rests and Y for lyric advances.

Each note, rest, and lyric advance is stored in groups of three characters (each voice ends with three ASCII 255s). The actual note is the first item in each group of three characters. The other two characters in each group contain the note duration, and other information which does not change during the process of transposing a song.

Armed with this information, I wrote Transposer, which will correctly change the key of any AMP song. Then, I decided that I needed to be able to ensure that the transposed song would be centered on an octave which is pleasing to the ear, or easy to use for singalongs.

The Octave Shifter was an easy program to write. To change the octave, all the program had to do was shift the notes up or down by twelve steps per octave. I considered combining the two programs, or revising the Transposer so it would "center" each song around middle-C, but decided to leave the two separate so Antic readers can make their own improvements.

Program Take-Apart

Since both programs work with AMP song files, they share a number of program lines. For very long songs, you may need to reserve more memory in line 60 for the string MU$. (If your computer has too little memory, you can also reduce the amount of memory required by making MU$ smaller.) You can estimate the memory needed by taking the number of disk sectors used by the stored song and multiplying this number by 130. For a song filling 100 disk sectors you'd change the DIM state ment for MU$ to 13000, for examaple.

In lines 130-260 the program gets the song file from your disk and stores the music characters in the string MU$. The End-of-File error tells the program when the entire song has been stored in MU$.

Lines 550-680 do the transposing. If a note is shifted to a value less than zero or more than 64, the program adds or subtracts twelve to keep all notes in the correct musical range for AMP. Notes that were originally at the extreme ends of AMP's range won't get lost, but may shift up or down an octave in relation to the rest of the tune.

NOTE: Transposer cannot correctly transpose data groups stored using the AMP NOTE command. If you transpose a song with such NOTEs, you will need to load the song into AMP and correct the NOTEs in the AMP editor.

SPECIAL DISK BONUS: FOUR AMP SONGS

For your musical entertainment, and to go with the Transposer and Shifter programs in this issue, we've included four Antic Music Processor (AMP) song files on disk. Transposer author Joe Cabuk sent in TRACES.AMP a shorter song complete with lyrics that makes a good test file for the Transposer program. Peter Fries of Plano, Texas wrote BOLERO.AMP which was a runner-up in our AMP song contest. Though we announced the winners back in the June 1989 issue, the size of the song (almost five minutes of music!) made it hard to fit on disk until now. JEDI.AMP brings a popular sci-fi theme to your Atari. Rounding out the disk, you'll find a familiar ballad, complete with lyrics on side B - ELEANOR.AMP.

You can modify any of these song files using the programs TRANSPOZ.BAS and SHIFTER.BAS, also on disk. However, to see your results - and hear the songs -you must have our popular Antic Music Processor program, which appeared in the June 1989 issue of Antic. From the AMP main menu you can Load your songs, then press [P] to play them back, or press [E] to see the notes in the editor.

Listing 1: SHIFTER.BAS Download

Listing 2: TRANSPOZ.BAS Download

On disk: BOLERO.AMP Download

On disk: ELEANOR.AMP Download

On disk: JEDI.AMP Download

On disk: TRACES.AMP Download


Joe Cabuk is a retired Air Force officer, living in Oak Ridge, Louisiana. He has owned Atari computers since 1984 and taught himself to program. This is his first article in Antic.