| 17 | // i16 float_to_fixed(float f) { return (i16)(f * FIXED_SCALE); } |
| 18 | |
| 19 | i16 float_to_fixed(float f) { |
| 20 | f = fl::clamp(f, -1.0f, 1.0f); |
| 21 | if (f < 0.0f) { |
| 22 | return (i16)(f * INT16_NEG); |
| 23 | } else { |
| 24 | return (i16)(f * INT16_POS); // Round to nearest |
| 25 | } |
| 26 | } |
| 27 | |
| 28 | // Convert fixed Q15 to float. |
| 29 | float fixed_to_float(i16 f) { |
no test coverage detected