Simple Synthesizer
- Type
- Sound
- Category
- Music keyboard project (hardware plus BASIC software)
- Author
- Vern Mastel
- Published in
- Antic, November 1983 (Vol. 2, No. 8)
- Year
- 1983
- Language
- Atari BASIC
- Requirements
- 16K RAM, Atari BASIC; a home-built one-octave keyboard on joystick port 1 (a joystick works for testing); optional 10K pots on the paddle inputs for volume
- Tags
- antic, music, synthesizer, hardware-project, joystick-port, paddles, diy, vern-mastel, 1983
About the program
Vern Mastel managed a Team Electronics store in Bismarck, North Dakota. In November 1983 he showed Antic readers how to turn a real piano-style keyboard into an Atari music peripheral using nothing but signal diodes, switches and a short BASIC program, with "no machine language subroutines". He got his keyboard from a junked Wurlitzer organ for $20. One octave, C to C, is all you need.
The trick is the joystick port. A joystick is just four direction switches and a trigger, and STICK(0) reports the four switches as a 4-bit number. A normal stick only produces 5–15, but grounding other combinations of the pins gives the missing values. So each controller port can be treated as a four-bit parallel input. A diode matrix lets one switch under each of the 13 keys pull down the right combination of pins, so each key returns its own STICK value, and that number indexes a table of pitches. Pots on the paddle inputs set the volume of each voice. Mastel recommended 10K pots rather than the usual 1 megohm so that the readings fall in a small, usable range.
The article warns that the wiring "should not be undertaken by beginners". Without the hardware, an ordinary joystick still plays a few of the notes.
Typing it in
The listing is plain text except for a few inverse digits in the menu ({inv}…{/inv}: press the Atari key before and after). Mastel commented the program heavily for the magazine. He then asked readers to delete the REMs after checking the program with TYPO, because they slow BASIC down enough to spoil the piano mode.
How to use it
Press 1–6 to pick a mode. The screen goes blank: Mastel found that with the display on, BASIC missed notes when he played fast. Press any computer key to get back to the menu.
- 1 Multiple voices: three voices an octave apart, each with its own paddle volume.
- 2, 3 Chords: each key plays its major chord (C also sounds E and G), in two octaves.
- 4–6 Piano: a held note fades away and won't sound again until you release the key and press it again. The size of the delay loop in line 60 sets the decay.
How it works
- Lines 500–1010 load the arrays
L,MandH(low, middle and high) with values from Atari's pitch chart, indexed by theSTICKvalue of each key. - The play loops just read
STICK(0)and the paddles, then issueSOUNDcommands. Value 15 means no key is down, so the sound is switched off. - Location 764 is checked on every pass, so that pressing any key on the computer's keyboard returns to the menu.
- Line 300 uses a logical value in
ON FLAG=1 GOTO 80: when the flag is 1 it jumps to the chord routine, and otherwise it falls through toGOTO 20.
Listing
1 REM PROGRAM 4
2 REM THE SIMPLE SYNTHESIZER BY VERN L. MASTEL
4 REM SET UP MATRIXES, OPEN KEYBOARD FOR INPUT
5 DIM H(13),M(13),L(13):OPEN #1,4,0,"K":TRAP 300:GOTO 200
19 REM MULTIVOICE ROUTINE LINES 20-40
20 K=STICK(0):L0=PADDLE(0):L1=PADDLE(1):L2=PADDLE(2):KC=PEEK(764):IF KC<>255 THEN 199
29 REM IF NO KEY IS PRESSED TURN OFF THE SOUND
30 IF K=15 THEN SOUND 0,0,0,0:SOUND 1,0,0,0:SOUND 2,0,0,0:GOTO 20
40 SOUND 0,M(K),10,L0:SOUND 1,L(K),10,L1:SOUND 2,H(K),10,L2:GOTO 20
49 REM PIANO MODE LINES 50 TO 75
50 K=STICK(0)
52 KC=PEEK(764):IF KC<>255 THEN 199
54 REM IF NO KEY IS PRESSED TURN OFF THE SOUND
55 IF K=15 THEN SOUND 0,0,0,0:GOTO 50
58 REM SAVE KEY IN LAST KEY PRESS, START DECAY LOOP
59 REM CHECK DURING LOOP TO SEE IF A KEY IS STILL PRESSED AND IF IT IS THE SAME KEY
60 LKP=K:FOR X=10 TO 0 STEP -1:SOUND 0,M(K),10,X:FOR D=1 TO 30:NEXT D:K=STICK(0):IF K=LKP THEN NEXT X
69 REM READ KEYBOARD AGAIN. IF KEY IS STILL THE SAME AT THE END OF DECAY WAIT FOR A NEW KEY TO BE PRESSED
70 NKP=STICK(0):IF NKP=LKP THEN 70
74 REM START SEQUENCE AGAIN
75 K=NKP:GOTO 55
79 REM CHORD ROUTINE. THIS IS THE SAME AS THE MULTIVOICE ROUTINE EXCEPT THE NOTE VALUES ARE DIFFERENT
80 K=STICK(0):L0=PADDLE(0):L1=PADDLE(1):L2=PADDLE(2):KC=PEEK(764):IF KC<>255 THEN 199
84 REM WATCH OUT FOR TWO KEYS BEING PRESSED AT ONE TIME GIVING A ZERO VALUE
85 IF K=0 THEN 80
89 REM IF NO KEY IS PRESSED TURN OF THE SOUND
90 IF K=15 THEN SOUND 0,0,0,0:SOUND 1,0,0,0:SOUND 2,0,0,0:GOTO 80
100 SOUND 0,L(K),10,L0:SOUND 1,M(K),10,L1:SOUND 2,H(K),10,L2:GOTO 80
198 REM THROW AWAY THE FIRST ATARI KEYPRESS AND SET UP THE SCREEN FOR THE MENU LINES 200 TO 220
199 GET #1,NULL
200 GRAPHICS 17:SETCOLOR 4,5,4:SETCOLOR 2,11,6:? #6:? #6:? #6;" SIMPLE SYNTHESIZER":? #6:? #6
210 ? #6:? #6:? #6;"MULTIPLE VOICES---{inv}1{/inv}":? #6:? #6;"1ST OCTAVE CHORDS-{inv}2{/inv}":? #6:? #6;"2ND OCTAVE CHORDS-{inv}3{/inv}"
215 ? #6:? #6;"PIANO OCTAVE 1----{inv}4{/inv}":? #6;"PIANO OCTAVE 2----{inv}5{/inv}":? #6;"PIANO OCTAVE 3----{inv}6{/inv}"
219 REM MAKE SURE THE INPUT IS VALID AND PROCESS THE CHOICE
220 ? #6:? #6:? #6;" SELECT MODE ({inv}1{/inv}-{inv}6{/inv})";:GET #1,C:IF C<49 OR C>54 THEN 200:FLAG=0
229 REM TURN OFF THE SCREEN AND LOAD THE CORRECT MATRIX VALUES FOR THE MODE SELECTED
230 POKE 559,0:GOTO 230+10*(C-48)
240 FLAG=0:RESTORE 510:GOTO 500
250 FLAG=1:RESTORE 610:GOTO 600
260 FLAG=1:RESTORE 710:GOTO 700
270 RESTORE 810:GOTO 800
280 RESTORE 910:GOTO 900
290 RESTORE 1010:GOTO 1000
299 REM DO CHORDS IF SELECTED OTHERWISE DO MULTIVOICE
300 ON FLAG=1 GOTO 80:GOTO 20
499 REM ALL OF THE PITCH VALUES ARE STORED AS DATA STATEMENTS AND READ UPON DEMAND
500 FOR X=1 TO 13:READ A,B,C:M(X)=A:L(X)=B:H(X)=C:NEXT X:GOTO 300
510 DATA 121,243,60,114,230,57,108,217,53,102,204,50,96,193,47,91,182,45,85,173,42,81,162,40,76,153,37
520 DATA 72,144,35,68,136,33,64,128,31,60,121,29
600 FOR X=1 TO 13:READ A,B,C:L(X)=A:M(X)=B:H(X)=C:NEXT X:GOTO 300
610 DATA 243,193,162,230,182,153,217,173,144,204,162,136,193,153,128,182,144,121,173,136,114,162,128,108
620 DATA 153,121,102,144,114,96,136,108,91,128,102,85,121,96,81
700 FOR X=1 TO 13:READ A,B,C:L(X)=A:M(X)=B:H(X)=C:NEXT X:GOTO 300
710 DATA 121,96,81,114,91,76,108,85,72,102,81,68,96,76,64,91,72,60
720 DATA 85,68,57,81,64,53,76,60,50,72,57,48,68,53,45,64,50,42,60,47,40
800 FOR X=1 TO 13:READ A:M(X)=A:NEXT X:GOTO 50
810 DATA 243,230,217,204,193,182,173,162,153,144,136,128,121
900 FOR X=1 TO 13:READ A:M(X)=A:NEXT X:GOTO 50
910 DATA 121,114,108,102,96,91,85,81,76,72,68,64,60
1000 FOR X=1 TO 13:READ A:M(X)=A:NEXT X:GOTO 50
1010 DATA 60, 57,53,50,47,45,42,40,37,35,33,31,29
Download
The original program from the Antic disk, to LOAD or ENTER instead of typing it: SMPSYNTH.BAS.
Credits
- Program listing: Simple Synthesizer — program listing (Antic, November 1983 (Vol. 2, No. 8)) — Vern Mastel
- Picture: The mode menu. Choosing a mode blanks the screen and hands over to the music keyboard. — Vern Mastel (program); screenshot by the site
- Antic, November 1983 (Vol. 2 No. 8): Simple Synthesizer, by Vern Mastel (atarimagazines.com) — Vern Mastel, 1983
- Antic disk, November 1983 - Vol. 2 No. 8: SMPSYNTH.BAS (detokenized listing) — AtariMagazines.com (Kevin Savetz), 1983
