code wiki / (root) / nx_polypitch.nx

nx_polypitch.nx

buildroot/runtime/nx_polypitch.nx

4105 B114 linesdepth 3pulls 3 transitivereach 4 importersview sourcekind library
docsdependenciesstructsconstsfunctions

about

nx_polypitch.nx -- INSTRUMENT-LEARN-GAME rung LG-3: POLYPHONIC pitch detection (chords). Guitars and pianos play several notes at once; a single-F0 detector (nx_pitch) can't see that. Instead of a big FFT (nx_fft caps at N=32 = 250 Hz bins, useless for notes), we run a GOERTZEL filter bank: evaluate the signal's energy DIRECTLY at each 12-TET note frequency. One cosine per note, O(N) per note -- exact note resolution, no FFT-bin quantization. A note is "present" when its Goertzel power is a local peak across the note grid AND above a fraction of the strongest note's power. The set of present notes = the chord. Pure integer. Imports only the x86_64 syscall layer (mmap scratch). Also exposes a sovereign full-range sin/cos (nx_pp_sinfull / nx_pp_cosfull) reusable across the audio arc. license_tier: ORIGINAL module: nishi-core.audio.polypitch depends: nishi-core.audio.note (note table, caller-built) capability: AUDIO_POLYPHONY

dependencies 1 imports · 4 importers

nx_syscalls_x86_64.nx nx_polypitch.nx nx_chord_grade.nx nx_chord_grade_gate.nx nx_fidelity_gate.nx nx_polypitch_gate.nx

imports: nx_syscalls_x86_64.nx

imported by: nx_chord_grade.nxnx_chord_grade_gate.nxnx_fidelity_gate.nxnx_polypitch_gate.nx

structs

none

consts

22const PP_PI: i64 = 205887 // pi in Q16.16
23const PP_HALFPI: i64 = 102944 // pi/2
24const PP_TWOPI: i64 = 411775 // 2*pi

functions

27func nx_pp_cosq16(th: i64) -> i64
41func nx_pp_cosfull(ph: i64) -> i64
called by 1: nx_pp_sinfull calls 1: nx_pp_cosq16
47func nx_pp_sinfull(ph: i64) -> i64
53func _pp_i16(pcm: *u8, i: i64) -> i64
called by 1: _pp_goertzel
62func _pp_goertzel(pcm: *u8, start: i64, N: i64, coeff_q14: i64) -> i64
called by 1: nx_polypitch calls 1: _pp_i16
82func nx_polypitch(pcm: *u8, start: i64, N: i64, fs: i64, tbl: *i64,