SynthMaker

Attack Envelope

Archive · 2007 5 old posts

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:

streamin length; streamout out; float x, step, oldval;

//Force length to be at least 16 samples

length = length + ((length<16)&16); step = 16/length;

// execute loop hop (16) { x = oldval + step; }

oldval=x; out=min(x,1);

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? 🙂

exonerate ·

hi basherT,

try this....

streamin length; streamin start; //0-1 value streamout out; float x, step, oldval; float y;

//Force length to be at least 16 samples

length = length + ((length<16)&16); step = 16/length;

// execute loop hop (16) { x = oldval + step; }

oldval=x;

y = x+start;

out=min(y,1);

i've not tested it but it should work 😉

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;

//Force length to be at least 16 samples

length = length + ((length<16)&16); step = 16 * (1 - start) / length;

// execute loop hop (16) { x = x + step; }

y = x+start; out=min(y,1);

I am at work now but will try it later. Thanks again. 🙂

Shifrin ·

That looks about right to me 😉

SHif.

Wrote something here? To have a post removed or your name hidden, write to [email protected].

Before your first post

A few rules keep this a friendly place. You agree to them once.

Shown next to what you post, here and in the app. It doesn’t have to be your real name: 3–24 lower-case letters, digits or _ (capitals become lower case, spaces become _).

    Then your post goes up straight away.

    Delete this reply?

    Open it in SynthMaker?

    It goes on the track you’re editing there, in place of that track’s sound, and into My sounds. Your other tracks stay as they are.

    Want to keep that track’s sound? Start a new song in SynthMaker first (Song › New song), then open this.

    Report this reply?

    Only the developer reads reports. The person isn’t told who reported them.

    What’s wrong with it?

    Block this person?

    You won’t see their posts and replies here any more. They aren’t told, and you can unblock them at any time.

    People you’ve blocked

    Their posts and replies are hidden from you. Unblock someone to see them again.

    The community rules

    A few rules keep this a friendly place. Everyone agrees to them once, before their first post.