ValleyAudio / ValleyRackFree

Modules for VCV Rack
Other
176 stars 24 forks source link

Continuity improvement for tanhDriveSignal() #58

Closed EleonoreMizo closed 3 years ago

EleonoreMizo commented 3 years ago

Hi, may I do a suggestion? I wanted to implement a Dattorro reverb and found out that you did one too with Plateau. I checked a bit the code and found tanhDriveSignal() in NonLinear.hpp. It seems that the formula for |x| in the 0.75–1.3 range breaks the curve continuity at 0.75. I don’t know if it was intended or not. This is the red curve on this graph. You could easily restore the continuity, along with the first derivative continuity by using x * (2.5 - x) - 0.5625, and lowering the other bound to 1.25.

ValleyAudio commented 3 years ago

Hey @EleonoreMizo , yes it looks like I made a slight mistake in my tanh approximation. I found that by narrowing the bounds for the linear region (y=x) to be between -0.7 to 0.7 this fixes the continuity. However, I think you're equation might be better since it maintains the range of the linear region. Thanks for spotting this error :)