Skip to content

Feature/ainr dev - #452

Open
vis4573 wants to merge 3 commits into
drexjj:devfrom
vis4573:feature/ainr-dev
Open

Feature/ainr dev#452
vis4573 wants to merge 3 commits into
drexjj:devfrom
vis4573:feature/ainr-dev

Conversation

@vis4573

@vis4573 vis4573 commented Aug 13, 2026

Copy link
Copy Markdown

I've been experimenting with adding neural-network noise reduction (AINR) to the sBitx firmware — it uses Xiph.org's RNNoise, a small AI model trained on thousands of hours of speech, so instead of just filtering frequencies it actually recognizes what a human voice sounds like and mutes everything else.

Results on 40m SSB have been impressive — band hiss between words drops to near silence while the voice stays clean. Works alongside the existing DSP/ANR options (use one at a time).

Two on-screen controls: AINR (on/off, main screen next to REC) and strength/weak-signal tuning. Runs fine on the stock Pi, ~15ms latency, voice modes only (won't touch your FT8).

Code is on my fork of the drexjj 64-bit firmware if anyone wants to try:
github.com/vis4573/sbitx (branch: feature/ainr-dev)

Build with the usual ./build sbitx. Feedback welcome — especially reports on weak-signal behavior!
73, VU3UBP
vu3ubp@gmail.com

The spectral-subtraction DSP stage computed scaled_noise_threshold from
the THSHLD field but never used it: the reduction sigmoid used a
hardcoded midpoint of 0.5, so adjusting THSHLD had no audible effect at
any setting.

- src/sbitx.c: use scaled_noise_threshold as the sigmoid midpoint in the
  spectral-subtraction reduction factor.
- src/sbitx_gtk.c: rescale scaleNoiseThreshold() output from 0.001-0.01
  to 0.1-2.0. The old range was ~50x too small to shift the midpoint
  meaningfully against typical per-bin SNR values (SNR ~ 1.0 at the
  noise floor). New mapping: 0 = aggressive subtraction, 100 =
  conservative.

Verified numerically (reduction curve now spreads properly across the
slider range) and on-air on 40m SSB (THSHLD audibly changes subtraction
aggressiveness).
Adds a third selectable noise-reduction mode alongside DSP and ANR:
AINR, based on Xiph.org's RNNoise - a small GRU recurrent neural
network trained for real-time speech denoising. Unlike the statistical
DSP/ANR stages it classifies audio by learned speech structure
(harmonics, pitch continuity, envelope), letting it suppress noise
between words to near silence and handle non-stationary noise (static
crashes, clicks) that power-tracking methods miss.

User-facing:
- AINR toggle on the main screen (left of REC); console \ainr on|off.
- While ON, two tuning fields appear beside it: AINRS (0-100, default
  80) - strength as a wet/dry mix; AINRV (0-50, default 25) - how far
  suppression relaxes while speech is detected, protecting weak/fading
  syllables from being gated.
- Voice modes only; deliberately not applied in FT8/FT4/DIGITAL. Modem
  decoders always receive unprocessed audio (hook is after modem_rx).
- Note: remote/web audio receives AINR-processed audio (the stage runs
  before the remote audio queue), so remote listeners benefit too.

Implementation:
- rnnoise/: vendored xiph/rnnoise v0.1.1 (BSD-3-clause, COPYING
  included). This version embeds the trained model weights in source
  (no network fetch at build time) and its FFT symbols are prefixed
  rnn_fft_*, so no collision with ft8_lib's kiss_fft.
- src/sbitx_rnn.c/h: 96k<->48k conversion, ring-buffered reframing into
  480-sample frames, automatic input level normalization toward the
  model's trained operating range (results independent of IF gain
  setting), VAD-adaptive wet/dry mixing with fast-attack/slow-release
  smoothing, sample-aligned dry path. ~10-20 ms added latency.
- src/sbitx.c: rnn_enabled hook in the voice-mode post-processing path
  (after modem_rx, before RX EQ); state reset on toggle-off.
- src/sbitx_gtk.c: field definitions, periodic value pickup in
  check_plugin_controls, conditional AINRS/AINRV visibility.
- Makefile: rnnoise sources and include path; ./build sbitx unchanged.

Testing: CPU on a Pi 4 sBitx v3 stays under 20% across all four cores
with AINR active. Amplitude passthrough verified at exactly 1.0 for
tone content; ~23x noise suppression at full strength; suppression
quality verified independent of input level; VAD relax/recovery timing
verified (~200 ms). Parameters tuned from multiple on-air sessions on
40m SSB.
Plain-language and technical writeups as a new README section: what
AINR is, where the controls are, adjustable parameters (AINRS/AINRV)
with ranges, defaults, and tuning guidance.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant