BBC Micro Music Masterclass

2 The ENVELOPE Statement

It is worth noting at this point that different musical instruments obviously have very different sound qualities. A flute has a pure, mellow sound and is generally played using continuous notes. A harpsichord on the other hand, is said to have a more abrasive quality of sound and, by the very nature of its construction and capabilities, must be played percussively.

Of course, the difference in sound mentioned above between these instruments is due not to one but to a number of factors - the most significant of which concern their volume envelopes and the actual sound source. In the case of the flute we are faced with what is almost a pure sine wave as a sound source, and an envelope which is in the main generated and controlled by the player. In the case of a harpsichord, by contrast, we are encountering a vibrating string capable of creating a rich and varied harmonic colour as a sound source, and a short envelope which ‘rings’ if the sustain pedal is pressed. The diagrammatic version of this explanation should help you appreciate what I’m talking about:



The sound chip in the BBC Micro uses an electronically generated square wave as a sound source. Harmonics can be added to its basic sound by mixing together more than one channel, a topic with which we shall deal at a later point in this text. The basic sound, however, will be electronic. Do not despair! The most important factor that contributes to recognisability in most musical instruments is volume envelope. Thus, if we take the sound of a clarinet and electronically give it a percussive envelope, the instruments sound is immediately transformed into something which akin to a marimba. By embracing this approach we can use the BBC’s square wave and convert it into a range of different-sounding instruments. ENVELOPE is the tool we will use to create these new sounds.

It needs to be emphasised that ENVELOPE actually does more than merely control the volume (amplitude) envelope of a SOUND, for it also has a pitch envelope component. The sophistication of the ENVELOPE statement means that a large number of parameters are required. This chapter will therefore set about explaining these parameters and demonstrating their use in sound shaping.

The form of the ENVELOPE statement is as follows:

ENVELOPE n,s,Pi1,Pi2,Pi3,Pnl,Pn2,Pn3,AA,AD,AS,AR,ALA,ALD


n is the envelope number
s is the length of each step in 1/100ths of a second
Pi1, Pi2 and Pi3 are the changes in pitch per step during sections 1, 2 and 3
Pnl, Pn2 and Pn3 are the number of steps in sections 1, 2 and 3 respectively
AA is the rate of change of amplitude during the attack phase
AD is the rate of change of amplitude during the decay phase
AS is the rate of change of amplitude during the sustain phase
AR is the rate of change of amplitude during the release phase
ALA is the target amplitude for the attack phase
ALD is the target amplitude for the decay phase

The ENVELOPE number n can take values from 1 to 16, and simply allows you to identify which ENVELOPE you have defined. The SOUND statement’s A value then specifies which ENVELOPE is to be used, allowing you to predefine up to sixteen ENVELOPEs and call them up simply by changing A. It should be noted, however, that if the BASIC statement BPUT# is being used, the number of available ENVELOPEs is reduced to four.

Both the Amplitude and the Pitch ENVELOPEs are worked out in terms of steps, and s specifies the length of time assigned to each step. This parameter has one other function, which is to either enable or disable the ENVELOPE auto-repeat. For values of s up to 127, the ENVELOPE automatically repeats itself. Values of s over 127 disable this function. For example:
3=3/100ths of a second steps with repeat ENVELOPE
130= 127+ 3=3/100ths of a second steps with no repeats.

The six parameters following s define the pitch envelope part of the ENVELOPE statement. The length of the defined pitch envelope is com-pletely independent of the amplitude envelope, however no sound will be heard unless a positive amplitude value is maintained.

Pi1, Pi2 and Pi3 can take values from -128 to 127. The ENVELOPE is divided into three regions and Pi1-3 control the degree of pitch change in each of these regions. Pitch can either rise or fall, and this accounts for the option of positive or negative values for Pi1-3. These values cannot be examined in isolation, but must also be related to the number of steps in each region.

Pnl, Pn2 and Pn3 can have values from 0 to 255. These parameters control the number of steps over which the specified pitch change will occur. This is best explained using the example below:

For the first region, let Pi1 equal 2 and Pnl equal 3. this would mean that for every step in region one the value of I would change by 2. Since the length of region one, specified by Pnl, is three steps, P would change by a total of 6 over the complete section. For example: if v=53 initially then at the end of the first section (region one) I will have the value 59. (See the diagram.)

If we decided that we wished the value of P to fall subsequent to this point, a negative value for Pi2 would be used.

If values are chosen such that Pi2 = -4 and Pn2 = 4 then the total pitch change over region two would be (-4 * 4) giving us a change of -16. So at the end of the second section (region two) P will equal 59 - 16 = 43.

The length of time each section will take is derived by taking the Pn value and multiplying by the value of s. The length of the complete ENVELOPE would then be given by the formula: (Pnl+Pn2+Pn3)*s. Thus, if in the above example s=100 then the length of each step would be one second. (100 * 1/100secs.) Since Pnl=3 and Pn2=4, the total envelope would hence take seven seconds to complete.

We should note at this point, however, that the duration of SOUND is also controlled by the o parameter in the SOUND statement. If D is less than the total pitch envelope time then the envelope will be cut off. If D is