BEEP .5,5: BEEP .5,3: BEEP .5,2:
BEEP 1,0
80 BEEP 1,0: BEEP 1,-5: BEEP 2,0
90 BEEP 1,0: BEEP 1,-5: BEEP 2,0
When you run this, you should get the funeral march from Mahler's first symphony, the bit where the goblins bury the US Cavalry man.
Suppose for example that your tune is written in the key of C minor, like the Mahler above. The beginning looks like this:

and you can write in the pitch values of the notes like this:

0 2 3 2 0 0 2 3 2 0 3 5 7 3 5 7
We have put in two ledger lines, just for good measure. Note how the E flat in the key signature affects not only the E in the top space, flattening it from 16 to 15, but also the E on the bottom line, flattening it from 4 to 3. It should now be quite easy to find the pitch value of any note on the stave.
If you want to change the key of the piece, the best thing is to set up a variable key and insert key+ before each pitch value: thus the second line becomes:
20 BEEP 1,key+0: BEEP 1,key+2: BEEP .5,
key+3: BEEP.5,key+2: BEEP 1,key+0
Before you run a program you must give key the appropriate value – 0 for C, 2 for D, 12 for C an octave up, and so on. You can get the computer in tune with another instrument by adjusting key, using fractional values.
You also have to work out the durations of all the notes. Since this is a fairly slow piece, we have allowed one second for a crotchet and based the rest on that, half a second for a quaver and so on.
More flexible is to set up a variable crotchet to store the length of a crotchet and specify the durations in terms of this. Then line 20 would become:
20 BEEP crotchet,key+0: BEEP crotchet,
key+2: BEEP crotchet/2,key+3: BEEP
crotchet/2,key+2: BEEP crotchet, key+0
(You will probably want to give crotchet and key shorter names.)
By giving crotchet appropriate values, you can easily vary the speed of the piece.
When using BEEP, one must remember that via NextBASIC we can only produce one tone per unit of time since this is done via the CPU, therefore you are restricted to unharmonised tunes. If you want harmonies, you should either use the PLAY command described in the following section or program the computer in Machine Code. Further-
ZX Spectrum Next User Manual, 3rd Edition (ISBN 978-1-5272-5496-1), written and illustrated by Phoebus R. Dokos. Copyright © 2020-2024 Phoebus Dokos / SpecNext Ltd. Licensed under CC BY-NC-SA 4.0. This is a transcription and can contain errors; check any doubt against the printed page.