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

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

#include <GGWaveEncoder.h>

Inheritance diagram for tinymodem::GGWaveEncoder:
Collaboration diagram for tinymodem::GGWaveEncoder:

Classes

struct  Tone
 a tone: FFT bin relative to freq_start and index of the phase offset More...

Public Member Functions

 GGWaveEncoder ()=default
 GGWaveEncoder (Print &out)
GGWaveConfig defaultConfig ()
 Provides a default configuration: ggwave-fast.
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 (GGWaveConfig 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 messages.
bool endTransmission (size_t silence_samples=0) override
bool isTransmitting () override
 true if there is data which was not sent yet
float symbolRate () override
 Data symbols per second.
GGWaveConfig & 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 sendMessage ()
void sendFrame (const Tone *tones, int ntones, int cycle, int frames)

Protected Attributes

GGWaveConfig cfg
GGWaveProtocol protocol
SampleOutput samples
OFDMTable table
bool is_active = false
int frame_size = 1024
uint8_t message [GGWaveConfig::MAX_PAYLOAD]
int message_len = 0
uint8_t encoded [GGWaveConfig::LENGTH_BYTES+GGWaveConfig::MAX_PAYLOAD+2 *(GGWaveConfig::MAX_PAYLOAD/5)+3]
Protected Attributes inherited from tinymodem::ModemEncoder
ToneOutput tones

Detailed Description

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

A message consists of the start marker (16 frames), the Reed-Solomon coded length (3 bytes), the Reed-Solomon coded payload and the end marker (16 frames). Each byte is sent as 2 simultaneous tones (one of 16 tones for each nibble) and each symbol lasts GGWaveProtocol::frames_per_tx frames.

Constructor & Destructor Documentation

◆ GGWaveEncoder() [1/2]

tinymodem::GGWaveEncoder::GGWaveEncoder ( )
default

◆ GGWaveEncoder() [2/2]

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

Member Function Documentation

◆ audioInfo()

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

◆ begin() [1/2]

bool tinymodem::GGWaveEncoder::begin ( )
inlineoverride

◆ begin() [2/2]

bool tinymodem::GGWaveEncoder::begin ( GGWaveConfig config)
inline

Starts the processing with the indicated configuration.

◆ config()

GGWaveConfig & tinymodem::GGWaveEncoder::config ( )
inline

The configuration which was provided in begin().

◆ defaultConfig()

GGWaveConfig tinymodem::GGWaveEncoder::defaultConfig ( )
inline

Provides a default configuration: ggwave-fast.

◆ end()

void tinymodem::GGWaveEncoder::end ( )
inlineoverride

◆ endTransmission()

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

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

Implements tinymodem::ModemEncoder.

◆ isTransmitting()

bool tinymodem::GGWaveEncoder::isTransmitting ( )
inlineoverridevirtual

true if there is data which was not sent yet

Implements tinymodem::ModemEncoder.

◆ operator bool()

tinymodem::GGWaveEncoder::operator bool ( )
inlineoverride

◆ sendFrame()

void tinymodem::GGWaveEncoder::sendFrame ( const Tone * tones,
int ntones,
int cycle,
int frames )
inlineprotected

Writes a frame with the indicated tones: the amplitude rises during the first 15% and falls during the last 15% of a cycle (symbol or marker) of frames (like ggwave's addAmplitudeSmooth())

◆ sendMessage()

void tinymodem::GGWaveEncoder::sendMessage ( )
inlineprotected

◆ setAudioInfo()

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

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

◆ setOutput()

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

◆ symbolRate()

float tinymodem::GGWaveEncoder::symbolRate ( )
inlineoverridevirtual

Data symbols per second.

Implements tinymodem::ModemEncoder.

◆ write()

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

Collects the bytes and sends full messages.

Member Data Documentation

◆ cfg

GGWaveConfig tinymodem::GGWaveEncoder::cfg
protected

◆ encoded

uint8_t tinymodem::GGWaveEncoder::encoded[GGWaveConfig::LENGTH_BYTES+GGWaveConfig::MAX_PAYLOAD+ 2 *(GGWaveConfig::MAX_PAYLOAD/5)+3]
protected

◆ frame_size

int tinymodem::GGWaveEncoder::frame_size = 1024
protected

◆ is_active

bool tinymodem::GGWaveEncoder::is_active = false
protected

◆ message

uint8_t tinymodem::GGWaveEncoder::message[GGWaveConfig::MAX_PAYLOAD]
protected

◆ message_len

int tinymodem::GGWaveEncoder::message_len = 0
protected

◆ protocol

GGWaveProtocol tinymodem::GGWaveEncoder::protocol
protected

◆ samples

SampleOutput tinymodem::GGWaveEncoder::samples
protected

◆ table

OFDMTable tinymodem::GGWaveEncoder::table
protected

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