[sdiy] software / firmware envelopes in C (or anything else)
Chris McDowell
declareupdate at gmail.com
Thu Nov 6 00:22:34 CET 2025
That is a really critical good point, Matthew. Thanks for pointing it out. They don't even claim to be simulating a capacitor, it really is an "exponential envelope".
I promise I have thought and thought (and thought again, for decades) about the shape I want the envelopes to take :) I did NOT think critically about what that fella's code is actually doing, but it's clear now.
Chris
> On Nov 5, 2025, at 5:17 PM, mskala at northcoastsynthesis.com wrote:
>
> On Wed, 5 Nov 2025, Chris McDowell wrote:
>
>> Woops, certainly meant to include thelink: https://www.musicdsp.org/en/latest/Synthesis/189-fast-exponential-env
>> elope-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 :)
>
> Well, I think what's at that link is not quite the same thing because it's
> making the rate proportional to the current level, whereas both the
> equation you first posted, and mine, make the rate proportional to the
> *difference* between the current level and the target, like a charging
> capacitor. Those are only the same thing in the case of a decay heading
> for zero.
>
> In particular, with the iteration I described, an envelope going from zero
> up to a peak for an attack would go first fast then slow, like a charging
> capacitor, whereas the link's version when going up would go first slow,
> then fast, and wouldn't work at all for really starting at exactly zero.
> Whenever currentLevel is zero, either version of the musicdsp.org code
> (with += and *, or just *=) will keep it permanently at zero.
>
> Probably a good idea to think carefully about what shape you actually want
> the output to take.
>
> --
> Matthew Skala
> North Coast Synthesis Ltd.
More information about the Synth-diy
mailing list