code wiki / _hdl_build / nx_mdct.nx

nx_mdct.nx

buildroot/runtime/_hdl_build/nx_mdct.nx

6264 B120 linesdepth 3pulls 3 transitivereach 1 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

about

nx_mdct.nx -- R1 of the transform ladder: the Modified Discrete Cosine Transform (the lapped transform every perceptual audio codec uses -- MP3/AAC/Opus-CELT). Built on the SAME sine absorbed into nx_audio_osc (osc_sin_unit) -- one sine, no dup. Sine analysis+synthesis window (Princen-Bradley) -> Time-Domain Aliasing Cancellation: overlap-add of consecutive half-overlapped blocks PERFECTLY reconstructs the signal. That PR property is a pure math gate (verifiable without ears). No-float -> deterministic/bit-reproducible (the exceed). Unlocks R2 = psychoacoustic masking + quantization = perceptual audio toward Opus. license_tier: ORIGINAL expect_exit: 0

dependencies 2 imports · 1 importers

nx_audio_osc.nx nx_syscalls.nx nx_mdct.nx nx_perceptual.nx

imports: nx_audio_osc.nxnx_syscalls.nx

imported by: nx_perceptual.nx

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

main mp sys_write sys_mmap mk_window osc_sin_unit osc_sin_s osc_qm osc_cos_s osc_qm ↻ osc_sin_unit ↻ mdct mbasis osc_sin_unit ↻ imdct mbasis ↻ mpn sys_mmap ↻ sys_write ↻ m_abs sys_exit

structs

none

consts

9const K_MAGIC_1100: i64 = 1100
10const K_MAGIC_2999: i64 = 2999
11const K_MAGIC_65536: i64 = 65536
13const OSCP: i64 = 65536
14const QPI: i64 = 16384 // pi/2 in osc units; cos(x) = sin(x + pi/2)

functions

16func mp(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
17func mpn(v: i64) -> i64
called by 1: main calls 2: sys_mmapsys_write
25func m_abs(v: i64) -> i64 { if v<0 { return 0-v } return v }
called by 1: main
28func mk_window(w: *i64, N: i64) -> i64
called by 2: mainmain calls 1: osc_sin_unit
35func mbasis(n: i64, k: i64, N: i64) -> i64
called by 2: mdctimdct calls 1: osc_sin_unit
42func mdct(x: *i64, X: *i64, w: *i64, N: i64) -> i64
called by 2: mainmain calls 1: mbasis
55func imdct(X: *i64, y: *i64, w: *i64, N: i64) -> i64
called by 1: main calls 1: mbasis
69func main() -> i64