code wiki / (root) / nx_voice_codec_v1_adapter.nx

nx_voice_codec_v1_adapter.nx

buildroot/runtime/nx_voice_codec_v1_adapter.nx

9274 B230 linesdepth 5pulls 10 transitivereach 0 importersview sourcekind orphan librarytopic voice
docsdependenciesstructsconstsfunctions

about

nx_voice_codec_v1_adapter.nx -- wraps NishiVoice v1 behind nx_codec. NishiVoice v1's native API takes `*i64` PCM-sample arrays + writes total-length-via-out-param. The OOP layer's nx_codec vtable speaks `*u8` byte buffers + returns-bytes-written. This adapter is the thin shim: it unpacks int16-LE PCM bytes into i64 samples, calls nx_voice_codec_encode, repacks decoded i64 samples back to int16-LE PCM bytes on the way out. Why this exists: nx_audio_session works against the nx_codec interface; the smoke `bench/nx_audio_session_smoke.nx` proved the plumbing with a passthrough codec. This file replaces passthrough with the REAL NishiVoice v1 substrate (~1850 LOC of LPC + VAD + FEC + frame format) without touching the session layer. Composes: nx_codec.nx -- abstract base nx_voice_codec.nx -- NishiVoice v1 encode + decode nx_voice_codec_tier.nx -- params per hw tier Per [[feedback-bits-up-exceed-never-match]]: zero new codec logic. The wrapper is glue, not invention. All audio quality wins/losses vs Opus belong to the underlying nx_voice_codec.

dependencies 5 imports · 0 importers

nx_syscalls.nx nx_codec.nx nx_voice_codec.nx nx_voice_codec_tier.nx nx_hwprobe.nx nx_voice_codec_v1_adapter.nx

imports: nx_syscalls.nxnx_codec.nxnx_voice_codec.nxnx_voice_codec_tier.nxnx_hwprobe.nx

imported by: nobody (leaf or entry point)

structs

54struct nx_voice_codec_v1_state

consts

42const NX_VC1A_VAD_BYTES: i64 = 64
43const NX_VC1A_FEC_BYTES: i64 = 64
44const NX_VC1A_FEC_LAST_CAP: i64 = 256
45const NX_VC1A_PREV_HASH: i64 = 32
46const NX_VC1A_LPC_SCRATCH: i64 = 168 // (NX_VC_MAX_LPC_ORDER+1) * 8
71const NX_VC1A_STATE_BYTES: i64 = 104

functions

76func _unpack_pcm_int16le(src: *u8, src_n: i64, dst: *i64, dst_cap: i64) -> i64
91func _pack_pcm_int16le(src: *i64, n_samples: i64, dst: *u8, dst_cap: i64) -> i64
107func nx_voice_codec_v1_encode(c: *nx_codec, src: *u8, src_n: i64,
134func nx_voice_codec_v1_decode(c: *nx_codec, src: *u8, src_n: i64,
166func nx_voice_codec_v1_new(c: *nx_codec) -> i64