blob: 9ae76f1e3cebc8ce12791a92d941af3d62a3dcbf (
about) (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
<objdefs>
<obj.normal id="ad m" uuid="9045d727a260ba66aa68c68f684eea2148aaf338" sha="b5f72335c41e5dec8763a23bed395833a6694bab">
<sDescription>attack decay envelope with modulation inputs</sDescription>
<author>Ricardo Wurmus</author>
<license>GPL</license>
<helpPatch>env.axh</helpPatch>
<inlets>
<frac32 name="a" description="attack time"/>
<frac32 name="d" description="decay time"/>
<bool32.rising name="trig" description="trigger"/>
</inlets>
<outlets>
<frac32.positive name="env" description="envelope output"/>
</outlets>
<displays/>
<params>
<frac32.s.map name="a"/>
<frac32.u.map.kdecaytime name="d"/>
</params>
<attribs/>
<code.declaration><![CDATA[
int8_t stage;
int ntrig;
int32_t val;
]]></code.declaration>
<code.init><![CDATA[
ntrig = 0;
val = 0;
]]></code.init>
<code.krate><![CDATA[
if ((inlet_trig>0) && !ntrig) {
ntrig = 1;
stage = 1;
} else if (!(inlet_trig>0)) {
ntrig = 0;
}
// decay
if (stage == 0) {
val = ___SMMLA(val,(-1<<26)+(param_d>>1)+(inlet_d>>1),val);
// attack
} else {
int32_t a;
MTOF(- param_a - inlet_a,a);
// shift to let val rise more slowly
a = a >> 4;
val = val + a;
// switch to decay phase at max
if (val > 0x07FFFFFF) {
val = 0x07FFFFFF;
stage = 0;
}
}
outlet_env = val;
]]></code.krate>
</obj.normal>
</objdefs>
|