little questions from old dev about C++ today style/portability (in: DSP and Plugin Devel…)
By: mystran
15 Sep 20:10
I would probably write something like this:
[code]
float Clipping11(float x)
{
x = std::min(std::max(x, -1.f), +1.f);
float x2 = x*x;
float x4 = x2*x2;
return 1.1f * x – 0.1f * ((x4*x4)*(x2*x));
}
[/code]
Checking godbolt, at least clang inlines std::pow(x, 11.f) into a series of multiplies if (and only if) you specify -ffast-math so whether you want to rely on that is kinda up to you.
The rationale for min/max clipping the argument and then processing the…
Go to first unread post in this topic
Read more here: Source link
