Magazine Archive

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

Soft Music

Article from Electronic Soundmaker & Computer Music, January 1984

Generating envelopes


In response to popular demand — some micro-music software. Gary Herman describes an envelope generator

With Texas Instruments now virtually giving away their TI-99/4A computer, it's almost worth buying one just to see what it will do. In fact, the TI-99/4A is a reasonable machine — the BASIC is quirky (good on editing, OK for graphics and sound, not too good on anything else) and the machine is surprisingly slow (especially since it uses a 16-bit processor), but it's reliable and often pleasant to use. There is a dearth of software and a corresponding lack of interest in the machine's sound facilities which — considering the £99 price tag — are quite impressive. The programme presented here goes some way to remedying that situation. It is easy to rewrite for other machines offering a sound command which handles frequency and volume, definable functions and numerical arrays.

The programme uses 10 functions (defined after some trial and error) or a series of input statements to load an array (VOL(X)) with values which determine the envelope of a note. There are also some elementary graphics to give a rough picture of the eventual envelope. For simplicity, the graphics statements (lines 30-70, lines 520-610 and lines 1470-1490) can be omitted (they will, in any case, need to be changed if the programme is to run on other machines). The Texas uses a SOUND command which specifies a duration variable, a frequency and a volume. Channels (there are three) are identified by position in the statement. Obviously, the programme will be of most value to a machine with no facility for controlling envelopes. The major obstacle to portability is the fact that on the Texas the volume parameters range from 30 (quietest) to 0 (loudest). Most other machines — more logically — allows volume to range from 0 (quietest) to 15 (loudest). Line 690 will need to be adjusted to cope with different sound commands and the functions defined in lines 910, 960, 1010, 1060, 1110, 1160, 1210, 1260, 1310 and 1360 will need to be adapted to take account of the volume control features of other computers (as will the manual setting section of the programme in lines 1430-1530). The principles of the programme's operation are, however, good for most BASICS.

Integrating A Function



As it stands, the programme is of most interest as an analytic or educational tool. It allows you to control the parameters of an envelope and see and hear what the effect is. The routines can, of course, be included in a more elaborate compositional, sequencing or real-time playing programme. In such contexts, the VOL array will probably need to be two dimensional — VOL(4,7) will give the 7th value for the envelope of the 4th note, for instance — but the method of setting the envelope for each note will be the same. The essential parts of the programme could be incorporated in a subroutine. The programme includes a repeat feature (lines 480-510 and lines 670 and 710) which repeats a note 10 times. This can be dropped or enhanced (for example, the number of repetitions could be varied by inputting a value for D in line 510). I find it useful to hear a note repeated. Incidentally, the best effects using this programme are obtained by enveloping noise which, on the Texas, is achieved by entering -1, -2, -3, -5, -6 or -7 in answer to the 'note frequency' request in line 80.

