Unified · Split
Binary file not shown.
Binary file not shown.
| @@ -142,6 +142,8 @@ extern "C" { · 141 unmodified lines | ||
| 142 | 142 | |
| 143 | 143 | float fastexp2f(float f); |
| 144 | 144 | |
| 145 | + float fastPowf(float a, float b) ; | |
| 146 | + double fastPow(double a, double b); | |
| 145 | 147 | |
| 146 | 148 | void LEAF_crossfade(float fade, float* volumes); |
| 147 | 149 | |
| @@ -152,6 +152,29 @@ float fastexp2f(float x) · 151 unmodified lines | ||
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | |
| 155 | +float fastPowf(float a, float b) { | |
| 156 | + union | |
| 157 | + { | |
| 158 | + float d; int x; | |
| 159 | + } | |
| 160 | + u = { a }; | |
| 161 | + | |
| 162 | + u.x = (int)(b * (u.x - 1064866805) + 1064866805); | |
| 163 | + return u.d; | |
| 164 | +} | |
| 165 | + | |
| 166 | + | |
| 167 | +double fastPow(double a, double b) { | |
| 168 | + union { | |
| 169 | + double d; | |
| 170 | + int x[2]; | |
| 171 | + } u = { a }; | |
| 172 | + | |
| 173 | + u.x[1] = (int)(b * (u.x[1] - 1072632447) + 1072632447); | |
| 174 | + | |
| 175 | + u.x[0] = 0; | |
| 176 | + return u.d; | |
| 177 | +} | |
| 155 | 178 | /* |
| 156 | 179 | you pass in a float array to get back two indexes representing the volumes of the left (index 0) and right (index 1) channels |
| 157 | 180 | when t is -1, volumes[0] = 0, volumes[1] = 1 |