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

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...

#include <OFDMEncoder.h>

Inheritance diagram for tinymodem::OFDMEncoder:
Collaboration diagram for tinymodem::OFDMEncoder:

Public Member Functions

 OFDMEncoder ()=default
 OFDMEncoder (Print &out)
OFDMConfig defaultConfig ()
 Provides a default configuration: ofdm32.
void setOutput (Print &out) override
void setAudioInfo (audio_tools::AudioInfo info) override
 Defines the sample rate and number of channels of the generated audio.
audio_tools::AudioInfo audioInfo () override
bool begin (OFDMConfig config)
 Starts the processing with the indicated configuration.
bool begin () override
void end () override
size_t write (const uint8_t *data, size_t len) override
 Collects the bytes and sends full frames.
bool endTransmission (size_t silence_samples=0) override
bool isTransmitting () override
 true if there is data which was not sent yet
float symbolRate () override
 OFDM symbols per second.
OFDMConfig & config ()
 The configuration which was provided in begin().
 operator bool () override
Public Member Functions inherited from tinymodem::ModemEncoder
void setOutput (Print &out) override
void setGenerator (audio_tools::SoundGenerator< int16_t > &generator)
audio_tools::SoundGenerator< int16_t > & getGenerator ()
 Provides the active tone generator.
virtual bool writeIdle (size_t nsamples)
 Sends an idle carrier: returns false if this is not supported.
void writeSilence (size_t nsamples)
 Writes the indicated number of samples of silence.
void writeTone (float freq, size_t nsamples)
 Writes a tone for the indicated number of samples.
void flush ()
 Ends the transmission.
const char * mime () override

Protected Member Functions

void sendFrame ()
void sendBits (const uint8_t *data, int len, int &bit_count)
void sendHeader (uint32_t header)
void sendSymbol (bool sync)
 Writes the cyclic prefix and the symbol.

Static Protected Member Functions

static int grayToPhase (int dibit)
 00 -> 0, 01 -> 90, 11 -> 180, 10 -> 270 degrees

Protected Attributes

OFDMConfig cfg
SampleOutput samples
OFDMTable table
bool is_active = false
int fft_size = 0
int prefix_size = 0
int first_bin = 0
float amplitude = 0.1f
audio_tools::Vector< uint8_t > phases
audio_tools::Vector< uint8_t > frame
int frame_len = 0
Protected Attributes inherited from tinymodem::ModemEncoder
ToneOutput tones

Detailed Description

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()).

A frame consists of a sync symbol (only even carriers, so the two halves are identical), a reference symbol, a header symbol with the length and the data symbols. Each symbol starts with a cyclic prefix.

Constructor & Destructor Documentation

◆ OFDMEncoder() [1/2]

tinymodem::OFDMEncoder::OFDMEncoder ( )
default

◆ OFDMEncoder() [2/2]

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

Member Function Documentation

◆ audioInfo()

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

◆ begin() [1/2]

bool tinymodem::OFDMEncoder::begin ( )
inlineoverride

◆ begin() [2/2]

bool tinymodem::OFDMEncoder::begin ( OFDMConfig config)
inline

Starts the processing with the indicated configuration.

◆ config()

OFDMConfig & tinymodem::OFDMEncoder::config ( )
inline

The configuration which was provided in begin().

◆ defaultConfig()

OFDMConfig tinymodem::OFDMEncoder::defaultConfig ( )
inline

Provides a default configuration: ofdm32.

◆ end()

void tinymodem::OFDMEncoder::end ( )
inlineoverride

◆ endTransmission()

bool tinymodem::OFDMEncoder::endTransmission ( size_t silence_samples = 0)
inlineoverridevirtual

Sends the collected bytes (and optional silence): returns true if data was sent

Implements tinymodem::ModemEncoder.

◆ grayToPhase()

int tinymodem::OFDMEncoder::grayToPhase ( int dibit)
inlinestaticprotected

00 -> 0, 01 -> 90, 11 -> 180, 10 -> 270 degrees

◆ isTransmitting()

bool tinymodem::OFDMEncoder::isTransmitting ( )
inlineoverridevirtual

true if there is data which was not sent yet

Implements tinymodem::ModemEncoder.

◆ operator bool()

tinymodem::OFDMEncoder::operator bool ( )
inlineoverride

◆ sendBits()

void tinymodem::OFDMEncoder::sendBits ( const uint8_t * data,
int len,
int & bit_count )
inlineprotected

Adds the bits (2 per carrier) and sends the full symbols. A symbol changes the phase of each carrier by 0, 90, 180 or 270 degrees. The carriers of an incomplete last symbol which are not used keep their phase.

◆ sendFrame()

void tinymodem::OFDMEncoder::sendFrame ( )
inlineprotected

◆ sendHeader()

void tinymodem::OFDMEncoder::sendHeader ( uint32_t header)
inlineprotected

The header bits change the phase by 0 or 180 degrees (more robust than QPSK) and are repeated on all carriers of the header symbols

◆ sendSymbol()

void tinymodem::OFDMEncoder::sendSymbol ( bool sync)
inlineprotected

Writes the cyclic prefix and the symbol.

◆ setAudioInfo()

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

Defines the sample rate and number of channels of the generated audio.

◆ setOutput()

void tinymodem::OFDMEncoder::setOutput ( Print & out)
inlineoverride

◆ symbolRate()

float tinymodem::OFDMEncoder::symbolRate ( )
inlineoverridevirtual

OFDM symbols per second.

Implements tinymodem::ModemEncoder.

◆ write()

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

Collects the bytes and sends full frames.

Member Data Documentation

◆ amplitude

float tinymodem::OFDMEncoder::amplitude = 0.1f
protected

◆ cfg

OFDMConfig tinymodem::OFDMEncoder::cfg
protected

◆ fft_size

int tinymodem::OFDMEncoder::fft_size = 0
protected

◆ first_bin

int tinymodem::OFDMEncoder::first_bin = 0
protected

◆ frame

audio_tools::Vector<uint8_t> tinymodem::OFDMEncoder::frame
protected

◆ frame_len

int tinymodem::OFDMEncoder::frame_len = 0
protected

◆ is_active

bool tinymodem::OFDMEncoder::is_active = false
protected

◆ phases

audio_tools::Vector<uint8_t> tinymodem::OFDMEncoder::phases
protected

◆ prefix_size

int tinymodem::OFDMEncoder::prefix_size = 0
protected

◆ samples

SampleOutput tinymodem::OFDMEncoder::samples
protected

◆ table

OFDMTable tinymodem::OFDMEncoder::table
protected

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