Longer Values for Envelope Object

grinch

Well-known member
Hi, I'm working on a project where I could use a really long envelope, was looking at maybe modifying the envelope object to incorporate longer times. Wanted to ask first if there was any particular reason the number 11880ms was picked for the maximum value for the phases. Seems oddly specific but I know there's a ton of optimization going on under the hood in these objects, so I wondered if this was chosen for some optimization reason, or to keep something from breaking. Seemed helpful to know before diving in. Thanks!
 
The 11880ms limit is due to a 16 bit integer which counts the number of 8 sample updates. 65535 * 8 / 44100 = ~11.89 seconds.

But another limitation is small error which accumulates due to limited resolution in the incremental gain adjustment on each 8 sample update. Longer duration requires more precision in the incremental gain adjustment factor. Many years ago this was increased to 30 bits (along with the 200ms to 11880ms increase).

https://github.com/PaulStoffregen/Audio/issues/102

You can find links on github to old forum conversations about that issue.

If you try to lengthen the maximum time by using more than 16 bits for the duration, you'll probably also need to increase the resolution of the incremental gain. Before Teensy 4.0 this would have probably required rather tricky code, since the straightforward way would need more than 32 bit resolution. But with the FPU support for 64 bit double, maybe it could be done in a fairly simple way. Maybe...
 
Back
Top