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

Olivia and Contestia demodulator (compatible with fldigi): the PCM audio data is written to the decoder and the decoded characters are written to the output. The input can be 8, 16 or 32 bit signed samples with any number of channels (only OliviaConfig::channel is evaluated). More...

#include <OliviaDecoder.h>

Inheritance diagram for tinymodem::OliviaDecoder:
Collaboration diagram for tinymodem::OliviaDecoder:

Public Member Functions

 OliviaDecoder ()=default
 OliviaDecoder (Print &out)
OliviaConfig defaultConfig ()
 Provides a default configuration: olivia-32-1000.
void setAudioInfo (audio_tools::AudioInfo info) override
 Defines the format of the input audio data.
audio_tools::AudioInfo audioInfo () override
bool begin (OliviaConfig config)
 Starts the processing with the indicated configuration.
bool begin () override
void end () override
 Processes the remaining samples and reports the end of the carrier.
void flush () override
 Processes the remaining samples (e.g. at the end of the input).
size_t write (const uint8_t *data, size_t len) override
 Provide PCM data to the decoder.
bool isCarrier () override
 true while a transmission is received
bool isFinished () override
 true if the decoding was stopped (rx_one)
float signalToNoise ()
 Signal to noise ratio of the synchronizer.
float frequencyOffset ()
 Frequency offset of the received signal in Hz.
OliviaConfig & config ()
 The configuration which was provided in begin().
 operator bool () override
Public Member Functions inherited from tinymodem::ModemDecoder
void setStatusOutput (Print &out)
 Defines the output for the ### CARRIER / ### NOCARRIER messages.
void setQuiet (bool quiet)
 Suppresses the status messages.
const char * mime () override

Protected Member Functions

void resetState ()
void resetSync ()
 Forgets the timing and frequency of the last transmission.
float noise ()
 uniform random value in the range -0.5 to 0.5
void addSample8k (float x)
void processSlice ()
 FFT over the last symbol_len samples and decoding of all offsets.
void softDecode (const float *tone_energy, int8_t *out)
 Soft bits of a symbol from the tone energies (like fldigi).
int repeatedSymbols (const int8_t *block)
 Number of symbols which are equal to the previous symbol (hard decision).
void linearize (const int8_t *buffer, int8_t *block)
 Copies the circular soft bit buffer: the oldest symbol first.
void evaluateBlock ()
 Provides the best block if the signal to noise ratio is sufficient.
void outputChar (uint8_t ch)
void startOfCarrier ()
void endOfCarrier ()
Protected Member Functions inherited from tinymodem::ModemDecoder
void status (const char *fmt,...)

Protected Attributes

OliviaConfig cfg
bool is_active = false
bool is_finished = false
PcmInput input
SampleRateConverter converter
OliviaCodec codec
SimpleFFT fft
uint32_t noise_seed = 1
int bits = 5
int tones = 32
int block_len = 64
int symbol_len = 512
int margin = 8
int offsets = 17
int phases = 128
int first_bin = 0
int width = 0
audio_tools::Vector< float > samples
audio_tools::Vector< float > window
audio_tools::Vector< float > fft_re
audio_tools::Vector< float > fft_im
audio_tools::Vector< float > energy
int sample_pos = 0
int slice_countdown = 0
int slice = 0
audio_tools::Vector< int8_t > soft
int soft_pos = 0
audio_tools::Vector< float > sync_signal
audio_tools::Vector< float > sync_noise
audio_tools::Vector< uint64_t > blocks
audio_tools::Vector< float > block_snr
int phase = 0
float best_signal = 0
float best_noise = 0
int best_phase = 0
int best_offset = 0
float snr = 0
bool carrier = false
bool escape = false
unsigned ndata = 0
unsigned nblocks = 0
float snr_total = 0
Protected Attributes inherited from tinymodem::ModemDecoder
Print * p_status = nullptr
bool is_quiet = false

Static Protected Attributes

static constexpr int SLICES = 2
static constexpr float BLOCK_THRESHOLD = 1.0f
 minimum signal to noise ratio of a block relative to the sync threshold

Detailed Description

Olivia and Contestia demodulator (compatible with fldigi): the PCM audio data is written to the decoder and the decoded characters are written to the output. The input can be 8, 16 or 32 bit signed samples with any number of channels (only OliviaConfig::channel is evaluated).

