statement/SOUND statement/SOUND
NAME
SOUND -- Produces a sound
ABBREVIATION
s <shift> O
SYNOPSIS
SOUND <voice>,<frq_control>,<duration>
FUNCTION
This statement produces a SOUND using one of the three voices (<voice>)
with a frequency control (<frq_control>) in the range of 0-1023 for a
duration (<duration>) of 0-65535 60ths of a second.
The Commodore 16 have 2 independent sound channels and ability to
produce square and white noise timbres as follows:
Voice Sound channel Wave shape
-----------------------------------
1 1 square
2 2 square
3 2 noise
If a SOUND for voice n is requested, and the previous SOUND for the same
n is still playing, BASIC waits for the previous SOUND to complete.
SOUND with a duration of 0 is a special case. It causes BASIC to turn
off the current SOUND for that voice immediately, regardless of the time
remaining on the previous SOUND.
INPUTS
<voice> - voice number (1-3)
<frq_control> - sound register value (0-1023)
<duration> - duration of a sound in 60ths of a second (0-65535)
RESULT
Cuts off or produces a sound with square or white noise timbre.
EXAMPLES
SOUND 2,800,3600
Plays a note using voice 2 with frequency set at 800 for one minute.
NOTES
The sound register value (<frq_control>) does not correspond directly to
the real sound frequence. If you want to produce a sound with a certain
frequency use the following formulas to find the sound register value
for the desired frequency:
formula for computers using PAL television standard
SOUND REGISTER VALUE = 1024-(111840.45/FREQUENCY)
formula for computers using NTSC television standard
SOUND REGISTER VALUE = 1024-(111860.781/FREQUENCY)
BUGS
None
SEE ALSO
VOL