nx_fft.nx
buildroot/runtime/nx_fft.nx
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
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
structs
| none |
consts
| 9 | const K_MAGIC_2000: i64 = 2000 |
| 10 | const K_MAGIC_1500: i64 = 1500 |
| 11 | const K_MAGIC_1000000: i64 = 1000000 |
| 12 | const K_MAGIC_1400: i64 = 1400 |
| 13 | const K_MAGIC_1600: i64 = 1600 |
| 15 | const OSCP: i64 = 65536 // osc one-cycle units (matches nx_audio_osc OSC_PHASE) |
| 16 | const QPI: i64 = 16384 // OSCP/4 = pi/2 in osc units (cos(x) = sin(x + pi/2)) |
| 120 | const NX_FFT_Q: i64 = 16384 |
functions
| 18 | func fp(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 } |
| 19 | func fpn(v: i64) -> i64 |
| 27 | func f_abs(v: i64) -> i64 { if v<0 { return 0-v } return v } called by 1: main |
| 30 | func fft(re: *i64, im: *i64, n: i64, dir: i64) -> i64 |
| 89 | func nx_fft_log2(n: i64) -> i64 |
| 96 | func nx_fft_bit_reverse(x: i64, bits: i64) -> i64 |
| 132 | func nx_fft_forward(re: *i64, im: *i64, n: i64) -> i64 called by 7: ds_noise_floords_spectral_gatebin_powernx_fft_2d_forwardmainnx_sound_stft+1 calls 1: fft |
| 136 | func nx_fft_inverse(re: *i64, im: *i64, n: i64) -> i64 |
| 147 | func nx_fft_power_spectrum(re: *i64, im: *i64, n: i64, pwr: *i64) -> i64 |
| 164 | func nx_fft_2d_forward(re: *i64, im: *i64, w: i64, h: i64) -> i64 |
| 188 | func main() -> i64 |