Magazine Archive

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

Keeping Us Posted...

Article from Electronic Soundmaker & Computer Music, April 1984

BBC envelopes


Gary Herman with more facts on the BBC's versatile ENVELOPE command


Two months ago, these pages dealt with the SOUND command in BBC BASIC and, last month, in reviewing the Acorn Electron, we went into some detail in discussing the pitch section of BBC BASIC's ENVELOPE command.

ENVELOPE seems to cause considerable difficulty, even for those who've been working with the BBC for months. 'I avoid using it altogether,' was one typical comment I heard recently — needless to say, the speaker was not a musician. Although daunting, the ENVELOPE command is the most interesting feature of the BBC computer's sound and music generating facilities, so it's worth the effort.

To recap, then: ENVELOPE affects the music or noise generated by the SOUND command. It does not generate sound itself and it can be placed anywhere in the body of a program or procedure also containing a SOUND command. Up to 16 different envelopes can be defined (although, if a program includes a command to write data to disk or cassette, then only four envelopes can be used). The envelopes are numbered, using the first parameter following the ENVELOPE command, from one to four or one to 16 and are called from the SOUND command by entering one (for envelope number one) to four or 16 (for envelope number four or 16) in the volume parameter of SOUND.

There are 14 envelope parameters. The first gives the envelope number, the second gives the length of each step in the envelope (and indicates whether the pitch envelope will repeat). This second parameter is called T in the BBC manual and we will abide by this convention. Parameters 3, 4 and 5 give the change in pitch (in quarter semi-tones) for each step of the pitch envelope — dividing the pitch envelope into three sections so that, for example, a note can rise, fall and then rise again in pitch during its course. Parameters 6, 7 and 8 give the number of steps in each of the three sections of the pitch envelope, so that if you add these numbers and multiply by the step duration given by T the resulting number tells you — in hundredths of a second — how long the pitch envelope lasts. If this length is less than the note duration given by the SOUND parameter, and if T is less than 128, the pitch envelope repeats until the note is over. A pitch envelope whose duration is less than the sound duration will simply not be completed.

Fig 1 The BBC's ADSR envelope


The last six parameters of the ENVELOPE command determine the amplitude envelope of a given sound. The amplitude envelope is related to the pitch envelope only by the parameter T, as we shall see. The amplitude envelope assumes a familiar ADSR form, in which a sound is analysed as rising to a peak volume (attack — A), falling to a plateau (decay — D), holding at that level (sustain — S) and dying away (release — R) (Fig 1). Few natural sounds are actually that simple to analyse, but the ADSR convention works well enough for synthesis that isn't too fussy. The ENVELOPE command gives very flexible control of the ADSR functions. Parameter 13 (attack target level — AT) sets the level at the end of the attack phase. This is the peak volume of the sound. Parameter 14 sets the level at the end of the decay phase — the plateau or sustain volume, DT. Parameters 9, 10, 11 and 12 set the change of amplitude per step in each of the ADSR phases — AS, DS, SS and RS. Unlike the pitch envelope section, the amplitude envelope section of the command gives no explicit indication of the number of steps. The amplitude envelope is, however, divided into discrete steps like the pitch envelope. It works like this:

The attack target level divided by the attack step parameter gives the number of steps in the attack phase. Despite the fact that there are 127 possible values for the attack target level, there are actually only 16 volume levels available from the hardware. Each volume level is actually a band of eight equal volume settings. The main consequence of this is that transitions during a rise or fall are not as smooth as they could be.

The attack phase lasts for (AS/AT)*T hundredths of a second (where T is less than 128). Similarly, the decay time is the number of steps in the decay phase multiplied by step length, which can be calculated by subtracting the plateau level from the attack target level, dividing by the decay step parameter and multiplying the result by T: (AT-DT)*T/DS. Since the total duration of the note is given by the SOUND command's fourth parameter (DUR), the length of the sustain phase is given by subtracting the lengths of the attack and decay phases combined from DUR. A sound is released only if there is no other sound waiting to be played on the same channel. The release phase extends the sound beyond the time given by DUR and its length can be calculated by dividing the plateau level by the release step parameter and multiplying the result by the step length — (DT/RS)*T. Clearly, if DUR — which gives the overall duration of the sound — is less than the combined lengths of the attack, decay and sustain phases, the sound will be cut short before the phases are completed.

Thus:

100 ENVELOPES 1, 100, 0, 0, 0, 0, 0, 0, 1, 1, 0, -127, 126, 0
200 SOUND 1, 1, 53, -1

gives an attack time of 126 seconds and an equal decay time. The sustain level is zero and since duration in line 200 is -1 the note continues indefinitely. Press ESCAPE to stop it. Change the 100 in line 100 to 20 and you get a note 49 seconds long. With this parameter, T, set at 1, the audible part of the note lasts 2.5 seconds.

100 ENVELOPE 1, 20, 0, 0, 0, 0, 0, 0, 12, -12, 0, - 127, 108, 0
200 SOUND 1, 1, 53, 100

gives a total duration of five seconds (from line 200) and attack and decay times of 1.8 seconds each. So, the sustain time at zero volume is now 1.4 seconds.

