Nu:Tekt NTS-1 digital SDK  v1.1-0
Macros
osc_api.h File Reference

Oscillator runtime API. More...

#include "float_math.h"
#include "int_math.h"
#include "fixed_math.h"

Go to the source code of this file.

Macros

#define __fast_inline   static inline __attribute__((always_inline, optimize("Ofast")))
 

Functions

Noise source
uint32_t _osc_rand (void)
 Random integer. More...
 
__fast_inline uint32_t osc_rand (void)
 
float _osc_white (void)
 Gaussian white noise. More...
 
__fast_inline float osc_white (void)
 

Runtime Environment

#define k_samplerate   (48000)
 
#define k_samplerate_recipf   (2.08333333333333e-005f)
 
const uint32_t k_osc_api_platform
 Current platform.
 
const uint32_t k_osc_api_version
 Current API version.
 
uint32_t _osc_mcu_hash (void)
 Get MCU hash. More...
 
__fast_inline uint32_t osc_mcu_hash (void)
 

Note to frequency conversion table

#define k_midi_to_hz_size   (152)
 
#define k_note_mod_fscale   (0.00392156862745098f)
 
#define k_note_max_hz   (23679.643054f)
 
const float midi_to_hz_lut_f [k_midi_to_hz_size]
 
__fast_inline float osc_notehzf (uint8_t note)
 Get Hertz value for note. More...
 
__fast_inline float osc_w0f_for_note (uint8_t note, uint8_t mod)
 Get floating point phase increment for given note and fine modulation. More...
 

Sine half-wave

Note
Wrap and negate for phase >= 0.5
#define k_wt_sine_size_exp   (7)
 
#define k_wt_sine_size   (1U<<k_wt_sine_size_exp)
 
#define k_wt_sine_u32shift   (24)
 
#define k_wt_sine_frrecip   (5.96046447753906e-008f)
 
#define k_wt_sine_mask   (k_wt_sine_size-1)
 
#define k_wt_sine_lut_size   (k_wt_sine_size+1)
 
const float wt_sine_lut_f [k_wt_sine_lut_size]
 
__fast_inline float osc_sinf (float x)
 Lookup value of sin(2*pi*x). More...
 
__fast_inline float osc_cosf (float x)
 Lookup value of cos(2*pi*x) in [0, 1.0] range. More...
 

Band-limited sawtooth half-waves

Note
Wrap interpolation towards zero for 0.5, negate and reverse phase for >= 0.5
#define k_wt_saw_size_exp   (7)
 
#define k_wt_saw_size   (1U<<k_wt_saw_size_exp)
 
#define k_wt_saw_u32shift   (24)
 
#define k_wt_saw_frrecip   (5.96046447753906e-008f)
 
#define k_wt_saw_mask   (k_wt_saw_size-1)
 
#define k_wt_saw_lut_size   (k_wt_saw_size+1)
 
#define k_wt_saw_notes_cnt   (7)
 
#define k_wt_saw_lut_tsize   (k_wt_saw_notes_cnt * k_wt_saw_lut_size)
 
const uint8_t wt_saw_notes [k_wt_saw_notes_cnt]
 
const float wt_saw_lut_f [k_wt_saw_lut_tsize]
 
__fast_inline float osc_sawf (float x)
 Sawtooth wave lookup. More...
 
__fast_inline float osc_bl_sawf (float x, uint8_t idx)
 Band-limited sawtooth wave lookup. More...
 
__fast_inline float osc_bl2_sawf (float x, float idx)
 Band-limited sawtooth wave lookup. More...
 
float _osc_bl_saw_idx (float note)
 Get band-limited sawtooth wave index for note. More...
 
__fast_inline float osc_bl_saw_idx (float note)
 

Band-limited square half-waves

Note
Wrap interpolation to zero for 0.5, negate and reverse phase for >= 0.5
#define k_wt_sqr_size_exp   7
 
#define k_wt_sqr_size   (1U<<k_wt_sqr_size_exp)
 
#define k_wt_sqr_u32shift   (24)
 
#define k_wt_sqr_frrecip   (5.96046447753906e-008f)
 
#define k_wt_sqr_mask   (k_wt_sqr_size-1)
 
#define k_wt_sqr_lut_size   (k_wt_sqr_size+1)
 
#define k_wt_sqr_notes_cnt   7
 
#define k_wt_sqr_lut_tsize   (k_wt_sqr_notes_cnt * k_wt_sqr_lut_size)
 
const uint8_t wt_sqr_notes [k_wt_sqr_notes_cnt]
 
const float wt_sqr_lut_f [k_wt_sqr_lut_tsize]
 
__fast_inline float osc_sqrf (float x)
 Square wave lookup. More...
 
__fast_inline float osc_bl_sqrf (float x, uint8_t idx)
 Band-limited square wave lookup. More...
 
__fast_inline float osc_bl2_sqrf (float x, float idx)
 Band-limited square wave lookup. More...
 
float _osc_bl_sqr_idx (float note)
 Get band-limited square wave index for note. More...
 
__fast_inline float osc_bl_sqr_idx (float note)
 

Band-limited parabolic half-waves.

Note
Wrap interpolation to zero for 0.5, negate and reverse phase for >= 0.5. Careful to negate index 0 when wrapping.
#define k_wt_par_size_exp   7
 
#define k_wt_par_size   (1U<<k_wt_par_size_exp)
 
