nx_polypitch.nx
buildroot/runtime/nx_polypitch.nx
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
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
| 22 | const PP_PI: i64 = 205887 // pi in Q16.16 |
| 23 | const PP_HALFPI: i64 = 102944 // pi/2 |
| 24 | const PP_TWOPI: i64 = 411775 // 2*pi |
functions
| 27 | func nx_pp_cosq16(th: i64) -> i64 |
| 41 | func nx_pp_cosfull(ph: i64) -> i64 |
| 47 | func nx_pp_sinfull(ph: i64) -> i64 |
| 53 | func _pp_i16(pcm: *u8, i: i64) -> i64 called by 1: _pp_goertzel |
| 62 | func _pp_goertzel(pcm: *u8, start: i64, N: i64, coeff_q14: i64) -> i64 |
| 82 | func nx_polypitch(pcm: *u8, start: i64, N: i64, fs: i64, tbl: *i64, |