code wiki / _hdl_build / nx_audio_binaural_beats.nx

nx_audio_binaural_beats.nx

buildroot/runtime/_hdl_build/nx_audio_binaural_beats.nx

4608 B88 linesdepth 3pulls 3 transitivereach 0 importersview sourcekind tooltopic audio
docsdependenciesstructsconstsfunctions

about

nx_audio_binaural_beats.nx -- binaural BEATS generator (operator 2026-06-23: s-class audio ecosystem + s-class self-hypnosis help). Two PURE SUSTAINED tones, one per ear at slightly different frequencies (L=200Hz, R=207Hz) -> the brain perceives a 7Hz THETA beat = a classic relaxation / self-hypnosis induction aid (the audio ecosystem powering hypnosis). Sustained sines via a 2nd-order resonator with r=1 (no decay); fade in/out to avoid clicks; our own RIFF writer. Sovereign, no float. license_tier: ORIGINAL expect_exit: 0

dependencies 1 imports · 0 importers

nx_audio_wav.nx nx_audio_binaural_beats.nx

imports: nx_audio_wav.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main bp bpn gen_tone cos_fp bqm bqm ↻ sin_fp bqm ↻ b_abs zero_cross wav_render_stereo wav_put_str wav_put_u32 wav_put_u16 wav_put_i16 wav_save sys_openat_wr sys_write sys_close

structs

none

consts

7const K_MAGIC_411774: i64 = 411774
9const OUTP: *u8 = "web_assets/ng_binaural_beats_theta.wav"
10const Q16: i64 = 65536
11const SR: i64 = 22050
12const NS: i64 = 88200 // 4.0 s
13const FBASE: i64 = 200 // left ear Hz
14const FBEAT: i64 = 7 // beat Hz -> right ear = 207 Hz (theta, relaxation)
15const AMP: i64 = 10000

functions

17func bp(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 }
called by 1: main
18func bpn(v: i64) -> i64
called by 1: main
26func b_abs(v: i64) -> i64 { if v<0 { return 0-v } return v }
called by 1: main
27func bqm(a: i64, b: i64) -> i64 { return (a*b)>>16 }
28func cos_fp(x: i64) -> i64 { let x2: i64=bqm(x,x); let x4: i64=bqm(x2,x2); return Q16 - (x2>>1) + (x4/24) }
called by 1: gen_tone calls 1: bqm
29func sin_fp(x: i64) -> i64 { let x2: i64=bqm(x,x); let x3: i64=bqm(x2,x); return x - (x3/6) }
called by 1: gen_tone calls 1: bqm
32func gen_tone(buf: *i64, f: i64) -> i64
called by 1: main calls 3: cos_fpbqmsin_fp
51func zero_cross(buf: *i64) -> i64
called by 1: main
57func main() -> i64