Magazine Archive

Home -> Magazines -> Issues -> Articles in this issue -> View

Micromusic

BASIC music loading program for the ZX81



So far in this series we've discussed machine code programming of the ZX81, and output ports for feeding synthesisers. This means we can feed out numbers representing notes to up to seven synthesisers, giving polyphonic music. In this, the last article on this subject (for a while at least) we shall describe a program for entering the coded notes into the machine. The machine code routine given last month expects to find its data in array A$, and Table 1 lists a program for entering numbers into the array. This program is the result of much alteration and "honing" — which explains the eccentric line numbering system — and this process is still continuing; there is plenty of scope for alteration and customising to suit personal requirements.

The REM statement in line 1 is the machine code routine itself, and is included only to give some idea of what this will look like; don't try to enter it from the keyboard, because it won't work. Instead, enter a REM statement with 180 characters in it (I usually use full stops) and then use the "machine code monitor" discussed in December; this is subsequently erased, leaving only line 1 of course, and the rest of the program can be entered as usual.

Line 9990 enables the program to be stored on cassette in "LOAD" and "RUN" fashion (actually LOAD and GOTO in this case) which saves the embarrassment caused if you try to start the program with RUN; this erases all the music data, of course. If you do stop the program when it contains data you want to keep, always restart using GOTO 100 to avoid bad language and broken computers.

Using the Program



When the program is first run, it will start off by asking you the number of voices (synthesisers) you want to use, the number of notes, and the name of the piece. The number of notes is not necessarily the same as the number of "blobs" in the music; this variable should more accurately be called "events". For instance, if a quaver is the shortest note in the piece, and the music is in 4/4 time, there will be 8 quavers per bar. For reasons which will be explained, you would probably want 16 events per bar, and a 100 bar piece would require 1600 events. You will need a 16K RAM pack to fit the program in, and with this amount of memory there is room for over 12800 events; using the maximum of seven voices, this allows 1825 events per voice, which should be sufficient for most uses.

Once the initial conditions are established, the program moves on to the "title page" which repeats the information you've just fed in, and also presents a list of choices of what to do next; this also happens when the program is loaded from tape.

The choices are selected by entering the appropriate letter. P, T and S should be self explanatory; C enables you to start again from scratch, and E (or indeed any character other than P, T, C or S) is for writing or altering the music. The letter E by itself will start at event 1; if you want to start halfway through, enter E250 (for instance) to start at event 250.

Once you are in edit mode, these letters still have the same effect, so you can skip about by entering E followed by a number for example; and there is also a further "menu" to aid the music entry. If the entry is a number (detected by lines 2115 to 2135) this is taken as a note to be entered; the note code system will vary according to the synthesiser in use, and this was covered in January.

V followed by a number allows you to choose which voice to enter; e g. V2 selects voice 2. A letter V at the top of the display points to the voice in use.
New line allows you to skip on to the next event without entering any data.
R enters a rest.
J repeats the previous entry.
K repeats the previous event, but on all voices at once; for sustaining a chord, for instance.
B repeats a whole block of several events. This is also useful for moving the data around — so that you can insert new material, for instance.
F (for fine) signals the end of the piece.
D (for da capo) also signifies the end, but makes the piece repeat until BREAK is pressed.

Figure 1. Music extract.


A Musical Example



Figure 1 is an extract from a piece by yours truly, written so that it uses the maximum of seven voices. The shortest note is a quaver, so you might expect the extract to need 8 events per bar, 16 altogether. In fact, in some places notes are repeated, but not "tied"; a musician playing these would automatically insert a small rest between them, even though one is not written. The computer has to be told about these rests explicitly, and so we allow 32 events to give room for the rests.

Table 2 shows how the piece would appear programmed in "linear" code — for feeding D to A converters for instance — and Table 3 gives the same thing in Wasp code; hopefully these examples will clarify any minor points I haven't explained.