Listing
10 REM TEXAS ENVELOPE SHAPER COPYRIGHT G. HERMAN 1983
20 CALL CLEAR
30 CALL CHAR (128, "FFFFFFFFFFFFFFFF")
40 CALL CHAR (158. "0101010101010101")
50 CALL CHAR (159. "FFOOOOOOOOOOOOOO")
60 CALL SCREEN (4)
70 CALL COLOR (13, 2, 2)
80 INPUT "NOTE FREQUENCY": FREQ
90 FOR P = 1 TO 200
100 NEXTP
110 CALL CLEAR
120 DIM HGT (30), VOL (30)
130 INPUT "DURATION (0 TO 30)": DUR
140 IF DUR < 0 THEN 160
150 IF DUR > 30 THEN 160 ELSE 220
160 CALL CLEAR
170 PRINT TAB (10): "OUT OF RANGE"
180 FOR P= 1 TO 200
190 NEXT P
200 GOTO 130
220 PRINT "ENVELOPE STEP (1 TO": DUR;")"
230 INPUT GRAD
240 IF GRAD < I THEN 260
250 IF GRAD > DUR THEN 260 ELSE 310
260 CALL CLEAR
270 PRINT TAB (10): "OUT OF RANGE"
280 FOR P = I TO 200
290 NEXT P
300 GOTO 220
310 GALL CLEAR
320 COL = 1
330 PRINT "ENVELOPE FORMS"
340 FOR P= I TO 200
350 NEXTP
360 GOSUB 750
370 CALL CLEAR
380 PRINT "CHECKING"
390 FOR X = 0 TO DUR STEP GRAD
400 IF VOL(X) < 0 THEN 410 ELSE 420
410 VOL(X) = 0
420 IF VOL(X) > 30 THEN 430 ELSE 440
430 VOL(X) = 30
440 NEXT X
450 PRINT TAB( 10): "OKAY"
460 FOR P = I TO 200
470 NEXT P
480 INPUT "REPEATING NOTE (Y OR N)?": D$
490 D -0
500 IF D$ = "Y" THEN 510 ELSE 520
510 D = 9
520 CALL CLEAR
530 CALL HCHAR (1,1.159,32)
540 CALL HCHAR (24,1,95,32)
550 CALL VCHAR (1, DUR/GRAD + 1,158.24)
560 FOR X = 0 TO DUR STEP GRAD
570 HGT (X) = VOL(X)/2
580 IF HGT(X) < 1 THEN 590 ELSE 600
590 HGT(X) = 1
600 CALL VCHAR (I.X/GRAD+ 1,128,HGT(X))
610 NEXT X
620 GOSUB 670
630 PRINT "DURATION = DUR:" STEP= ";GRAD
640 INPUT "AGAIN (Y OR N)? ":A$
650 IF AS = "Y" THEN 130
660 END
670 FOR OVER = 0 TO 1)
680 FOR X = 0 TO DUR STEP GRAD
690 CALL SOUND (-100, FREQ, VOL(X))
700 NEXT X
710 NEXT OVER
720 RETURN
730 CALL CLEAR
740 CALL SCREEN (10)
750 INPUT "PRESET ENVELOPES (Y OR N); ":B$
760 IF B$ = "N" THEN 1410
770 CALL CLEAR
780 PRINT TAB(5): "CHOOSE:"
790 PRINT TAB(8); "SINE (1)"
800 PRINT TAB(8); "COSINE (2)"
810 PRINT TAB(8); "SAWTOOTH (3)"
820 PRINT TAB(8); "FLATPEAK (4)''
830 PRINT TAB(8); "LIN RISE (5)"
840 PRINT TAB(8); "LIN DECY (6)"
850 PRINT TAB(8); "LOG DECY (7)"
860 PRINT TAB(8); "EXP DECY (8)"
870 PRINT TAB(8); "SQ. S/R (9)"
880 PRINT TAB(8); "SORT. DCY (10)"
890 INPUT ENV
900 ON ENV GOTO 910, 960, 1010, 1060, 1110, 1160, 1210,1260, 1310, 1360
910 DEF F(Z) = 30*SIN(Z*22/105)
920 FOR X = 0 TO DUR STEP GRAD
930 VOL(X) = F(X)
940 NEXT X
950 RETURN
960 DEF G(Z) = 30*COS(Z*22/105)
970 FOR X = 0 TO DUR STEP GRAD
980 VOL(X) = G(X)
990 NEXT X
1000 RETURN
1010 DEF H(Z) = (Z**2)*9/70-53*Z/14 + 30
1020 FOR X = 0 TO DUR STEP GRAD
1030 VOL(X) = H(X)
1040 NEXT X
1050 RETURN
1060 DEF I(Z) = 30-3*Z
1070 FOR X = 0 TO DUR STEP GRAD
1080 VOL(X) = I(X)
1090 NEXT X
1100 RETURN
1110 DEF J(Z) = 30-Z
1120 FOR X = 0 TO DUR STEP GRAD
1130 VOL(X) = J(X)
1140 NEXT X
1150 RETURN
1160 DEF K(Z) = Z
1170 FOR X = 0 TO DUR STEP GRAD
1180 VOL(X) = K(X)
1190 NEXT X
1200 RETURN
1210 DEF L(Z) = 10*INT(LOG(Z + 1))
1220 FOR X = 0 TO DUR STEP GRAD
1230 VOL(X) = L(X)
1240 NEXT X
1250 RETURN
1260 DEF M(Z) = INT(EXP(Z/8.8))
1270 FOR X = 0 TO DUR STEP GRAD
1280 VOL(X) = M(X)
1290 NEXT X
1300 RETURN
1310 DEF N(Z) = (Z**3)/1000
1320 OR X = 0 TO DUR STEP GRAD
1330 VOL(X) = N(X)
1340 NEXT X
1350 RETURN
1360 DEF Q(Z) = 6*INT(SQR(Z))
1370 FOR X = 0 TO DUR STEP GRAD
1380 VOL(X) = Q(X)
1390 NEXT X
1400 RETURN
1410 CALL CLEAR
1420 PRINT "MANUAL SETTING"
1430 FOR Z = 0 TO DUR STEP GRAD
1440 PRINT Z/GRAD+ 1; "OUT OF"; INT (DUR/GRAD + 1)
1450 INPUT "KEY LEVEL(30 SOFT, 0 LOUD)":Y
1460 VOL(Z) = Y
1470 FOR P = 0 TO Z
1480 CALL VCHAR (1.P/GRAD + 1,128,VOL(P)/2)
1490 NEXT P
1500 FOR P = 1 TO 100
1510 NEXTP
1520 CALL CLEAR
1530 NEXT Z
1540 RETURN


More with this topic


Browse by Topic:

Computing



Previous Article in this issue

Alpha Waves


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 - Jan 1984

Donated & scanned by: Mike Gorman

Topic:

Computing


Feature by Gary Herman

Previous article in this issue:

> Alpha Waves


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 December 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