Nu:Tekt NTS-1 digital SDK
v1.1-0
|
Go to the documentation of this file.
56 #define __fast_inline static inline __attribute__((always_inline, optimize("Ofast")))
84 __fast_inline uint32_t fx_mcu_hash(
void) {
95 __fast_inline uint16_t fx_get_bpm(
void) {
106 __fast_inline
float fx_get_bpmf(
void) {
122 #define k_wt_sine_size_exp (7)
123 #define k_wt_sine_size (1U<<k_wt_sine_size_exp)
124 #define k_wt_sine_u32shift (24)
125 #define k_wt_sine_frrecip (5.96046447753906e-008f) // 1/(1<<24)
126 #define k_wt_sine_mask (k_wt_sine_size-1)
127 #define k_wt_sine_lut_size (k_wt_sine_size+1)
129 extern const float wt_sine_lut_f[k_wt_sine_lut_size];
138 const float p = x - (uint32_t)x;
141 const float x0f = 2.f * p * k_wt_sine_size;
142 const uint32_t x0p = (uint32_t)x0f;
144 const uint32_t x0 = x0p & k_wt_sine_mask;
145 const uint32_t x1 = (x0 + 1) & k_wt_sine_mask;
147 const float y0 =
linintf(x0f - x0p, wt_sine_lut_f[x0], wt_sine_lut_f[x1]);
148 return (x0p < k_wt_sine_size)?y0:-y0;
179 return fx_sinuf(x+((k_wt_sine_size>>2)<<k_wt_sine_u32shift));
194 #define k_log_size_exp (8)
195 #define k_log_size (1U<<k_log_size_exp)
196 #define k_log_mask (k_log_size-1)
197 #define k_log_lut_size (k_log_size+1)
199 extern const float log_lut_f[k_log_lut_size];
209 const float idxf = x * k_log_size;
210 const uint32_t idx = (uint32_t)idxf;
211 const float y0 = log_lut_f[idx];
212 const float y1 = log_lut_f[idx+1];
213 return linintf(idxf - idx, y0, y1);
216 #define k_tanpi_size_exp (8)
217 #define k_tanpi_size (1U<<k_tanpi_size_exp)
218 #define k_tanpi_mask (k_tanpi_size-1)
219 #define k_tanpi_range_recip (2.04081632653061f) // 1/0.49
220 #define k_tanpi_lut_size (k_tanpi_size+1)
222 extern const float tanpi_lut_f[k_log_lut_size];
232 const float idxf = x * k_tanpi_range_recip * k_tanpi_size;
233 const uint32_t idx = (uint32_t)idxf;
234 const float y0 = tanpi_lut_f[idx];
235 const float y1 = tanpi_lut_f[idx+1];
236 return linintf(idxf - idx, y0, y1);
239 #define k_sqrtm2log_size_exp (8)
240 #define k_sqrtm2log_size (1U<<k_sqrtm2log_size_exp)
241 #define k_sqrtm2log_mask (k_sqrtm2log_size-1)
242 #define k_sqrtm2log_base (0.005f)
243 #define k_sqrtm2log_range_recip (1.00502512562814f) // 1/0.995
244 #define k_sqrtm2log_lut_size (k_sqrtm2log_size+1)
246 extern const float sqrtm2log_lut_f[k_sqrtm2log_lut_size];
256 const float idxf = (x-k_sqrtm2log_base) * k_sqrtm2log_range_recip * k_sqrtm2log_size;
257 const uint32_t idx = (uint32_t)idxf;
258 const float y0 = sqrtm2log_lut_f[idx];
259 const float y1 = sqrtm2log_lut_f[idx+1];
260 return linintf(idxf - idx, y0, y1);
263 #define k_pow2_size_exp (8)
264 #define k_pow2_size (1U<<k_pow2_size_exp)
265 #define k_pow2_scale (85.3333333333333f) // 256 / 3
266 #define k_pow2_mask (k_pow2_size-1)
267 #define k_pow2_lut_size (k_pow2_size+1)
269 extern const float pow2_lut_f[k_pow2_lut_size];
279 const float idxf = x * k_pow2_scale;
280 const uint32_t idx = (uint32_t)idxf;
281 const float y0 = pow2_lut_f[idx];
282 const float y1 = pow2_lut_f[idx+1];
283 return linintf(idxf - idx, y0, y1);
308 return x - c * (x*x*x);
311 #define k_cubicsat_size_exp (7)
312 #define k_cubicsat_size (1U<<k_cubicsat_size_exp)
313 #define k_cubicsat_mask (k_cubicsat_size-1)
314 #define k_cubicsat_lut_size (k_cubicsat_size+1)
316 extern const float cubicsat_lut_f[k_cubicsat_lut_size];
326 const uint32_t xi = (uint32_t)x;
327 const float y0 = cubicsat_lut_f[xi];
328 const float y1 = cubicsat_lut_f[xi+1];
332 #define k_schetzen_size_exp (7)
333 #define k_schetzen_size (1U<<k_schetzen_size_exp)
334 #define k_schetzen_mask (k_schetzen_size-1)
335 #define k_schetzen_lut_size (k_schetzen_size+1)
337 extern const float schetzen_lut_f[k_schetzen_lut_size];
347 const uint32_t xi = (uint32_t)x;
348 const float y0 = schetzen_lut_f[xi];
349 const float y1 = schetzen_lut_f[xi+1];
361 #define k_bitres_size_exp (7)
362 #define k_bitres_size (1U<<k_bitres_size_exp)
363 #define k_bitres_mask (k_bitres_size-1)
364 #define k_bitres_lut_size (k_bitres_size+1)
366 extern const float bitres_lut_f[k_bitres_lut_size];
376 const float xf = x * k_bitres_size;
377 const uint32_t xi = (uint32_t)xf;
378 const float y0 = bitres_lut_f[xi];
379 const float y1 = bitres_lut_f[xi+1];
380 return linintf(xf - xi, y0, y1);
402 __fast_inline uint32_t fx_rand(
void) {
413 __fast_inline
float fx_white(
void) {
const uint32_t k_fx_api_platform
Current platform.
__fast_inline float fx_cosf(float x)
Lookup value of cos(2*pi*x) in [0, 1.0] range.
uint32_t _fx_rand(void)
Random integer.
__fast_inline float fx_sinf(float x)
Lookup value of sin(2*pi*x).
__fast_inline float fx_sqrtm2logf(float x)
Lookup value of sqrt(-2*log(x)) in [0.005, 1.0] range.
Fixed Point Math Utilities.
__fast_inline float fx_cosuf(uint32_t x)
Lookup value of cos(2*pi*x) in [0, 1.0] range.
__fast_inline float fx_sat_schetzenf(float x)
Schetzen saturation.
uint16_t _fx_get_bpm(void)
Get current tempo as beats per minute as integer.
Floating Point Math Utilities.
const uint32_t k_fx_api_version
Current API version.
__fast_inline float fx_sinuf(uint32_t x)
Lookup value of sin(2*pi*x) in [0, 1.0] range.
uint32_t _fx_mcu_hash(void)
Get MCU hash.
static float si_copysignf(const float x, const float y)
Return x with sign of y applied.
float _fx_get_bpmf(void)
Get current tempo as beats per minute as floating point.
__fast_inline float fx_logf(float x)
Lookup value of log(x) in [0.00001, 1.0] range.
__fast_inline float fx_sat_cubicf(float x)
Cubic saturation.
float _fx_white(void)
Gaussian white noise.
__fast_inline float fx_tanpif(float x)
Lookup value of tan(pi*x) in [0.0001, 0.49] range.
__fast_inline float fx_bitresf(float x)
Bit depth scaling table.
static float clip1f(const float x)
Clip upper bound of x to 1.f (inclusive)
__fast_inline float fx_pow2f(float x)
Lookup value of 2^k for k in [0, 3.0] range.
static float clip1m1f(const float x)
Clip x to [-1.f, 1.f] (inclusive)
static float linintf(const float fr, const float x0, const float x1)
Linear interpolation.
__fast_inline float fx_softclipf(const float c, float x)
Soft clip.
static float si_fabsf(float x)
Absolute value.