code wiki / (root) / wav_writer.nx

wav_writer.nx

buildroot/runtime/wav_writer.nx

5388 B146 linesdepth 3pulls 3 transitivereach 0 importersview sourcekind tooltopic wav
docsdependenciesstructsconstsfunctions

about

wav_writer.nx -- serialise 16-bit PCM WAV files (canonical 44-byte header + raw samples). Paired with wav_header.nx for the reader half of the roundtrip. Use cases: debug tones, sovereign test-signal generation, dumping buffers from a DSP pipeline during bring-up, tiny synth prototypes without external tooling. Produces the standard 44-byte canonical PCM header: RIFF [size] WAVE fmt [16] fmt_code=1 channels sample_rate byte_rate block_align bits_per_sample data [size] <samples> Samples are little-endian signed i16 in (-32768..32767). Caller owns the sample buffer; this module writes header + copies. Invariants: W1 Only 16-bit PCM produced today. 8 / 24 / 32 bit and float formats pending a future commit. W2 num_samples is PER-CHANNEL sample count (not total sample-frames across channels). Total bytes = num_samples * num_channels * 2. W3 Output buffer must be at least 44 + 2*channels*num_samples bytes or WAV_ERR_SHORT is returned.

dependencies 1 imports · 0 importers

syscalls.nx wav_writer.nx

imports: syscalls.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main wav_write_pcm16 wav_write_header wav_write_u32 wav_write_u16 wav_write_u16 ↻

structs

none

consts

29const WAV_WR_ERR_SHORT: i64 = -1
30const WAV_WR_ERR_BITS: i64 = -2

functions

33func wav_write_u16(out: *u8, off: i64, v: i64) -> i64 {
40func wav_write_u32(out: *u8, off: i64, v: i64) -> i64 {
called by 1: wav_write_header
51func wav_write_header(out: *u8, cap: i64,
91func wav_write_pcm16(out: *u8, cap: i64,
called by 1: main calls 2: wav_write_headerwav_write_u16
114func main() -> i64 {
calls 1: wav_write_pcm16