code wiki / (root) / nx_fft.nx

nx_fft.nx

buildroot/runtime/nx_fft.nx

11675 B227 linesdepth 3pulls 3 transitivereach 25 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

about

nx_fft.nx -- R0 of the transform ladder: a sovereign no-float radix-2 FFT (Cooley-Tukey, DIT, in-place). The foundation rung for MDCT (R1) -> psychoacoustic perceptual audio (R2+). Twiddles COMPOSE the sine that was absorbed into nx_audio_osc (osc_sin_unit) -- one sine, no dup. Fixed-point (Q16 twiddles, integer data), so the result is DETERMINISTIC / bit-reproducible across machines -- the s-class exceed dimension vs float FFTs whose rounding varies by platform. Gated by MATH properties verifiable without ears: round-trip reconstruction + known answers (DC -> single bin; impulse -> flat spectrum). license_tier: ORIGINAL expect_exit: 0

dependencies 2 imports · 6 importers

nx_audio_osc.nx nx_syscalls.nx nx_fft.nx nx_denoise_spectral.nx nx_fft_f32.nx nx_fft_test.nx nx_fnet_mix.nx nx_sound.nx nx_triangulation_crypto_fft.nx

imports: nx_audio_osc.nxnx_syscalls.nx

imported by: nx_denoise_spectral.nxnx_fft_f32.nxnx_fft_test.nxnx_fnet_mix.nxnx_sound.nxnx_triangulation_crypto_fft.nx

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main fp sys_write sys_mmap fft osc_sin_unit osc_sin_s osc_qm osc_cos_s osc_qm ↻ f_abs fpn sys_mmap ↻ sys_write ↻ sys_exit

structs

none

consts

9const K_MAGIC_2000: i64 = 2000
10const K_MAGIC_1500: i64 = 1500
11const K_MAGIC_1000000: i64 = 1000000
12const K_MAGIC_1400: i64 = 1400
13const K_MAGIC_1600: i64 = 1600
15const OSCP: i64 = 65536 // osc one-cycle units (matches nx_audio_osc OSC_PHASE)
16const QPI: i64 = 16384 // OSCP/4 = pi/2 in osc units (cos(x) = sin(x + pi/2))
120const NX_FFT_Q: i64 = 16384

functions

18func fp(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 }
called by 1: main calls 1: sys_write
19func fpn(v: i64) -> i64
called by 1: main calls 2: sys_mmapsys_write
27func f_abs(v: i64) -> i64 { if v<0 { return 0-v } return v }
called by 1: main
30func fft(re: *i64, im: *i64, n: i64, dir: i64) -> i64
89func nx_fft_log2(n: i64) -> i64
96func nx_fft_bit_reverse(x: i64, bits: i64) -> i64
132func nx_fft_forward(re: *i64, im: *i64, n: i64) -> i64
136func nx_fft_inverse(re: *i64, im: *i64, n: i64) -> i64
called by 3: ds_spectral_gatemainmain calls 1: fft
147func nx_fft_power_spectrum(re: *i64, im: *i64, n: i64, pwr: *i64) -> i64
164func nx_fft_2d_forward(re: *i64, im: *i64, w: i64, h: i64) -> i64
188func main() -> i64