wav_writer.nx
buildroot/runtime/wav_writer.nx
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
imports: syscalls.nx
imported by: nobody (leaf or entry point)
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| 29 | const WAV_WR_ERR_SHORT: i64 = -1 |
| 30 | const WAV_WR_ERR_BITS: i64 = -2 |
functions
| 33 | func wav_write_u16(out: *u8, off: i64, v: i64) -> i64 { |
| 40 | func wav_write_u32(out: *u8, off: i64, v: i64) -> i64 {
called by 1: wav_write_header |
| 51 | func wav_write_header(out: *u8, cap: i64, |
| 91 | func wav_write_pcm16(out: *u8, cap: i64, |
| 114 | func main() -> i64 {
calls 1: wav_write_pcm16 |