nx_voice_codec_v1_adapter.nx
buildroot/runtime/nx_voice_codec_v1_adapter.nx
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
imports: nx_syscalls.nxnx_codec.nxnx_voice_codec.nxnx_voice_codec_tier.nxnx_hwprobe.nx
imported by: nobody (leaf or entry point)
structs
| 54 | struct nx_voice_codec_v1_state |
consts
| 42 | const NX_VC1A_VAD_BYTES: i64 = 64 |
| 43 | const NX_VC1A_FEC_BYTES: i64 = 64 |
| 44 | const NX_VC1A_FEC_LAST_CAP: i64 = 256 |
| 45 | const NX_VC1A_PREV_HASH: i64 = 32 |
| 46 | const NX_VC1A_LPC_SCRATCH: i64 = 168 // (NX_VC_MAX_LPC_ORDER+1) * 8 |
| 71 | const NX_VC1A_STATE_BYTES: i64 = 104 |
functions
| 76 | func _unpack_pcm_int16le(src: *u8, src_n: i64, dst: *i64, dst_cap: i64) -> i64 called by 1: nx_voice_codec_v1_encode |
| 91 | func _pack_pcm_int16le(src: *i64, n_samples: i64, dst: *u8, dst_cap: i64) -> i64 called by 1: nx_voice_codec_v1_decode |
| 107 | func nx_voice_codec_v1_encode(c: *nx_codec, src: *u8, src_n: i64, |
| 134 | func nx_voice_codec_v1_decode(c: *nx_codec, src: *u8, src_n: i64, |
| 166 | func nx_voice_codec_v1_new(c: *nx_codec) -> i64 |