The input is converted to 8000 Hz. Twice per symbol the tone energies are measured with an FFT and converted to soft bits for each possible frequency offset (+/- OliviaConfig::sync_margin FFT bins). For each time slice and frequency offset the last FEC block is decoded after every symbol. The synchronizer integrates the signal and noise of the decoded blocks over OliviaConfig::sync_integration blocks and selects the block timing and the frequency offset with the strongest signal. A block is provided if its signal to noise ratio is above OliviaConfig::sync_threshold. The idle character 0 is not provided.

Memory: about (2 * sync_margin + 1) * 3 * symbolsPerBlock() * (bits per symbol + 16) bytes plus 20 * symbolLen() bytes, e.g. 30 kB for olivia-32-1000.

Constructor & Destructor Documentation

◆ OliviaDecoder() [1/2]

tinymodem::OliviaDecoder::OliviaDecoder ( )
default

◆ OliviaDecoder() [2/2]

tinymodem::OliviaDecoder::OliviaDecoder ( Print & out)
inline

Member Function Documentation

◆ addSample8k()

void tinymodem::OliviaDecoder::addSample8k ( float x)
inlineprotected

◆ audioInfo()

audio_tools::AudioInfo tinymodem::OliviaDecoder::audioInfo ( )
inlineoverride

◆ begin() [1/2]

bool tinymodem::OliviaDecoder::begin ( )
inlineoverride

◆ begin() [2/2]

bool tinymodem::OliviaDecoder::begin ( OliviaConfig config)
inline

Starts the processing with the indicated configuration.

◆ config()

OliviaConfig & tinymodem::OliviaDecoder::config ( )
inline

The configuration which was provided in begin().

◆ defaultConfig()

OliviaConfig tinymodem::OliviaDecoder::defaultConfig ( )
inline

Provides a default configuration: olivia-32-1000.

◆ end()

void tinymodem::OliviaDecoder::end ( )
inlineoverride

Processes the remaining samples and reports the end of the carrier.

◆ endOfCarrier()

void tinymodem::OliviaDecoder::endOfCarrier ( )
inlineprotected

◆ evaluateBlock()

void tinymodem::OliviaDecoder::evaluateBlock ( )
inlineprotected

Provides the best block if the signal to noise ratio is sufficient.

◆ flush()

void tinymodem::OliviaDecoder::flush ( )
inlineoverridevirtual

Processes the remaining samples (e.g. at the end of the input).

Implements tinymodem::ModemDecoder.

◆ frequencyOffset()

float tinymodem::OliviaDecoder::frequencyOffset ( )
inline

Frequency offset of the received signal in Hz.

◆ isCarrier()

bool tinymodem::OliviaDecoder::isCarrier ( )
inlineoverridevirtual

true while a transmission is received

Implements tinymodem::ModemDecoder.

◆ isFinished()

bool tinymodem::OliviaDecoder::isFinished ( )
inlineoverridevirtual

true if the decoding was stopped (rx_one)

Implements tinymodem::ModemDecoder.

◆ linearize()

void tinymodem::OliviaDecoder::linearize ( const int8_t * buffer,
int8_t * block )
inlineprotected

Copies the circular soft bit buffer: the oldest symbol first.

◆ noise()

float tinymodem::OliviaDecoder::noise ( )
inlineprotected

uniform random value in the range -0.5 to 0.5

◆ operator bool()

tinymodem::OliviaDecoder::operator bool ( )
inlineoverride

◆ outputChar()

void tinymodem::OliviaDecoder::outputChar ( uint8_t ch)
inlineprotected

◆ processSlice()

void tinymodem::OliviaDecoder::processSlice ( )
inlineprotected

FFT over the last symbol_len samples and decoding of all offsets.

◆ repeatedSymbols()

int tinymodem::OliviaDecoder::repeatedSymbols ( const int8_t * block)
inlineprotected

Number of symbols which are equal to the previous symbol (hard decision).

◆ resetState()

void tinymodem::OliviaDecoder::resetState ( )
inlineprotected

◆ resetSync()

void tinymodem::OliviaDecoder::resetSync ( )
inlineprotected

Forgets the timing and frequency of the last transmission.

◆ setAudioInfo()

void tinymodem::OliviaDecoder::setAudioInfo ( audio_tools::AudioInfo info)
inlineoverride

Defines the format of the input audio data.

◆ signalToNoise()

float tinymodem::OliviaDecoder::signalToNoise ( )
inline

Signal to noise ratio of the synchronizer.

◆ softDecode()

void tinymodem::OliviaDecoder::softDecode ( const float * tone_energy,
int8_t * out )
inlineprotected

