TinyModem
Header-only software audio modem library
Loading...
Searching...
No Matches
tinymodem Namespace Reference

TinyModem: software audio modems and packets with error correction. More...

Classes

struct  AX25Config
 Configuration of the AX.25 packet radio modem (AX25Encoder, AX25Decoder): Bell 202 AFSK with 1200 baud, NRZI and HDLC framing, as used by APRS. More...
class  AX25Frame
 Conversion between AX.25 frames and the monitor text format (SRC>DEST,DIGI1,DIGI2*:info) and the KISS framing. More...
class  AX25Decoder
 AX.25 packet radio demodulator (APRS, 1200 baud AFSK). The PCM audio data is written to the decoder and the received frames with a correct frame check sequence are written to the output: as monitor text lines (SRC>DEST,DIGI:info) or as KISS frames (see AX25Config::format). More...
class  AX25Encoder
 AX.25 packet radio modulator (APRS, 1200 baud AFSK). The written data is converted to AX.25 frames, which are sent with HDLC framing (flags, bit stuffing, frame check sequence) and NRZI coding. More...
class  FX25
 FX.25: AX.25 frames with Reed-Solomon forward error correction (as implemented by direwolf). The complete HDLC frame (flag, bit stuffed frame with FCS, flags as fill) is the data part of a Reed-Solomon code word, which is preceded by a 64 bit correlation tag that identifies the code. A receiver without FX.25 still decodes the HDLC frame in the data part. More...
class  IL2P
 IL2P (Improved Layer 2 Protocol, as implemented by direwolf): an AX.25 frame is sent as a scrambled header with Reed-Solomon parity and a scrambled payload in Reed-Solomon blocks, without HDLC framing and NRZI. Header type 1 compresses the addresses and the control field of frames with 2 addresses, header type 0 carries the complete AX.25 frame as payload. More...
struct  CSSConfig
 Configuration of the chirp spread spectrum modem (CSSEncoder, CSSDecoder), which works like LoRa in the audio band: each symbol is a linear chirp over the bandwidth, which starts at one of N = 2^SF frequencies and carries SF bits (SF = spreading factor). The signal can be received far below the noise level and is robust against frequency offsets, different clocks and echoes. It is not compatible with LoRa radios. More...
class  CSSFrame
 Frame format of the chirp spread spectrum modem: the bytes of the header code word (length and parity) and of the payload code word (data, CRC-16 and parity) are sent as SF bits per symbol, most significant bit first. The symbol value is the inverse Gray code of the bits, so that a detection in the neighboring FFT bin causes only 1 wrong bit. More...
class  CSSDecoder
 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...
class  CSSEncoder
 Chirp spread spectrum modulator (LoRa-like): the written bytes are collected and sent as frame when CSSConfig::max_frame bytes are available or when you call endTransmission() (or flush()). A frame consists of the preamble (up chirps), 2 down chirps, the header and the payload. Each symbol is a chirp which starts at the frequency of its value and wraps around at the end of the band. The phase is continuous. More...
class  DataCodec
 Converts between characters and the data bits of a frame. More...
class  AsciiCodec
 ASCII 8-bit data (passthrough). More...
class  BinaryCodec
 Raw N-bit binary data: prints the bits as '0' and '1' followed by newline. More...
class  BaudotCodec
 Baudot (ITA2) 5-bit data. More...
class  CallerIDCodec
 Caller-ID (USA SDMF/MDMF) decoder. See http://melabs.com/resources/callerid.htm. More...
class  UICCodec
 UIC-751-3 ground-train or train-ground decoder. More...
class  PrintFilter
 Print which replaces non printable characters with '.'. More...
class  SampleRateConverter
 Converts the sample rate of a signal with a windowed sinc low pass filter (by default the cut off is at 45% of the lower sample rate). More...
class  SimpleFFT
 Radix 2 complex FFT with a precomputed twiddle table. More...
