rtlsdr

package
v0.3.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PPMToHz

func PPMToHz(ppm int, centerHz uint32) int64

PPMToHz returns the absolute-Hz offset implied by a PPM value at the given center frequency. Useful when reporting calibration results.

Types

type DCBlocker

type DCBlocker struct {
	// contains filtered or unexported fields
}

DCBlocker subtracts a slowly-tracked DC bias from a complex sample stream. Useful because RTL-SDR dongles park noticeable DC at the tuned center bin.

func NewDCBlocker

func NewDCBlocker(alpha float64) *DCBlocker

func (*DCBlocker) Process

func (d *DCBlocker) Process(in []complex64)

type IQBalancer

type IQBalancer struct {
	GainQ float32 // amplitude scale for Q
	Phase float32 // radians, applied to Q via Q' = Q*cos - I*sin
}

IQBalancer applies a single-coefficient IQ-imbalance correction (gain + phase) measured against a calibration tone. Coefficients are 1.0 and 0.0 by default (passthrough).

func (IQBalancer) Process

func (b IQBalancer) Process(in []complex64)

type IQImbalanceCorrector added in v0.2.7

type IQImbalanceCorrector struct {
	// contains filtered or unexported fields
}

IQImbalanceCorrector blindly estimates and removes the front-end I/Q imbalance from a streaming complex signal. It tracks the second-order moments of the *raw* input with a slow EMA, derives the correcting IQBalancer once a warmup has elapsed, and applies it in-place. Because the moments are always measured from the raw input (never the corrected output) there is no feedback loop, and a static hardware imbalance converges and stays. Off the hot path by default — opt-in (issue #402). Not safe for concurrent use.

func NewIQImbalanceCorrector added in v0.2.7

func NewIQImbalanceCorrector() *IQImbalanceCorrector

NewIQImbalanceCorrector returns a corrector with a slow moment EMA (~100k samples, ≈40 ms at 2.4 MSPS) and a short warmup before it starts correcting.

func (*IQImbalanceCorrector) Coefficients added in v0.2.7

func (c *IQImbalanceCorrector) Coefficients() (gainQ, phaseRad float32)

Coefficients returns the corrector's current GainQ and Phase (radians) — for surfacing the converged estimate in diagnostics.

func (*IQImbalanceCorrector) Process added in v0.2.7

func (c *IQImbalanceCorrector) Process(in []complex64)

Process updates the imbalance estimate from the raw input, then corrects the chunk in-place. During warmup it is a passthrough (GainQ=1, Phase=0).

type IQImbalanceStats added in v0.2.7

type IQImbalanceStats struct {
	// contains filtered or unexported fields
}

IQImbalanceStats accumulates the second-order moments of a complex stream — E[I²], E[Q²], E[I·Q] — and derives the front-end I/Q gain/phase imbalance from them. For a constant-envelope signal (FM / C4FM) the ideal baseband is circularly symmetric (E[I²] = E[Q²], E[I·Q] = 0), so any departure measures the receiver's I/Q imbalance directly. Used both as a replay diagnostic and as the estimator behind IQImbalanceCorrector (issue #402: an uncorrected RTL-SDR imbalance, worst at the on-channel DC the DDC sits on, is the leading explanation for the asymmetric demodulated eye).

func (*IQImbalanceStats) Balancer added in v0.2.7

func (s *IQImbalanceStats) Balancer() IQBalancer

Balancer returns the IQBalancer coefficients that correct the measured imbalance: GainQ equalizes the I/Q powers and Phase de-correlates I and Q (Q' = GainQ·Q·cosΦ − I·sinΦ ⇒ E[I·Q']=0, E[Q'²]=E[I²]). Identity when insufficient/degenerate data has been seen.

func (*IQImbalanceStats) Count added in v0.2.7

func (s *IQImbalanceStats) Count() uint64

Count returns the number of samples observed so far.

func (*IQImbalanceStats) GainImbalanceDB added in v0.2.7

func (s *IQImbalanceStats) GainImbalanceDB() float64

GainImbalanceDB is 10·log10(E[I²]/E[Q²]): the I-vs-Q power imbalance in dB (0 = balanced). Equivalently 20·log10(GainQ).

func (*IQImbalanceStats) ImageRejectionDB added in v0.2.7

func (s *IQImbalanceStats) ImageRejectionDB() float64

ImageRejectionDB approximates the front-end image-rejection ratio implied by the measured imbalance (higher is better; a clean front-end is ≳ 40 dB). The small-imbalance approximation image/signal ≈ (εgain² + φ²)/4.

func (*IQImbalanceStats) Observe added in v0.2.7

func (s *IQImbalanceStats) Observe(in []complex64)

Observe folds a chunk of raw IQ into the running moments.

func (*IQImbalanceStats) PhaseImbalanceDeg added in v0.2.7

func (s *IQImbalanceStats) PhaseImbalanceDeg() float64

PhaseImbalanceDeg is the I/Q quadrature error in degrees, from the normalized I·Q correlation (0 = perfect quadrature).

Directories

Path Synopsis
Package purego is the pure-Go RTL-SDR driver — the sdr.Device / sdr.Driver implementation that composes the platform USB transport (internal/sdr/rtlsdr/usb), the RTL2832U register layer (internal/sdr/rtlsdr/rtl2832u), and the per-chip tuner drivers (internal/sdr/rtlsdr/tuners).
Package purego is the pure-Go RTL-SDR driver — the sdr.Device / sdr.Driver implementation that composes the platform USB transport (internal/sdr/rtlsdr/usb), the RTL2832U register layer (internal/sdr/rtlsdr/rtl2832u), and the per-chip tuner drivers (internal/sdr/rtlsdr/tuners).
Package rtl2832u is the pure-Go register / I2C-bridge layer that sits between the platform USB transport (internal/sdr/rtlsdr/usb) and the per-tuner drivers.
Package rtl2832u is the pure-Go register / I2C-bridge layer that sits between the platform USB transport (internal/sdr/rtlsdr/usb) and the per-tuner drivers.
Package tuners houses the per-chip tuner drivers that sit between the RTL2832U register layer (internal/sdr/rtlsdr/rtl2832u) and the top-level [sdr.Device].
Package tuners houses the per-chip tuner drivers that sit between the RTL2832U register layer (internal/sdr/rtlsdr/rtl2832u) and the top-level [sdr.Device].
Package usb is the platform-abstraction layer that the pure-Go RTL-SDR driver speaks to.
Package usb is the platform-abstraction layer that the pure-Go RTL-SDR driver speaks to.

Jump to

Keyboard shortcuts

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