★ CODING ★ LISTINGS ★ Sound advice ★ |
Sound - Sound Advice (Popular Computing Weekly) | Coding Listings |
Design your own sounds on the Amstrad machines with this urogram from John Durst One of the most ambitious features of the Amstrad machines is the system which produces computer music. With up to three channels on the go, along with volume envelopes and tonal modulation, it can produce quite impressive Victory fanfares and the like. But the cost in human wear and tear is appalling; people have been found running through the snowy streets in their underwear, scattering handfuls of graphs and data lists. Before things get hopelessly out of hand, something must be done to reduce the drudgery. And here, for a start, is a Basic program which can help. The two features which most affect the quality of a musical note (in Amstrad terms) are the Volume Envelope and the Tone Envelope. The first allows you to sculpture the loudness of the note; the second modifies the frequency of the note, with much the same effect as the way a violinist waggles his finger on the string to give an added richness to the note he is playing. Both these features can be coded, using the Env function (for Envelope Volume) and the Enc function (Envelope Tone). These two functions are programmed in Basic as Data lists, which can be read off by the Sound command. They have to be entered as lists of figures, which must be calculated in advance - usually from graphic sketches of the shapes of envelope required. Now. graphics and calculations are two things computers are very good at, so why not get the Amstrad to take the sweat out of coding the envelopes ? The program here lets you draw the outline of the envelope you are planning, on the TV screen. As described in the User Instructions (Ch6, p8), the envelope has to be made up of straight-line sections; in this program, you hit the Enter key at the end of each section you have drawn and the computer calculates and stores the appropriate values (and prints them out). When you have designed your envelope you hit the Numeric Pad Enter and the whole thing is converted mto an Env (or Enf) function and the musical note is played. You can then go on to design another one and see how that works. There is room for up to 15 of each kind of Envelope (stored in two arrays) and, obviously, these can be Saved and used later in your own programs. Program Notes
A program of this kind relies heavily on single, plus or minus increments. You are dealing all the time with the three numbers 1 , 0 and 1. Hence the rash of flags, "Sgn" and "Abs". Basic is very cumbersome when coping with this; look at Lines 330/340, for instance. This is a case when machine code would be both neater and easier to understand. However, the whole thing seems to work and it really does help to take some of the headache out of Amstrad music.
|