Shakuhachi Keyboard
- Type
- Sound
- Category
- Generative music / sound demo
- Author
- Albert Baggetta
- Published in
- ANALOG Computing (1987); adapted by GIA Software (1988) and reprinted on the Czech disk magazine Flop, issue 5
- Year
- 1987
- Language
- Atari BASIC
- Requirements
- Any 8-bit Atari with Atari BASIC (the GIA REM says "for all ATARI XL/XE"); disk or cassette
- Tags
- music, pokey, sound, generative, analog-computing, flop, gia-software, atari-basic
- Related
- BASICally Melodic, Programming Music on the Atari: From DATA Statements to Interrupt-Driven Players, POKEY Sound Basics: SOUND, Registers and Your First Effects, SIMUL$ Four-Voice Sound (De Re Atari), Drum Synth and Bass Synth, Advanced POKEY: AUDCTL, 16-Bit Voices, Filters and Volume-Only Sound
About the program
The shakuhachi is the end-blown Japanese bamboo flute. Albert Baggetta's little program, credited "(c) 1987 ANALOG Computing" in its REMs, gives you an endless, gently random melody in that style. It picks notes from a five-note scale, lets each one swell up from silence, and adds a whisper of noise on a second voice to suggest breath. This version was prepared by the Czech group GIA Software in 1988 ("program SHAKEY.BAS … for all ATARI XL/XE, disk or cassette") and distributed on the disk magazine Flop 5.
Typing it in
- The REM box in lines 10–30 uses CTRL-Q, CTRL-R, CTRL-E, CTRL-Z and CTRL-C line-drawing characters. It's decorative, so type plain dashes if you prefer.
- The title graphic in lines 120–180 is built with
CHR$()codes rather than typed graphics characters. 8 and 10 are the two triangle characters (CTRL-H ◢ and CTRL-J ◣), 7 is the diagonal CTRL-G, and 136 and 138 are the inverse forms of the triangles. Together they draw two little mountain peaks around the title, and there's nothing special to type. - Line 200 prints a row of
^characters to underline "JAPANESE SCALE". - In line 340,
:REM REMOVE REM FOR DELAY BETWEEN NOTES AB=1^1is a leftover comment. Leave it as it is.
How to use it
Just RUN it. The screen fades in (lines 210–220 ramp the colour luminance), then the program plays forever and prints each note name as it sounds: G, A, C, D, E or G. Press BREAK to stop, and type END or press RESET to silence the last note.
How it works
- Line 100 sets up GRAPHICS 0 with all colours black and
POKE 703,4(BOTSCR, the number of text-window lines). It writes the title through#6, the S: channel that BASIC'sGRAPHICScommand opens, so no cursor is drawn. - Lines 230–300 choose one of six pitches at random with
ON X GOTO. The POKEY values 162, 144, 121, 108, 96 and 81 make a pentatonic scale (G A C D E G), which is the scale family used in much traditional Japanese music. Any order of these notes sounds pleasant. - Line 310 is the "breath". Voice 0 plays the note (distortion 10, pure tone) while its volume climbs from 0 to 4 in steps of 0.3. At the same time voice 1 plays pitch 1 with distortion 8 (noise) at volume 1.
- Line 330 holds the note for a random time of up to 350 empty loop passes, then line 340 cuts the sound and the next note begins.
Variations to try
- Change the scale. Swap in other POKEY pitch values in lines 250–300 for a blues or major pentatonic.
- Give it longer, more flute-like swells by raising the top volume in line 310 (up to 15) and reducing the step size.
- Add a second melodic voice on channel 2 a fifth above (roughly two-thirds of the pitch value).
Listing
10 REM {CTRL-Q}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-E}
20 REM | SHAKUHACHI KEYBOARD |
30 REM {CTRL-Z}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-R}{CTRL-C}
40 REM by Albert Baggetta
50 REM (c) 1987 ANALOG Computing
60 REM (p) 1988 by GIA Software
70 REM program SHAKEY.BAS
80 REM for all ATARI XL/XE
90 REM disk or cassette
100 GRAPHICS 0:POKE 703,4:POKE 752,1:? #6;CHR$(125):SETCOLOR 1,0,0:SETCOLOR 2,0,0:SETCOLOR 4,0,0
110 ? #6:? #6:? #6:? #6
120 ? #6;" ";CHR$(8);CHR$(10)
130 ? #6;" ";CHR$(8);CHR$(7);CHR$(136);CHR$(138)
140 ? #6;" ";CHR$(136)
150 ? #6;" Shakuhachi Keyboard"
160 ? #6:? #6;" ";CHR$(8);CHR$(10)
170 ? #6;" ";CHR$(8);CHR$(7);CHR$(136);CHR$(138)
180 ? #6;" ";CHR$(136)
190 POSITION 0,18:? #6;" JAPANESE SCALE"
200 POSITION 0,19:? #6;" ^^^^^^^^^^^^^^^^^^"
210 FOR I=1 TO 15
220 SETCOLOR 2,1,I:SETCOLOR 4,1,I:SETCOLOR 1,1,15-I:NEXT I
230 X=INT(RND(0)*6)+1
240 ON X GOTO 250,260,270,280,290,300
250 P=162:? "G ";:GOTO 310
260 P=144:? "A ";:GOTO 310
270 P=121:? "C ";:GOTO 310
280 P=108:? "D ";:GOTO 310
290 P=96:? "E ";:GOTO 310
300 P=81:? "G ";:GOTO 310
310 FOR D=0 TO 4 STEP 0.3:SOUND 0,P,10,D:SOUND 1,1,8,1:NEXT D
320 SOUND 0,P,10,D:SOUND 1,1,8,1
330 FOR E=1 TO INT(RND(0)*350):NEXT E
340 SOUND 1,0,0,0:SOUND 0,0,0,0:REM REMOVE REM FOR DELAY BETWEEN NOTES AB=1^1
350 GOTO 230
Credits
- Program listing: Shakuhachi Keyboard — program listing (ANALOG Computing (1987); adapted by GIA Software (1988) and reprinted on the Czech disk magazine Flop, issue 5) — Albert Baggetta
- Gury's Atari 8-bit Forever — Shakuhachi Keyboard — Albert Baggetta
