Click Here To Go To The Your Computer Archive

Written By Chris Melville

Cover Art
Click Here To Enlarge Loading Screen

Loading Screen
Click Here To Enlarge Opening Screen

Opening Screen
Click Here To Enlarge Screenshot

Game Screenshot

Envelope Plotter

Whether your musical tastes are heavy metal or Trapp family singers the BBC Micro has something to offer. This month and next month Chris Melville shows you how to turn your BBC into a musical instrument

The BBC Micro is one of the most impressive machines on the market, and its capabilities for music generation are much-praised.

That does not mean, however, that every BBC owner can immediately plug in and stan emulating Gary Numan, though this article will show you how to take full advantageof the features that are present in the BBC's music box.

We will now define the initial problems you may encounter, and see what can be done to overcome them, so that our micros can stan making pleasant noises.

There are two main hardware grumbles - both easy ro solve. Most BBC Micros emit an annoying buzz from the loudspeaker during hormal use. This is caused by signals from the data bus being amplified. A IOKohm resistor across pins 16 and IS of the IMHz bus should cure it - you can either fit a plug, or solder it to the corresponding tracks on the PCB. Acorn will be doing this themselves soon.

Secondly, if the tinniness inherent in the small internal speaker is restrictive, you can connect an external amplifier of 50Kohms impedance to pin PLl6 on the PCB. These modifications might affect your warranty, so check with your local Acorn Service Centre.

Statement Syntax

Moving on to documentation, I presume that the Envelope and Sound statements are now understood, thanks to the new user guide and to previous articles such as that in July Your Computer, bur briefly, the ENVELOPE statement has the following syntax:

where n is the envelope number - usually 1-4, or 1-16 ifnot using tape filing in Basic: and 1 is the length of a time step - usually 1-127 for pitch envelope repeat. Add 127 if the pitch envelope is not for repeat. The change of pitch per step in the corresponding pitch parts is given by pi ,p2,p3 from -128 to 127. The number of steps in each pan of the pitch envelope is designated by nl,n2,n3 from 0 to 255. The al,a2 give the change of amplitude in attack, and change of step in decay pans, using values from -127 to 127. The a3,a4 give the change of amplitude in sustain and the change of step in release, using values from -127 to O. The tl,t2 are the target levels for amplitude at the end of the attack, decay parts; o to 126. And here, briefly, is the syntax for the SOUND statement:

  Pitch Envelope Amplitude Envelope
ENVELOPE n,1,p1,p2,p3,n1,n2,n3, a1,a2,a3,a4,t1,t2
d = dummy flag, 0 or 1
s = sync flag, 0 or 3
f = flush queue flag, 0 or 1
c = channel number, 0 to 3
a = amplitude, 0 to -15 for envelope 1 to 16
p = pitch, 0 to 255 for a music channel, or 0 to 7 for a noise channel
d = duration of sound 10 to 2550ms.

In BBC Basic sound qualities are programmed using the Envelope statement as shown above. However, a statement followed by 14 parameters does not give much idea of the sound it will produce.

The EnvPlot program, for 32K, allows you to draw an envelope directly on the VDU by moving a cursor around. Then you edit it, sampling the sound produced. You define the pitch and amplitude pans separately on separate axes.

EnvPlot enables the user to stan from scratch and define both pitch and amplitude envelopes on the screen. Theprogram is either in Pitch Mode; blue background, pitch envelope/axes displayed, pitch envelope information displayed at top of screen: or Amplitude Mode, red background, amplitude envelope/axes, and amplitude envelope information at top of screen when the user is entering or manipulating the amplitude envelope.

The two modes are interchangeable at any stage, and if you re-enter either, you will be returned to where you left off. There is a cursor on the screen which is moved about by using the arrowed keys. You cannot move the cursor anywhere that would produce out-of¬range parameters.

Presssing any function key will rub out the cursor and, when the function has been executed, the cursor will reappear on the last-entered point. All of the functions are foolproof. For example, you cannot Sound the envelope unless you have completed both pitch and amplitude sections. All parameters entered are checked before they are accepted.

In Pitch Mode the Y-axis is labelled relative to f -. which is the pitch used in the Sound statement concerned. When moving the cursor about, remember that the dotted line can have a gradient - given as P/STP at the top - of zero even when it is not horizontal, since integer arithmetic and integer parameters cannot give totally accurate results. If the gradient of any section is zero, then, when the computer Sounds that part, there will be no pitch change.

Relative Pitch

The Y-axis is the relative pitch, the X-axis is the number of steps. The actual duration of a step depends on what you have set it as.

The pitch envelope has three sections, for each section the computer needs to find the gradient, that is pitch/step; and its length in steps to u e in the Envelope statement.

Whether the pitch envelope keeps cycling over is, of course, determined by the value chosen for the step length. In Amplitude Mode the Y-axis represents amplitude, the X-axis represents steps.

The parameters taken for the amplitude part of an envelope statement are somewhat odd, and the system used by the computer can cause amplitude envelopes to differ from the one you have drawn.

For this reason it is usually best to have a horizontal sustain section otherwise the note will fade quickly due to inaccuracies caused by the computer's Sound software dealing only in integers.

The end of the sustain section determines how long the note is Sounded for, although the amplitude can reach 0 before this thus effectively ending the note.

The release section does not have to end on the X-axis, it is only its gradient that is needed for the Envelope statement. Now for a complete description of all the functions assigned to the soft keys:

F0 EnterPoint - Enters position of cursor as next point on current envelope.
F1 DeletePoint - Deletes last point entered.
F2 Parameters - Gives completed envelope as the Envelope and Sound parameters needed to produce it.
F3 RescaleAxesUsed - to rescale the x and/or y axes. There are two options: first, normal rescale-in which the axis is rescaled and any of the envelope parts are adjusted suitably; second, alternative rescale-the axis is rescaled but the graph shape is left in the same position.
F4 Set Step - Used to set the length of a step, and also whether the pitch envelope auto-repeats or not.
F5 Sound Env - Demonstrates a completed envelope in one of three voices
F6 Amp Mode - Enters program into Amplitude Mode
F7 Pitch Mode - Enters program into Amplitude Mode
F8 Infinite Stn - Set any future notes with an infinite sustain part - also cancels it
F9 Unused

Note also that Escape starts the program all over again and so Break should be used to exit the program.

I would like to offer two simple yet useful tips for saving programs (especially long ones) on cassette.

Because of the bugs present in the BBC cassette-filing system, it is a neccessary precaution to Save programs several times in order to ensure at least one will Load back. It can be very boring sitting around waiting for long programs to save so that they can be saved over again, especially at 300 baud, so a good idea is to type:

*KEY 0 SAVE"programname"|M|MTIME=0:REPEAT:UNTIL TIME=500|M

Then set your cassette recording and press soft key F0 say four times, one for each copy. You can then go away and have a cup of tea - the program will be saved four times with an inter-program gap of five seconds for those recorders with no motor control.

A much-criticised oversight on the BBC is the lack of a Verify command, since *CAT is not really the same thing. However if you try:

*LOAD "" 8000

then the computer will load the target program from hexadecimal 8000 onwards, which is, of course, read-only memory in the BBC Micro. However, although nothing is actually loaded into RAM, the machine still thinks it is loading a proper program. It will thus report any errors that occur, including the corrupting of block 00 - the most common of the cassette-filing system bugs.