As you will see, a certain amount of effort (not to say tedium) is involved in entering a lengthy piece of music; this is the price you pay for such a good value system. How much would a 12 000 note sequencer cost from a commercial manufacturer, if such a machine were available? For the sake of a day's work slaving over a hot TV set, my ZX81 can play nearly any music I choose, as many times as I like, and much better than I ever could! (My chess computer keeps beating me too.)

Table 1. BASIC music entry program.
(Click image for higher resolution version)


Table 2
1 30 37 32 28 22 18 6
2 30 37 32 28 22 18 6
3 30 37 32 28 22 18 6
4 R 37 32 28 22 18 6
5 37 37 32 28 22 18 6
6 R 37 32 28 22 18 6
7 32 37 32 28 22 18 6
8 R R R R R R R
9 32 37 32 27 23 18 13
10 R 37 32 27 23 18 13
11 35 37 32 27 23 18 13
12 R 37 32 27 23 18 13
13 32 37 32 27 23 18 13
14 R R R R R R 13
15 27 37 32 27 23 18 13
16 R R R R R R R
17 28 42 37 33 28 21 6
18 28 42 37 33 28 21 6
19 28 42 37 33 28 21 6
20 R 42 37 33 28 21 6
21 35 42 37 33 28 21 6
22 R 42 37 33 28 21 6
23 32 42 37 33 28 21 6
24 R R R R R R R
25 30 42 37 33 28 21 9
26 R 42 37 33 28 21 9
27 33 42 37 33 28 21 9
28 33 42 37 33 28 21 9
29 33 42 37 33 28 21 9
30 R 42 37 33 28 21 9
31 32 42 37 33 28 21 9
32 R R R R R R R
33 STOP

Table 2. Figure 1 music in "linear" code.


Table 3
1 23 16 21 25 35 39 39
2 23 16 21 25 35 39 39
3 23 16 21 25 35 39 39
4 R 16 21 25 35 39 39
5 16 16 21 25 35 39 39
6 R 16 21 25 35 39 39
7 21 16 21 25 35 39 39
8 R R R R R R R
9 21 16 21 26 34 39 32
10 R 16 21 26 34 39 32
11 18 16 21 26 34 39 32
12 R 16 21 26 34 39 32
13 21 16 21 26 34 39 32
14 R R R R R R 32
15 26 16 21 26 34 39 32
16 R R R R R R R
17 25 7 16 20 25 36 39
18 25 7 16 20 25 36 39
19 25 7 16 20 25 36 39
20 R 7 16 20 25 36 39
21 18 7 16 20 25 36 39
22 R 7 16 20 25 36 39
23 21 7 16 20 25 36 39
24 R R R R R R R
25 23 7 16 20 25 36 36
26 R 7 16 20 25 36 36
27 20 7 16 20 25 36 36
28 20 7 16 20 25 36 36
29 20 7 16 20 25 36 36
30 R 7 16 20 25 36 36
31 21 7 16 20 25 36 36
32 R R R R R R R
33 STOP

Table 3. Figure 1 Music in Wasp code. Note that the bass Wasp will need to be set an octave lower than the others to get in range.


Also featuring gear in this article



Previous Article in this issue

Video Review

Next article in this issue

Cassette Reviews


Electronics & Music Maker - Copyright: Music Maker Publications (UK), Future Publishing.

 

Electronics & Music Maker - Mar 1982

Topic:

Computing


Gear in this article:

Computer > Sinclair > ZX81

Feature by Peter Maydew

Previous article in this issue:

> Video Review

Next article in this issue:

> Cassette Reviews


Help Support The Things You Love

mu:zines is the result of thousands of hours of effort, and will require many thousands more going forward to reach our goals of getting all this content online.

If you value this resource, you can support this project - it really helps!

Please Contribute to mu:zines by supplying magazines, scanning or donating funds. Thanks!

We currently are running with a balance of £100+, with total outgoings so far of £1,046.00. More details...
muzines_logo_02

Small Print

Terms of usePrivacy