nx_voice_codec_v2.nx
buildroot/runtime/nx_voice_codec_v2.nx
about
nx_voice_codec_v2.nx -- NishiVoice v2: the REAL LPC-residual voice codec the v1 skeleton described but didn't build.
encode: PCM -> autocorr -> Levinson (a[1..p] Q30) -> analysis filter (true residual) -> quantise -> range-code.
decode: range-decode -> dequantise -> LPC synthesis filter -> PCM. Entirely on the x86_64 LPC lineage so autocorr +
levinson + synth + range coder all share one syscalls module (the v1 codec's nx_lpc/nx_syscalls path can't compose
with the range coder). Frame = [order:1][Q:2][n:2][a_q30: order*8][resid_len:2][entropy residual]. The coeffs are
carried full Q30 here (correctness first); LSF/reflection-coeff quantisation to shrink the header is the follow-on.
license_tier: ORIGINAL
dependencies 4 imports · 1 importers
imports: nx_lpc_autocorr.nxnx_lpc_levinson.nxnx_lpc_synth.nxnx_resid_entropy.nx
imported by: nx_voice_codec_v2_gate.nx
structs
| none |
consts
| 12 | const V2_MAGIC_32768: i64 = 32768 |
| 13 | const V2_MAGIC_65536: i64 = 65536 |
| 14 | const V2_MAGIC_4096: i64 = 4096 |
| 16 | const V2_ALPHA: i64 = 65 // residual symbol alphabet (|residual| up to 32) |
functions
| 18 | func _v2_abs(v: i64) -> i64 { if v < 0 { return 0 - v } return v } called by 1: v2_encode |
| 19 | func _v2_ld16(buf: *u8, idx: i64) -> i64 { var v: i64 = buf[idx*2] | (buf[idx*2+1] << 8); if v >= V2_MAGIC_32768 { v = v - V2_MAGIC_65536 } return v } called by 1: v2_encode |
| 20 | func _v2_st16(buf: *u8, idx: i64, v: i64) -> i64 { var x: i64 = v; if x < 0 { x = x + V2_MAGIC_65536 } buf[idx*2] = x & 0xff; buf[idx*2+1] = (x >> 8) & 0xff; return 0 } called by 1: v2_decode |
| 21 | func _v2_ld64(buf: *u8, byteoff: i64) -> i64 { var v: i64 = 0; var b: i64 = 0; while b < 8 { v = v | (buf[byteoff + b] << (b*8)); b = b + 1 } return v } called by 1: v2_encode |
| 22 | func _v2_st64(buf: *u8, byteoff: i64, v: i64) -> i64 { var b: i64 = 0; while b < 8 { buf[byteoff + b] = (v >> (b*8)) & 0xff; b = b + 1 } return 0 } called by 1: v2_stepup |
| 23 | func _v2_w16(buf: *u8, off: i64, v: i64) -> i64 { buf[off] = v & 0xff; buf[off+1] = (v >> 8) & 0xff; return off + 2 } called by 1: v2_encode |
| 24 | func _v2_r16(buf: *u8, off: i64) -> i64 { return buf[off] | (buf[off+1] << 8) } called by 1: v2_decode |
| 28 | func v2_stepup(k: *i64, p: i64, a_out: *u8) -> i64 |
| 48 | func v2_encode(s_pcm: *u8, n: i64, order: i64, out: *u8, cap: i64) -> i64 |
| 106 | func v2_decode(inb: *u8, len: i64, out_pcm: *u8, out_cap: i64) -> i64 |