Page 1 of 1

Plucked or exponential decay

Posted: Fri Jul 12, 2013 11:21 pm
by jacob
I would like to create a volume decay (envelope) like a plucked string has.

Like this one (hand drawn):

s97sg7f39hc87g9sdf52.jpg
s97sg7f39hc87g9sdf52.jpg (8.59 KiB) Viewed 11443 times

I would like to be able to control with knobs the decay time (duration (0-20 seconds) from volume 1 to 0) and the amount of the exponential effect.

I could not find the way to do it. Does anyone have any idea how this can be done?

Re: Plucked or exponential decay

Posted: Sat Jul 13, 2013 12:15 am
by MyCo
Have a look at this:
http://synthmaker.co.uk/forum/viewtopic ... =30#p61053

When curve turned to the right, the envelope gets the shape you want. For plucked string, you have to turn Sustain & Release down to zero, and only use the decay.

Re: Plucked or exponential decay

Posted: Sat Jul 13, 2013 12:36 pm
by jacob
Great, that is exactly what I need. Also the Attack, Sustain and Release could be useful actually.

I guess I have to trim this down, understand it and create my own code to use.

Re: Plucked or exponential decay

Posted: Sat Jul 13, 2013 2:09 pm
by jacob
Maybe you could help me with this :)

What does the first part do?

8a97fuiz2i2.PNG
8a97fuiz2i2.PNG (17.28 KiB) Viewed 11424 times


I see a knob value with 0-1 comes trough. But what is sharpness and scale for?

The result of the "exp" box is bewteen 0-10 - the scale float multiplied the 0-1 result up to 0-10.

Actually I can simply delete the "exp" box and it still works. Is that exp-box only for making the knob exponential in it's behavior - like becoming more sensible in higher or lower knob ranges?

And the hop-box does what? Making it hop some samples to not be calculated?

The main variables needed before the code comes are: decaySamplesHoped, decayStepSize and curve( 1 to -1 )?

But I guess the code which calculates the decay is the most important. But it is written with the assembler - I don't understand that :)

Is the assembler more efficient in cpu usage than the code or why do you use it? If yes, how much :)

I need the most important part: the decay calculation. If on every sample the volume becomes calculated through a code block, I need a simple calculation which uses the current time already passed (which gets updated on every cycle within the variable currentSample). And there would be two other knobs to control the curve in it's shape/exponantial and tell the code how long the decay should last.

Let's say I have these current values:
currentSample = 200
decayTime = 44100 samples (would be one second)
curve = not sure what is needed here (maybe the exponent)
maxVolume would be 1 I guess

Can I calculate the currentVolume with only these values on every cycle?