added trigonometric functions with normalized input and used them
This commit is contained in:
parent
6ef98b1382
commit
9069596f8d
@ -9,7 +9,8 @@
|
||||
* Added BW_RESTRICT and removed BW_MALLOC, BW_REALLOC, and BW_FREE from
|
||||
bw_common.
|
||||
* Added new monophonic synth example bw_example_synth_mono.
|
||||
* Added new bw_omega_3lognr() and bw_tanhf_3() fast math routines.
|
||||
* Added new bw_sin2pif_3(), bw_cos2pif_3(), bw_tan2pif_3(),
|
||||
bw_omega_3lognr(), and bw_tanhf_3() fast math routines.
|
||||
* Using bw_one_pole for smoothing bw_vol.
|
||||
* Simplified and rewritten example synth, renamed as
|
||||
bw_example_synth_simple.
|
||||
|
@ -225,6 +225,15 @@ static inline float bw_rcpf_2(float x);
|
||||
*
|
||||
* Relative error < 0.0013%.
|
||||
*
|
||||
* #### bw_sin2pif_3()
|
||||
* ```>>> */
|
||||
static inline float bw_sin2pif_3(float x);
|
||||
/*! <<<```
|
||||
* Returns an approximation of the sine of 2 * pi * `x`, where `x` is given
|
||||
* in radians.
|
||||
*
|
||||
* Absolute error < 0.011, relative error < 1.7%.
|
||||
*
|
||||
* #### bw_sinf_3()
|
||||
* ```>>> */
|
||||
static inline float bw_sinf_3(float x);
|
||||
@ -234,6 +243,15 @@ static inline float bw_sinf_3(float x);
|
||||
*
|
||||
* Absolute error < 0.011, relative error < 1.7%.
|
||||
*
|
||||
* #### bw_cos2pif_3()
|
||||
* ```>>> */
|
||||
static inline float bw_cos2pif_3(float x);
|
||||
/*! <<<```
|
||||
* Returns an approximation of the cosine of 2 * pi * `x`, where `x` is given
|
||||
* in radians.
|
||||
*
|
||||
* Absolute error < 0.011, relative error < 1.7%.
|
||||
*
|
||||
* #### bw_cosf_3()
|
||||
* ```>>> */
|
||||
static inline float bw_cosf_3(float x);
|
||||
@ -243,6 +261,19 @@ static inline float bw_cosf_3(float x);
|
||||
*
|
||||
* Absolute error < 0.011, relative error < 1.7%.
|
||||
*
|
||||
* #### bw_tan2pif_3()
|
||||
* ```>>> */
|
||||
static inline float bw_tan2pif_3(float x);
|
||||
/*! <<<```
|
||||
* Returns an approximation of the tangent of 2 * pi * `x`, where `x` is
|
||||
* given in radians.
|
||||
*
|
||||
* Not guaranteed to work for `x` too close to singularities. Safe
|
||||
* range: `x` in [-1/4 + 5e-4f / pi, 1/4 - 5e-4f / pi] + k / 2, where k is
|
||||
* any integer number.
|
||||
*
|
||||
* Absolute error < 0.06, relative error < 0.8%.
|
||||
*
|
||||
* #### bw_tanf_3()
|
||||
* ```>>> */
|
||||
static inline float bw_tanf_3(float x);
|
||||
@ -450,8 +481,7 @@ static inline float bw_rcpf_2(float x) {
|
||||
return v.f;
|
||||
}
|
||||
|
||||
static inline float bw_sinf_3(float x) {
|
||||
x = 0.1591549430918953f * x;
|
||||
static inline float bw_sin2pif_3(float x) {
|
||||
x = x - bw_floorf(x);
|
||||
float xp1 = x + x - 1.f;
|
||||
float xp2 = bw_absf(xp1);
|
||||
@ -459,12 +489,25 @@ static inline float bw_sinf_3(float x) {
|
||||
return -bw_copysignf(1.f, xp1) * (xp + xp * xp * (-0.05738534102710938f - 0.1107398163618408f * xp));
|
||||
}
|
||||
|
||||
static inline float bw_sinf_3(float x) {
|
||||
return bw_sin2pif_3(0.1591549430918953f * x);
|
||||
}
|
||||
|
||||
static inline float bw_cos2pif_3(float x) {
|
||||
return bw_sin2pif_3(x + 0.25f);
|
||||
}
|
||||
|
||||
static inline float bw_cosf_3(float x) {
|
||||
return bw_sinf_3(x + 1.570796326794896f);
|
||||
return bw_cos2pif_3(0.1591549430918953f * x);
|
||||
}
|
||||
|
||||
static inline float bw_tan2pif_3(float x) {
|
||||
return bw_sin2pif_3(x) * bw_rcpf_2(bw_cos2pif_3(x));
|
||||
}
|
||||
|
||||
static inline float bw_tanf_3(float x) {
|
||||
return bw_sinf_3(x) * bw_rcpf_2(bw_cosf_3(x));
|
||||
x = 0.1591549430918953f * x;
|
||||
return bw_sin2pif_3(x) * bw_rcpf_2(bw_cos2pif_3(x));
|
||||
}
|
||||
|
||||
static inline float bw_log2f_3(float x) {
|
||||
|
@ -78,7 +78,7 @@ static inline void bw_osc_sin_process(const float *x, float* y, int n_samples);
|
||||
#include <bw_math.h>
|
||||
|
||||
static inline float bw_osc_sin_process1(float x) {
|
||||
return bw_sinf_3(6.283185307179586f * x);
|
||||
return bw_sin2pif_3(x);
|
||||
}
|
||||
|
||||
static inline void bw_osc_sin_process(const float *x, float* y, int n_samples) {
|
||||
|
Loading…
Reference in New Issue
Block a user