nx_rec_grade.nx
buildroot/runtime/nx_rec_grade.nx
about
nx_rec_grade.nx -- AUDIO arc, voice-recording thread: grade a recording's
technical quality so a bad capture is caught BEFORE it pollutes a voicebank /
clone. Clipping wrecks the LPC spectral envelope; too-quiet kills SNR; a DC
offset biases autocorrelation -- all three corrupt every downstream rung, so
the recorder gates its own input.
Pure integer, NO floats, NO syscalls, NO imports (operates on a caller buffer).
Metrics over i16-LE mono PCM s[0..n):
peak = max |s|
dc = mean(s) (offset)
rms_ac = sqrt( mean(s^2) - dc^2 ) (AC level, offset removed)
clip_cnt = #{ |s| >= REC_CLIP } (samples pinned near full-scale)
nx_rec_grade(pcm, n, out) -> verdict
out[0]=peak out[1]=rms_ac out[2]=dc out[3]=clip_cnt
Verdict priority: CLIPPED > DC_BIAS > TOO_QUIET > TOO_LOUD > GOOD.
license_tier: ORIGINAL
module: nishi-core.audio.rec_grade
capability: AUDIO_RECORDING_QUALITY
dependencies 1 imports · 1 importers
imports: nx_vecmath.nx
imported by: nx_rec_grade_gate.nx
structs
| none |
consts
| 24 | const REC_GOOD: i64 = 0 |
| 25 | const REC_CLIPPED: i64 = 1 |
| 26 | const REC_DC_BIAS: i64 = 2 |
| 27 | const REC_TOO_QUIET: i64 = 3 |
| 28 | const REC_TOO_LOUD: i64 = 4 |
| 30 | const REC_CLIP: i64 = 32000 // |s| at/above this is clipping |
| 31 | const REC_CLIP_FRAC: i64 = 200 // CLIPPED if clip_cnt > n/200 (0.5%) |
| 32 | const REC_QUIET_RMS: i64 = 800 // below this AC level = too quiet |
| 33 | const REC_LOUD_RMS: i64 = 26000 // above this AC level = clip risk |
functions
| 36 | func _rec_isqrt(x: i64) -> i64 { return vm_isqrt(x) } |
| 38 | func _rec_i16(pcm: *u8, i: i64) -> i64 called by 1: nx_rec_grade |
| 46 | func nx_rec_grade(pcm: *u8, n: i64, out: *i64) -> i64 |