nx_pitch.nx
buildroot/runtime/nx_pitch.nx
about
nx_pitch.nx -- sovereign integer F0 (fundamental-frequency / pitch)
detector via the YIN cumulative-mean-normalized difference function
(CMNDF). Pure integer fixed-point, NO floats, NO syscalls, NO imports.
This is the SHARED bottom rung of the Nishi audio arc -- one primitive
that three threads all stand on:
* voice clone -> a speaker's pitch range/contour is part of identity
* singing teacher -> "am I on the right note?" = sung F0 vs target F0
* voice recording -> pitch stability / monotone detection
(no-orphans "shared primitive" rule: build once, reuse everywhere.)
Re-derived integer-only from de Cheveigne & Kawahara 2002 (YIN),
patent-clean. Not CREPE, not pYIN, not any proprietary tracker.
API (all buffers caller-owned; the organ touches no OS state):
nx_pitch_f0(pcm,start,win,fs,min_lag,max_lag,out) -> F0_hz
pcm: *u8 i16-LE mono PCM
start: first sample index of the analysis window
win: window length in samples (>= 2*max_lag recommended)
fs: sample rate (Hz)
min_lag: smallest lag searched (= fs / F0max)
max_lag: largest lag searched (= fs / F0min)
out: *i64 [0]=confidence Q14 (16384 - cmndf_min, clamped >=0)
[1]=best lag (period, samples)
returns: F0 = fs / best_lag (Hz), or 0 if degenerate
nx_pitch_is_voiced(conf_q14) -> 1 voiced / 0 unvoiced
license_tier: ORIGINAL
module: nishi-core.audio.pitch
capability: AUDIO_F0_PITCH
dependencies 0 imports · 5 importers
imports: none
imported by: nx_note_gate.nxnx_pitch_gate.nxnx_pitch_grade.nxnx_song_grade.nxnx_voiceprint.nx
structs
| none |
consts
| 32 | const NX_PITCH_Q14: i64 = 16384 |
| 36 | const NX_PITCH_VOICED_CONF_MIN: i64 = 9000 |
functions
| 39 | func _px_i16(pcm: *u8, idx: i64) -> i64 called by 1: nx_pitch_f0 |
| 49 | func nx_pitch_f0(pcm: *u8, start: i64, win: i64, fs: i64, |
| 87 | func nx_pitch_is_voiced(conf_q14: i64) -> i64 |