annotate src/psf2/peops2/adsr.c @ 3198:83b1a4e5f453

alsa-ng: Keep mixer open even when playback stopped.
author John Lindgren <john.lindgren@tds.net>
date Wed, 22 Jul 2009 16:42:16 -0400
parents 62cc6d667119
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2737
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
1 /***************************************************************************
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
2 adsr.c - description
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
3 -------------------
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
4 begin : Wed May 15 2002
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
5 copyright : (C) 2002 by Pete Bernert
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
6 email : BlackDove@addcom.de
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
7 ***************************************************************************/
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
8
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
9 /***************************************************************************
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
10 * *
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
11 * This program is free software; you can redistribute it and/or modify *
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
12 * it under the terms of the GNU General Public License as published by *
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
13 * the Free Software Foundation; either version 2 of the License, or *
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
14 * (at your option) any later version. See also the license.txt file for *
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
15 * additional informations. *
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
16 * *
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
17 ***************************************************************************/
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
18
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
19 //*************************************************************************//
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
20 // History of changes:
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
21 //
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
22 // 2003/05/14 - xodnizel
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
23 // - removed stopping of reverb on sample end
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
24 //
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
25 // 2003/01/06 - Pete
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
26 // - added Neill's ADSR timings
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
27 //
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
28 // 2002/05/15 - Pete
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
29 // - generic cleanup for the Peops release
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
30 //
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
31 //*************************************************************************//
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
32
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
33 #include "stdafx.h"
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
34
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
35 #define _IN_ADSR
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
36
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
37 // will be included from spu.c
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
38 #ifdef _IN_SPU
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
39
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
40 ////////////////////////////////////////////////////////////////////////
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
41 // ADSR func
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
42 ////////////////////////////////////////////////////////////////////////
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
43
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
44 unsigned long RateTable[160];
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
45
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
46 void InitADSR(void) // INIT ADSR
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
47 {
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
48 unsigned long r,rs,rd;int i;
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
49
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
50 memset(RateTable,0,sizeof(unsigned long)*160); // build the rate table according to Neill's rules (see at bottom of file)
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
51
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
52 r=3;rs=1;rd=0;
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
53
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
54 for(i=32;i<160;i++) // we start at pos 32 with the real values... everything before is 0
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
55 {
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
56 if(r<0x3FFFFFFF)
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
57 {
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
58 r+=rs;
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
59 rd++;if(rd==5) {rd=1;rs*=2;}
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
60 }
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
61 if(r>0x3FFFFFFF) r=0x3FFFFFFF;
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
62
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
63 RateTable[i]=r;
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
64 }
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
65 }
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
66
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
67 ////////////////////////////////////////////////////////////////////////
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
68
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
69 INLINE void StartADSR(int ch) // MIX ADSR
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
70 {
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
71 s_chan[ch].ADSRX.lVolume=1; // and init some adsr vars
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
72 s_chan[ch].ADSRX.State=0;
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
73 s_chan[ch].ADSRX.EnvelopeVol=0;
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
74 }
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
75
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
76 ////////////////////////////////////////////////////////////////////////
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
77
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
78 INLINE int MixADSR(int ch) // MIX ADSR
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
79 {
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
80 if(s_chan[ch].bStop) // should be stopped:
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
81 { // do release
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
82 if(s_chan[ch].ADSRX.ReleaseModeExp)
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
83 {
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
84 switch((s_chan[ch].ADSRX.EnvelopeVol>>28)&0x7)
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
85 {
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
86 case 0: s_chan[ch].ADSRX.EnvelopeVol-=RateTable[(4*(s_chan[ch].ADSRX.ReleaseRate^0x1F))-0x18 +0 + 32]; break;
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
87 case 1: s_chan[ch].ADSRX.EnvelopeVol-=RateTable[(4*(s_chan[ch].ADSRX.ReleaseRate^0x1F))-0x18 +4 + 32]; break;
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
88 case 2: s_chan[ch].ADSRX.EnvelopeVol-=RateTable[(4*(s_chan[ch].ADSRX.ReleaseRate^0x1F))-0x18 +6 + 32]; break;
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
89 case 3: s_chan[ch].ADSRX.EnvelopeVol-=RateTable[(4*(s_chan[ch].ADSRX.ReleaseRate^0x1F))-0x18 +8 + 32]; break;
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
90 case 4: s_chan[ch].ADSRX.EnvelopeVol-=RateTable[(4*(s_chan[ch].ADSRX.ReleaseRate^0x1F))-0x18 +9 + 32]; break;
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
91 case 5: s_chan[ch].ADSRX.EnvelopeVol-=RateTable[(4*(s_chan[ch].ADSRX.ReleaseRate^0x1F))-0x18 +10+ 32]; break;
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
92 case 6: s_chan[ch].ADSRX.EnvelopeVol-=RateTable[(4*(s_chan[ch].ADSRX.ReleaseRate^0x1F))-0x18 +11+ 32]; break;
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
93 case 7: s_chan[ch].ADSRX.EnvelopeVol-=RateTable[(4*(s_chan[ch].ADSRX.ReleaseRate^0x1F))-0x18 +12+ 32]; break;
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
94 }
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
95 }
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
96 else
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
97 {
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
98 s_chan[ch].ADSRX.EnvelopeVol-=RateTable[(4*(s_chan[ch].ADSRX.ReleaseRate^0x1F))-0x0C + 32];
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
99 }
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
100
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
101 if(s_chan[ch].ADSRX.EnvelopeVol<0)
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
102 {
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
103 s_chan[ch].ADSRX.EnvelopeVol=0;
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
104 s_chan[ch].bOn=0;
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
105 //s_chan[ch].bReverb=0;
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
106 //s_chan[ch].bNoise=0;
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
107 }
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
108
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
109 s_chan[ch].ADSRX.lVolume=s_chan[ch].ADSRX.EnvelopeVol>>21;
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
110 return s_chan[ch].ADSRX.lVolume;
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
111 }
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
112 else // not stopped yet?
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
113 {
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
114 if(s_chan[ch].ADSRX.State==0) // -> attack
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
115 {
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
116 if(s_chan[ch].ADSRX.AttackModeExp)
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
117 {
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
118 if(s_chan[ch].ADSRX.EnvelopeVol<0x60000000)
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
119 s_chan[ch].ADSRX.EnvelopeVol+=RateTable[(s_chan[ch].ADSRX.AttackRate^0x7F)-0x10 + 32];
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
120 else
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
121 s_chan[ch].ADSRX.EnvelopeVol+=RateTable[(s_chan[ch].ADSRX.AttackRate^0x7F)-0x18 + 32];
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
122 }
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
123 else
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
124 {
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
125 s_chan[ch].ADSRX.EnvelopeVol+=RateTable[(s_chan[ch].ADSRX.AttackRate^0x7F)-0x10 + 32];
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
126 }
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
127
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
128 if(s_chan[ch].ADSRX.EnvelopeVol<0)
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
129 {
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
130 s_chan[ch].ADSRX.EnvelopeVol=0x7FFFFFFF;
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
131 s_chan[ch].ADSRX.State=1;
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
132 }
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
133
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
134 s_chan[ch].ADSRX.lVolume=s_chan[ch].ADSRX.EnvelopeVol>>21;
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
135 return s_chan[ch].ADSRX.lVolume;
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
136 }
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
137 //--------------------------------------------------//
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
138 if(s_chan[ch].ADSRX.State==1) // -> decay
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
139 {
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
140 switch((s_chan[ch].ADSRX.EnvelopeVol>>28)&0x7)
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
141 {
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
142 case 0: s_chan[ch].ADSRX.EnvelopeVol-=RateTable[(4*(s_chan[ch].ADSRX.DecayRate^0x1F))-0x18+0 + 32]; break;
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
143 case 1: s_chan[ch].ADSRX.EnvelopeVol-=RateTable[(4*(s_chan[ch].ADSRX.DecayRate^0x1F))-0x18+4 + 32]; break;
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
144 case 2: s_chan[ch].ADSRX.EnvelopeVol-=RateTable[(4*(s_chan[ch].ADSRX.DecayRate^0x1F))-0x18+6 + 32]; break;
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
145 case 3: s_chan[ch].ADSRX.EnvelopeVol-=RateTable[(4*(s_chan[ch].ADSRX.DecayRate^0x1F))-0x18+8 + 32]; break;
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
146 case 4: s_chan[ch].ADSRX.EnvelopeVol-=RateTable[(4*(s_chan[ch].ADSRX.DecayRate^0x1F))-0x18+9 + 32]; break;
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
147 case 5: s_chan[ch].ADSRX.EnvelopeVol-=RateTable[(4*(s_chan[ch].ADSRX.DecayRate^0x1F))-0x18+10+ 32]; break;
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
148 case 6: s_chan[ch].ADSRX.EnvelopeVol-=RateTable[(4*(s_chan[ch].ADSRX.DecayRate^0x1F))-0x18+11+ 32]; break;
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
149 case 7: s_chan[ch].ADSRX.EnvelopeVol-=RateTable[(4*(s_chan[ch].ADSRX.DecayRate^0x1F))-0x18+12+ 32]; break;
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
150 }
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
151
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
152 if(s_chan[ch].ADSRX.EnvelopeVol<0) s_chan[ch].ADSRX.EnvelopeVol=0;
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
153 if(((s_chan[ch].ADSRX.EnvelopeVol>>27)&0xF) <= s_chan[ch].ADSRX.SustainLevel)
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
154 {
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
155 s_chan[ch].ADSRX.State=2;
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
156 }
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
157
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
158 s_chan[ch].ADSRX.lVolume=s_chan[ch].ADSRX.EnvelopeVol>>21;
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
159 return s_chan[ch].ADSRX.lVolume;
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
160 }
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
161 //--------------------------------------------------//
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
162 if(s_chan[ch].ADSRX.State==2) // -> sustain
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
163 {
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
164 if(s_chan[ch].ADSRX.SustainIncrease)
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
165 {
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
166 if(s_chan[ch].ADSRX.SustainModeExp)
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
167 {
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
168 if(s_chan[ch].ADSRX.EnvelopeVol<0x60000000)
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
169 s_chan[ch].ADSRX.EnvelopeVol+=RateTable[(s_chan[ch].ADSRX.SustainRate^0x7F)-0x10 + 32];
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
170 else
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
171 s_chan[ch].ADSRX.EnvelopeVol+=RateTable[(s_chan[ch].ADSRX.SustainRate^0x7F)-0x18 + 32];
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
172 }
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
173 else
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
174 {
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
175 s_chan[ch].ADSRX.EnvelopeVol+=RateTable[(s_chan[ch].ADSRX.SustainRate^0x7F)-0x10 + 32];
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
176 }
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
177
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
178 if(s_chan[ch].ADSRX.EnvelopeVol<0)
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
179 {
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
180 s_chan[ch].ADSRX.EnvelopeVol=0x7FFFFFFF;
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
181 }
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
182 }
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
183 else
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
184 {
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
185 if(s_chan[ch].ADSRX.SustainModeExp)
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
186 {
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
187 switch((s_chan[ch].ADSRX.EnvelopeVol>>28)&0x7)
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
188 {
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
189 case 0: s_chan[ch].ADSRX.EnvelopeVol-=RateTable[((s_chan[ch].ADSRX.SustainRate^0x7F))-0x1B +0 + 32];break;
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
190 case 1: s_chan[ch].ADSRX.EnvelopeVol-=RateTable[((s_chan[ch].ADSRX.SustainRate^0x7F))-0x1B +4 + 32];break;
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
191 case 2: s_chan[ch].ADSRX.EnvelopeVol-=RateTable[((s_chan[ch].ADSRX.SustainRate^0x7F))-0x1B +6 + 32];break;
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
192 case 3: s_chan[ch].ADSRX.EnvelopeVol-=RateTable[((s_chan[ch].ADSRX.SustainRate^0x7F))-0x1B +8 + 32];break;
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
193 case 4: s_chan[ch].ADSRX.EnvelopeVol-=RateTable[((s_chan[ch].ADSRX.SustainRate^0x7F))-0x1B +9 + 32];break;
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
194 case 5: s_chan[ch].ADSRX.EnvelopeVol-=RateTable[((s_chan[ch].ADSRX.SustainRate^0x7F))-0x1B +10+ 32];break;
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
195 case 6: s_chan[ch].ADSRX.EnvelopeVol-=RateTable[((s_chan[ch].ADSRX.SustainRate^0x7F))-0x1B +11+ 32];break;
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
196 case 7: s_chan[ch].ADSRX.EnvelopeVol-=RateTable[((s_chan[ch].ADSRX.SustainRate^0x7F))-0x1B +12+ 32];break;
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
197 }
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
198 }
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
199 else
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
200 {
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
201 s_chan[ch].ADSRX.EnvelopeVol-=RateTable[((s_chan[ch].ADSRX.SustainRate^0x7F))-0x0F + 32];
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
202 }
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
203
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
204 if(s_chan[ch].ADSRX.EnvelopeVol<0)
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
205 {
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
206 s_chan[ch].ADSRX.EnvelopeVol=0;
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
207 }
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
208 }
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
209 s_chan[ch].ADSRX.lVolume=s_chan[ch].ADSRX.EnvelopeVol>>21;
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
210 return s_chan[ch].ADSRX.lVolume;
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
211 }
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
212 }
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
213 return 0;
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
214 }
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
215
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
216 #endif
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
217
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
218 /*
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
219 James Higgs ADSR investigations:
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
220
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
221 PSX SPU Envelope Timings
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
222 ~~~~~~~~~~~~~~~~~~~~~~~~
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
223
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
224 First, here is an extract from doomed's SPU doc, which explains the basics
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
225 of the SPU "volume envelope":
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
226
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
227 *** doomed doc extract start ***
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
228
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
229 --------------------------------------------------------------------------
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
230 Voices.
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
231 --------------------------------------------------------------------------
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
232 The SPU has 24 hardware voices. These voices can be used to reproduce sample
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
233 data, noise or can be used as frequency modulator on the next voice.
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
234 Each voice has it's own programmable ADSR envelope filter. The main volume
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
235 can be programmed independently for left and right output.
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
236
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
237 The ADSR envelope filter works as follows:
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
238 Ar = Attack rate, which specifies the speed at which the volume increases
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
239 from zero to it's maximum value, as soon as the note on is given. The
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
240 slope can be set to lineair or exponential.
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
241 Dr = Decay rate specifies the speed at which the volume decreases to the
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
242 sustain level. Decay is always decreasing exponentially.
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
243 Sl = Sustain level, base level from which sustain starts.
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
244 Sr = Sustain rate is the rate at which the volume of the sustained note
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
245 increases or decreases. This can be either lineair or exponential.
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
246 Rr = Release rate is the rate at which the volume of the note decreases
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
247 as soon as the note off is given.
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
248
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
249 lvl |
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
250 ^ | /\Dr __
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
251 Sl _| _ / _ \__--- \
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
252 | / ---__ \ Rr
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
253 | /Ar Sr \ \
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
254 | / \\
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
255 |/___________________\________
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
256 ->time
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
257
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
258 The overal volume can also be set to sweep up or down lineairly or
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
259 exponentially from it's current value. This can be done seperately
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
260 for left and right.
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
261
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
262 Relevant SPU registers:
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
263 -------------------------------------------------------------
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
264 $1f801xx8 Attack/Decay/Sustain level
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
265 bit |0f|0e 0d 0c 0b 0a 09 08|07 06 05 04|03 02 01 00|
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
266 desc.|Am| Ar |Dr |Sl |
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
267
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
268 Am 0 Attack mode Linear
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
269 1 Exponential
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
270
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
271 Ar 0-7f attack rate
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
272 Dr 0-f decay rate
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
273 Sl 0-f sustain level
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
274 -------------------------------------------------------------
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
275 $1f801xxa Sustain rate, Release Rate.
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
276 bit |0f|0e|0d|0c 0b 0a 09 08 07 06|05|04 03 02 01 00|
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
277 desc.|Sm|Sd| 0| Sr |Rm|Rr |
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
278
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
279 Sm 0 sustain rate mode linear
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
280 1 exponential
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
281 Sd 0 sustain rate mode increase
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
282 1 decrease
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
283 Sr 0-7f Sustain Rate
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
284 Rm 0 Linear decrease
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
285 1 Exponential decrease
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
286 Rr 0-1f Release Rate
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
287
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
288 Note: decay mode is always Expontial decrease, and thus cannot
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
289 be set.
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
290 -------------------------------------------------------------
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
291 $1f801xxc Current ADSR volume
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
292 bit |0f 0e 0d 0c 0b 0a 09 08 07 06 05 04 03 02 01 00|
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
293 desc.|ADSRvol |
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
294
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
295 ADSRvol Returns the current envelope volume when
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
296 read.
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
297 -- James' Note: return range: 0 -> 32767
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
298
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
299 *** doomed doc extract end ***
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
300
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
301 By using a small PSX proggie to visualise the envelope as it was played,
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
302 the following results for envelope timing were obtained:
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
303
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
304 1. Attack rate value (linear mode)
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
305
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
306 Attack value range: 0 -> 127
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
307
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
308 Value | 48 | 52 | 56 | 60 | 64 | 68 | 72 | | 80 |
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
309 -----------------------------------------------------------------
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
310 Frames | 11 | 21 | 42 | 84 | 169| 338| 676| |2890|
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
311
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
312 Note: frames is no. of PAL frames to reach full volume (100%
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
313 amplitude)
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
314
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
315 Hmm, noticing that the time taken to reach full volume doubles
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
316 every time we add 4 to our attack value, we know the equation is
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
317 of form:
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
318 frames = k * 2 ^ (value / 4)
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
319
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
320 (You may ponder about envelope generator hardware at this point,
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
321 or maybe not... :)
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
322
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
323 By substituting some stuff and running some checks, we get:
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
324
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
325 k = 0.00257 (close enuf)
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
326
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
327 therefore,
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
328 frames = 0.00257 * 2 ^ (value / 4)
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
329 If you just happen to be writing an emulator, then you can probably
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
330 use an equation like:
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
331
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
332 %volume_increase_per_tick = 1 / frames
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
333
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
334
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
335 ------------------------------------
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
336 Pete:
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
337 ms=((1<<(value>>2))*514)/10000
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
338 ------------------------------------
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
339
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
340 2. Decay rate value (only has log mode)
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
341
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
342 Decay value range: 0 -> 15
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
343
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
344 Value | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
345 ------------------------------------------------
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
346 frames | | | | | 6 | 12 | 24 | 47 |
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
347
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
348 Note: frames here is no. of PAL frames to decay to 50% volume.
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
349
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
350 formula: frames = k * 2 ^ (value)
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
351
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
352 Substituting, we get: k = 0.00146
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
353
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
354 Further info on logarithmic nature:
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
355 frames to decay to sustain level 3 = 3 * frames to decay to
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
356 sustain level 9
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
357
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
358 Also no. of frames to 25% volume = roughly 1.85 * no. of frames to
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
359 50% volume.
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
360
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
361 Frag it - just use linear approx.
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
362
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
363 ------------------------------------
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
364 Pete:
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
365 ms=((1<<value)*292)/10000
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
366 ------------------------------------
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
367
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
368
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
369 3. Sustain rate value (linear mode)
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
370
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
371 Sustain rate range: 0 -> 127
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
372
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
373 Value | 48 | 52 | 56 | 60 | 64 | 68 | 72 |
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
374 -------------------------------------------
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
375 frames | 9 | 19 | 37 | 74 | 147| 293| 587|
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
376
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
377 Here, frames = no. of PAL frames for volume amplitude to go from 100%
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
378 to 0% (or vice-versa).
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
379
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
380 Same formula as for attack value, just a different value for k:
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
381
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
382 k = 0.00225
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
383
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
384 ie: frames = 0.00225 * 2 ^ (value / 4)
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
385
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
386 For emulation purposes:
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
387
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
388 %volume_increase_or_decrease_per_tick = 1 / frames
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
389
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
390 ------------------------------------
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
391 Pete:
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
392 ms=((1<<(value>>2))*450)/10000
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
393 ------------------------------------
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
394
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
395
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
396 4. Release rate (linear mode)
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
397
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
398 Release rate range: 0 -> 31
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
399
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
400 Value | 13 | 14 | 15 | 16 | 17 |
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
401 ---------------------------------------------------------------
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
402 frames | 18 | 36 | 73 | 146| 292|
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
403
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
404 Here, frames = no. of PAL frames to decay from 100% vol to 0% vol
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
405 after "note-off" is triggered.
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
406
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
407 Formula: frames = k * 2 ^ (value)
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
408
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
409 And so: k = 0.00223
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
410
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
411 ------------------------------------
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
412 Pete:
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
413 ms=((1<<value)*446)/10000
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
414 ------------------------------------
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
415
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
416
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
417 Other notes:
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
418
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
419 Log stuff not figured out. You may get some clues from the "Decay rate"
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
420 stuff above. For emu purposes it may not be important - use linear
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
421 approx.
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
422
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
423 To get timings in millisecs, multiply frames by 20.
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
424
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
425
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
426
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
427 - James Higgs 17/6/2000
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
428 james7780@yahoo.com
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
429
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
430 //---------------------------------------------------------------
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
431
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
432 OLD adsr mixing according to james' rules... has to be called
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
433 every one millisecond
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
434
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
435
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
436 long v,v2,lT,l1,l2,l3;
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
437
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
438 if(s_chan[ch].bStop) // psx wants to stop? -> release phase
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
439 {
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
440 if(s_chan[ch].ADSR.ReleaseVal!=0) // -> release not 0: do release (if 0: stop right now)
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
441 {
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
442 if(!s_chan[ch].ADSR.ReleaseVol) // --> release just started? set up the release stuff
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
443 {
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
444 s_chan[ch].ADSR.ReleaseStartTime=s_chan[ch].ADSR.lTime;
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
445 s_chan[ch].ADSR.ReleaseVol=s_chan[ch].ADSR.lVolume;
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
446 s_chan[ch].ADSR.ReleaseTime = // --> calc how long does it take to reach the wanted sus level
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
447 (s_chan[ch].ADSR.ReleaseTime*
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
448 s_chan[ch].ADSR.ReleaseVol)/1024;
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
449 }
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
450 // -> NO release exp mode used (yet)
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
451 v=s_chan[ch].ADSR.ReleaseVol; // -> get last volume
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
452 lT=s_chan[ch].ADSR.lTime- // -> how much time is past?
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
453 s_chan[ch].ADSR.ReleaseStartTime;
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
454 l1=s_chan[ch].ADSR.ReleaseTime;
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
455
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
456 if(lT<l1) // -> we still have to release
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
457 {
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
458 v=v-((v*lT)/l1); // --> calc new volume
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
459 }
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
460 else // -> release is over: now really stop that sample
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
461 {v=0;s_chan[ch].bOn=0;s_chan[ch].ADSR.ReleaseVol=0;s_chan[ch].bNoise=0;}
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
462 }
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
463 else // -> release IS 0: release at once
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
464 {
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
465 v=0;s_chan[ch].bOn=0;s_chan[ch].ADSR.ReleaseVol=0;s_chan[ch].bNoise=0;
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
466 }
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
467 }
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
468 else
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
469 {//--------------------------------------------------// not in release phase:
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
470 v=1024;
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
471 lT=s_chan[ch].ADSR.lTime;
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
472 l1=s_chan[ch].ADSR.AttackTime;
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
473
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
474 if(lT<l1) // attack
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
475 { // no exp mode used (yet)
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
476 // if(s_chan[ch].ADSR.AttackModeExp)
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
477 // {
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
478 // v=(v*lT)/l1;
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
479 // }
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
480 // else
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
481 {
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
482 v=(v*lT)/l1;
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
483 }
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
484 if(v==0) v=1;
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
485 }
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
486 else // decay
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
487 { // should be exp, but who cares? ;)
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
488 l2=s_chan[ch].ADSR.DecayTime;
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
489 v2=s_chan[ch].ADSR.SustainLevel;
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
490
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
491 lT-=l1;
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
492 if(lT<l2)
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
493 {
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
494 v-=(((v-v2)*lT)/l2);
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
495 }
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
496 else // sustain
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
497 { // no exp mode used (yet)
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
498 l3=s_chan[ch].ADSR.SustainTime;
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
499 lT-=l2;
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
500 if(s_chan[ch].ADSR.SustainModeDec>0)
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
501 {
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
502 if(l3!=0) v2+=((v-v2)*lT)/l3;
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
503 else v2=v;
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
504 }
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
505 else
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
506 {
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
507 if(l3!=0) v2-=(v2*lT)/l3;
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
508 else v2=v;
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
509 }
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
510
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
511 if(v2>v) v2=v;
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
512 if(v2<=0) {v2=0;s_chan[ch].bOn=0;s_chan[ch].ADSR.ReleaseVol=0;s_chan[ch].bNoise=0;}
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
513
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
514 v=v2;
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
515 }
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
516 }
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
517 }
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
518
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
519 //----------------------------------------------------//
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
520 // ok, done for this channel, so increase time
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
521
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
522 s_chan[ch].ADSR.lTime+=1; // 1 = 1.020408f ms;
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
523
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
524 if(v>1024) v=1024; // adjust volume
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
525 if(v<0) v=0;
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
526 s_chan[ch].ADSR.lVolume=v; // store act volume
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
527
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
528 return v; // return the volume factor
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
529 */
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
530
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
531
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
532 //-----------------------------------------------------------------------------
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
533 //-----------------------------------------------------------------------------
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
534 //-----------------------------------------------------------------------------
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
535
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
536
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
537 /*
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
538 -----------------------------------------------------------------------------
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
539 Neill Corlett
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
540 Playstation SPU envelope timing notes
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
541 -----------------------------------------------------------------------------
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
542
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
543 This is preliminary. This may be wrong. But the model described herein fits
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
544 all of my experimental data, and it's just simple enough to sound right.
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
545
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
546 ADSR envelope level ranges from 0x00000000 to 0x7FFFFFFF internally.
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
547 The value returned by channel reg 0xC is (envelope_level>>16).
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
548
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
549 Each sample, an increment or decrement value will be added to or
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
550 subtracted from this envelope level.
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
551
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
552 Create the rate log table. The values double every 4 entries.
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
553 entry #0 = 4
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
554
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
555 4, 5, 6, 7,
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
556 8,10,12,14,
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
557 16,20,24,28, ...
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
558
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
559 entry #40 = 4096...
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
560 entry #44 = 8192...
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
561 entry #48 = 16384...
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
562 entry #52 = 32768...
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
563 entry #56 = 65536...
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
564
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
565 increments and decrements are in terms of ratelogtable[n]
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
566 n may exceed the table bounds (plan on n being between -32 and 127).
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
567 table values are all clipped between 0x00000000 and 0x3FFFFFFF
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
568
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
569 when you "voice on", the envelope is always fully reset.
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
570 (yes, it may click. the real thing does this too.)
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
571
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
572 envelope level begins at zero.
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
573
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
574 each state happens for at least 1 cycle
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
575 (transitions are not instantaneous)
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
576 this may result in some oddness: if the decay rate is uberfast, it will cut
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
577 the envelope from full down to half in one sample, potentially skipping over
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
578 the sustain level
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
579
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
580 ATTACK
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
581 ------
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
582 - if the envelope level has overflowed past the max, clip to 0x7FFFFFFF and
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
583 proceed to DECAY.
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
584
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
585 Linear attack mode:
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
586 - line extends upward to 0x7FFFFFFF
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
587 - increment per sample is ratelogtable[(Ar^0x7F)-0x10]
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
588
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
589 Logarithmic attack mode:
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
590 if envelope_level < 0x60000000:
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
591 - line extends upward to 0x60000000
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
592 - increment per sample is ratelogtable[(Ar^0x7F)-0x10]
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
593 else:
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
594 - line extends upward to 0x7FFFFFFF
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
595 - increment per sample is ratelogtable[(Ar^0x7F)-0x18]
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
596
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
597 DECAY
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
598 -----
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
599 - if ((envelope_level>>27)&0xF) <= Sl, proceed to SUSTAIN.
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
600 Do not clip to the sustain level.
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
601 - current line ends at (envelope_level & 0x07FFFFFF)
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
602 - decrement per sample depends on (envelope_level>>28)&0x7
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
603 0: ratelogtable[(4*(Dr^0x1F))-0x18+0]
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
604 1: ratelogtable[(4*(Dr^0x1F))-0x18+4]
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
605 2: ratelogtable[(4*(Dr^0x1F))-0x18+6]
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
606 3: ratelogtable[(4*(Dr^0x1F))-0x18+8]
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
607 4: ratelogtable[(4*(Dr^0x1F))-0x18+9]
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
608 5: ratelogtable[(4*(Dr^0x1F))-0x18+10]
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
609 6: ratelogtable[(4*(Dr^0x1F))-0x18+11]
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
610 7: ratelogtable[(4*(Dr^0x1F))-0x18+12]
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
611 (note that this is the same as the release rate formula, except that
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
612 decay rates 10-1F aren't possible... those would be slower in theory)
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
613
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
614 SUSTAIN
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
615 -------
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
616 - no terminating condition except for voice off
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
617 - Sd=0 (increase) behavior is identical to ATTACK for both log and linear.
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
618 - Sd=1 (decrease) behavior:
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
619 Linear sustain decrease:
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
620 - line extends to 0x00000000
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
621 - decrement per sample is ratelogtable[(Sr^0x7F)-0x0F]
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
622 Logarithmic sustain decrease:
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
623 - current line ends at (envelope_level & 0x07FFFFFF)
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
624 - decrement per sample depends on (envelope_level>>28)&0x7
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
625 0: ratelogtable[(Sr^0x7F)-0x1B+0]
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
626 1: ratelogtable[(Sr^0x7F)-0x1B+4]
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
627 2: ratelogtable[(Sr^0x7F)-0x1B+6]
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
628 3: ratelogtable[(Sr^0x7F)-0x1B+8]
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
629 4: ratelogtable[(Sr^0x7F)-0x1B+9]
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
630 5: ratelogtable[(Sr^0x7F)-0x1B+10]
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
631 6: ratelogtable[(Sr^0x7F)-0x1B+11]
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
632 7: ratelogtable[(Sr^0x7F)-0x1B+12]
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
633
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
634 RELEASE
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
635 -------
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
636 - if the envelope level has overflowed to negative, clip to 0 and QUIT.
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
637
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
638 Linear release mode:
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
639 - line extends to 0x00000000
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
640 - decrement per sample is ratelogtable[(4*(Rr^0x1F))-0x0C]
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
641
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
642 Logarithmic release mode:
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
643 - line extends to (envelope_level & 0x0FFFFFFF)
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
644 - decrement per sample depends on (envelope_level>>28)&0x7
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
645 0: ratelogtable[(4*(Rr^0x1F))-0x18+0]
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
646 1: ratelogtable[(4*(Rr^0x1F))-0x18+4]
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
647 2: ratelogtable[(4*(Rr^0x1F))-0x18+6]
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
648 3: ratelogtable[(4*(Rr^0x1F))-0x18+8]
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
649 4: ratelogtable[(4*(Rr^0x1F))-0x18+9]
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
650 5: ratelogtable[(4*(Rr^0x1F))-0x18+10]
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
651 6: ratelogtable[(4*(Rr^0x1F))-0x18+11]
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
652 7: ratelogtable[(4*(Rr^0x1F))-0x18+12]
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
653
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
654 -----------------------------------------------------------------------------
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
655 */
62cc6d667119 Import a bunch of stuff for new psf2 plugin.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
656