I’m looking for a way to modify an incoming OSC or MIDI value, and what I want is to have the options found in an envelope like those used in music; attack, decay, sustain and release.
My inital thought was to use the smooth envelope modifier, but I can’t get it to behave the way I want.
Is there a way to do this inside Notch? I’m currently looking at the expression modifier, but I’m not sure what to put in to get an ADSR function out of it.
So I got this from ChatGPT
var attackTime = 0.2;
var decayTime = 0.3;
var sustainLevel = 0.5;
var releaseTime = 0.4;
var attack = t < attackTime ? t / attackTime : 1.0;
var decay = t < (attackTime + decayTime) ? 1.0 - (1.0 - sustainLevel) * ((t - attackTime) / decayTime) : sustainLevel;
var release = t < (attackTime + decayTime + releaseTime) ? decay - (decay * (t - (attackTime + decayTime)) / releaseTime) : 0.0;
var result = attack * decay * release;
Hope that helps.
Oh, I guess I got that mixed up hehe
Thanks for your help!