Soft bits of a symbol from the tone energies (like fldigi).

◆ startOfCarrier()

void tinymodem::OliviaDecoder::startOfCarrier ( )
inlineprotected

◆ write()

size_t tinymodem::OliviaDecoder::write ( const uint8_t * data,
size_t len )
inlineoverride

Provide PCM data to the decoder.

Member Data Documentation

◆ best_noise

float tinymodem::OliviaDecoder::best_noise = 0
protected

◆ best_offset

int tinymodem::OliviaDecoder::best_offset = 0
protected

◆ best_phase

int tinymodem::OliviaDecoder::best_phase = 0
protected

◆ best_signal

float tinymodem::OliviaDecoder::best_signal = 0
protected

◆ bits

int tinymodem::OliviaDecoder::bits = 5
protected

◆ block_len

int tinymodem::OliviaDecoder::block_len = 64
protected

◆ block_snr

audio_tools::Vector<float> tinymodem::OliviaDecoder::block_snr
protected

◆ BLOCK_THRESHOLD

float tinymodem::OliviaDecoder::BLOCK_THRESHOLD = 1.0f
staticconstexprprotected

minimum signal to noise ratio of a block relative to the sync threshold

◆ blocks

audio_tools::Vector<uint64_t> tinymodem::OliviaDecoder::blocks
protected

◆ carrier

bool tinymodem::OliviaDecoder::carrier = false
protected

◆ cfg

OliviaConfig tinymodem::OliviaDecoder::cfg
protected

◆ codec

OliviaCodec tinymodem::OliviaDecoder::codec
protected

◆ converter

SampleRateConverter tinymodem::OliviaDecoder::converter
protected

◆ energy

audio_tools::Vector<float> tinymodem::OliviaDecoder::energy
protected

◆ escape

bool tinymodem::OliviaDecoder::escape = false
protected

◆ fft

SimpleFFT tinymodem::OliviaDecoder::fft
protected

◆ fft_im

audio_tools::Vector<float> tinymodem::OliviaDecoder::fft_im
protected

◆ fft_re

audio_tools::Vector<float> tinymodem::OliviaDecoder::fft_re
protected

◆ first_bin

int tinymodem::OliviaDecoder::first_bin = 0
protected

◆ input

PcmInput tinymodem::OliviaDecoder::input
protected

◆ is_active

bool tinymodem::OliviaDecoder::is_active = false
protected

◆ is_finished

bool tinymodem::OliviaDecoder::is_finished = false
protected

◆ margin

int tinymodem::OliviaDecoder::margin = 8
protected

◆ nblocks

unsigned tinymodem::OliviaDecoder::nblocks = 0
protected

◆ ndata

unsigned tinymodem::OliviaDecoder::ndata = 0
protected

◆ noise_seed

uint32_t tinymodem::OliviaDecoder::noise_seed = 1
protected

◆ offsets

int tinymodem::OliviaDecoder::offsets = 17
protected

◆ phase

int tinymodem::OliviaDecoder::phase = 0
protected

◆ phases

int tinymodem::OliviaDecoder::phases = 128
protected

◆ sample_pos

int tinymodem::OliviaDecoder::sample_pos = 0
protected

◆ samples

audio_tools::Vector<float> tinymodem::OliviaDecoder::samples
protected

◆ slice

int tinymodem::OliviaDecoder::slice = 0
protected

◆ slice_countdown

int tinymodem::OliviaDecoder::slice_countdown = 0
protected

◆ SLICES

int tinymodem::OliviaDecoder::SLICES = 2
staticconstexprprotected

◆ snr

float tinymodem::OliviaDecoder::snr = 0
protected

◆ snr_total

float tinymodem::OliviaDecoder::snr_total = 0
protected

◆ soft

audio_tools::Vector<int8_t> tinymodem::OliviaDecoder::soft
protected

◆ soft_pos

int tinymodem::OliviaDecoder::soft_pos = 0
protected

◆ symbol_len

int tinymodem::OliviaDecoder::symbol_len = 512
protected

◆ sync_noise

audio_tools::Vector<float> tinymodem::OliviaDecoder::sync_noise
protected

◆ sync_signal

audio_tools::Vector<float> tinymodem::OliviaDecoder::sync_signal
protected

◆ tones

int tinymodem::OliviaDecoder::tones = 32
protected

◆ width

int tinymodem::OliviaDecoder::width = 0
protected

◆ window

audio_tools::Vector<float> tinymodem::OliviaDecoder::window
protected

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