code wiki / _hdl_build / nx_hyp_audio.nx
nx_hyp_audio.nx
buildroot/runtime/_hdl_build/nx_hyp_audio.nx
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
imports: nx_syscalls.nxnx_f64.nxnx_f64_cvt.nx_pe_f64sincos.nx
imported by: nobody (leaf or entry point)
structs
| none |
consts
| 28 | const HYP_WAV_OK: i64 = 1 |
| 29 | const HYP_WAV_OPEN_FAIL: i64 = 2 |
| 30 | const HYP_WAV_WRITE_FAIL: i64 = 3 |
| 31 | const HYP_WAV_BAD_PARAMS: i64 = 4 |
| 33 | const HYP_TAB_BITS: i64 = 12 |
| 34 | const HYP_TAB_N: i64 = 4096 // = 1 << HYP_TAB_BITS, full sine cycle |
| 35 | const HYP_PHASE_BITS: i64 = 32 // phase accumulator width |
| 36 | const HYP_PEAK: i64 = 32767 // int16 full scale |
| 37 | const HYP_GAIN_DENOM: i64 = 1000 // envelope gains are permil |
| 38 | const HYP_MHZ_DENOM: i64 = 1000 // frequencies are milli-hertz |
| 39 | const HYP_WAV_HEADER_BYTES: i64 = 44 |
| 42 | const HYP_TWO_PI_F64: i64 = 0x401921FB54442D18 |
functions
| 48 | func hyp_table_init(tab: *i64) -> i64 |
| 62 | func hyp_phase_step(freq_mhz: i64, sample_rate_hz: i64) -> i64 called by 1: hyp_session_bed |
| 70 | func hyp_tone_fill(buf: *i64, n: i64, stride: i64, off: i64, tab: *i64, called by 1: hyp_session_bed |
| 94 | func hyp_env_apply(buf: *i64, n: i64, stride: i64, off: i64, called by 1: hyp_session_bed |
| 121 | func _hw_le32(buf: *u8, off: i64, v: i64) -> i64 called by 1: hyp_wav_build_header |
| 129 | func _hw_le16(buf: *u8, off: i64, v: i64) -> i64 called by 1: hyp_wav_build_header |
| 137 | func hyp_wav_build_header(header: *u8, sample_rate_hz: i64, channels: i64, |
| 162 | func hyp_wav_write(path: *u8, sample_rate_hz: i64, channels: i64, |
| 203 | func hyp_session_bed(path: *u8, sample_rate_hz: i64, dur_ms: i64, |