Here’s a program that lets you play the TS 2068 like a piano, by using the BEEP function. Or maybe I should say like a xylophone, since the instrument will not sustain notes, but rather gives the impression of sustaining by repeating a note rapidly. First, let’s have a look at what the BEEP does. You will remember that BEEP needs an argument of two numbers, the first specifying the duration of the note, and the second defining its frequency (pitch). If 0 is used as a pitch signal, middle “C” is generated. The pitch rises a half tone for each time that number is increased by 1; it goes down a half tone for each time the number is decreased by 1. (Fractional increases or decreases are permitted if your ear will resolve intervals smaller than a half tone). NOTE: in the tempered scale to which pianos (and TS 2068’s) are tuned, a half tone (also known as a semi-tone) represents a frequency ratio equal to the twelfth root of two. I should mention here that there is an error on page 66 of the 2068 manual. Numbers 4 and 5 should be replaced by 3 and 4, respectively, and “FA and SOL” should read “MI and FA”. You can program a major scale into your computer with the following mini-program:
10 LET F=0
20 FOR G=1 TO 15
30 BEEP 1,F
40 IF G=3 OR G=7 THEN LET F=F-1
50 IF G=10 OR G=14 THEN LET F=F-1
60 LET F=F+2
70 NEXT G
A little experimenting with the length of the note showed that .05 was about the shortest I could make the constant in line 30 and still have a pitch defined well enough to suit my ear. If the duration of the BEEP is too short, it degenerates into a click. If the note is too long, then operation will be sluggish. Fool around with it yourself, and see what value suits you best. If you want, you can make it flexible, to be set initially each time you RUN the program. Or you could even make the length of the tone depend on its frequency, by setting up a second array to store a tone length for each note. As you can see from the listing, the program itself is very simple. The “working part” of the program is contained in lines 100 to 140–the rest of the program is used only once, to set up a matrix of notes to correspond to the computer’s keys. The line numbers used in lines 634 to 795 are not as capricious as they might look. If you will compare them with lines 520 and 550, you will see that their line numbers are related to the positions in array A, so that A(34) becomes the first number in line 634, A(195) becomes the first number in line 795, and so on. When the program is first RUN, the FOR-NEXT loops in lines 520 to 570 (and the single-step “loop” of line 580) assign the appropriate values to array A, and then let you know when the “piano” is ready to play. You will find then that the lower-case values of the bottom two rows of keys give you an octave of notes (C to B), which is continued for a little over an octave on the top two rows. The lower of the two rows acts as the piano’s white keys in each case, while the upper of each pair of rows serves as the black keys. It will help you to keep them straight if you identify the black keys in some way, as by sticking a square of masking tape on keys S, D, G, H, J, 2, 3, 5, 6, 7, 9, and 0. But don’t use anything (like fingernail polish, for instance) that could damage the surfaces of the keys, or would be hard to remove. To extend the range of the instrument, the symbol shift key makes all notes sound an octave higher than their normal pitch, while use of the capital shift lowers by one octave the pitch of all notes played on the lower rank of keys.
Listing 1 – The 2068 Piano
10 GO TO 500
100 IF INKEY$="" THEN GO TO 100
110 LET B=CODE INKEY$
120 IF B<1 OR B>205 THEN GO TO 100
130 BEEP .05,A(B)
140 GO TO 100
500 DIM A(205)
510 RESTORE
520 FOR F=34 TO 121
530 READ N: LET A(F)=N
540 NEXT F
550 FOR F=195 TO 205
560 READ N: LET A(F)=N
570 NEXT F
580 LET A(172)=36
585 CLS : PRINT "READY"
590 GO TO 100
634 DATA 40,27,0,30,32,34
640 DATA 0,37,19,0,21,22,23,17,27,0
650 DATA 13,15,0,18,20,22,0,25,12,38
660 DATA 29,0,31,16,25,0,-5,-8,-9,0
670 DATA 0,-6,-4,0,-2,0,0,-1,-3,0
680 DATA 0,0,0,-11,0,0,-7,0,-10,0
690 DATA -12,0,0,0,20,39,14,0,7,4
700 DATA 3,16,0,6,8,24,10,0,0,11
710 DATA 9,26,28,12,17,1,19,23,5,14
720 DATA 2,21
795 DATA 13,0,35,33,24,28,26,0,18,0,15
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.