ENVELOPES from The Brown Envelope The subject of BBC BASIC's ENVELOPEcommand is probably an old trick (orwhatever) to a lot of people, but theredoes seem to be a bit of difficultygoing on in a portion of the BBCprogramming population. For example, in 8BS 24, there was anenquiry about writing ENVELOPEs. I haveanswered that as best as I could (Ed:below). I think I'd better start with a bit ofa feasibility study. The BBC can handlevolume and pitch ENVELOPEs, but thereare only two timbre generators: noiseand pulse. It is therefore quite hardto have a realistic simulation of aninstrument that doesn't use one ofthese two generators. FORMAT The format of the ENVELOPE command isENVELOPE no, t, pi1, pi2, pi3, pd1,pd2, pd3, ar, dr, sr, rr, fal, fdl. No is the ENVELOPE number, which issimply used as an identification numberfor the rest to be referred to as. ITIS NOTHING TO DO WITH THE CHANNELNUMBER. Let me just explain this(because it caused awful problems forme when I was beginning the subject):when you want an ENVELOPE sounded, putthe envelope number as the secondparameter of the SOUND command, insteadof - volume. You can control the volumeof the sound with the parameters of theENVELOPE. Something else to clear up:you don't have to always defineENVELOPEs at the beginning of theprogram. I find it a lot easier todefine them when I want them,especially considering that if youdefine more than four, page &900 willstart to be used up. The range of no isone to fifteen. t is time, and I usually put a 1 here.More about this later. BOING! The first thing that I do when I workout ENVELOPEs is to think of how thevolume goes. For example, a bell has aloud, sharp hit, fades quickly to aloud hum, and then, more slowly, fadesaway into the distance. What we areinterested in here are the parameterscalled ar, dr, sr, rr, fal, and fdl.These stand for attack rate, decayrate, sustain rate, release rate, finalattack level, and final decay level,respectively. They all range from -128to +127. The bell has a sharp attack,so ar can be a sharp 100. This meansthat every t centiseconds (see abovefor t), the sound will increase by 100,until it is equal to or greater thanthe final attack level. Put this to 100as well. I always work in 100's;thinking of % of the maximum soundlevel. The bell then quickly fades to a hum,so set dr to -30, and fdl to 40. Thismeans that, after the sound has reachedthe hundred, it will decrease by 30every t centiseconds, until it reaches40. For sustain rate put -1, and forrelease rate put -1, which means thatthe sound will decrease by -1 for therest of the duration specified in theSOUND statement (sustain rate), andthen, if there is any left after that,and no note after that is specified, itwill carry on decreasing by -1. You canalter the "echo" by altering rr: thecloser to 0 the negative number, theless the echo. Once all this is done, now is the timeto decide on the overall volume of theenvelope. Divide ar, dr, sr, rr, fal,and fdl by 100/v, where v is the volumenumber that you would like. I make aprocedure to do this for me, when I'mencoding a tune, so I don't need towork out a new ENVELOPE every time Iwould like to change the volume. TWIDDLE! Pi1, pi2, pi3, pd1, pd2, and pd3 can,in most envelopes, be set to 0, 0, 0,0, 0, 0. You will probably find this ina lot of ENVELOPEs in books and things.They are, however, quite useful,sometimes, as they effect the pitch ofan ENVELOPE. Basically, pi is pitchincrement over the interval of pd timest centiseconds. There are three"stages" of change, indicated by the 1,2, and 3. Try 1, -1, 0, 1, 1, 0 for a vibratoeffect. Altering the first two numbers(1 and -1) will change the differencein "wobble", and altering the fourthand fifth will change how long itspends "wobbling". Altering the last 0can give some strange, and also useful,effects. As far as music goes, that's all thatis really useful in those pitchenvelope numbers. If, however, you aremaking a sound effect, then there ismore to look at in this area. Nothingcan replace a good bit of fiddlingaround at the keyboard, in thisrespect. FIDDLE! When you try out your ENVELOPE,altering t might make it sound nicer.Values plus 128 will not repeat thechanges in pitch, that is:- t = 1: o o o o o o o o o o o o o o o o etc. t = 128 + 1: o (ie. 129) : ooooooooooo etc. The above example is assuming that youwere using pi values of 1 and -1respectively for the pitch envelope,and the o represents the pitch. HUM! Sometimes, when writing a sound effect,that is not on the noise channel, itmakes a "vacuum" effect if you do thesame sound on ANOTHER channel WITHOUTthe envelope, eg.: ENVELOPE1,2,2,-2,0,1,1,0,127,-10,-2,-1,127,117 : REM Suck! SOUND 1,1,50,50 SOUND 2,-15,50,50 SO THIS IS FAREWELL The Brown Envelope thinks that it is agood idea to make yourself an ENVELOPElibrary. Why not send it in to 8BS? Itwould be nice to give documentation toyour ENVELOPE, as they can sometimes bespoiled through improper use of theSOUND statement, or the user may notrealize their full potential. I may beback in the future with moreenclosures, or as something else (Brownas that's my surname) to suit thearticle!!! Don't forget to buyrecycled envelopes, and make your ownat the keyboard (or whatever)! Goodbye.Silas has also supplied the followingenvelopes in answer to Theo Gray'senquiry in Issue 24: Distorted Guitar: ENVELOPE1,1,1,-1,0,1,1,0,126,-1,-1,-1,126,100 Bass: ENVELOPE2,1,0,0,0,0,0,0,126,0,0,-50,126,126 Use this on its own, or, if you've aspare channel, use SOUND3,2,P,D:SOUND2,-15,P,D Toms: I'm afraid not on channel 0. UseENVELOPE 3,129,1,-1,0,1,1,0,126,-20,-10,-1,126,50 and SOUND 3 (or whatever),3,P,D thiswill hit and then silence on thatchannel for the remainder of D. Cymbals: ENVELOPE4,1,0,0,0,0,0,0,126,-5,-1,-1,126,100 SOUND 0,4,4,D will clash, and thensilence on that channel for theremainder of D. Snare Drum: ENVELOPE5,129,-1,1,0,1,1,0,100,-10,-10,-1,100,90 SOUND 0,5,4,D will hit and then besilent for the remainder of D.