code wiki / (root) / nx_bfsk.nx

nx_bfsk.nx

buildroot/runtime/nx_bfsk.nx

6186 B162 linesdepth 3pulls 3 transitivereach 0 importersview sourcekind orphan library
docsdependenciesstructsconstsfunctions

about

nx_bfsk.nx -- Binary Frequency Shift Keying modem. Apparatus substrate piece between the codec layer (bytes) and the radio layer (samples). Integer-only, Q10 phase, square-wave reference signals for fully-bits-up correlator demodulation. Doctrinal stance: this is the primitive that lets NishiVoice frames modulate onto an HF carrier driving a ground dipole, or onto a UHF carrier driving a chirp-spread-spectrum mesh. No external DSP library; the modulator IS the math; the demod IS the math. Math (public domain since Hartley 1928): bit 0 -> N samples of a square wave at frequency f0 bit 1 -> N samples of a square wave at frequency f1 demod -> correlate received samples against reference square wave at f0 and f1; pick whichever correlation is larger. Phase accumulator is Q10 (1024 units per period), so phase_inc_q10 for frequency f at sample rate fs = round(f * 1024 / fs). At fs= 8000 and f0=1200, phase_inc_0 = 154; at f1=2200, phase_inc_1=282. genealogy_id: hartley_1928_modulation + bell_202_1962_fsk_audio + nx_voice_codec_v1_q10 lineage_id: nishi_bfsk_q10

dependencies 1 imports · 0 importers

nx_syscalls_x86_64.nx nx_bfsk.nx

imports: nx_syscalls_x86_64.nx

imported by: nobody (leaf or entry point)

structs

none

consts

34const NX_BFSK_VERDICT_UNKNOWN: i64 = 0
35const NX_BFSK_VERDICT_OK: i64 = 1
36const NX_BFSK_VERDICT_BUF_TOO_SMALL: i64 = 2
37const NX_BFSK_VERDICT_BAD_PARAMS: i64 = 3
38const NX_BFSK_VERDICT_SNR_LOW: i64 = 4 // demod ran but correlation margin too small
39const NX_BFSK_VERDICT_N: i64 = 5
41const NX_BFSK_PHASE_PERIOD: i64 = 1024
42const NX_BFSK_PHASE_HALF: i64 = 512
43const NX_BFSK_AMPLITUDE: i64 = 32767 // int16 peak

functions

47func nx_bfsk_phase_inc(f_hz: i64, fs_hz: i64) -> i64
57func _ref_sign(i: i64, phase_inc: i64) -> i64
67func nx_bfsk_modulate(
calls 1: _ref_sign
106func nx_bfsk_demodulate(
calls 1: _ref_sign
158func nx_bfsk_verdict_is_valid(v: i64) -> i64