Change the sound duration parameter in line 200 to 50 and the note is cut short during the decay phase about 1.1 seconds before its amplitude reaches zero. To hear the note release from this level, change the release step parameter from —127 to —1. The note now dies away to zero.

Now make the attack sharper by changing the attack step parameter in line 100 from 12 to 36. This gives an attack duration of (108/36)*(20/100), or 0.6 seconds. Decay stays at 1.8 seconds. The note then continues for 2.5 — (0.6+1.8), or 0.1 seconds but it has already reached zero amplitude so there is no release. Change the duration parameter in line 200 from 50 to 40 (two seconds) and the note will be cut off before the decay phase ends and you will hear it die away.

If the step length parameter, T, in line 100 is changed from 20 to 5, attack time will be 0.15 seconds and decay time 0.45 seconds and there will be no audible sustain or release. But if the last parameter in line 100 (the decay target level) is given a positive value (say, 48), you will be able to hear the sustain and the release. The decay phase is, of course, shorter — lasting only 0.25 seconds. Since the attack phase still lasts 0.15 seconds, the note will sustain for 1.6 seconds. The release takes about two more seconds.

Now make T equal to one and decay step equal to -1. Attack time is 0.03 seconds and decay time 1.08 seconds. There will be a 0.89 second sustain and a quick release (0.48 seconds). So far, we have not mixed pitch and amplitude envelopes — but let's try it:

100 ENVELOPE 1, 1, -1, 36, 0, 108, 3, 0, 36, -1,0, -1, 126, 48
200 SOUND 1, 1,53, 40

imposes a pitch envelope on the last-produced sound. The pitch envelope lasts for (108 + 3)*1/100, or 1.11 seconds — which is equal to the length of the attack-decay phase of the amplitude envelope. Pitch falls by 108 quarter semitones in the first phase, rises by 36*3, or 108 quarter semitones in the second phase and stays where it is in the third phase. After that, the pitch envelope repeats until the note is over. Change the step parameter in line 100 from one to 128 and the pitch envelope does not repeat. Now swap pitch parameters around:

100 ENVELOPE 1, 128, 36, -1, 0, 3, 108, 0, 36, -1, 0, -1, 126, 48
or
100 ENVELOPE 1, 128, -1, 0, 36, 108, 0, 3, 36, -1, 0, -1, 126, 48

and you should hear how the pitch changes occur differently at different points in the note. More musical effects can be obtained by levelling out the pitch changes:

100 ENVELOPE 1, 128, -1, 1, -1, 28, 56, 28, 36, -1, 0, -1, 126, 48

gives a pitch envelope that lasts 1.12 seconds with an attack-decay phase of 1.11 seconds. Changing the ...28, 56, 28... to... 10, 20, 10... and ...1, 2, 1... gives quite pleasing effects, substantially altered if the step length parameter is changed to one and the pitch envelope repeats. Finally, it is possible to place pitch changes anywhere in the note — as in:

100 ENVELOPE 1, 128, 0, 1, -1, 80, 20, 20, 36, -1, 0, -1, 108, 48

which gives a 'bend' to the note after 0.8 seconds lasting 0.4 seconds. The bend therefore straddles the decay and sustain phases of the note, rather like the effect of using a tremolo arm on a guitar.


More with this topic


Browse by Topic:

Computing


Also featuring gear in this article

BBC Micro
(ES Feb 84)

BBC Reverb
(ES Feb 84)

BeeBMIDI (Part 1)
(EMM Jun 84)

BeeBMIDI (Part 2)
(EMM Jul 84)

BeeBMIDI (Part 3)
(EMM Aug 84)

BeeBMIDI (Part 4)
(EMM Nov 84)

BeeBMIDI (Part 5)
(EMM Dec 84)

BeeBMIDI (Part 6)
(EMM Jan 85)

BeeBMIDI (Part 7)
(EMM Mar 85)

Soft Music
(ES Mar 84)


Browse category: Computer > Acorn


Featuring related gear



Previous Article in this issue

Microcosm

Next article in this issue

Lynx Grid Programmer


Publisher: Electronic Soundmaker & Computer Music - Cover Publications Ltd, Northern & Shell Ltd.

The current copyright owner/s of this content may differ from the originally published copyright notice.
More details on copyright ownership...

 

Electronic Soundmaker - Apr 1984

Donated & scanned by: Mike Gorman

Topic:

Computing


Gear in this article:

Computer > Acorn > BBC Model B

Feature by Gary Herman

Previous article in this issue:

> Microcosm

Next article in this issue:

> Lynx Grid Programmer


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!

Donations for October 2024
Issues donated this month: 0

New issues that have been donated or scanned for us this month.

Funds donated this month: £0.00

All donations and support are gratefully appreciated - thank you.


Magazines Needed - Can You Help?

Do you have any of these magazine issues?

> See all issues we need

If so, and you can donate, lend or scan them to help complete our archive, please get in touch via the Contribute page - thanks!

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

Monetary donations go towards site running costs, and the occasional coffee for me if there's anything left over!
muzines_logo_02

Small Print

Terms of usePrivacy