esp-sdr-zephyr
Raw I/Q receive and transmit on the ESP32-S3/C6 Wi-Fi radio, for Zephyr
Loading...
Searching...
No Matches
Signal processing helpers

The turn constant, windows, sinc, FFT and whole-cycle tones, header only and free of Zephyr (esp_sdr_dsp.h). More...

Macros

#define ESP_SDR_TAU   6.28318530717958647692
#define ESP_SDR_TAU_F   6.28318530717958647692f

Enumerations

enum  esp_sdr_window {
  ESP_SDR_WINDOW_HAMMING , ESP_SDR_WINDOW_HANN , ESP_SDR_WINDOW_BLACKMAN , ESP_SDR_WINDOW_RECT ,
  ESP_SDR_WINDOW_BLACKMAN_HARRIS
}

Functions

static float esp_sdr_window (enum esp_sdr_window kind, uint32_t k, uint32_t span)
 One window coefficient.
static float esp_sdr_sincf (float x)
 Normalized sinc.
static double esp_sdr_sinc (double x)
 Normalized sinc in double precision (host tools, filter design).
static float esp_sdr_bessel_i0f (float x)
 Modified Bessel function of the first kind, order 0, for Kaiser windows.
static float esp_sdr_kaiser_beta (float db)
 Kaiser's beta for a stop band attenuation.
static void esp_sdr_fft_twiddles (float *tw_cos, float *tw_sin, uint32_t n)
 Twiddle factors for esp_sdr_fft().
static void esp_sdr_fft (float *re, float *im, uint32_t n, const float *tw_cos, const float *tw_sin, uint32_t tw_n)
 Forward FFT in place, radix 2, output in natural order (DC first).
static size_t esp_sdr_tone_period (double hz, double fs, size_t n_min, size_t n_max, long *cycles)
 The period of a seamless tone loop.
static double esp_sdr_tone_phase (long cycles, size_t k, size_t n)
 Phase of one sample of a tone period.

Detailed Description

The turn constant, windows, sinc, FFT and whole-cycle tones, header only and free of Zephyr (esp_sdr_dsp.h).

Macro Definition Documentation

◆ ESP_SDR_TAU

#define ESP_SDR_TAU   6.28318530717958647692

Radians per turn; pi is ESP_SDR_TAU / 2.

◆ ESP_SDR_TAU_F

#define ESP_SDR_TAU_F   6.28318530717958647692f

ESP_SDR_TAU as a float.

Enumeration Type Documentation

◆ esp_sdr_window

Window shapes, in the order of gnuradio.fft.window's kinds.

Enumerator
ESP_SDR_WINDOW_HAMMING 

0.54 - 0.46 cos.

ESP_SDR_WINDOW_HANN 

0.5 - 0.5 cos.

ESP_SDR_WINDOW_BLACKMAN 

0.42 - 0.5 cos + 0.08 cos 2.

ESP_SDR_WINDOW_RECT 

All ones.

ESP_SDR_WINDOW_BLACKMAN_HARRIS 

Four-term Blackman-Harris.

Function Documentation

◆ esp_sdr_bessel_i0f()

float esp_sdr_bessel_i0f ( float x)
inlinestatic

Modified Bessel function of the first kind, order 0, for Kaiser windows.

The power series, stopped once a term no longer changes a float sum (the window betas in use need some 20 terms).

Parameters
xArgument.
Returns
I0(x).

◆ esp_sdr_fft()

void esp_sdr_fft ( float * re,
float * im,
uint32_t n,
const float * tw_cos,
const float * tw_sin,
uint32_t tw_n )
inlinestatic

Forward FFT in place, radix 2, output in natural order (DC first).

Parameters
reReal parts, n entries.
imImaginary parts, n entries.
nPoints, a power of two up to tw_n.
tw_cosTwiddles of esp_sdr_fft_twiddles() for tw_n.
tw_sinTwiddles of esp_sdr_fft_twiddles() for tw_n.
tw_nThe tables' transform size.

◆ esp_sdr_fft_twiddles()

void esp_sdr_fft_twiddles ( float * tw_cos,
float * tw_sin,
uint32_t n )
inlinestatic

Twiddle factors for esp_sdr_fft().

Parameters
tw_cosOut: cos(-tau k / n) for k below n / 2.
tw_sinOut: sin(-tau k / n) for k below n / 2.
nThe largest transform the tables serve, a power of two.

◆ esp_sdr_kaiser_beta()

float esp_sdr_kaiser_beta ( float db)
inlinestatic

Kaiser's beta for a stop band attenuation.

A Kaiser window coefficient is I0(beta sqrt(1 - r^2)) / I0(beta), r from -1 to 1 over the window (esp_sdr_bessel_i0f()).

Parameters
dbStop band attenuation, dB.
Returns
beta (0 below 21 dB: a rectangular window).

◆ esp_sdr_sinc()

double esp_sdr_sinc ( double x)
inlinestatic

Normalized sinc in double precision (host tools, filter design).

Parameters
xArgument.
Returns
sin(pi x) / (pi x), 1 near 0.

◆ esp_sdr_sincf()

float esp_sdr_sincf ( float x)
inlinestatic

Normalized sinc.

Parameters
xArgument.
Returns
sin(pi x) / (pi x), 1 near 0.

◆ esp_sdr_tone_period()

size_t esp_sdr_tone_period ( double hz,
double fs,
size_t n_min,
size_t n_max,
long * cycles )
inlinestatic

The period of a seamless tone loop.

Searches the lengths from n_max down to n_min for the one whose whole number of cycles comes closest to hz, and stops at the first within 1 Hz.

Parameters
hzTone frequency, Hz, either sign.
fsSample rate, Hz.
n_minShortest period, at least 1.
n_maxLongest period, at least n_min.
cyclesOut: whole cycles in the period (negative for negative hz).
Returns
The period length in samples.

◆ esp_sdr_tone_phase()

double esp_sdr_tone_phase ( long cycles,
size_t k,
size_t n )
inlinestatic

Phase of one sample of a tone period.

Parameters
cyclesWhole cycles in the period, from esp_sdr_tone_period().
kSample index.
nPeriod length.
Returns
The phase of sample k in radians, 0 to tau, reduced in turns first so that long periods keep their precision.

◆ esp_sdr_window()

float esp_sdr_window ( enum esp_sdr_window kind,
uint32_t k,
uint32_t span )
inlinestatic

One window coefficient.

Parameters
kindWindow shape.
kIndex, 0 to span.
spanThe index of the window's far end: n - 1 for a symmetric window of n coefficients (filter design), n for a periodic one (spectra).
Returns
The coefficient at k.