code wiki / (root) / nx_voice_codec_v2.nx

nx_voice_codec_v2.nx

buildroot/runtime/nx_voice_codec_v2.nx

6700 B135 linesdepth 5pulls 8 transitivereach 1 importersview sourcekind librarytopic voice
docsdependenciesstructsconstsfunctions

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

nx_lpc_autocorr.nx nx_lpc_levinson.nx nx_lpc_synth.nx nx_resid_entropy.nx nx_voice_codec_v2.nx nx_voice_codec_v2_gate.nx

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

12const V2_MAGIC_32768: i64 = 32768
13const V2_MAGIC_65536: i64 = 65536
14const V2_MAGIC_4096: i64 = 4096
16const V2_ALPHA: i64 = 65 // residual symbol alphabet (|residual| up to 32)

functions

18func _v2_abs(v: i64) -> i64 { if v < 0 { return 0 - v } return v }
called by 1: v2_encode
19func _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
20func _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
21func _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
22func _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
23func _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
24func _v2_r16(buf: *u8, off: i64) -> i64 { return buf[off] | (buf[off+1] << 8) }
called by 1: v2_decode
28func v2_stepup(k: *i64, p: i64, a_out: *u8) -> i64
called by 2: v2_encodev2_decode calls 1: _v2_st64
48func v2_encode(s_pcm: *u8, n: i64, order: i64, out: *u8, cap: i64) -> i64
106func v2_decode(inb: *u8, len: i64, out_pcm: *u8, out_cap: i64) -> i64