8-Bit Software Online Conversion

ENVELOPES from The Brown Envelope The subject of BBC BASIC's ENVELOPE command is probably an old trick (or whatever) to a lot of people, but there does seem to be a bit of difficulty going on in a portion of the BBC programming population. For example, in 8BS 24, there was an enquiry about writing ENVELOPEs. I have answered that as best as I could (Ed: below). I think I'd better start with a bit of a feasibility study. The BBC can handle volume and pitch ENVELOPEs, but there are only two timbre generators: noise and pulse. It is therefore quite hard to have a realistic simulation of an instrument that doesn't use one of these two generators. FORMAT The format of the ENVELOPE command is ENVELOPE no, t, pi1, pi2, pi3, pd1, pd2, pd3, ar, dr, sr, rr, fal, fdl. No is the ENVELOPE number, which is simply used as an identification number for the rest to be referred to as. IT IS NOTHING TO DO WITH THE CHANNEL NUMBER. Let me just explain this (because it caused awful problems for me when I was beginning the subject): when you want an ENVELOPE sounded, put the envelope number as the second parameter of the SOUND command, instead of - volume. You can control the volume of the sound with the parameters of the ENVELOPE. Something else to clear up: you don't have to always define ENVELOPEs at the beginning of the program. I find it a lot easier to define them when I want them, especially considering that if you define more than four, page &900 will start to be used up. The range of no is one 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 work out ENVELOPEs is to think of how the volume goes. For example, a bell has a loud, sharp hit, fades quickly to a loud hum, and then, more slowly, fades away into the distance. What we are interested in here are the parameters called ar, dr, sr, rr, fal, and fdl. These stand for attack rate, decay rate, sustain rate, release rate, final attack level, and final decay level, respectively. They all range from -128 to +127. The bell has a sharp attack, so ar can be a sharp 100. This means that every t centiseconds (see above for t), the sound will increase by 100, until it is equal to or greater than the final attack level. Put this to 100 as well. I always work in 100's; thinking of % of the maximum sound level. The bell then quickly fades to a hum, so set dr to -30, and fdl to 40. This means that, after the sound has reached the hundred, it will decrease by 30 every t centiseconds, until it reaches 40. For sustain rate put -1, and for release rate put -1, which means that the sound will decrease by -1 for the rest of the duration specified in the SOUND statement (sustain rate), and then, if there is any left after that, and no note after that is specified, it will carry on decreasing by -1. You can alter the "echo" by altering rr: the closer to 0 the negative number, the less the echo. Once all this is done, now is the time to decide on the overall volume of the envelope. Divide ar, dr, sr, rr, fal, and fdl by 100/v, where v is the volume number that you would like. I make a procedure to do this for me, when I'm encoding a tune, so I don't need to work out a new ENVELOPE every time I would 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 in a lot of ENVELOPEs in books and things. They are, however, quite useful, sometimes, as they effect the pitch of an ENVELOPE. Basically, pi is pitch increment over the interval of pd times t centiseconds. There are three "stages" of change, indicated by the 1, 2, and 3. Try 1, -1, 0, 1, 1, 0 for a vibrato effect. Altering the first two numbers (1 and -1) will change the difference in "wobble", and altering the fourth and fifth will change how long it spends "wobbling". Altering the last 0 can give some strange, and also useful, effects. As far as music goes, that's all that is really useful in those pitch envelope numbers. If, however, you are making a sound effect, then there is more to look at in this area. Nothing can replace a good bit of fiddling around at the keyboard, in this respect. FIDDLE! When you try out your ENVELOPE, altering t might make it sound nicer. Values plus 128 will not repeat the changes 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 you were using pi values of 1 and -1 respectively for the pitch envelope, and the o represents the pitch. HUM! Sometimes, when writing a sound effect, that is not on the noise channel, it makes a "vacuum" effect if you do the same sound on ANOTHER channel WITHOUT the envelope, eg.: ENVELOPE 1,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 a good idea to make yourself an ENVELOPE library. Why not send it in to 8BS? It would be nice to give documentation to your ENVELOPE, as they can sometimes be spoiled through improper use of the SOUND statement, or the user may not realize their full potential. I may be back in the future with more enclosures, or as something else (Brown as that's my surname) to suit the article!!! Don't forget to buy recycled envelopes, and make your own at the keyboard (or whatever)! Goodbye. Silas has also supplied the following envelopes in answer to Theo Gray's enquiry in Issue 24: Distorted Guitar: ENVELOPE 1,1,1,-1,0,1,1,0,126,-1,-1,-1,126,100 Bass: ENVELOPE 2,1,0,0,0,0,0,0,126,0,0,-50,126,126 Use this on its own, or, if you've a spare channel, use SOUND 3,2,P,D:SOUND2,-15,P,D Toms: I'm afraid not on channel 0. Use ENVELOPE 3,129,1,-1,0,1,1,0,126,-20,-10,-1,126,5 0 and SOUND 3 (or whatever),3,P,D this will hit and then silence on that channel for the remainder of D. Cymbals: ENVELOPE 4,1,0,0,0,0,0,0,126,-5,-1,-1,126,100 SOUND 0,4,4,D will clash, and then silence on that channel for the remainder of D. Snare Drum: ENVELOPE 5,129,-1,1,0,1,1,0,100,-10,-10,-1,100,9 0 SOUND 0,5,4,D will hit and then be silent for the remainder of D.