[sdiy] software / firmware envelopes in C (or anything else)

Chris McDowell declareupdate at gmail.com
Wed Nov 5 23:57:18 CET 2025


Woops, certainly meant to include the link: https://www.musicdsp.org/en/latest/Synthesis/189-fast-exponential-envelope-generator.html

and yes, their usage of log() is just about calculating the rate. 

your version looks to be functionally the same as the one in the link, one multiply and one add. my version has a subtract in there that I apparently don't need and this is, of course, why I asked :) 

Chris 

> On Nov 5, 2025, at 4:48 PM, mskala at northcoastsynthesis.com wrote:
> 
> On Wed, 5 Nov 2025, Chris McDowell via Synth-diy wrote:
> 
>> output += (target - output) * rate 
> 
>> my question for this deep well of synth experience: is there a better way to
>> do it? I came across a similar strategy on musicdsp.org recently that
>> suggested baking the target into the coefficient, which does indeed save one
>> subtract per iteration with the tradeoff that you have to do more math when
>> changing envelope states. its use of log() (admittedly infrequently) makes
>> me not all that interested, even if that's maybe a little irrational. If I
> 
> I don't know what the "similar strategy" you have in mind is.  The way
> I'm familiar with doing this kind of moving average looks like:
> 
> output += (target*rate)
> output *= 1/(1+rate)
> 
> You precalculate target*rate when you change the target, and 1/(1+rate)
> when you change the rate, so it's one add and one multiply, of stored
> constant values, per ordinary iteration.
> 
> I'm not sure how log() would come into it - maybe if you're trying to
> choose the rate based on a desired length of time to charge or discharge
> to a certain point, but that's no more true here than in the original
> iteration.
> 
> -- 
> Matthew Skala
> North Coast Synthesis Ltd.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://synth-diy.org/pipermail/synth-diy/attachments/20251105/4d1ad743/attachment.htm>


More information about the Synth-diy mailing list