<!-- PDF page 145 -->

```
   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:

![Stave: treble clef, key signature of three flats, common time, the first four bars of the Mahler tune](/documentation/manual/rev3/figures/p145-mahler-stave.png)

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

![The same stave with the pitch value of each note written under it](/documentation/manual/rev3/figures/p145-mahler-stave-pitches.png)

```
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-

