Bedtime. /Math Utilities

Math Utilities

Fast math functions optimized for embedded use

uint32_t isqrt(uint32_t n)

Fast integer square root

uint32_tnInput value

Returns — Integer square root of n

uint32_t r = isqrt(10000);  // Returns 100
int16_t lutsin_q15(uint16_t phase)
uint16_tphase

sin(2*pi * phase/65536) in Q15. Interpolated, so smooth at any rate.

int16_t lutcos_q15(uint16_t phase)
uint16_tphase

cos(2*pi * phase/65536) in Q15.

int16_t lutexp_neg_q15(int16_t x)
int16_tx

exp(-x) for x in [0, 32767] -> [32767, 0]. Suitable for decay envelopes.

int16_t lutsat_q15(int16_t x)
int16_tx

Soft saturation curve - a tanh-like squash of a Q15 value.