#define k_wt_par_u32shift   (24)
 
#define k_wt_par_frrecip   (5.96046447753906e-008f)
 
#define k_wt_par_mask   (k_wt_par_size-1)
 
#define k_wt_par_lut_size   (k_wt_par_size+1)
 
#define k_wt_par_notes_cnt   7
 
#define k_wt_par_lut_tsize   (k_wt_par_notes_cnt * k_wt_par_lut_size)
 
const uint8_t wt_par_notes [k_wt_par_notes_cnt]
 
const float wt_par_lut_f [k_wt_par_lut_tsize]
 
__fast_inline float osc_parf (float x)
 Parabolic wave lookup. More...
 
__fast_inline float osc_bl_parf (float x, uint8_t idx)
 Band-limited parabolic wave lookup. More...
 
__fast_inline float osc_bl2_parf (float x, float idx)
 Band-limited parabolic wave lookup. More...
 
float _osc_bl_par_idx (float note)
 Get band-limited parabolic wave index for note. More...
 
__fast_inline float osc_bl_par_idx (float note)
 

Wave banks.

Banks are organized in categories from A to F in order of increasing harmonic components.

#define k_waves_size_exp   (7)
 
#define k_waves_size   (1U<<k_waves_size_exp)
 
#define k_waves_u32shift   (24)
 
#define k_waves_frrecip   (5.96046447753906e-008f)
 
#define k_waves_mask   (k_waves_size-1)
 
#define k_waves_lut_size   (k_waves_size+1)
 
#define k_waves_a_cnt   16
 
#define k_waves_b_cnt   16
 
#define k_waves_c_cnt   14
 
#define k_waves_d_cnt   13
 
#define k_waves_e_cnt   15
 
#define k_waves_f_cnt   16
 
const float *const wavesA [k_waves_a_cnt]
 
const float *const wavesB [k_waves_b_cnt]
 
const float *const wavesC [k_waves_c_cnt]
 
const float *const wavesD [k_waves_d_cnt]
 
const float *const wavesE [k_waves_e_cnt]
 
const float *const wavesF [k_waves_f_cnt]
 
static float osc_wave_scanf (const float *w, float x)
 
static float osc_wave_scanuf (const float *w, uint32_t x)
 

Various function lookups

#define k_log_size_exp   (8)
 
#define k_log_size   (1U<<k_log_size_exp)
 
#define k_log_mask   (k_log_size-1)
 
#define k_log_lut_size   (k_log_size+1)
 
#define k_tanpi_size_exp   (8)
 
#define k_tanpi_size   (1U<<k_tanpi_size_exp)
 
#define k_tanpi_mask   (k_tanpi_size-1)
 
#define k_tanpi_range_recip   (2.04081632653061f)
 
#define k_tanpi_lut_size   (k_tanpi_size+1)
 
#define k_sqrtm2log_size_exp   (8)
 
#define k_sqrtm2log_size   (1U<<k_sqrtm2log_size_exp)
 
#define k_sqrtm2log_mask   (k_sqrtm2log_size-1)
 
#define k_sqrtm2log_base   (0.005f)
 
#define k_sqrtm2log_range_recip   (1.00502512562814f)
 
#define k_sqrtm2log_lut_size   (k_sqrtm2log_size+1)
 
const float log_lut_f [k_log_lut_size]
 
const float tanpi_lut_f [k_log_lut_size]
 
const float sqrtm2log_lut_f [k_sqrtm2log_lut_size]
 
__fast_inline float osc_logf (float x)
 Lookup value of log(x) in [0.00001, 1.0] range. More...
 
__fast_inline float osc_tanpif (float x)
 Lookup value of tan(pi*x) in [0.0001, 0.49] range. More...
 
__fast_inline float osc_sqrtm2logf (float x)
 Lookup value of sqrt(-2*log(x)) in [0.005, 1.0] range. More...
 

Clipping and Saturation.

#define k_cubicsat_size_exp   (7)
 
#define k_cubicsat_size   (1U<<k_cubicsat_size_exp)
 
#define k_cubicsat_mask   (k_cubicsat_size-1)
 
#define k_cubicsat_lut_size   (k_cubicsat_size+1)
 
#define k_schetzen_size_exp   (7)
 
#define k_schetzen_size   (1U<<k_schetzen_size_exp)
 
#define k_schetzen_mask   (k_schetzen_size-1)
 
#define k_schetzen_lut_size   (k_schetzen_size+1)
 
const float cubicsat_lut_f [k_cubicsat_lut_size]
 
const float schetzen_lut_f [k_schetzen_lut_size]
 
__fast_inline float osc_softclipf (const float c, float x)
 Soft clip. More...
 
__fast_inline float osc_sat_cubicf (float x)
 Cubic saturation. More...
 
__fast_inline float osc_sat_schetzenf (float x)
 Schetzen saturation. More...
 

Bit reduction.

#define k_bitres_size_exp   (7)
 
#define k_bitres_size   (1U<<k_bitres_size_exp)
 
#define k_bitres_mask   (k_bitres_size-1)
 
#define k_bitres_lut_size   (k_bitres_size+1)
 
const float bitres_lut_f [k_bitres_lut_size]
 
__fast_inline float osc_bitresf (float x)
 Bit depth scaling table. More...
 

Detailed Description

Oscillator runtime API.

Definition in file osc_api.h.