rtl433  UNKNOWN
RTL-433 utility
baseband.h File Reference

Various functions for baseband sample processing. More...

Go to the source code of this file.

Data Structures

struct  filter_state
 Filter state buffer. More...
 
struct  demodfm_state
 FM_Demod state buffer. More...
 

Typedefs

typedef struct filter_state filter_state_t
 Filter state buffer. More...
 
typedef struct demodfm_state demodfm_state_t
 FM_Demod state buffer. More...
 

Functions

void envelope_detect (uint8_t const *iq_buf, uint16_t *y_buf, uint32_t len)
 This will give a noisy envelope of OOK/ASK signals. More...
 
void envelope_detect_nolut (uint8_t const *iq_buf, uint16_t *y_buf, uint32_t len)
 This will give a noisy envelope of OOK/ASK signals. More...
 
void magnitude_est_cu8 (uint8_t const *iq_buf, uint16_t *y_buf, uint32_t len)
 122/128, 51/128 Magnitude Estimator for CU8 (SIMD has min/max). More...
 
void magnitude_true_cu8 (uint8_t const *iq_buf, uint16_t *y_buf, uint32_t len)
 True Magnitude for CU8 (sqrt can SIMD but float is slow). More...
 
void magnitude_est_cs16 (int16_t const *iq_buf, uint16_t *y_buf, uint32_t len)
 122/128, 51/128 Magnitude Estimator for CS16 (SIMD has min/max). More...
 
void magnitude_true_cs16 (int16_t const *iq_buf, uint16_t *y_buf, uint32_t len)
 True Magnitude for CS16 (sqrt can SIMD but float is slow). More...
 
void baseband_low_pass_filter (uint16_t const *x_buf, int16_t *y_buf, uint32_t len, filter_state_t *state)
 Lowpass filter. More...
 
void baseband_demod_FM (uint8_t const *x_buf, int16_t *y_buf, unsigned long num_samples, demodfm_state_t *state)
 FM demodulator. More...
 
void baseband_demod_FM_cs16 (int16_t const *x_buf, int16_t *y_buf, unsigned long num_samples, demodfm_state_t *state)
 For evaluation. More...
 
void baseband_init (void)
 Initialize tables and constants. More...
 

Detailed Description

Various functions for baseband sample processing.

Copyright (C) 2012 by Benjamin Larsson benja.nosp@m.min@.nosp@m.south.nosp@m.pole.nosp@m..se Copyright (C) 2015 Tommy Vestermark

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

Typedef Documentation

◆ demodfm_state_t

FM_Demod state buffer.

◆ filter_state_t

typedef struct filter_state filter_state_t

Filter state buffer.

Function Documentation

◆ baseband_demod_FM()

void baseband_demod_FM ( uint8_t const *  x_buf,
int16_t y_buf,
unsigned long  num_samples,
demodfm_state_t state 
)

FM demodulator.

Function is stateful

Parameters
x_bufinput samples (I/Q samples in interleaved uint8)
[out]y_bufoutput from FM demodulator
lennumber of samples to process
[in,out]stateState to store between chunk processing

[b,a] = butter(1, 0.1) -> 3x tau (95%) ~10 samples

[b,a] = butter(1, 0.2) -> 3x tau (95%) ~5 samples

References atan2_int16(), demodfm_state::bi, demodfm_state::br, demodfm_state::xlp, and demodfm_state::ylp.

Referenced by sdr_callback().

◆ baseband_demod_FM_cs16()

void baseband_demod_FM_cs16 ( int16_t const *  x_buf,
int16_t y_buf,
unsigned long  num_samples,
demodfm_state_t state 
)

For evaluation.

For evaluation.

[b,a] = butter(1, 0.1) -> 3x tau (95%) ~10 samples

[b,a] = butter(1, 0.2) -> 3x tau (95%) ~5 samples

References atan2_int32(), demodfm_state::bi, demodfm_state::br, demodfm_state::xlp, and demodfm_state::ylp.

Referenced by sdr_callback().

◆ baseband_init()

void baseband_init ( void  )

Initialize tables and constants.

Should be called once at startup.

References calc_squares().

Referenced by main().

◆ baseband_low_pass_filter()

void baseband_low_pass_filter ( uint16_t const *  x_buf,
int16_t y_buf,
uint32_t  len,
filter_state_t state 
)

Lowpass filter.

Function is stateful

Parameters
x_bufinput samples to be filtered
[out]y_bufoutput from filter
lennumber of samples to process
[in,out]stateState to store between chunk processing

Lowpass filter.

[b,a] = butter(1, Wc) # low pass filter with cutoff pi*Wc radians Q1.15*Q15.0 = Q16.15 Q16.15>>1 = Q15.14 Q15.14 + Q15.14 + Q15.14 could possibly overflow to 17.14 but the b coeffs are small so it wont happen Q15.14>>14 = Q15.0 /

[b,a] = butter(1, 0.01) -> 3x tau (95%) ~100 samples

[b,a] = butter(1, 0.05) -> 3x tau (95%) ~20 samples

References filter_state::x, and filter_state::y.

Referenced by sdr_callback().

◆ envelope_detect()

void envelope_detect ( uint8_t const *  iq_buf,
uint16_t y_buf,
uint32_t  len 
)

This will give a noisy envelope of OOK/ASK signals.

Subtract the bias (-128) and get an envelope estimation (absolute squared)

Parameters
iq_bufinput samples (I/Q samples in interleaved uint8)
[out]y_bufoutput
lennumber of samples to process

Subtract the bias (-128) and get an envelope estimation The output will be written in the input buffer

Returns
pointer to the input buffer

References scaled_squares.

Referenced by sdr_callback().

◆ envelope_detect_nolut()

void envelope_detect_nolut ( uint8_t const *  iq_buf,
uint16_t y_buf,
uint32_t  len 
)

This will give a noisy envelope of OOK/ASK signals.

Subtracts the bias (-128) and calculates the norm (scaled by 16384). Using a LUT is slower for O1 and above.

◆ magnitude_est_cs16()

void magnitude_est_cs16 ( int16_t const *  iq_buf,
uint16_t y_buf,
uint32_t  len 
)

122/128, 51/128 Magnitude Estimator for CS16 (SIMD has min/max).

Referenced by sdr_callback().

◆ magnitude_est_cu8()

void magnitude_est_cu8 ( uint8_t const *  iq_buf,
uint16_t y_buf,
uint32_t  len 
)

122/128, 51/128 Magnitude Estimator for CU8 (SIMD has min/max).

Note that magnitude emphasizes quiet signals / deemphasizes loud signals.

◆ magnitude_true_cs16()

void magnitude_true_cs16 ( int16_t const *  iq_buf,
uint16_t y_buf,
uint32_t  len 
)

True Magnitude for CS16 (sqrt can SIMD but float is slow).

◆ magnitude_true_cu8()

void magnitude_true_cu8 ( uint8_t const *  iq_buf,
uint16_t y_buf,
uint32_t  len 
)

True Magnitude for CU8 (sqrt can SIMD but float is slow).