
The ZX Spectrum can make sounds of an infinite variety. The frequency of the note
and its duration are under the control of the user. The command BEEP
is used to tell the computer to make a sound. BEEP
is an extended mode command and is obtained using the Z
key.
The
'centre' frequency for the BEEP command is middle C. This can
be varied within the BEEP command, and any note can be obtained
if it is expressed as semitones or parts of semitones above or below
this centre frequency. If the command
BEEP
2,0 is
entered the computer should emit a sound at middle C pitch for two seconds.
The two numbers between them control the sort of note that is emitted,
the first giving the length of the note in seconds, and the second the pitch of
the note in semitones above middle C. Thus the pitch code for middle C is 0, that
for C# is 1, for D it is 2, and so on up to the next C above which is 12, because
12 semitones make one octave. You can carry on to 13 and beyond, if you want,
so that the higher the number, the higher the pitch.
Try this:
BEEP
1,4: BEEP 1,2: BEEP 2,0 You
should hear no less than the first bar of Three Blind Mice. Since you
can join quite a few BEEPs together with colons like this, you
could, if you had the patience, produce a whole tune. You might like
to try using more notes than just three.
(Colons don't just join BEEPs together; you can use them to build composite
commands out of any of the elementary commands.)
As a more complicated example, you can make a singing chameleon command
by mixing BEEP and
BORDER together:
BORDER
1: BEEP 1,14: BORDER 3: BEEP 1,16: BORDER 4: BEEP 1,12: BORDER 6:
BEEP 1,0: BORDER 5: BEEP 4,7: BORDER 1 (Don't
worry about the fact that this stretches over from one line to the next:
the computer doesn't take any notice of this.)
A short program to play a whole series of notes could be as follows:
10
FOR x=0 TO 24
20 BEEP 2, x
30 NEXT x There
are a lot more things that can be done with this command - see the BASIC
programming manual for other ideas.
For notes lower than middle C the number of semitones is indicated by
a negative number.
|
|