|
TinyModem
Header-only software audio modem library
|
Chirp spread spectrum demodulator (LoRa-like): the PCM audio data is written to the decoder and the payload of the received frames with a correct CRC is written to the output. The input can be 8, 16 or 32 bit signed samples with any number of channels (only CSSConfig::channel is evaluated). More...
#include <CSSDecoder.h>


Classes | |
| struct | Peak |
| Peak of a spectrum. More... | |
Public Member Functions | |
| CSSDecoder ()=default | |
| CSSDecoder (Print &out) | |
| CSSConfig | defaultConfig () |
| Provides a default configuration: css7 (SF 7, 1000 Hz). | |
| void | setAudioInfo (audio_tools::AudioInfo info) override |
| Defines the format of the input audio data. | |
| audio_tools::AudioInfo | audioInfo () override |
| bool | begin (CSSConfig config) |
| Starts the processing with the indicated configuration. | |
| bool | begin () override |
| void | end () override |
| Processes the remaining samples and reports the statistics. | |
| 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 frame is received | |
| bool | isFinished () override |
| true if the decoding was stopped (rx_one) | |
| size_t | frameCount () |
| Number of received frames with a correct CRC. | |
| size_t | errorCount () |
| Number of frames which could not be decoded. | |
| float | frequencyOffset () |
| Frequency offset of the last frame in Hz. | |
| CSSConfig & | 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 Types | |
| enum | State { SEARCH , SYNC , HEADER , PAYLOAD } |
Protected Member Functions | |
| void | resetState () |
| float | noise () |
| uniform random value in the range -0.5 to 0.5 | |
| void | addSample (float x) |
| Mixes a sample to the baseband and resamples it to the bandwidth. | |
| void | addBaseband (float re, float im) |
| Peak | spectrum (bool up, float offset) |
| float | signedBin (float pos) |
| signed value of a bin (-n/2 to n/2) | |
| void | processWindow () |
| void | search () |
| Preamble: the same bin in consecutive windows. | |
| void | sync () |
| float | estimateDrift () |
| Change of the preamble peaks per symbol (least squares fit). | |
| void | data () |
| Header and payload symbols. | |
| void | endOfCarrier (bool ok, int corrected=0) |
| Protected Member Functions inherited from tinymodem::ModemDecoder | |
| void | status (const char *fmt,...) |
Protected Attributes | |
| CSSConfig | cfg |
| bool | is_active = false |
| bool | is_finished = false |
| PcmInput | input |
| uint32_t | noise_seed = 1 |
| int | n = 128 |
| int | m = 256 |
| SimpleFFT | fft |
| SampleRateConverter | converter |
| float | mix_re = 1 |
| float | mix_im = 0 |
| float | mix_step_re = 1 |
| float | mix_step_im = 0 |
| uint32_t | mix_count = 0 |
| audio_tools::Vector< float > | ring_re |
| audio_tools::Vector< float > | ring_im |
| audio_tools::Vector< float > | fft_re |
| audio_tools::Vector< float > | fft_im |
| audio_tools::Vector< float > | power |
| audio_tools::Vector< float > | chirp_re |
| audio_tools::Vector< float > | chirp_im |
| int64_t | count = 0 |
| int64_t | next_start = 0 |
| State | state = SEARCH |
| int | hits = 0 |
| int | candidate = 0 |
| int | sync_windows = 0 |
| float | last_up = 0 |
| float | ups [MAX_UPS] |
| int | nups = 0 |
| float | drift = 0 |
| float | rate_factor = 1 |
| float | sync_offset = 0 |
| float | freq_offset = 0 |
| audio_tools::Vector< uint16_t > | symbols |
| int | nsymbols = 0 |
| int | needed = 0 |
| int | frame_len = 0 |
| float | snr_total = 0 |
| size_t | frames = 0 |
| size_t | errors = 0 |
| Protected Attributes inherited from tinymodem::ModemDecoder | |
| Print * | p_status = nullptr |
| bool | is_quiet = false |
Static Protected Attributes | |
| static constexpr int | RING = 4 |
| static constexpr int | OVERSAMPLING = 2 |
| static constexpr int | PREAMBLE_HITS = 3 |
| static constexpr float | TRACKING_GAIN = 0.3f |
| tracking of the remaining offset per symbol | |
| static constexpr float | DRIFT_GAIN = 0.02f |
| tracking of the remaining drift per symbol | |
| static constexpr float | MIN_DRIFT = 0.08f |
| min drift in bins per symbol for the correction of the sample rate | |
| static constexpr int | MAX_UPS = 16 |
| max preamble windows for the drift estimation | |
Chirp spread spectrum demodulator (LoRa-like): the PCM audio data is written to the decoder and the payload of the received frames with a correct CRC is written to the output. The input can be 8, 16 or 32 bit signed samples with any number of channels (only CSSConfig::channel is evaluated).
The signal is mixed to the complex baseband and resampled to the bandwidth, so that a symbol has N = 2^SF samples. A symbol is multiplied with the conjugate chirp (dechirped): the result is a tone, whose FFT bin is the symbol value. The preamble is detected by the same bin in consecutive windows; the bins of the up and down chirps provide the time and frequency offset. During the frame the timing follows a different clock of the sender.
The receiver must use the same ecc_bytes as the transmitter.
|
protected |
|
default |
|
inline |
|
inlineprotected |
|
inlineprotected |
Mixes a sample to the baseband and resamples it to the bandwidth.
|
inlineoverride |
|
inlineoverride |
|
inline |
Starts the processing with the indicated configuration.
|
inline |
The configuration which was provided in begin().
|
inlineprotected |
Header and payload symbols.
|
inline |
Provides a default configuration: css7 (SF 7, 1000 Hz).
|
inlineoverride |
Processes the remaining samples and reports the statistics.
|
inlineprotected |
|
inline |
Number of frames which could not be decoded.
|
inlineprotected |
Change of the preamble peaks per symbol (least squares fit).
|
inlineoverridevirtual |
Processes the remaining samples (e.g. at the end of the input).
Implements tinymodem::ModemDecoder.
|
inline |
Number of received frames with a correct CRC.
|
inline |
Frequency offset of the last frame in Hz.
|
inlineoverridevirtual |
true while a frame is received
Implements tinymodem::ModemDecoder.
|
inlineoverridevirtual |
true if the decoding was stopped (rx_one)
Implements tinymodem::ModemDecoder.
|
inlineprotected |
uniform random value in the range -0.5 to 0.5
|
inlineoverride |
|
inlineprotected |
|
inlineprotected |
|
inlineprotected |
Preamble: the same bin in consecutive windows.
|
inlineoverride |
Defines the format of the input audio data.
|
inlineprotected |
signed value of a bin (-n/2 to n/2)
|
inlineprotected |
Dechirped spectrum of the window at next_start: up or down chirp, shifted by the frequency offset (in bins). The power of both parts of the chirp is added, which is robust against any time offset.
|
inlineprotected |
Waits for the down chirps: up peak = tau + offset, down peak = -tau + offset
|
inlineoverride |
Provide PCM data to the decoder.
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
staticconstexprprotected |
tracking of the remaining drift per symbol
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
staticconstexprprotected |
max preamble windows for the drift estimation
|
staticconstexprprotected |
min drift in bins per symbol for the correction of the sample rate
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
staticconstexprprotected |
baseband samples per chip: the two parts of a chirp (before and after the wrap around) are separate tones, which makes the detection robust against a fractional time offset
|
protected |
|
staticconstexprprotected |
|
protected |
|
staticconstexprprotected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
staticconstexprprotected |
tracking of the remaining offset per symbol
|
protected |