TinyModem
Header-only software audio modem library
Loading...
Searching...
No Matches
tinymodem::FSKDemodulator Class Reference

FSK bit and frame analysis (port of minimodem's fsk.c). Instead of a full FFT we use the Goertzel algorithm from the AudioTools to determine the magnitude of the mark and space bands. The bands are defined like the FFT bins of minimodem, so the results are equivalent. More...

#include <FSKDemodulator.h>

Public Member Functions

bool begin (float sample_rate, float f_mark, float f_space, float filter_bw)
 Defines the tones and the filter bandwidth: returns false if invalid.
float findFrame (const float *samples, unsigned frame_nsamples, unsigned try_first_sample, unsigned try_max_nsamples, unsigned try_step_nsamples, float try_confidence_search_limit, const char *expect_bits_string, uint64_t *bits_outp, float *ampl_outp, unsigned *frame_start_outp)
int detectCarrier (const float *samples, unsigned nsamples, float min_mag_threshold)
void setTonesByBandShift (unsigned b_mark, int b_shift)
 Redefines the mark and space band.
unsigned fftSize ()
unsigned bandCount ()
float bandWidth ()
unsigned markBand ()
unsigned spaceBand ()

Protected Member Functions

float bandFrequency (unsigned band)
 center frequency of the FFT bin which corresponds to the band
bool setupDetector (audio_tools::GoertzelDetector &detector, unsigned band, unsigned nsamples)
float magnitude (audio_tools::GoertzelDetector &detector, const float *samples, unsigned nsamples)
 unscaled magnitude of the band over n samples
float bandMagnitude (const float *samples, unsigned nsamples, unsigned band)
void bitAnalyze (const float *samples, unsigned bit_nsamples, unsigned *bit_outp, float *bit_signal_mag_outp, float *bit_noise_mag_outp)
float frameAnalyze (const float *samples, float samples_per_bit, int n_bits, const char *expect_bits, uint64_t *bits_outp, float *ampl_outp)
 returns confidence value [0.0 to INFINITY]

Protected Attributes

float sample_rate = 0.0f
float f_mark = 0.0f
float f_space = 0.0f
float band_width = 0.0f
unsigned fftsize = 0
unsigned nbands = 0
unsigned b_mark = 0
unsigned b_space = 0
audio_tools::GoertzelDetector mark_detector
audio_tools::GoertzelDetector space_detector
unsigned detector_nsamples = 0

Static Protected Attributes

static constexpr int MAX_BITS = 72

Detailed Description

FSK bit and frame analysis (port of minimodem's fsk.c). Instead of a full FFT we use the Goertzel algorithm from the AudioTools to determine the magnitude of the mark and space bands. The bands are defined like the FFT bins of minimodem, so the results are equivalent.

Member Function Documentation

◆ bandCount()

unsigned tinymodem::FSKDemodulator::bandCount ( )
inline

◆ bandFrequency()

float tinymodem::FSKDemodulator::bandFrequency ( unsigned band)
inlineprotected

center frequency of the FFT bin which corresponds to the band

◆ bandMagnitude()

float tinymodem::FSKDemodulator::bandMagnitude ( const float * samples,
unsigned nsamples,
unsigned band )
inlineprotected

◆ bandWidth()

float tinymodem::FSKDemodulator::bandWidth ( )
inline

◆ begin()

bool tinymodem::FSKDemodulator::begin ( float sample_rate,
float f_mark,
float f_space,
float filter_bw )
inline

Defines the tones and the filter bandwidth: returns false if invalid.

◆ bitAnalyze()

void tinymodem::FSKDemodulator::bitAnalyze ( const float * samples,
unsigned bit_nsamples,
unsigned * bit_outp,
float * bit_signal_mag_outp,
float * bit_noise_mag_outp )
inlineprotected

◆ detectCarrier()

int tinymodem::FSKDemodulator::detectCarrier ( const float * samples,
unsigned nsamples,
float min_mag_threshold )
inline

Returns the band with the max magnitude or -1. Port of fsk_detect_carrier()

◆ fftSize()

unsigned tinymodem::FSKDemodulator::fftSize ( )
inline

◆ findFrame()

float tinymodem::FSKDemodulator::findFrame ( const float * samples,
unsigned frame_nsamples,
unsigned try_first_sample,
unsigned try_max_nsamples,
unsigned try_step_nsamples,
float try_confidence_search_limit,
const char * expect_bits_string,
uint64_t * bits_outp,
float * ampl_outp,
unsigned * frame_start_outp )
inline

Analyzes the expected bits starting at samples and returns the confidence: [0.0 to INFINITY]. Port of fsk_find_frame().

◆ frameAnalyze()

float tinymodem::FSKDemodulator::frameAnalyze ( const float * samples,
float samples_per_bit,
int n_bits,
const char * expect_bits,
uint64_t * bits_outp,
float * ampl_outp )
inlineprotected

returns confidence value [0.0 to INFINITY]

◆ magnitude()

float tinymodem::FSKDemodulator::magnitude ( audio_tools::GoertzelDetector & detector,
const float * samples,
unsigned nsamples )
inlineprotected

unscaled magnitude of the band over n samples

◆ markBand()

unsigned tinymodem::FSKDemodulator::markBand ( )
inline

◆ setTonesByBandShift()

void tinymodem::FSKDemodulator::setTonesByBandShift ( unsigned b_mark,
int b_shift )
inline

Redefines the mark and space band.

◆ setupDetector()

bool tinymodem::FSKDemodulator::setupDetector ( audio_tools::GoertzelDetector & detector,
unsigned band,
unsigned nsamples )
inlineprotected

◆ spaceBand()

unsigned tinymodem::FSKDemodulator::spaceBand ( )
inline

Member Data Documentation

◆ b_mark

unsigned tinymodem::FSKDemodulator::b_mark = 0
protected

◆ b_space

unsigned tinymodem::FSKDemodulator::b_space = 0
protected

◆ band_width

float tinymodem::FSKDemodulator::band_width = 0.0f
protected

◆ detector_nsamples

unsigned tinymodem::FSKDemodulator::detector_nsamples = 0
protected

◆ f_mark

float tinymodem::FSKDemodulator::f_mark = 0.0f
protected

◆ f_space

float tinymodem::FSKDemodulator::f_space = 0.0f
protected

◆ fftsize

unsigned tinymodem::FSKDemodulator::fftsize = 0
protected

◆ mark_detector

audio_tools::GoertzelDetector tinymodem::FSKDemodulator::mark_detector
protected

◆ MAX_BITS

int tinymodem::FSKDemodulator::MAX_BITS = 72
staticconstexprprotected

◆ nbands

unsigned tinymodem::FSKDemodulator::nbands = 0
protected

◆ sample_rate

float tinymodem::FSKDemodulator::sample_rate = 0.0f
protected

◆ space_detector

audio_tools::GoertzelDetector tinymodem::FSKDemodulator::space_detector
protected

The documentation for this class was generated from the following file: