| @@ -64,6 +64,38 @@ float interpolate3phase(float *buf, const int peakindex) · 63 unmodified lines |
| 64 | 64 | return(fraction); |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | + |
| 68 | +// from http://www.wild-magic.com - found on music-dsp list |
| 69 | +float fastcosf(float fAngle) |
| 70 | +{ |
| 71 | + float fASqr = fAngle*fAngle; |
| 72 | + float fResult = -2.605e-07f; |
| 73 | + fResult *= fASqr; |
| 74 | + fResult += 2.47609e-05f; |
| 75 | + fResult *= fASqr; |
| 76 | + fResult -= 1.3888397e-03f; |
| 77 | + fResult *= fASqr; |
| 78 | + fResult += 4.16666418e-02f; |
| 79 | + fResult *= fASqr; |
| 80 | + fResult -= 4.999999963e-01f; |
| 81 | + fResult *= fASqr; |
| 82 | + fResult += 1.0f; |
| 83 | + return fResult; |
| 84 | +} |
| 85 | + |
| 86 | +float fastercosf(float fAngle) |
| 87 | +{ |
| 88 | + float fASqr = fAngle*fAngle; |
| 89 | + float fResult = 3.705e-02f; |
| 90 | + fResult *= fASqr; |
| 91 | + fResult -= 4.967e-01f; |
| 92 | + fResult *= fASqr; |
| 93 | + fResult += 1.0f; |
| 94 | + return fResult; |
| 95 | +} |
| 96 | + |
| 97 | + |
| 98 | + |
| 67 | 99 | // alternative implementation for abs() |
| 68 | 100 | // REQUIRES: 32 bit integers |
| 69 | 101 | int fastabs_int(int in){ |
| @@ -444,6 +476,31 @@ void LEAF_generate_exp(float* buffer, float base, float start, float end, float · 374 unmodified lines |
| 444 | 476 | } |
| 445 | 477 | } |
| 446 | 478 | |
| 479 | +void LEAF_generate_atodb(float* buffer, int size) |
| 480 | +{ |
| 481 | + float increment = 1.0f / (float)size; |
| 482 | + float x = 0.0f; |
| 483 | + for (int i = 0; i < size; i++) |
| 484 | + { |
| 485 | + buffer[i] = atodb(x); |
| 486 | + x += increment; |
| 487 | + } |
| 488 | +} |
| 489 | + |
| 490 | + |
| 491 | +void LEAF_generate_atodbPositiveClipped(float* buffer, float lowerThreshold, float range, int size) |
| 492 | +{ |
| 493 | + float increment = 1.0f / (float)size; |
| 494 | + float x = 0.0f; |
| 495 | + float scalar = range / fastabsf(lowerThreshold); |
| 496 | + for (int i = 0; i < size; i++) |
| 497 | + { |
| 498 | + float temp = atodb(x); |
| 499 | + temp = LEAF_clip(lowerThreshold, temp, 0.0f); |
| 500 | + buffer[i] = (temp-lowerThreshold) * scalar; |
| 501 | + x += increment; |
| 502 | + } |
| 503 | +} |
| 447 | 504 | |
| 448 | 505 | // http://www.martin-finke.de/blog/articles/audio-plugins-018-polyblep-oscillator/ |
| 449 | 506 | // http://www.kvraudio.com/forum/viewtopic.php?t=375517 |