summaryrefslogtreecommitdiff
path: root/objects/env/ad m.axo
diff options
context:
space:
mode:
authorrekado <rekado@elephly.net>2016-09-06 22:13:03 +0200
committerrekado <rekado@elephly.net>2016-09-06 23:31:22 +0200
commit8a4bca986c57062e96f1e58281b3eff52a856ee6 (patch)
tree11b125b567c212739a6585862628f0565f51ce35 /objects/env/ad m.axo
Initial commit.
Diffstat (limited to 'objects/env/ad m.axo')
-rw-r--r--objects/env/ad m.axo60
1 files changed, 60 insertions, 0 deletions
diff --git a/objects/env/ad m.axo b/objects/env/ad m.axo
new file mode 100644
index 0000000..9ae76f1
--- /dev/null
+++ b/objects/env/ad m.axo
@@ -0,0 +1,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>