From the original SynthMaker forum (2004–2014), with its members’ names and dates.
BasherT ·
Hi All
I have been very quiet recently looking at all sorts of stuff. One of the things I have been trying to do is to produce some code that will act like the attack part of an ADSR envelope. I think I have succeeded:
This ramps the volume from 0 to 1 nicely over whatever number of samples you choose to input as the variable length.
What I have been wondering though is how to change this code so that I can start the base of the envelope curb at any number between 0 and 1 and increase the volume from that point up? I just can't seem to crack it. Any tips for a beginner? 🙂
oh and the oldval as far as i can see is not needed, all thats happing is your delaying the loop by one sample. you could just write x=x+step and get rid of the oldval all together.
cheers 😉
Exo
stefan ·
Exonerate: that method will give you a different attack length with the same length setting if you change the start value, since the slope is still the same. If you want to rectify that, I think doing step = 16 * (1 - start) / length; should do the trick.
BasherT ·
Thanks guys.
If I am understanding you both correctly, the code should be:
streamin length; //number of samples
streamin start; //0-1 value
streamout out;
float x, step;
float y;