Triggering ADSR in Gen
Hi,I have the following question: I want to add an ADSR Gen patch to another Gen patch. To trigger the ADSR function, a toggle object is needed, which in this case is an object at the MSP level that feeds into the Gen object. However, I want to stay entirely within Gen. I want to integrate this ADSR into an existing Gen patch where the toggle signal is already present. Since I'm not very familiar with Codebox, how can I trigger the gate value directly within the Gen patch using Codebox?
Thanks!
Well a gate signal is typically just a signal that is either 0 or 1, so any place in your gen patch where you have generated such a signal, you should just be able to route that into whatever code you have for the ADSR.
Hard to give more advice than that without seeing more of the patch in question. But at a guess, your codebox probably has a Param gate;
which is then used as the 1st argument to the adsrRpt()
function call. Just replace that argument with whatever gate signal you have in your gen patch.
Thanx!, here is the patch
OK yes, confirmed that you can just replace the gate
argument in the line lvl, stage = adsrRpt(gate, preslope, a, d, sus, r, rpt);
with whatever gate signal you want to use.
i think there might be a bug in gen~ here?
when i change 'gate' to the word 'gat', and define it in an appropriate place as 'gat = in1;' (while also removing the param named 'gate'), it doesn't register the signal coming in through the first inlet, but once i change it to 'in2' it does work...
furthermore, when i then changed that back to 'gat = in1;' to see if it could work from inlet 1, not only does it not work, but after that i can no longer get it back to work with 'gat = in2;', instead i have to create a 3rd inlet for 'gat = in3;' and then it works again(?)
let me know if you need video of that last part where it also requires in3 if you try in1 again^... but it seems like a strange behavior to me to keep needing a newer inlet for this type of thing to work(?)
(i'm on a MacBookPro M1-MacOS Sonoma 14.6.1 with Max 8.6.4)
______________________..........
no wait! maybe not a huge issue, i realize now if you just restart max(or maybe just reload the patch), the original code utilizing 'in1' does work:
i guess i'll still leave the video and first part of this post here, just in case it helps remind others to try restarting gen~ if you ever run into this weirdness.
ThomasZalud, i love this patch! 🙌
Oh, thanks, but it's not mine. I found it somewhere in the cycling world, and thanks for the help.
and oh yes this works fine!!