Piano

See all articles from The Plotter v2 n4
Author(s): Roger Valentine
Publication: The Plotter
Pub Details: The Plotter v2 n4 (Volume 2, Issue 4)
Date: April 1984
Pages: 2

Our 2068 program comes this time comes from the book THE TIMEX SINCLAIR 2068 by Roger Valentine.

  10 LET n$="q2w3er5t6y7ui9o0p"
20 DIM a(256)
30 FOR j=1 TO 17:LET a(CODE n$(j)+1=j
40 NEXT j
50 LET i=CODE INKEY$+1
60 IF a(i) THEN BEEP .5,a(i)-1
70 GO TO 50
9000 SAVE "PIANO" LINE 0

This short program redefines the top row of letter keys (QWERTYUIOP) to be the white keys of a piano and the proper number keys above them to be the black piano keys. The letter “E” produces the note E. Q will produce C. The number 4 is not used.

LINE NOTES:

10      Sets up the new array
        that changes the pitch of
        the BEEP.
30+50   Adjusr by +1 and -1 to
 60     compensate for the fact
        that the character code
        starts at 0 and our array
        starts at 1.
60      Also rejects any keypress
        which has no redefined
        value, and produces a 1/2
        second VEEP for the piano
        keys.

Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.