nx_audio_osc.nx
buildroot/runtime/nx_audio_osc.nx
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
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
| 10 | const OSC_MAGIC_5040: i64 = 5040 |
| 11 | const OSC_MAGIC_65536: i64 = 65536 |
| 12 | const OSC_MAGIC_40320: i64 = 40320 |
| 13 | const OSC_MAGIC_32768: i64 = 32768 |
| 14 | const OSC_MAGIC_16384: i64 = 16384 |
| 15 | const OSC_MAGIC_411774: i64 = 411774 |
| 16 | const OSC_MAGIC_51472: i64 = 51472 |
| 17 | const OSC_MAGIC_102944: i64 = 102944 |
| 19 | const OSC_PHASE: i64 = 65536 // one cycle (Q16) |
functions
| 22 | func osc_square(out: *i64, n: i64, freq: i64, rate: i64, amp: i64) -> i64 |
| 37 | func osc_saw(out: *i64, n: i64, freq: i64, rate: i64, amp: i64) -> i64 |
| 51 | func osc_triangle(out: *i64, n: i64, freq: i64, rate: i64, amp: i64) -> i64 called by 1: main |
| 67 | func osc_qm(a: i64, b: i64) -> i64 { return (a * b) >> 16 } |
| 68 | func 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 } |
| 69 | func 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 } |
| 71 | func osc_sin_unit(ph: i64) -> i64 |
| 82 | func osc_sine(out: *i64, n: i64, freq: i64, rate: i64, amp: i64) -> i64 calls 1: osc_sin_unit |
| 90 | func osc_sweep(out: *i64, n: i64, f0: i64, f1: i64, rate: i64, amp: i64) -> i64 |