A Matter of Time works out the register values needed to make the TS2068’s AY sound chip envelope last a given time. You enter a number of seconds, up to 9.5. The program shows the fine-tune and coarse-tune values for envelope registers 11 and 12, the frequency, and the matching PAUSE value, then plays a tone with that envelope so you can hear it, and asks again.
The screen credits Peter Ross.
Program Analysis
The program is ten lines long. It takes the envelope frequency as F=1/S and the envelope period as EP=1764000/(256*F), using the chip’s 1.764 MHz clock. The whole part of EP/256 is the coarse value and the remainder, times 256, is the fine value. Line 50 then plays a tone on channel A (SOUND 1,1;0,21;7,62;11,ft;12,ct;13,11;8,16), waits 60*S frames and turns it off.
Notable Techniques
- Envelope shape 11 is used for the test tone.
- The prompt is printed in the lower screen with
PRINT #1.
This copy comes from a Larken disk, the TTSUC library disk “Music and Sound”. It was converted for tape (the disk command was removed from the save line) and tested in ZEsarUX.
Source Code
10 REM ** A MATTER OF TIME ***
15 PAPER 0: BORDER 0: INK 5: BRIGHT 1: CLS : PRINT AT 11,3;"THIS PROGRAM IS USEFUL IN FIG-URING OUT THE REQUIRED REGISTER VALUES FOR SETTING THE ENVELOPE GENERATOR TO A SPECIFIC AMOUNT OF SECONDS (UP TO 9.5).": PRINT #1;AT 1,0;"PRESS ANY KEY": PAUSE 0
20 INPUT "HOW MANY SECONDS ? ";S: LET F=1/S: PAPER 1: BORDER 1: BRIGHT 1: INK 6: CLS
25 LET EP=1764000/(256*F)
30 LET CT=INT (EP/256)
40 LET FT=INT (((EP/256)-INT (EP/256))*256)
45 PRINT INK 2; PAPER 0;AT 1,1;"CONTROLLING THE TIME ON THE EG"''' INK 6; PAPER 1;"SECONDS ";S'"FINE TUNE ";FT'"COARSE TUNE ";CT'"FREQ ";F'"PAUSE ";60*S; INK 3;AT 21,17;"by Peter Ross"
50 SOUND 1,1;0,21;7,62;11,ft;12,ct;13,11;8,16: PAUSE 60*s: SOUND 8,0;7,63: GO TO 20
9997 STOP
9998 SAVE "EnvGen.B1" LINE 1Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.


