electro-smith / libDaisy

Hardware Library for the Daisy Audio Platform
https://www.electro-smith.com/daisy
MIT License
313 stars 131 forks source link

AnalogControl - Coeff calculation can result in unusable values #474

Closed stephenhensley closed 2 years ago

stephenhensley commented 2 years ago

The coeff is calculated as:

1.0 / (slew_seconds * samplerate_ * 0.5f)

This means that a "slew time" less than half of the samplerate period (1 / samplerate) will output a coeff that is greater than 1.

At coeff=1, the filter is essentially bypassed. Beyond that, it will not function properly as a filter, and will balloon toward infinity.

I see two possible solutions, and it may be worth employing both:

The second option would also require revisiting the SetSampleRate function as that recalculates the coeff based on samplerate and slew_seconds. (Weirdly, it looks like bipolar CVs have their slew locked at 0.002, that should probably be able to change..)