nx_wav.nx
buildroot/runtime/nx_wav.nx
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
imports: nx_syscalls_x86_64.nx
imported by: nobody (leaf or entry point)
structs
| none |
consts
| 41 | const NX_WAV_VERDICT_UNKNOWN: i64 = 0 |
| 42 | const NX_WAV_VERDICT_OK: i64 = 1 |
| 43 | const NX_WAV_VERDICT_OPEN_FAIL: i64 = 2 |
| 44 | const NX_WAV_VERDICT_WRITE_FAIL: i64 = 3 |
| 45 | const NX_WAV_VERDICT_BAD_PARAMS: i64 = 4 |
| 46 | const NX_WAV_VERDICT_N: i64 = 5 |
| 48 | const NX_WAV_HEADER_BYTES: i64 = 44 |
functions
| 51 | func _w_le32(buf: *u8, off: i64, v: i64) -> i64 called by 1: nx_wav_build_header |
| 60 | func _w_le16(buf: *u8, off: i64, v: i64) -> i64 called by 1: nx_wav_build_header |
| 68 | func nx_wav_build_header( |
| 95 | func nx_wav_open(path: *u8, sample_rate_hz: i64, channels: i64, n_samples: i64, |
| 118 | func nx_wav_write_samples(fd: i64, samples: *i64, n: i64) -> i64 called by 1: nx_wav_write_file |
| 143 | func nx_wav_write_file(path: *u8, sample_rate_hz: i64, channels: i64, |
| 156 | func nx_wav_verdict_is_valid(v: i64) -> i64 |