code wiki / (root) / nx_wav.nx

nx_wav.nx

buildroot/runtime/nx_wav.nx

5889 B160 linesdepth 3pulls 3 transitivereach 0 importersview sourcekind orphan librarytopic wav
docsdependenciesstructsconstsfunctions

about

nx_wav.nx -- pure-NishiLang RIFF/WAVE (PCM 16-bit LE) writer. Why a sovereign WAV writer: it gives the substrate a path from i64 sample buffers to a file the operating system can play through any sound card with no library, no codec, no userspace audio stack dependency. /tmp/foo.wav -> aplay -> speakers; we hear our BFSK tones in the air. That is the "real test" hook between the modem primitives and human ears. The WAV header is the 1991 Microsoft RIFF spec; fully public. We write the canonical 44-byte form (no LIST/INFO chunks). genealogy_id: rfc_riff_1991 + microsoft_wave_spec + nx_bfsk_q10 lineage_id: nishi_wav_writer_q10 Header layout (PCM 16-bit LE, 44 bytes total): [0..3] "RIFF" [4..7] chunk size = 36 + data_bytes (LE u32) [8..11] "WAVE" [12..15] "fmt " [16..19] 16 (fmt chunk size, PCM) [20..21] 1 (PCM format) [22..23] channels [24..27] sample_rate [28..31] byte_rate = sample_rate * channels * 2 [32..33] block_align = channels * 2 [34..35] bits_per_sample = 16 [36..39] "data" [40..43] data_bytes = n_samples * channels * 2 [44..] sample data, int16 LE

dependencies 1 imports · 0 importers

nx_syscalls_x86_64.nx nx_wav.nx

imports: nx_syscalls_x86_64.nx

imported by: nobody (leaf or entry point)

structs

none

consts

41const NX_WAV_VERDICT_UNKNOWN: i64 = 0
42const NX_WAV_VERDICT_OK: i64 = 1
43const NX_WAV_VERDICT_OPEN_FAIL: i64 = 2
44const NX_WAV_VERDICT_WRITE_FAIL: i64 = 3
45const NX_WAV_VERDICT_BAD_PARAMS: i64 = 4
46const NX_WAV_VERDICT_N: i64 = 5
48const NX_WAV_HEADER_BYTES: i64 = 44

functions

51func _w_le32(buf: *u8, off: i64, v: i64) -> i64
called by 1: nx_wav_build_header
60func _w_le16(buf: *u8, off: i64, v: i64) -> i64
called by 1: nx_wav_build_header
68func nx_wav_build_header(
called by 1: nx_wav_open calls 2: _w_le32_w_le16
95func nx_wav_open(path: *u8, sample_rate_hz: i64, channels: i64, n_samples: i64,
118func nx_wav_write_samples(fd: i64, samples: *i64, n: i64) -> i64
called by 1: nx_wav_write_file
143func nx_wav_write_file(path: *u8, sample_rate_hz: i64, channels: i64,
156func nx_wav_verdict_is_valid(v: i64) -> i64