[sdiy] software / firmware envelopes in C (or anything else)
Chris McDowell
declareupdate at gmail.com
Thu Nov 6 00:30:52 CET 2025
> If you've got an FPU, does it really matter?
Eh, not really! Certainly not if I have headroom, but I don't always.
I wonder about it here because it's not something you can easily get feedback on at the pub, as you all know, and because in some applications like a polyphonic FM synth on an STM32G431, the envelopes operations are happening more than any others. shaving off one operation really could make a difference with 32+ envelopes going, assuming the compiler isn't already doing it for me.
> a chip that doesn't even have a *multiply*
and indeed you sir are a wild man, hats off.
Chris
> On Nov 5, 2025, at 5:16 PM, Tom Wiltshire <tom at electricdruid.net> wrote:
>
> If you've got an FPU, does it really matter? That seems like a simple enough sum for hardware of that level.
>
> You mentioned my code, and I had to find a different way because I was using a chip that doesn't even have a *multiply*, let alone an FPU. Hence the entirely different approach.
>
> FWIW, Ear Level have the best articles about both the basic filter and using it to generate envelopes, but if you've been looking into it, you'll have seen them:
>
> https://www.earlevel.com/main/2012/12/15/a-one-pole-filter/
> https://www.earlevel.com/main/2013/06/01/envelope-generators/
>
> HTH,
> Tom
>
>
>
>> On 5 Nov 2025, at 21:55, Chris McDowell via Synth-diy <synth-diy at synth-diy.org <mailto:synth-diy at synth-diy.org>> wrote:
>>
>> Howdy list,
>>
>> I've been thinking about this for about a decade. I use what the web calls a "leaky integrator" all over my synth code. I first used it as the basis of an envelope some 15 years ago when mimicking the Moog Rogue's strategy of providing a target and a "rate" to a lowpass filter built around a 3080 OTA. On an MCU with an FPU, it works pretty much great. the basics:
>>
>> output += (target - output) * rate
>>
>> where target changes based on what stage of an envelope we're in and rate is some small float coefficient calculated based on desired stage length in milliseconds.
>>
>> 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 <http://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 find myself num_envelopes cycles away from meeting a timing deadline, I'll consider it...
>>
>> I'm familiar with Tom Wiltshire's envelope chip, which is another cool and very different strategy. What else is out there?!
>>
>> Cheers,
>> Chris McDowell
>> ________________________________________________________
>> This is the Synth-diy mailing list
>> Submit email to: Synth-diy at synth-diy.org <mailto:Synth-diy at synth-diy.org>
>> View archive at: https://synth-diy.org/pipermail/synth-diy/
>> Check your settings at: https://synth-diy.org/mailman/listinfo/synth-diy
>> Selling or trading? Use marketplace at synth-diy.org <mailto:marketplace at synth-diy.org>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://synth-diy.org/pipermail/synth-diy/attachments/20251105/82442d6a/attachment.htm>
More information about the Synth-diy
mailing list