code wiki / (root) / nx_audio_osc.nx

nx_audio_osc.nx

buildroot/runtime/nx_audio_osc.nx

4280 B101 linesdepth 2pulls 2 transitivereach 35 importersview sourcekind librarytopic audio
docsdependenciesstructsconstsfunctions

about

nx_audio_osc.nx -- SOVEREIGN AUDIO ENGINE rung R3: oscillators (synth source). Generates waveforms via a phase accumulator -- the source side of synthesis (the mixer/resampler/pan are the processing side). Square/saw/triangle are trig-free integer math; sine (table/approx) is a later rung. Phase is Q16 in [0, OSC_PHASE); phase increment = freq*OSC_PHASE/rate. Amplitude in i16 range. license_tier: ORIGINAL.

dependencies 1 imports · 9 importers

nx_syscalls.nx nx_audio_osc.nx nx_audio_bark.nx nx_audio_critters.nx nx_audio_demo_test.nx nx_audio_osc_test.nx nx_audio_wav_test.nx nx_bioacoustic_bench.nx nx_fft.nx nx_mdct.nx nx_perceptual.nx

imports: nx_syscalls.nx

imported by: nx_audio_bark.nxnx_audio_critters.nxnx_audio_demo_test.nxnx_audio_osc_test.nxnx_audio_wav_test.nxnx_bioacoustic_bench.nxnx_fft.nxnx_mdct.nxnx_perceptual.nx

structs

none

consts

10const OSC_MAGIC_5040: i64 = 5040
11const OSC_MAGIC_65536: i64 = 65536
12const OSC_MAGIC_40320: i64 = 40320
13const OSC_MAGIC_32768: i64 = 32768
14const OSC_MAGIC_16384: i64 = 16384
15const OSC_MAGIC_411774: i64 = 411774
16const OSC_MAGIC_51472: i64 = 51472
17const OSC_MAGIC_102944: i64 = 102944
19const OSC_PHASE: i64 = 65536 // one cycle (Q16)

functions

22func osc_square(out: *i64, n: i64, freq: i64, rate: i64, amp: i64) -> i64
called by 3: mainmainmain
37func osc_saw(out: *i64, n: i64, freq: i64, rate: i64, amp: i64) -> i64
called by 2: mainmain
51func osc_triangle(out: *i64, n: i64, freq: i64, rate: i64, amp: i64) -> i64
called by 1: main
67func osc_qm(a: i64, b: i64) -> i64 { return (a * b) >> 16 }
called by 2: osc_sin_sosc_cos_s
68func osc_sin_s(x: i64) -> i64 { let x2: i64=osc_qm(x,x); let x3: i64=osc_qm(x2,x); let x5: i64=osc_qm(x3,x2); let x7: i64=osc_qm(x5,x2); return x - x3/6 + x5/120 - x7/OSC_MAGIC_5040 }
called by 1: osc_sin_unit calls 1: osc_qm
69func osc_cos_s(x: i64) -> i64 { let x2: i64=osc_qm(x,x); let x4: i64=osc_qm(x2,x2); let x6: i64=osc_qm(x4,x2); let x8: i64=osc_qm(x4,x4); return OSC_MAGIC_65536 - x2/2 + x4/24 - x6/720 + x8/OSC_MAGIC_40320 }
called by 2: add_formantosc_sin_unit calls 1: osc_qm
71func osc_sin_unit(ph: i64) -> i64
82func osc_sine(out: *i64, n: i64, freq: i64, rate: i64, amp: i64) -> i64
calls 1: osc_sin_unit
90func osc_sweep(out: *i64, n: i64, f0: i64, f1: i64, rate: i64, amp: i64) -> i64
called by 1: place_sweep calls 1: osc_sin_unit