struct  DTMFConfig
 Configuration of the DTMF (touch tone) modem (DTMFEncoder, DTMFDecoder): each of the characters 0-9, *, #, A, B, C and D is sent as the sum of a row tone (697 - 941 Hz) and a column tone (1209 - 1633 Hz). More...
class  DTMFKeys
 The DTMF keypad: the tones and the characters of the 16 keys. More...
class  DTMFDecoder
 DTMF (touch tone) demodulator: the PCM audio data is written to the decoder and the received keys (0-9, *, #, A-D) are written to the output. The input can be 8, 16 or 32 bit signed samples with any number of channels (only DTMFConfig::channel is evaluated). More...
class  DTMFEncoder
 DTMF (touch tone) modulator: each written character 0-9, *, #, A-D (also a-d) is sent as a tone pair of DTMFConfig::tone_ms followed by a pause of DTMFConfig::pause_ms. A ',' adds a pause of DTMFConfig::comma_ms, all other characters are ignored. The tones fade in and out within 2 ms to avoid clicks. More...
class  FSKDecoder
 FSK demodulator: PCM audio data is written to the decoder and the decoded data is written to the output that was defined with setOutput(). Supported input formats are 8, 16 or 32 bit signed integer samples with any number of channels (only config.channel is evaluated). The decoding is compatible with minimodem –tx. More...
class  FSKDemodulator
 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...
class  FSKEncoder
 FSK modulator: converts the written characters into 16 bit PCM audio which is written to the defined output. The generated signal is compatible with minimodem –rx. More...
struct  GGWaveProtocol
 Transmission protocol of ggwave (https://github.com/ggerganov/ggwave): the ids and parameters are identical to the original. The tones are multiples of sample_rate / samplesPerFrame (46.875 Hz at 48 kHz). More...
struct  GGWaveConfig
 Configuration of the ggwave compatible modem (GGWaveEncoder, GGWaveDecoder). Each message (up to 140 bytes) starts and ends with a marker and is protected by Reed-Solomon codes. Each byte is sent as 2 of 16 tones which are transmitted at the same time. More...
class  GGWaveDecoder
 ggwave compatible demodulator: the PCM audio data is written to the decoder and the payload of the received messages is written to the output. The input can be 8, 16 or 32 bit signed samples with any number of channels (only GGWaveConfig::channel is evaluated). More...
class  GGWaveEncoder
 ggwave compatible modulator: the written bytes are collected into messages of up to 140 bytes. A message is sent when it is full or when you call endTransmission() (or flush()). The generated audio is identical to the audio of ggwave (variable length format). More...
struct  MFSKConfig
 Configuration of the multi-tone FSK modem (MFSKEncoder, MFSKDecoder). Each symbol is one of tones tones and carries log2(tones) bits. The tones are base_freq + i * tone_spacing. More...
class  MFSKDecoder
 Multi-tone FSK demodulator: PCM audio data is written to the decoder and the decoded bytes are written to the output. The input can be 8, 16 or 32 bit signed samples with any number of channels (only MFSKConfig::channel is evaluated). More...
class  MFSKEncoder
 Multi-tone FSK modulator: converts the written bytes into 16 bit PCM audio. Each symbol is one of MFSKConfig::tones tones and carries log2(tones) bits (Gray coded, most significant bit first). More...
class  FSKToneGenerator
 Default sine generator of the encoders: like minimodem it keeps the phase continuous when the frequency is changed (continuous phase FSK) and restarts it at phase 0 after silence (frequency 0). More...
class  ToneOutput
 Writes tones of a SoundGenerator as 16 bit PCM with the requested number of channels and volume to a Print. More...
class  SampleOutput
 Writes float samples (-1.0 to 1.0) as 16 bit PCM with the requested number of channels and volume to a Print. More...
class  PcmInput
 Assembles the PCM frames from the written bytes and provides the samples of the selected channel as float (-1.0 to 1.0). Supports 8, 16 and 32 bit signed samples. More...
class  ByteQueue
 FIFO for received data which grows when needed: e.g. one decoding step can produce more data than expected (like a Caller-ID message). More...
class  ModemEncoder
 Common API of the modulators (FSKEncoder, MFSKEncoder): the written data is converted to 16 bit PCM audio which is written to the output. More...
class  ModemDecoder
 Common API of the demodulators (FSKDecoder, MFSKDecoder): PCM audio data is written to the decoder and the decoded data is written to the output. Status messages (### CARRIER and ### NOCARRIER) are written to the status output. More...
struct  ModemConfig
 Configuration of the FSK modem. The fields correspond to the command line options of minimodem. Call setMode() to select one of the predefined baud modes ("1200", "300", "rtty", "tdd", "same", "callerid", "uic-train", "uic-ground", "V.21" or any number N for a Bell-like N bps modem) first and then change the individual fields. Fields which are left at 0 (or -1) are derived automatically when the encoder or decoder is started. More...
class  BasicModemStream
 Arduino Stream API for a modem (encoder and decoder): the written characters are modulated to the audio output and the audio input is demodulated into characters that can be read. You can use only the output (transmit only), only the input (receive only) or both. More...
class  ModemStream
 Arduino Stream API for the minimodem compatible FSK modem: print() transmits, read() receives. See BasicModemStream. More...
class  MFSKStream
 Arduino Stream API for the multi-tone FSK modem: print() transmits, read() receives. See BasicModemStream. More...
class  AX25Stream
 Arduino Stream API for the AX.25 packet radio modem (APRS): print() transmits the frames, read() provides the received frames, both as monitor text lines or KISS frames. See BasicModemStream. More...
class  PSKStream
 Arduino Stream API for the PSK modem (PSK31 to PSK500): print() transmits, read() receives. See BasicModemStream. More...
class  OFDMStream
 Arduino Stream API for the OFDM modem: print() collects the data, flush() sends it as frame, read() receives. See BasicModemStream. More...
class  GGWaveStream
 Arduino Stream API for the ggwave compatible modem: print() collects the data (up to 140 bytes), flush() sends it as message, read() receives. See BasicModemStream. More...
class  OliviaStream
 Arduino Stream API for the Olivia and Contestia modems (compatible with fldigi): print() transmits, flush() completes the last block, read() receives. See BasicModemStream. More...
class  CSSStream
 Arduino Stream API for the chirp spread spectrum modem (LoRa-like): print() collects the data, flush() sends it as frame, read() receives. See BasicModemStream. More...
class  MorseStream
 Arduino Stream API for Morse code (International or American): print() transmits, read() receives. See BasicModemStream. More...
class  DTMFStream
 Arduino Stream API for the DTMF (touch tone) modem: print() sends the keys 0-9, *, #, A-D, read() provides the received keys. See BasicModemStream. More...
class  BasicModemStreamRTOS
 BasicModemStream which receives in a separate task (FreeRTOS on ESP32 and RP2040, a std::thread on the desktop): the task reads the audio input and decodes it, so the decoding does not block your loop() and no audio is lost while loop() is busy. available(), read() and peek() only access the received data and can be called from any task. More...
class  ModemStreamRTOS
 ModemStream (FSK) which receives in a separate task. See BasicModemStreamRTOS. More...
class  MFSKStreamRTOS
 MFSKStream (multi-tone FSK) which receives in a separate task. See BasicModemStreamRTOS. More...
class  AX25StreamRTOS
 AX25Stream (APRS) which receives in a separate task. See BasicModemStreamRTOS. More...
class  PSKStreamRTOS
 PSKStream which receives in a separate task. See BasicModemStreamRTOS. More...
class  OFDMStreamRTOS
 OFDMStream which receives in a separate task. See BasicModemStreamRTOS. More...
class  GGWaveStreamRTOS
 GGWaveStream which receives in a separate task. See BasicModemStreamRTOS. More...
class  OliviaStreamRTOS
 OliviaStream which receives in a separate task. See BasicModemStreamRTOS. More...
class  CSSStreamRTOS
 CSSStream which receives in a separate task. See BasicModemStreamRTOS. More...
class  MorseStreamRTOS
 MorseStream which receives in a separate task. See BasicModemStreamRTOS. More...
class  DTMFStreamRTOS
 DTMFStream which receives in a separate task. See BasicModemStreamRTOS. More...
struct  MorseConfig
 Configuration of the Morse code modem (MorseEncoder, MorseDecoder): a tone which is switched on and off (CW). The speed is defined in words per minute (PARIS): a unit (the length of a dot) is 1.2 / wpm seconds. More...
class  MorseCode
 The Morse code tables and timing. A code is a string of '.' (dot), '-' (dash), '_' (long dash of the American L), '=' (longer dash of the American 0) and ' ' (space within a character of American Morse). More...
class  MorseDecoder
 Morse code demodulator (CW): the PCM audio data is written to the decoder and the decoded characters (upper case) are written to the output. The input can be 8, 16 or 32 bit signed samples with any number of channels (only MorseConfig::channel is evaluated). More...
class  MorseEncoder
 Morse code modulator (CW): each written character is sent as dots and dashes of a tone with the timing of the alphabet (International: dot 1, dash 3, element space 1, letter space 3, word space 7 units). A space (or a character which is not in the alphabet) is a word space. The tone is switched on and off with a raised cosine ramp of MorseConfig::ramp_ms. More...
struct  OFDMConfig
 Configuration of the OFDM modem (OFDMEncoder, OFDMDecoder): the data is transmitted in parallel on carriers subcarriers with differential QPSK (2 bits per carrier and symbol). Each symbol has a cyclic prefix (guard interval) against echoes. More...
class  OFDMTable
 Sine and cosine of 2 * PI * i / size. More...
class  OFDMDecoder
 OFDM demodulator: the PCM audio data is written to the decoder and the decoded frames are written to the output. The input can be 8, 16 or 32 bit signed samples with any number of channels (only OFDMConfig::channel is evaluated). More...
class  OFDMEncoder
 OFDM modulator: the written bytes are collected into frames (up to OFDMConfig::max_frame bytes) which are transmitted with differential QPSK on all carriers. A frame is sent when it is full or when you call endTransmission() (or flush()). More...
struct  OliviaConfig
 Configuration of the Olivia and Contestia modems (OliviaEncoder, OliviaDecoder): MFSK with 2 to 256 tones and a strong forward error correction (Walsh-Hadamard codes over blocks of 64 or 32 symbols), as designed by Pawel Jalocha and implemented by fldigi. More...
class  OliviaCodec
 The forward error correction of Olivia and Contestia (as in fldigi): each character of a block of bitsPerSymbol() characters is a Walsh-Hadamard code word of 64 (Contestia: 32) bits, which is scrambled and spread diagonally over the 64 (32) symbols of the block. More...
class  OliviaDecoder
 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...
class  OliviaEncoder
 Olivia and Contestia modulator (compatible with fldigi): the written characters are collected in blocks of bitsPerSymbol() characters, which are FEC encoded into 64 (Contestia: 32) symbols. Each symbol is a tone with a raised cosine envelope over two symbol periods, so consecutive symbols overlap by half. More...
struct  PacketStatistics
 Statistics of the received packets. More...
struct  PacketFormat
 Constants of the packet format. More...
class  PacketEncoder
 Splits the written data into packets with a CRC-16 and Reed-Solomon forward error correction, which are framed with HDLC-style flags (0x7E) and byte stuffing, and writes them to the output (e.g. a ModemStream). More...
class  PacketDecoder
 Receives the packets of a PacketEncoder: the written bytes (e.g. the output of a modem decoder) are deframed, corrected and checked, and the payload of the valid packets is written to the output. More...
class  PacketStream
 Reliable data transfer over any Stream (e.g. a ModemStream, an MFSKStream or a Serial): the written data is sent in packets with CRC-16 and Reed-Solomon forward error correction, and only correct data can be read. Corrupted packets which can't be corrected are dropped. More...
struct  PSKConfig
 Configuration of the PSK modem (PSKEncoder, PSKDecoder): differential PSK with cosine shaped transitions like PSK31, compatible with fldigi. More...
class  Varicode
 The PSK31 Varicode (as extended by fldigi to all 256 byte values): frequent characters have short codes. A code starts and ends with 1 and contains no "00": the characters are separated by "00". More...
class  MFSKVaricode
 The IZ8BLY MFSK Varicode (as used by fldigi for 8PSK): a code starts with 1 and does not contain "001", so a character ends when "001" is received (the 1 starts the next character). More...
class  QPSKCode
 Rate 1/2 convolutional code with K=5 (polynomials 0x17 and 0x19) of QPSK31 (fldigi) and a soft decision Viterbi decoder. More...
class  PSKDecoder
 PSK demodulator (BPSK, QPSK and 8PSK compatible with fldigi): the PCM audio data is written to the decoder and the decoded bytes are written to the output. The input can be 8, 16 or 32 bit signed samples with any number of channels (only PSKConfig::channel is evaluated). More...
class  PSKEncoder
 PSK modulator (compatible with fldigi): the written bytes are Varicode encoded and each symbol is a phase step with a cosine shaped transition from the previous phase. More...
class  RSCodec
 Reed-Solomon code over GF(256) with the polynomial 0x11d and lengths which are defined at runtime. The generator roots are alpha^fcr to alpha^(fcr+ecc-1): fcr = 0 is used by ggwave (Mike Lubinets' library) and IL2P, fcr = 1 by FX.25. The parity bytes follow the message, the first byte is the highest power (like Phil Karn's library). More...

Typedefs

using GGWaveRS = RSCodec

Enumerations

enum class  AX25Format { TEXT , KISS }
enum class  AX25Layer2 { AX25 , FX25 , IL2P }
enum  GGWaveProtocolId {
  GGWAVE_AUDIBLE_NORMAL = 0 , GGWAVE_AUDIBLE_FAST = 1 , GGWAVE_AUDIBLE_FASTEST = 2 , GGWAVE_ULTRASOUND_NORMAL = 3 ,
  GGWAVE_ULTRASOUND_FAST = 4 , GGWAVE_ULTRASOUND_FASTEST = 5 , GGWAVE_DT_NORMAL = 6 , GGWAVE_DT_FAST = 7 ,
  GGWAVE_DT_FASTEST = 8
}
 Protocol ids of ggwave: the values are identical to ggwave's ggwave_ProtocolId. The mono-tone protocols (MT, 9 - 11) are not supported. More...
enum class  DataFormat {
  ASCII , BAUDOT , BINARY , CALLERID ,
  UIC_TRAIN , UIC_GROUND
}
 Data encoding which is used for the payload of a frame. More...
enum class  MorseAlphabet { INTERNATIONAL , AMERICAN }
 Morse code alphabet. More...
enum class  PSKModulation { BPSK , QPSK , PSK8 }
 Modulation of the PSK modem. More...

Functions

uint64_t bitReverse (uint64_t value, unsigned bits)
 Reverses the ordering of the bits on an integer.
uint64_t bitWindow (uint64_t value, unsigned offset, unsigned bits)
 Gets "bits" bits from "value" starting "offset" bits from the start.
unsigned grayEncode (unsigned value)
 Gray code of a value: neighbouring tones differ in a single bit.
unsigned grayDecode (unsigned gray)
 Inverse of grayEncode().
uint16_t crc16 (const uint8_t *data, size_t len, uint16_t crc=0xFFFF)
 CRC-16-CCITT (polynomial 0x1021, initial value 0xFFFF).

Detailed Description

TinyModem: software audio modems and packets with error correction.

Typedef Documentation

◆ GGWaveRS

Reed-Solomon code of ggwave: the generator roots are alpha^0 to alpha^(ecc-1)

Enumeration Type Documentation

◆ AX25Format

enum class tinymodem::AX25Format
strong

Format of the data which is written to the AX25Encoder and provided by the AX25Decoder

Enumerator
TEXT 

one frame per line in the monitor format: SRC>DEST,DIGI1,DIGI2:info

KISS 

KISS frames (0xC0 0x00 frame 0xC0), used by APRS and packet radio applications

◆ AX25Layer2

enum class tinymodem::AX25Layer2
strong

Frame format which is transmitted by the AX25Encoder: the AX25Decoder receives all formats

Enumerator
AX25 

HDLC framing (standard AX.25).

FX25 

FX.25: HDLC frame with Reed-Solomon FEC (compatible with AX.25).

IL2P 

IL2P: Improved Layer 2 Protocol with Reed-Solomon FEC.

◆ DataFormat

enum class tinymodem::DataFormat
strong

Data encoding which is used for the payload of a frame.

Enumerator
ASCII 

ASCII 8-N-1 (or 7-N-1).

BAUDOT 

Baudot 5 bit (RTTY, TDD).

BINARY 

print the raw data bits as '0'/'1' (receive only)

CALLERID 

Bell 202 Caller-ID (SDMF/MDMF, receive only).

UIC_TRAIN 

UIC-751-3 train to ground (receive only).

UIC_GROUND 

UIC-751-3 ground to train (receive only).

◆ GGWaveProtocolId

Protocol ids of ggwave: the values are identical to ggwave's ggwave_ProtocolId. The mono-tone protocols (MT, 9 - 11) are not supported.

Enumerator
GGWAVE_AUDIBLE_NORMAL 
GGWAVE_AUDIBLE_FAST 
GGWAVE_AUDIBLE_FASTEST 
GGWAVE_ULTRASOUND_NORMAL 
GGWAVE_ULTRASOUND_FAST 
GGWAVE_ULTRASOUND_FASTEST 
GGWAVE_DT_NORMAL 
GGWAVE_DT_FAST 
GGWAVE_DT_FASTEST 

◆ MorseAlphabet

enum class tinymodem::MorseAlphabet
strong

Morse code alphabet.

Enumerator
INTERNATIONAL 

International Morse code (ITU-R M.1677): dots and dashes of 3 units.

AMERICAN 

American Morse code (railroad telegraph): dashes of 2 units, long dashes and spaces within some characters

◆ PSKModulation

enum class tinymodem::PSKModulation
strong

Modulation of the PSK modem.

Enumerator
BPSK 

1 bit per symbol, PSK31 Varicode

QPSK 

2 bits per symbol: rate 1/2 convolutional code (K=5) on 1 data bit per symbol, PSK31 Varicode

PSK8 

3 bits per symbol without FEC, MFSK Varicode

Function Documentation

◆ bitReverse()

uint64_t tinymodem::bitReverse ( uint64_t value,
unsigned bits )
inline

Reverses the ordering of the bits on an integer.

◆ bitWindow()

uint64_t tinymodem::bitWindow ( uint64_t value,
unsigned offset,
unsigned bits )
inline

Gets "bits" bits from "value" starting "offset" bits from the start.

◆ crc16()

uint16_t tinymodem::crc16 ( const uint8_t * data,
size_t len,
uint16_t crc = 0xFFFF )
inline

CRC-16-CCITT (polynomial 0x1021, initial value 0xFFFF).

◆ grayDecode()

unsigned tinymodem::grayDecode ( unsigned gray)
inline

Inverse of grayEncode().

◆ grayEncode()

unsigned tinymodem::grayEncode ( unsigned value)
inline

Gray code of a value: neighbouring tones differ in a single bit.