electro-smith / DaisySP

A Powerful DSP Library in C++
https://www.electro-smith.com/daisy
Other
836 stars 131 forks source link

Fix for numerical error #183

Closed cutlasses closed 1 year ago

cutlasses commented 1 year ago

Fix for an issue where if an envelope was re-triggered when it was at the very end of the attack stage it could get locked and never complete. This was because cinc could become so small (due to the delta between the current value and the target value being very small, and then divided by the sample rate) that when added to val the value of val does not change (due to floating point inaccuracies). Ensure cinc is at least as big as std epsilon, so that it will always cause val to change.

[This is my first ever pull request, so apologies if this is not the correct way to contribute to DaisySP]

ndonald2 commented 1 year ago

Hi @cutlasses, thanks a lot for this contribution. I am helping Electrosmith with PR review. Everything looks good here, I was able to reproduce the issue and confirm that this fixes it. Nice!

There's a linter check failure, could you please run clang-format -i Source/Control/adenv.cpp from the root of the repo and commit the changes? After that I can get this merged.

Thanks!

cutlasses commented 1 year ago

Hi Nick,

I think I’ve done that now, it was a single space that Clang format has removed haha.

Thanks for taking the change.

Scott

On 24 Apr 2023, at 22:20, Nick Donaldson @.***> wrote:

clang-format -i Source/Control/adenv.cpp