|
Gin
|
Fast approximations for trigonometric and hyperbolic functions. More...
#include <gin_fastmath.h>
Static Public Member Functions | |
| static F | fastSin (F x) |
| Fast sine wave approximation. | |
| static F | fastTanh (const F x) |
| Fast hyperbolic tangent approximation. | |
Fast approximations for trigonometric and hyperbolic functions.
FastMath provides optimized approximations of trigonometric and hyperbolic functions that trade accuracy for speed. These are useful in DSP applications where perceptual accuracy is more important than mathematical precision, such as waveshaping, modulation, and real-time synthesis.
Key Features:
Accuracy vs Speed: These approximations are significantly faster than std:: equivalents but introduce small errors. For most audio applications, the errors are inaudible and the speed benefit is worthwhile.
Usage:
Credits: Based on algorithms by Mike Jarmy (MIT License)
Fast sine wave approximation.
Computes an approximation of sin(x) using a polynomial approximation. Provides good accuracy with significantly better performance than std::sin.
Valid Range: -π to π
Algorithm: Based on parabolic approximation with extra precision term.
| x | Angle in radians (must be in range [-π, π]) |
Fast hyperbolic tangent approximation.
Computes an approximation of tanh(x) using a rational polynomial. Particularly useful for waveshaping and soft-clipping in audio applications.
Characteristics:
Algorithm: Rational polynomial approximation optimized for audio.
| x | Input value (any real number) |