code wiki / _hdl_build / nx_hyp_audio.nx

nx_hyp_audio.nx

buildroot/runtime/_hdl_build/nx_hyp_audio.nx

9047 B219 linesdepth 5pulls 5 transitivereach 0 importersview sourcekind orphan library
docsdependenciesstructsconstsfunctions

about

nx_hyp_audio.nx -- HYP arc H0: sovereign hypnotherapy session-audio bed. Spec: knowledge/specs/2026-06-10-hypnosis-practice-ladder.md Waveform source = the team's gated max-ulp=1 f64 sincos kernel (_pe_f64sincos.nx, CAPREG294): hyp_table_init generates the sine table AT RUNTIME from that kernel -- oracle-from-runtime, no stored waveform data. Per-sample synthesis is then INTEGER-ONLY (32-bit phase accumulator + table lerp), so rendering minutes of stereo audio costs well under a second -- slow is a bug. Frequencies cross the API as integer milli-hertz; envelope gains as permil rows (dur_ms, gain_start, gain_end) -- pacing patterns (e.g. 4-7-8 relaxation breathing) are DATA tables the caller owns, never code here. DEBT (named in spec): the 44-byte RIFF/WAVE header below duplicates nx_wav.nx, because nx_wav imports nx_syscalls_x86_64.nx whose sys_* definitions collide with the nx_syscalls.nx lane the f64 stack lives on. Retire this duplication when the syscall modules unify. genealogy_id: rfc_riff_1991 + nishi_wav_writer_q10 + _pe_f64sincos license_tier: ORIGINAL

dependencies 4 imports · 0 importers

nx_syscalls.nx nx_f64.nx nx_f64_cvt.nx _pe_f64sincos.nx nx_hyp_audio.nx

imports: nx_syscalls.nxnx_f64.nxnx_f64_cvt.nx_pe_f64sincos.nx

imported by: nobody (leaf or entry point)

structs

none

consts

28const HYP_WAV_OK: i64 = 1
29const HYP_WAV_OPEN_FAIL: i64 = 2
30const HYP_WAV_WRITE_FAIL: i64 = 3
31const HYP_WAV_BAD_PARAMS: i64 = 4
33const HYP_TAB_BITS: i64 = 12
34const HYP_TAB_N: i64 = 4096 // = 1 << HYP_TAB_BITS, full sine cycle
35const HYP_PHASE_BITS: i64 = 32 // phase accumulator width
36const HYP_PEAK: i64 = 32767 // int16 full scale
37const HYP_GAIN_DENOM: i64 = 1000 // envelope gains are permil
38const HYP_MHZ_DENOM: i64 = 1000 // frequencies are milli-hertz
39const HYP_WAV_HEADER_BYTES: i64 = 44
42const HYP_TWO_PI_F64: i64 = 0x401921FB54442D18

functions

48func hyp_table_init(tab: *i64) -> i64
62func hyp_phase_step(freq_mhz: i64, sample_rate_hz: i64) -> i64
called by 1: hyp_session_bed
70func hyp_tone_fill(buf: *i64, n: i64, stride: i64, off: i64, tab: *i64,
called by 1: hyp_session_bed
94func hyp_env_apply(buf: *i64, n: i64, stride: i64, off: i64,
called by 1: hyp_session_bed
121func _hw_le32(buf: *u8, off: i64, v: i64) -> i64
129func _hw_le16(buf: *u8, off: i64, v: i64) -> i64
137func hyp_wav_build_header(header: *u8, sample_rate_hz: i64, channels: i64,
called by 1: hyp_wav_write calls 2: _hw_le32_hw_le16
162func hyp_wav_write(path: *u8, sample_rate_hz: i64, channels: i64,
203func hyp_session_bed(path: *u8, sample_rate_hz: i64, dur_ms: i64,