160 For reference the six parameters are defined again here. Parameter Range Function A -127 to 127 Change of amplitude per step during attack phase AD -127 to 127 Change of amplitude per step during decay phase AS -127 to 0 Change of amplitude per step during sustain phase AR -127 to 0 Change of amplitude per step during release phase ALA 0 to 126 Target level at end of attack phase ALD 0 to 126 Target level at end of decay phase In our example the attack phase takes four seconds and each step lasts 1/4 seconds so there will be 16 steps.
We want these 16 steps to get us from an amplitude of zero to an amplitude of at least 100 – if we make each step increase the amplitude by seven we will get there in 16 steps. So parameter AA = 7. During the decay phase the amplitude must drop from 100 to 60 in two seconds. During two seconds there are eight steps. So the amplitude drops 40 units (100- 60) in eight steps – so each step must reduce the amplitude by five units. Thus AD=-5. So far we have determined the following parameters of the amplitude envelope. A=7 AD=-5 ALA=100 ALD=50 In our case the amplitude does not change during the sustain period so we can set AS = 0. The sound will go on until the sustain phase is ended.
The total time allowed for the attack, decay and sustain phases is given by the duration part of the SOUND command. The release phase then starts. Note that the length of the attack and decay phases is set by the values chosen for AA, AD, ALA and ALD but that the sustain phase can be terminated either by the amplitude reaching zero or the time set by the duration of the SOUND statement running out. The duration has to be set with care to ensure that it doesn’t cut the note off at the wrong moment. At the end of the sustain period the note enters the release phase where the note changes in amplitude at the rate set by AR until it reaches zero.