summaryrefslogtreecommitdiff
path: root/objects
diff options
context:
space:
mode:
Diffstat (limited to 'objects')
-rw-r--r--objects/env/ad m.axo19
1 files changed, 11 insertions, 8 deletions
diff --git a/objects/env/ad m.axo b/objects/env/ad m.axo
index 9ae76f1..fd12bf9 100644
--- a/objects/env/ad m.axo
+++ b/objects/env/ad m.axo
@@ -19,24 +19,27 @@
</params>
<attribs/>
<code.declaration><![CDATA[
+// upper nibble: "triggered", lower nibble: stage (0x00 for decay, 0x0F for attack)
int8_t stage;
-int ntrig;
int32_t val;
]]></code.declaration>
<code.init><![CDATA[
-ntrig = 0;
+stage = 0x00;
val = 0;
]]></code.init>
<code.krate><![CDATA[
-if ((inlet_trig>0) && !ntrig) {
- ntrig = 1;
- stage = 1;
+
+// If trigger and not yet triggered
+if ((inlet_trig>0) && !((stage & 0xF0)>>4)) {
+ // set "triggered" and "attack"
+ stage = 0xFF;
} else if (!(inlet_trig>0)) {
- ntrig = 0;
+ // set "not triggered"
+ stage &= 0x0F;
}
// decay
-if (stage == 0) {
+if ((stage & 0x0F) == 0) {
val = ___SMMLA(val,(-1<<26)+(param_d>>1)+(inlet_d>>1),val);
// attack
@@ -51,7 +54,7 @@ if (stage == 0) {
// switch to decay phase at max
if (val > 0x07FFFFFF) {
val = 0x07FFFFFF;
- stage = 0;
+ stage &= 0xF0;
}
}
outlet_env = val;