!lm10
!rm76
Two Fancy Tone Generators....................Mark Kriegsman

I was not quite satisfied with the sound from Bob Sander-Cederlof's "Touch-Tone Simulator" (AAL February 1981, page 5,6).  His method for making two simulataneous tones was to play one tone for a while and then the other one for a while, letting your ear put it all together.  I have written the following DUAL.TONES program which mixes the two tones together in a more realistic way.  I also wrote SINGLE.TONE which plays a given tone at 16 different volume levels.  All out of the standard Apple speaker!  Really!

The programs are accessed from Applesoft with the "&".  (See lines 1510 and 1830.)  SINGLE.TONE is called with &T followed by three expressions separated by commas.  The three expressions are for the tone, duration, and volume, respectively.  Tone is a value from 0 to 255, duration a value from 0 to 65535, and volume a value from 0 to 15.  Experiment with different settings and you will see how it works.  By making loops which change both pitch and volume, you can simulate the sound of a falling bomb or a passing car.

DUAL.TONES also needs three parameters:  tone#1, duration, and tone#2, respectively.  The two tone values must be between 0 and 255; duration is again a value from 0 to 65535.  It is interesting to try two tone values very close together, to hear the beating effect, and two tones at harmonic intervals to hear the chords.  I think &D 254,28000,255 sounds a little like a light saber.  Again, a loop which varies both tone values can make some exciting sound effects!

Lines 1340-1400 are executed when you BRUN B.AMPERTONE; they set up the ampersand vector for Applesoft.  Once this is done, an ampersand in your program or typed in as a direct command will start executing the AMPERTONE subroutine.

Lines 1440-1490 determine which & routine you are calling.  The character following the "&" is in the A-register.  If it is "T", SINGLE.TONE is called; if "D", DUAL.TONE is called; if neither, you get SYNTAX ERR.

Subroutines in the Applesoft ROMs are used to read the parameter expressions (lines 2190-2230).  GTBYTC advances to the next character, and then evaluates the expression that starts there.  If the value is between 0 and 255 it is returned in the X-register.  (If not, you get RANGE ERR.)  CHKCOM makes sure the next character is a comma; if it isn't, you get SYNTAX ERR.  GETNUM is used in executing the POKE statement.  It looks for an expression giving a value between 0 and 65535, then a comma, and then another expression giving a value between 0 and 255.  The first value is stored at $50 and $51, and the second is returned in the X-register.

[Mark Kriegsman is a 15-year-old Apple expert living in Summit, New Jersey.  I wrote the article above based on two letters and a program he sent.  (Bob Sander-Cederlof)]
