Peripheral Information

Adding a Voice Track to Atari Programs

John Victor

This technique shows you how to let your Atari talk - that is, play audio cassettes totally under the control of your program.

We recently had a chance to see the latest in audio-visual technology - a video tape machine being controlled by an Apple computer. The student was shown selected film sequences on the video tape. Then the video tape would stop and the student would be asked questions by the computer.

This demonstration had some impressive features, but the most important was the integration of voice with the computer question and answer technique. The same effect can be generated on an Atari 400 by combining text, graphics, animation, and color with a sound track recorded on an audio cassette. And the Atari 400 is significantly cheaper and easier to program than the combination video tape player/computer.

There are several ways that a software designer/programmer can sync a cassette voice track to visuals on the computer screen. The cassette player that plugs into the Atari computer records and plays in a stereo format. The right track on the tape records and plays digital information (such as programs or data files), while the left track plays audio recordings. The "Talk and Teach" ROM and tapes supplied with Atari computers use both tracks simultaneously. As the voice explains material, ASCII characters are read off the digital track and shown on the screen. The two are coordinated in the manufacturing process so that they are always synchronized.

The problem with the "Talk and Teach" system for the average Atari owner is that the development of the Talk and Teach cassettes requires different hardware than is supplied with the Atari system. In fact, the system may be developed and run on non-Atari equipment - we have seen the cassettes run on a modified TRS-80 computer.

The simplest and most practical method for Atari users to sync voice with their own educational programs is to use a "timed-BASIC" method, The visuals are programmed into a BASIC program and run simultaneously with an audio tape cassette. The program would then start and stop the Atari cassette player and change the visuals on the TV screen based on timing routines built into the program. The key to making this system work is that the audio tape must start at the same point each time it is used.

The computer course designer-programmer first writes a script as though he or she were producing a sound/filmstrip presentation. The spoken words, music, etc. would be specified along with a detailed description of what is to appear on the TV screen. The designer-programmer then writes a BASIC program that will produce the desired visual effects.

The next step is to coordinate the voice with the visuals. The best way to do this is to have a preliminary routine within the computer "freeze" each screen display until the programmer hits the 'RETURN' key. This can be done by sending the program to an INPUT subroutine, but this has the undesired side effect of printing an extraneous question mark on the screen. We prefer using the subroutine shown below since it prints nothing at all on the screen:

5000 IF PEEK(764)<>255 THEN POKE 764,255:RETURN
5010 GOTO 5000

Memory location 764 indicates whether a key has been pressed. If no key has been pressed, the number 255 will be stored there. When a key has been pressed, the routine sets the value back to 255 (to keep the computer from printing the key press) and the program returns from the subroutine.

The designer-programmer should read through the script and manually check the screen changes to see that the BASIC program and the script match up and produce the desired results.

The third step is to place timing routines into the program so that the visuals will be in sync with the recorded voice. We do NOT recommend using FOR... NEXT timing loops for these routines. FOR... NEXT loop timing is not linear on the Atari. This means that the Atari might take one second to count from 1 to 300 in one loop, and less time to do the same count in another loop of different length. In addition, the length of the program and position of the subroutine also affects the count.

Fortunately, the programmer can utilize a built-in clock used by the Atari computer to count the scan lines in the TV display, which is stored in memory locations 18, 19 and 20. Location 20 counts in "jiffies" or 1/60 second. Each 1/60 increases the value stored in location 20 by 1. When the count reaches 256, the value is cleared to 0 and location 19 is incremented by 1. It takes the computer about 4.27 seconds to count from 1 to 256 in location 20, and about 18.2 minutes to count from 1 to 256 in location 19. You can watch this process with the following program:

10 PRINT PEEK(20), PEEK(19), PEEK(18): GOTO 10

The results from these PEEKs could he converted to seconds, but we prefer to work in jiffies, which requires less math on the computer's part.

SECONDS = (PEEK(19)*256 + PEEK(20))/60
JIFFIES = PEEK(19)* 256 + PEEK(20)

We recommend that at this point the designer-programmer makes the final audio cassette that is to go with the computer program. The program can be timed to this cassette, and, if all copies of the cassette can he made to use the same starting point, then the program will work with all copies as well.

The task now is to figure out the timing for each change so that the changes will be made in sync with the audio cassette. Figure 1 shows a program that we developed to automatically make these measurements for an audio tape. The user puts the audio tape in the Atari cassette player and rewinds it to the very beginning. With the play button depressed, the user runs the program. Line 20 starts the cassette player, and the program begins timing. At each point where the user wished the computer to change the visual (in conjunction with the voice), the user hits the 'RETURN' key. At the end of the program the cassette is shut off, and the user is given the times between each point on the voice track where the computer is to change the visual.

The user should note that memory locations 19 and 20 are set back to 0 after each timing, and that line 55 looks specifically for an input from the 'RETURN' key. This program counts up to 15 changes, but this number can be increased by increasing COUNT in lines 40 and 100.

The last step is to insert the time values into the computer program and to check to see that the voice cassette works in sync with the program. Figure 2 shows a program that we wrote to illustrate how timing values can be coordinated with a teaching program and audio tape. Line 50 of the program defines the subroutines, of which there are three: one to print questions on the screen, one to time the visual so that the voice on the tape can read the question, and one to shut off the tape so that the student can answer the question just asked.

The QUESTIONASK subroutine in lines 4000-4030 gets its information for each question from a DATA line, which includes question number, screen color, answer to the question, number of lines to be read, and the lines of text making up the question. After printing the question, the program sets the time value for the voice, and goes to the clock subroutine at 5000-5020. When the correct time elapses, the program goes to the QUESTIONANSWER routine, Here the tape is shut off, and the user is required to answer the question. Upon answering, the tape is turned back on.

The time values in this program are based on our own personal reading of the questions.

While it is possible to record both programs and audio on the same cassette and still utilize the method we have described here, the best way is to record programs and audio separately. Ideally, the programs would be stored on disk and the voice on cassette.

It is possible that with very long audio cassettes the computer and tape will get out of sync due to small variations of the cassette player. The designer-programmer can correct for this by occasionally having the student press 'RETURN' when he or she hears a beep on the audio track, This gives a frame of reference for the program timing to match up to the tape. The least obvious way of doing this is to have the student press 'RETURN' before answering a question.

Program 1. Timing Program

Download (Saved BASIC)
Download / View (Listed BASIC)

Program 2. Timing For Tutorials Using Voice and Timing Loops

Download (Saved BASIC)
Download / View (Listed BASIC)

Return to Table of Contents | Previous Section | Next Section