https://www.musicdsp.org/en/latest/Synthesis/13-sine-calculation.html phase should be between between -LAB_PI and +LAB_PI
| 27 | // https://www.musicdsp.org/en/latest/Synthesis/13-sine-calculation.html |
| 28 | // phase should be between between -LAB_PI and +LAB_PI |
| 29 | inline float burk_fast_sine(const double phase) |
| 30 | { |
| 31 | // Factorial coefficients. |
| 32 | const float IF3 = 1.f / (2 * 3); |
| 33 | const float IF5 = IF3 / (4 * 5); |
| 34 | const float IF7 = IF5 / (6 * 7); |
| 35 | const float IF9 = IF7 / (8 * 9); |
| 36 | const float IF11 = IF9 / (10 * 11); |
| 37 | |
| 38 | // Wrap phase back into region where results are more accurate. |
| 39 | double x = (phase > +LAB_HALF_PI) ? +(LAB_PI - phase) |
| 40 | : ((phase < -LAB_HALF_PI) ? -(LAB_PI + phase) : phase); |
| 41 | |
| 42 | double x2 = (x * x); |
| 43 | |
| 44 | // Taylor expansion out to x**11/11! factored into multiply-adds |
| 45 | return static_cast<float>( |
| 46 | x * (x2 * (x2 * (x2 * (x2 * ((x2 * (-IF11)) + IF9) - IF7) + IF5) - IF3) + 1) |
| 47 | ); |
| 48 | } |
| 49 | |
| 50 | static char const * const s_types[] = { |
| 51 | "None", "Sine", "FastSine", "Square", "Sawtooth", "Falling Sawtooth", |