voice

package
v0.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 14, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package voice provides analog voice-privacy descramblers — the keyless / weak-key spectral schemes still found on RF voice channels. The core operation is full-band spectral inversion (the classic "frequency inverter" scrambler), which is its own inverse, so the same call both scrambles and descrambles.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BandEnergy

func BandEnergy(samples []float64, loFrac, hiFrac float64) float64

BandEnergy returns the energy of a real signal in the normalized frequency band [loFrac, hiFrac] of Nyquist (each in 0..1), via a direct DFT-bin sum. Useful for confirming an inversion moved energy from the low band to the high band (and for tests).

func BandInvert

func BandInvert(samples []float64, loFrac, hiFrac float64) []float64

BandInvert spectrally inverts a single normalized band [loFrac,hiFrac] of Nyquist. BandInvert(s,0,1) is full-band inversion (cf. SpectralInvert).

func DetectInversion

func DetectInversion(samples []float64, frameLen int) []bool

DetectInversion is a best-effort per-frame inversion detector for full-band rolling inverters: voiced speech concentrates energy in the lower half of the band, so a frame with more high-band than low-band energy is flagged as inverted. It is a heuristic sync aid, not exact recovery.

func RollingAuto

func RollingAuto(samples []float64, frameLen int) ([]float64, []bool)

RollingAuto detects full-band-inverted frames and undoes them, returning the descrambled signal and the per-frame flags it acted on.

func RollingInvert

func RollingInvert(samples []float64, frameLen int, splits []float64) []float64

RollingInvert applies a per-frame split-band inversion: frame i is inverted with splits[i % len(splits)]. Re-applying the same schedule descrambles a rolling/hopping inverter whose schedule is known. A split of 1.0 is a full-band inversion of that frame.

func SpectralInvert

func SpectralInvert(samples []float64) []float64

SpectralInvert inverts the spectrum of a real signal by multiplying every other sample by -1 (mixing with a Nyquist-rate carrier). This maps frequency f to fs/2 − f, which is exactly the full-band "frequency inverter" analog scramble. Applying it twice returns the original signal.

func SpectralInvertInt16

func SpectralInvertInt16(samples []int16) []int16

SpectralInvertInt16 is SpectralInvert over 16-bit PCM, clamping on the rare overflow at full scale.

func SplitBandInvert

func SplitBandInvert(samples []float64, split float64) []float64

SplitBandInvert inverts the low sub-band [0,split] and the high sub-band [split,1] independently — the classic split-band (variable-split) inverter. The two sub-bands are disjoint by construction, so it is its own inverse.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL