'Play' your home computer
Gary Evans tells you what to do with your micro after shooting down the last space invader.
While it would be unrealistic to expect any home micro user to duplicate the sounds produced by a bank of Fairlights, the current generation of low cost microcomputers do offer a wide range of music making abilities. The flexibility of the more popular computers' sound generators varies greatly, but even the best offers a fairly limited performance — inferior to a £40 Casio keyboard. This is because a micro's strength lies in being able to do a lot of different things — for example, produce hi-resolution graphics or drive a printer as well as make sounds. A micro is a sort of jack of many trades without being a master of any. If any particular application demands excellence in one particular area, it is usual to relegate the computer to the role of a controller of a specialised peripheral.
Having set the general scene we will move on to look at the effects generation capabilities of four popular micros — the Sinclair Spectrum, the Oric-1, the BBC Micro and the recently launched Sord M5.
The command that makes the Spectrum produce sounds is BEEP. This command is followed by two parameters that govern the duration and pitch of the note produced. A typical sound command on the Spectrum would thus be:
You will notice that both parameters are numerical, with the duration of the note being specified in seconds and the pitch of the note being given as the number of semi tones above middle C — by using negative values of pitch, notes below middle C can be sounded. The command above therefore produces middle C for one second. To sound, for instance, the note G for half a second, the command would be
You will notice that decimal values of duration are allowed, as indeed are decimal pitch parameters — useful when tuning the Spectrum to other sources of sound.
Sounds produced can be shifted up and down an octave by adding (or subtracting) 12 to the pitch parameter for each octave shift desired.
To save having to rewrite programs if it's necessary to transpose any composition, it's possible to use a variable name as part of the pitch statement. Thus:
BEEP 5, KEY + 2
would allow the note to be sounded in C minor if KEY were first set to 0, or an octave above if KEY were set to 12 at the start of the program.
In a similar fashion, a variable can be added to the duration section of the BEEP command.
BEEP crotchet, KEY+ 2:
BEEP crotchet/2, KEY + 4
— shows duration and pitch controlled by both a variable and an integer value. By altering the value of a crotchet, the speed of the composition can be readily controlled.
The above command represents the most versatile form of the Spectrum BEEP command and, even in this form, it can be seen to be fairly limited. All the notes produced are of exactly the same volume, with no possibility for emphasising particular notes, and it is only possible to produce one note at a time — no scope for harmonising.
The Oric, in common with the machines yet to be described, is able to offer a fairly sophisticated sound capability by virtue of the fact that it uses a dedicated IC to take care of its sound channel. Whereas the Spectrum produces all its sounds by toggling one of its output lines high and low under software control, computers like the Oric function by loading data into a set of registers within a Programmable Sound Generator (PSG) IC, which then takes care of producing the sound.
The main sound commands on the Oric are SOUND, PLAY and MUSIC. Taking each in turn, SOUND is a command that allows a note of a given tone to be produced — a noise of a given 'pitch' can also be generated. The form of the command is
SOUND channel, period, volume
The channel number is in the range 1 to 6, with channel 1, 2 and 3 controlling the three independent tone generators of the Oric while 4, 5 and 6 enable the noise channel in conjunction with one of the three tone channels.
PERIOD is not as you might expect a duration parameter, but sets the frequency of the note produced. The values of PERIOD are in the range 0 to 32.
VOLUME is a self-explanatory statement, with the parameter taking a value in the range 1 to 15 — if VOLUME is set to zero the output level will be controlled by the PLAY command.
The PLAY command defines the type of sound produced by the Oric and has the following form.
PLAY tone enable, noise enable, envelope mode, envelope period
TONE/ENABLE allows the combination of tone channels contributing to the output to be specified. It takes on values between 0 (no channels on) and 7 (all three channels producing sound).
NOISE ENABLE functions as does tone enable, but for the noise channel — there is only one noise channel and this command specifies which tone channel it will be associated with.
ENVELOPE/MODE allows a series of predefined envelopes to control the volume of the sound produced.
ENVELOPE PERIOD controls how long either of the finite envelopes take to start or end the sound. It has a value between 0 and 32767.
The MUSIC command is similar to the PLAY statement, but allows notes from the musical scale to be produced. It takes the form
MUSIC channel, octave, note, volume
CHANNEL as before selects one of the three tone channels.
OCTAVE allows one of seven octaves (0 is the lowest) to be enabled.
NOTE takes value between 1 and 12, with 1 corresponding to C, 2 to C and so on, up to 12 which produces B.
VOLUME is as for the PLAY command.
Using these three commands the Oric can provide very comprehensive sound capability.
The BBC micro has a similar sort of capability to the Oric. Music control is by the command SOUND.
The statement has four parameters; these are channel number (0 to 3), amplitude (0 to -15), pitch (0 to 255) and duration.
Again the machine has three tone channels and a noise channel (channel number 0). The pitch is given by a numeric value according to the table shown.
The scope of the basic SOUND facility can be extended by using an ENVELOPE command. Four envelopes are available, using a negative amplitude number in the sound command in the range 1 to 4.
The envelope command is followed by 14 numbers and gives an extremely comprehensive control of both amplitude and pitch of the tone channel selected.
Of all the machines described, the recently launched Sord M5 offers one of the most powerful facilities from the music point of view.
The M5 with the Basic F cartridge offers a play command that allows notes to be entered not as numerics, but in the more familiar alphabetic format
is the basic form of the command. By adding a '+' or '-' sign before a note, any note can be sharpened or flattened.
The octave in which the notes are sounded can be altered from within a play statement by the command 0 followed by a number from 3 to 8.
By adding a number after any note the duration can be changed — thus
plays a half note — omitting duration assumes a quarter note is desired.
A PLAY statement could typically look like the following:
PLAY "c e g o7 c2 o5 g"
The M5 allows harmonics to be generated as well as a number of other musical effects including rests, tempo variation, dotted notes, etc.
If you aim to use a micro to produce music, it's clear that the facilities offered by the different models on the market vary greatly. Software is available for most machines which can enhance the basic performance of any of them. As in most areas of micro computing, the major limitation in composing is likely to be the imagination of the musician programming the computer.
Feature by Gary Evans
Previous article in this issue:
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!