1 /***************************************************************************
\r
4 begin : Wed May 15 2002
\r
5 copyright : (C) 2002 by Pete Bernert
\r
6 email : BlackDove@addcom.de
\r
7 ***************************************************************************/
\r
8 /***************************************************************************
\r
10 * This program is free software; you can redistribute it and/or modify *
\r
11 * it under the terms of the GNU General Public License as published by *
\r
12 * the Free Software Foundation; either version 2 of the License, or *
\r
13 * (at your option) any later version. See also the license.txt file for *
\r
14 * additional informations. *
\r
16 ***************************************************************************/
\r
22 // will be included from spu.c
\r
25 ////////////////////////////////////////////////////////////////////////
\r
27 ////////////////////////////////////////////////////////////////////////
\r
29 unsigned long RateTable[160];
\r
31 void InitADSR(void) // INIT ADSR
\r
33 unsigned long r,rs,rd;int i;
\r
35 memset(RateTable,0,sizeof(unsigned long)*160); // build the rate table according to Neill's rules (see at bottom of file)
\r
39 for(i=32;i<160;i++) // we start at pos 32 with the real values... everything before is 0
\r
44 rd++;if(rd==5) {rd=1;rs*=2;}
\r
46 if(r>0x3FFFFFFF) r=0x3FFFFFFF;
\r
52 ////////////////////////////////////////////////////////////////////////
\r
54 INLINE void StartADSR(int ch) // MIX ADSR
\r
56 s_chan[ch].ADSRX.lVolume=1; // and init some adsr vars
\r
57 s_chan[ch].ADSRX.State=0;
\r
58 s_chan[ch].ADSRX.EnvelopeVol=0;
\r
61 ////////////////////////////////////////////////////////////////////////
\r
63 INLINE int MixADSR(int ch) // MIX ADSR
\r
65 if(s_chan[ch].bStop) // should be stopped:
\r
67 if(s_chan[ch].ADSRX.ReleaseModeExp)
\r
69 switch((s_chan[ch].ADSRX.EnvelopeVol>>28)&0x7)
\r
71 case 0: s_chan[ch].ADSRX.EnvelopeVol-=RateTable[(4*(s_chan[ch].ADSRX.ReleaseRate^0x1F))-0x18 +0 + 32]; break;
\r
72 case 1: s_chan[ch].ADSRX.EnvelopeVol-=RateTable[(4*(s_chan[ch].ADSRX.ReleaseRate^0x1F))-0x18 +4 + 32]; break;
\r
73 case 2: s_chan[ch].ADSRX.EnvelopeVol-=RateTable[(4*(s_chan[ch].ADSRX.ReleaseRate^0x1F))-0x18 +6 + 32]; break;
\r
74 case 3: s_chan[ch].ADSRX.EnvelopeVol-=RateTable[(4*(s_chan[ch].ADSRX.ReleaseRate^0x1F))-0x18 +8 + 32]; break;
\r
75 case 4: s_chan[ch].ADSRX.EnvelopeVol-=RateTable[(4*(s_chan[ch].ADSRX.ReleaseRate^0x1F))-0x18 +9 + 32]; break;
\r
76 case 5: s_chan[ch].ADSRX.EnvelopeVol-=RateTable[(4*(s_chan[ch].ADSRX.ReleaseRate^0x1F))-0x18 +10+ 32]; break;
\r
77 case 6: s_chan[ch].ADSRX.EnvelopeVol-=RateTable[(4*(s_chan[ch].ADSRX.ReleaseRate^0x1F))-0x18 +11+ 32]; break;
\r
78 case 7: s_chan[ch].ADSRX.EnvelopeVol-=RateTable[(4*(s_chan[ch].ADSRX.ReleaseRate^0x1F))-0x18 +12+ 32]; break;
\r
83 s_chan[ch].ADSRX.EnvelopeVol-=RateTable[(4*(s_chan[ch].ADSRX.ReleaseRate^0x1F))-0x0C + 32];
\r
86 if(s_chan[ch].ADSRX.EnvelopeVol<0)
\r
88 s_chan[ch].ADSRX.EnvelopeVol=0;
\r
90 //s_chan[ch].bReverb=0;
\r
91 //s_chan[ch].bNoise=0;
\r
94 s_chan[ch].ADSRX.lVolume=s_chan[ch].ADSRX.EnvelopeVol>>21;
\r
95 return s_chan[ch].ADSRX.lVolume;
\r
97 else // not stopped yet?
\r
99 if(s_chan[ch].ADSRX.State==0) // -> attack
\r
101 if(s_chan[ch].ADSRX.AttackModeExp)
\r
103 if(s_chan[ch].ADSRX.EnvelopeVol<0x60000000)
\r
104 s_chan[ch].ADSRX.EnvelopeVol+=RateTable[(s_chan[ch].ADSRX.AttackRate^0x7F)-0x10 + 32];
\r
106 s_chan[ch].ADSRX.EnvelopeVol+=RateTable[(s_chan[ch].ADSRX.AttackRate^0x7F)-0x18 + 32];
\r
110 s_chan[ch].ADSRX.EnvelopeVol+=RateTable[(s_chan[ch].ADSRX.AttackRate^0x7F)-0x10 + 32];
\r
113 if(s_chan[ch].ADSRX.EnvelopeVol<0)
\r
115 s_chan[ch].ADSRX.EnvelopeVol=0x7FFFFFFF;
\r
116 s_chan[ch].ADSRX.State=1;
\r
119 s_chan[ch].ADSRX.lVolume=s_chan[ch].ADSRX.EnvelopeVol>>21;
\r
120 return s_chan[ch].ADSRX.lVolume;
\r
122 //--------------------------------------------------//
\r
123 if(s_chan[ch].ADSRX.State==1) // -> decay
\r
125 switch((s_chan[ch].ADSRX.EnvelopeVol>>28)&0x7)
\r
127 case 0: s_chan[ch].ADSRX.EnvelopeVol-=RateTable[(4*(s_chan[ch].ADSRX.DecayRate^0x1F))-0x18+0 + 32]; break;
\r
128 case 1: s_chan[ch].ADSRX.EnvelopeVol-=RateTable[(4*(s_chan[ch].ADSRX.DecayRate^0x1F))-0x18+4 + 32]; break;
\r
129 case 2: s_chan[ch].ADSRX.EnvelopeVol-=RateTable[(4*(s_chan[ch].ADSRX.DecayRate^0x1F))-0x18+6 + 32]; break;
\r
130 case 3: s_chan[ch].ADSRX.EnvelopeVol-=RateTable[(4*(s_chan[ch].ADSRX.DecayRate^0x1F))-0x18+8 + 32]; break;
\r
131 case 4: s_chan[ch].ADSRX.EnvelopeVol-=RateTable[(4*(s_chan[ch].ADSRX.DecayRate^0x1F))-0x18+9 + 32]; break;
\r
132 case 5: s_chan[ch].ADSRX.EnvelopeVol-=RateTable[(4*(s_chan[ch].ADSRX.DecayRate^0x1F))-0x18+10+ 32]; break;
\r
133 case 6: s_chan[ch].ADSRX.EnvelopeVol-=RateTable[(4*(s_chan[ch].ADSRX.DecayRate^0x1F))-0x18+11+ 32]; break;
\r
134 case 7: s_chan[ch].ADSRX.EnvelopeVol-=RateTable[(4*(s_chan[ch].ADSRX.DecayRate^0x1F))-0x18+12+ 32]; break;
\r
137 if(s_chan[ch].ADSRX.EnvelopeVol<0) s_chan[ch].ADSRX.EnvelopeVol=0;
\r
138 if(((s_chan[ch].ADSRX.EnvelopeVol>>27)&0xF) <= s_chan[ch].ADSRX.SustainLevel)
\r
140 s_chan[ch].ADSRX.State=2;
\r
143 s_chan[ch].ADSRX.lVolume=s_chan[ch].ADSRX.EnvelopeVol>>21;
\r
144 return s_chan[ch].ADSRX.lVolume;
\r
146 //--------------------------------------------------//
\r
147 if(s_chan[ch].ADSRX.State==2) // -> sustain
\r
149 if(s_chan[ch].ADSRX.SustainIncrease)
\r
151 if(s_chan[ch].ADSRX.SustainModeExp)
\r
153 if(s_chan[ch].ADSRX.EnvelopeVol<0x60000000)
\r
154 s_chan[ch].ADSRX.EnvelopeVol+=RateTable[(s_chan[ch].ADSRX.SustainRate^0x7F)-0x10 + 32];
\r
156 s_chan[ch].ADSRX.EnvelopeVol+=RateTable[(s_chan[ch].ADSRX.SustainRate^0x7F)-0x18 + 32];
\r
160 s_chan[ch].ADSRX.EnvelopeVol+=RateTable[(s_chan[ch].ADSRX.SustainRate^0x7F)-0x10 + 32];
\r
163 if(s_chan[ch].ADSRX.EnvelopeVol<0)
\r
165 s_chan[ch].ADSRX.EnvelopeVol=0x7FFFFFFF;
\r
170 if(s_chan[ch].ADSRX.SustainModeExp)
\r
172 switch((s_chan[ch].ADSRX.EnvelopeVol>>28)&0x7)
\r
174 case 0: s_chan[ch].ADSRX.EnvelopeVol-=RateTable[((s_chan[ch].ADSRX.SustainRate^0x7F))-0x1B +0 + 32];break;
\r
175 case 1: s_chan[ch].ADSRX.EnvelopeVol-=RateTable[((s_chan[ch].ADSRX.SustainRate^0x7F))-0x1B +4 + 32];break;
\r
176 case 2: s_chan[ch].ADSRX.EnvelopeVol-=RateTable[((s_chan[ch].ADSRX.SustainRate^0x7F))-0x1B +6 + 32];break;
\r
177 case 3: s_chan[ch].ADSRX.EnvelopeVol-=RateTable[((s_chan[ch].ADSRX.SustainRate^0x7F))-0x1B +8 + 32];break;
\r
178 case 4: s_chan[ch].ADSRX.EnvelopeVol-=RateTable[((s_chan[ch].ADSRX.SustainRate^0x7F))-0x1B +9 + 32];break;
\r
179 case 5: s_chan[ch].ADSRX.EnvelopeVol-=RateTable[((s_chan[ch].ADSRX.SustainRate^0x7F))-0x1B +10+ 32];break;
\r
180 case 6: s_chan[ch].ADSRX.EnvelopeVol-=RateTable[((s_chan[ch].ADSRX.SustainRate^0x7F))-0x1B +11+ 32];break;
\r
181 case 7: s_chan[ch].ADSRX.EnvelopeVol-=RateTable[((s_chan[ch].ADSRX.SustainRate^0x7F))-0x1B +12+ 32];break;
\r
186 s_chan[ch].ADSRX.EnvelopeVol-=RateTable[((s_chan[ch].ADSRX.SustainRate^0x7F))-0x0F + 32];
\r
189 if(s_chan[ch].ADSRX.EnvelopeVol<0)
\r
191 s_chan[ch].ADSRX.EnvelopeVol=0;
\r
194 s_chan[ch].ADSRX.lVolume=s_chan[ch].ADSRX.EnvelopeVol>>21;
\r
195 return s_chan[ch].ADSRX.lVolume;
\r
204 James Higgs ADSR investigations:
\r
206 PSX SPU Envelope Timings
\r
207 ~~~~~~~~~~~~~~~~~~~~~~~~
\r
209 First, here is an extract from doomed's SPU doc, which explains the basics
\r
210 of the SPU "volume envelope":
\r
212 *** doomed doc extract start ***
\r
214 --------------------------------------------------------------------------
\r
216 --------------------------------------------------------------------------
\r
217 The SPU has 24 hardware voices. These voices can be used to reproduce sample
\r
218 data, noise or can be used as frequency modulator on the next voice.
\r
219 Each voice has it's own programmable ADSR envelope filter. The main volume
\r
220 can be programmed independently for left and right output.
\r
222 The ADSR envelope filter works as follows:
\r
223 Ar = Attack rate, which specifies the speed at which the volume increases
\r
224 from zero to it's maximum value, as soon as the note on is given. The
\r
225 slope can be set to lineair or exponential.
\r
226 Dr = Decay rate specifies the speed at which the volume decreases to the
\r
227 sustain level. Decay is always decreasing exponentially.
\r
228 Sl = Sustain level, base level from which sustain starts.
\r
229 Sr = Sustain rate is the rate at which the volume of the sustained note
\r
230 increases or decreases. This can be either lineair or exponential.
\r
231 Rr = Release rate is the rate at which the volume of the note decreases
\r
232 as soon as the note off is given.
\r
236 Sl _| _ / _ \__--- \
\r
240 |/___________________\________
\r
243 The overal volume can also be set to sweep up or down lineairly or
\r
244 exponentially from it's current value. This can be done seperately
\r
245 for left and right.
\r
247 Relevant SPU registers:
\r
248 -------------------------------------------------------------
\r
249 $1f801xx8 Attack/Decay/Sustain level
\r
250 bit |0f|0e 0d 0c 0b 0a 09 08|07 06 05 04|03 02 01 00|
\r
251 desc.|Am| Ar |Dr |Sl |
\r
253 Am 0 Attack mode Linear
\r
256 Ar 0-7f attack rate
\r
258 Sl 0-f sustain level
\r
259 -------------------------------------------------------------
\r
260 $1f801xxa Sustain rate, Release Rate.
\r
261 bit |0f|0e|0d|0c 0b 0a 09 08 07 06|05|04 03 02 01 00|
\r
262 desc.|Sm|Sd| 0| Sr |Rm|Rr |
\r
264 Sm 0 sustain rate mode linear
\r
266 Sd 0 sustain rate mode increase
\r
268 Sr 0-7f Sustain Rate
\r
269 Rm 0 Linear decrease
\r
270 1 Exponential decrease
\r
271 Rr 0-1f Release Rate
\r
273 Note: decay mode is always Expontial decrease, and thus cannot
\r
275 -------------------------------------------------------------
\r
276 $1f801xxc Current ADSR volume
\r
277 bit |0f 0e 0d 0c 0b 0a 09 08 07 06 05 04 03 02 01 00|
\r
280 ADSRvol Returns the current envelope volume when
\r
282 -- James' Note: return range: 0 -> 32767
\r
284 *** doomed doc extract end ***
\r
286 By using a small PSX proggie to visualise the envelope as it was played,
\r
287 the following results for envelope timing were obtained:
\r
289 1. Attack rate value (linear mode)
\r
291 Attack value range: 0 -> 127
\r
293 Value | 48 | 52 | 56 | 60 | 64 | 68 | 72 | | 80 |
\r
294 -----------------------------------------------------------------
\r
295 Frames | 11 | 21 | 42 | 84 | 169| 338| 676| |2890|
\r
297 Note: frames is no. of PAL frames to reach full volume (100%
\r
300 Hmm, noticing that the time taken to reach full volume doubles
\r
301 every time we add 4 to our attack value, we know the equation is
\r
303 frames = k * 2 ^ (value / 4)
\r
305 (You may ponder about envelope generator hardware at this point,
\r
308 By substituting some stuff and running some checks, we get:
\r
310 k = 0.00257 (close enuf)
\r
313 frames = 0.00257 * 2 ^ (value / 4)
\r
314 If you just happen to be writing an emulator, then you can probably
\r
315 use an equation like:
\r
317 %volume_increase_per_tick = 1 / frames
\r
320 ------------------------------------
\r
322 ms=((1<<(value>>2))*514)/10000
\r
323 ------------------------------------
\r
325 2. Decay rate value (only has log mode)
\r
327 Decay value range: 0 -> 15
\r
329 Value | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
\r
330 ------------------------------------------------
\r
331 frames | | | | | 6 | 12 | 24 | 47 |
\r
333 Note: frames here is no. of PAL frames to decay to 50% volume.
\r
335 formula: frames = k * 2 ^ (value)
\r
337 Substituting, we get: k = 0.00146
\r
339 Further info on logarithmic nature:
\r
340 frames to decay to sustain level 3 = 3 * frames to decay to
\r
343 Also no. of frames to 25% volume = roughly 1.85 * no. of frames to
\r
346 Frag it - just use linear approx.
\r
348 ------------------------------------
\r
350 ms=((1<<value)*292)/10000
\r
351 ------------------------------------
\r
354 3. Sustain rate value (linear mode)
\r
356 Sustain rate range: 0 -> 127
\r
358 Value | 48 | 52 | 56 | 60 | 64 | 68 | 72 |
\r
359 -------------------------------------------
\r
360 frames | 9 | 19 | 37 | 74 | 147| 293| 587|
\r
362 Here, frames = no. of PAL frames for volume amplitude to go from 100%
\r
363 to 0% (or vice-versa).
\r
365 Same formula as for attack value, just a different value for k:
\r
369 ie: frames = 0.00225 * 2 ^ (value / 4)
\r
371 For emulation purposes:
\r
373 %volume_increase_or_decrease_per_tick = 1 / frames
\r
375 ------------------------------------
\r
377 ms=((1<<(value>>2))*450)/10000
\r
378 ------------------------------------
\r
381 4. Release rate (linear mode)
\r
383 Release rate range: 0 -> 31
\r
385 Value | 13 | 14 | 15 | 16 | 17 |
\r
386 ---------------------------------------------------------------
\r
387 frames | 18 | 36 | 73 | 146| 292|
\r
389 Here, frames = no. of PAL frames to decay from 100% vol to 0% vol
\r
390 after "note-off" is triggered.
\r
392 Formula: frames = k * 2 ^ (value)
\r
394 And so: k = 0.00223
\r
396 ------------------------------------
\r
398 ms=((1<<value)*446)/10000
\r
399 ------------------------------------
\r
404 Log stuff not figured out. You may get some clues from the "Decay rate"
\r
405 stuff above. For emu purposes it may not be important - use linear
\r
408 To get timings in millisecs, multiply frames by 20.
\r
412 - James Higgs 17/6/2000
\r
413 james7780@yahoo.com
\r
415 //---------------------------------------------------------------
\r
417 OLD adsr mixing according to james' rules... has to be called
\r
418 every one millisecond
\r
421 long v,v2,lT,l1,l2,l3;
\r
423 if(s_chan[ch].bStop) // psx wants to stop? -> release phase
\r
425 if(s_chan[ch].ADSR.ReleaseVal!=0) // -> release not 0: do release (if 0: stop right now)
\r
427 if(!s_chan[ch].ADSR.ReleaseVol) // --> release just started? set up the release stuff
\r
429 s_chan[ch].ADSR.ReleaseStartTime=s_chan[ch].ADSR.lTime;
\r
430 s_chan[ch].ADSR.ReleaseVol=s_chan[ch].ADSR.lVolume;
\r
431 s_chan[ch].ADSR.ReleaseTime = // --> calc how long does it take to reach the wanted sus level
\r
432 (s_chan[ch].ADSR.ReleaseTime*
\r
433 s_chan[ch].ADSR.ReleaseVol)/1024;
\r
435 // -> NO release exp mode used (yet)
\r
436 v=s_chan[ch].ADSR.ReleaseVol; // -> get last volume
\r
437 lT=s_chan[ch].ADSR.lTime- // -> how much time is past?
\r
438 s_chan[ch].ADSR.ReleaseStartTime;
\r
439 l1=s_chan[ch].ADSR.ReleaseTime;
\r
441 if(lT<l1) // -> we still have to release
\r
443 v=v-((v*lT)/l1); // --> calc new volume
\r
445 else // -> release is over: now really stop that sample
\r
446 {v=0;s_chan[ch].bOn=0;s_chan[ch].ADSR.ReleaseVol=0;s_chan[ch].bNoise=0;}
\r
448 else // -> release IS 0: release at once
\r
450 v=0;s_chan[ch].bOn=0;s_chan[ch].ADSR.ReleaseVol=0;s_chan[ch].bNoise=0;
\r
454 {//--------------------------------------------------// not in release phase:
\r
456 lT=s_chan[ch].ADSR.lTime;
\r
457 l1=s_chan[ch].ADSR.AttackTime;
\r
459 if(lT<l1) // attack
\r
460 { // no exp mode used (yet)
\r
461 // if(s_chan[ch].ADSR.AttackModeExp)
\r
472 { // should be exp, but who cares? ;)
\r
473 l2=s_chan[ch].ADSR.DecayTime;
\r
474 v2=s_chan[ch].ADSR.SustainLevel;
\r
479 v-=(((v-v2)*lT)/l2);
\r
482 { // no exp mode used (yet)
\r
483 l3=s_chan[ch].ADSR.SustainTime;
\r
485 if(s_chan[ch].ADSR.SustainModeDec>0)
\r
487 if(l3!=0) v2+=((v-v2)*lT)/l3;
\r
492 if(l3!=0) v2-=(v2*lT)/l3;
\r
497 if(v2<=0) {v2=0;s_chan[ch].bOn=0;s_chan[ch].ADSR.ReleaseVol=0;s_chan[ch].bNoise=0;}
\r
504 //----------------------------------------------------//
\r
505 // ok, done for this channel, so increase time
\r
507 s_chan[ch].ADSR.lTime+=1; // 1 = 1.020408f ms;
\r
509 if(v>1024) v=1024; // adjust volume
\r
511 s_chan[ch].ADSR.lVolume=v; // store act volume
\r
513 return v; // return the volume factor
\r
517 //-----------------------------------------------------------------------------
\r
518 //-----------------------------------------------------------------------------
\r
519 //-----------------------------------------------------------------------------
\r
523 -----------------------------------------------------------------------------
\r
525 Playstation SPU envelope timing notes
\r
526 -----------------------------------------------------------------------------
\r
528 This is preliminary. This may be wrong. But the model described herein fits
\r
529 all of my experimental data, and it's just simple enough to sound right.
\r
531 ADSR envelope level ranges from 0x00000000 to 0x7FFFFFFF internally.
\r
532 The value returned by channel reg 0xC is (envelope_level>>16).
\r
534 Each sample, an increment or decrement value will be added to or
\r
535 subtracted from this envelope level.
\r
537 Create the rate log table. The values double every 4 entries.
\r
544 entry #40 = 4096...
\r
545 entry #44 = 8192...
\r
546 entry #48 = 16384...
\r
547 entry #52 = 32768...
\r
548 entry #56 = 65536...
\r
550 increments and decrements are in terms of ratelogtable[n]
\r
551 n may exceed the table bounds (plan on n being between -32 and 127).
\r
552 table values are all clipped between 0x00000000 and 0x3FFFFFFF
\r
554 when you "voice on", the envelope is always fully reset.
\r
555 (yes, it may click. the real thing does this too.)
\r
557 envelope level begins at zero.
\r
559 each state happens for at least 1 cycle
\r
560 (transitions are not instantaneous)
\r
561 this may result in some oddness: if the decay rate is uberfast, it will cut
\r
562 the envelope from full down to half in one sample, potentially skipping over
\r
567 - if the envelope level has overflowed past the max, clip to 0x7FFFFFFF and
\r
570 Linear attack mode:
\r
571 - line extends upward to 0x7FFFFFFF
\r
572 - increment per sample is ratelogtable[(Ar^0x7F)-0x10]
\r
574 Logarithmic attack mode:
\r
575 if envelope_level < 0x60000000:
\r
576 - line extends upward to 0x60000000
\r
577 - increment per sample is ratelogtable[(Ar^0x7F)-0x10]
\r
579 - line extends upward to 0x7FFFFFFF
\r
580 - increment per sample is ratelogtable[(Ar^0x7F)-0x18]
\r
584 - if ((envelope_level>>27)&0xF) <= Sl, proceed to SUSTAIN.
\r
585 Do not clip to the sustain level.
\r
586 - current line ends at (envelope_level & 0x07FFFFFF)
\r
587 - decrement per sample depends on (envelope_level>>28)&0x7
\r
588 0: ratelogtable[(4*(Dr^0x1F))-0x18+0]
\r
589 1: ratelogtable[(4*(Dr^0x1F))-0x18+4]
\r
590 2: ratelogtable[(4*(Dr^0x1F))-0x18+6]
\r
591 3: ratelogtable[(4*(Dr^0x1F))-0x18+8]
\r
592 4: ratelogtable[(4*(Dr^0x1F))-0x18+9]
\r
593 5: ratelogtable[(4*(Dr^0x1F))-0x18+10]
\r
594 6: ratelogtable[(4*(Dr^0x1F))-0x18+11]
\r
595 7: ratelogtable[(4*(Dr^0x1F))-0x18+12]
\r
596 (note that this is the same as the release rate formula, except that
\r
597 decay rates 10-1F aren't possible... those would be slower in theory)
\r
601 - no terminating condition except for voice off
\r
602 - Sd=0 (increase) behavior is identical to ATTACK for both log and linear.
\r
603 - Sd=1 (decrease) behavior:
\r
604 Linear sustain decrease:
\r
605 - line extends to 0x00000000
\r
606 - decrement per sample is ratelogtable[(Sr^0x7F)-0x0F]
\r
607 Logarithmic sustain decrease:
\r
608 - current line ends at (envelope_level & 0x07FFFFFF)
\r
609 - decrement per sample depends on (envelope_level>>28)&0x7
\r
610 0: ratelogtable[(Sr^0x7F)-0x1B+0]
\r
611 1: ratelogtable[(Sr^0x7F)-0x1B+4]
\r
612 2: ratelogtable[(Sr^0x7F)-0x1B+6]
\r
613 3: ratelogtable[(Sr^0x7F)-0x1B+8]
\r
614 4: ratelogtable[(Sr^0x7F)-0x1B+9]
\r
615 5: ratelogtable[(Sr^0x7F)-0x1B+10]
\r
616 6: ratelogtable[(Sr^0x7F)-0x1B+11]
\r
617 7: ratelogtable[(Sr^0x7F)-0x1B+12]
\r
621 - if the envelope level has overflowed to negative, clip to 0 and QUIT.
\r
623 Linear release mode:
\r
624 - line extends to 0x00000000
\r
625 - decrement per sample is ratelogtable[(4*(Rr^0x1F))-0x0C]
\r
627 Logarithmic release mode:
\r
628 - line extends to (envelope_level & 0x0FFFFFFF)
\r
629 - decrement per sample depends on (envelope_level>>28)&0x7
\r
630 0: ratelogtable[(4*(Rr^0x1F))-0x18+0]
\r
631 1: ratelogtable[(4*(Rr^0x1F))-0x18+4]
\r
632 2: ratelogtable[(4*(Rr^0x1F))-0x18+6]
\r
633 3: ratelogtable[(4*(Rr^0x1F))-0x18+8]
\r
634 4: ratelogtable[(4*(Rr^0x1F))-0x18+9]
\r
635 5: ratelogtable[(4*(Rr^0x1F))-0x18+10]
\r
636 6: ratelogtable[(4*(Rr^0x1F))-0x18+11]
\r
637 7: ratelogtable[(4*(Rr^0x1F))-0x18+12]
\r
639 -----------------------------------------------------------------------------
\r