SoDaRadio-5.0.3-master:8901fb5
Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
SoDa::CWGenerator Class Reference

A text to morse envelope converter. More...

#include <CWGenerator.hxx>

Public Member Functions

 CWGenerator (DatMBox *cw_env_stream, double _samp_rate, unsigned int _env_buf_len)
 Constructor. More...
 
void setCWSpeed (unsigned int wpm)
 set the speed of the cw stream in words per minute More...
 
unsigned int getCWSpeed ()
 tell us what the current CW speed is More...
 
bool readyForMore ()
 check envelope stream to see if we have less than 1 second's worth of stuff enqueued More...
 
bool sendChar (char c)
 encode a character into the envelope buffer More...
 

Private Member Functions

void appendToOut (const float *v, unsigned int vlen)
 add a buffer of envelope pieces to the outgoing envelope buffer More...
 
void flushBuffer ()
 push the current buffer out to the transmitter, filling it with zeros More...
 
void clearBuffer ()
 empty the current envelope, don't send it along to the TX unit More...
 
SoDaBufgetFreeSoDaBuf ()
 get an envelope that we can fill in More...
 
void initMorseMap ()
 setup the mapping from ascii character to morse sequence More...
 

Private Attributes

DatMBoxenv_stream
 this is the stream we send envelope buffers into. More...
 
double sample_rate
 we need to know how long a sample is (in time) More...
 
unsigned int env_buf_len
 the length of an envelope buffer More...
 
unsigned int words_per_minute
 
unsigned int edge_sample_count
 edges are 'pre-built' this is the length of an edge, in samples More...
 
unsigned int bufs_per_sec
 number of envelope buffers required per second. More...
 
float * dit
 prototype dit buffer More...
 
unsigned int dit_len
 number of samples in prototype dit More...
 
float * dah
 prototype dah buffer More...
 
unsigned int dah_len
 number of samples in prototype dah More...
 
float * inter_char_space
 prototype space between characters More...
 
unsigned int ics_len
 number of samples in prototype space between characters More...
 
float * inter_word_space
 prototype space between words More...
 
unsigned int first_iws_len
 number of samples in prototype space between words More...
 
unsigned int iws_len
 if space is repeated, number of samples in prototype space between words More...
 
float * rising_edge
 a gentle shape for the leading edge of a pulse More...
 
float * falling_edge
 a gentle shape for the trailing edge of a pulse More...
 
SoDaBufcur_buf
 the current envelope to be filled in More...
 
unsigned int cur_buf_idx
 where are we in the buffer? More...
 
unsigned int cur_buf_len
 how much of the buffer is unfilled? More...
 
bool in_digraph
 if true, we're sending a two-character (no inter-char space) sequence (like _AR) More...
 
bool last_was_space
 if true, next interword space should be a little short More...
 

Static Private Attributes

static std::map< char, std::string > morse_map
 map from ascii character to dits-and-dahs More...
 

Detailed Description

A text to morse envelope converter.

Methods accept a character and encode it into wiggles in the output envelope stream.

Definition at line 44 of file CWGenerator.hxx.

Constructor & Destructor Documentation

◆ CWGenerator()

CWGenerator::CWGenerator ( DatMBox cw_env_stream,
double  _samp_rate,
unsigned int  _env_buf_len 
)

Constructor.

Parameters
cw_env_streamenvelope stream from text-to-CW converter
_samp_ratesample rate for outbound envelope
_env_buf_lenlength of outbound buffer

Definition at line 41 of file CWGenerator.cxx.

References bufs_per_sec, cur_buf, cur_buf_idx, cur_buf_len, dah, dit, edge_sample_count, env_buf_len, env_stream, falling_edge, SoDa::SoDaBuf::getComplexMaxLen(), getFreeSoDaBuf(), in_digraph, initMorseMap(), inter_char_space, inter_word_space, morse_map, rising_edge, sample_rate, and setCWSpeed().

Member Function Documentation

◆ appendToOut()

void CWGenerator::appendToOut ( const float *  v,
unsigned int  vlen 
)
private

add a buffer of envelope pieces to the outgoing envelope buffer

Parameters
vvector of floating point envelope amplitudes
vlenlength of envelope segment

Definition at line 195 of file CWGenerator.cxx.

References cur_buf, cur_buf_idx, cur_buf_len, env_stream, SoDa::SoDaBuf::getComplexMaxLen(), SoDa::SoDaBuf::getFloatBuf(), getFreeSoDaBuf(), and SoDa::MultiMBox< T >::put().

Referenced by getCWSpeed(), and sendChar().

◆ clearBuffer()

void CWGenerator::clearBuffer ( )
private

empty the current envelope, don't send it along to the TX unit

Definition at line 242 of file CWGenerator.cxx.

References cur_buf, cur_buf_idx, cur_buf_len, SoDa::SoDaBuf::getComplexMaxLen(), and SoDa::SoDaBuf::setFloatLen().

Referenced by getCWSpeed().

◆ flushBuffer()

void CWGenerator::flushBuffer ( )
private

push the current buffer out to the transmitter, filling it with zeros

Definition at line 226 of file CWGenerator.cxx.

References cur_buf, cur_buf_idx, cur_buf_len, env_stream, SoDa::SoDaBuf::getComplexMaxLen(), SoDa::SoDaBuf::getFloatBuf(), getFreeSoDaBuf(), and SoDa::MultiMBox< T >::put().

Referenced by getCWSpeed().

◆ getCWSpeed()

unsigned int SoDa::CWGenerator::getCWSpeed ( )
inline

tell us what the current CW speed is

Returns
words per minute

Definition at line 64 of file CWGenerator.hxx.

References appendToOut(), clearBuffer(), flushBuffer(), readyForMore(), sendChar(), and words_per_minute.

◆ getFreeSoDaBuf()

SoDaBuf* SoDa::CWGenerator::getFreeSoDaBuf ( )
inlineprivate

get an envelope that we can fill in

Returns
a pointer to a floating point envelope buffer

Definition at line 102 of file CWGenerator.hxx.

References SoDa::MultiMBox< T >::alloc(), env_buf_len, env_stream, and initMorseMap().

Referenced by appendToOut(), CWGenerator(), and flushBuffer().

◆ initMorseMap()

void CWGenerator::initMorseMap ( )
private

setup the mapping from ascii character to morse sequence

Definition at line 101 of file CWGenerator.cxx.

References morse_map.

Referenced by CWGenerator(), and getFreeSoDaBuf().

◆ readyForMore()

bool CWGenerator::readyForMore ( )

check envelope stream to see if we have less than 1 second's worth of stuff enqueued

Returns
true if we need to encode more characters

Definition at line 92 of file CWGenerator.cxx.

References bufs_per_sec, env_stream, and SoDa::MultiMBox< T >::inFlightCount().

Referenced by getCWSpeed(), SoDa::CWTX::run(), and SoDa::CWTX::sendAvailChar().

◆ sendChar()

bool CWGenerator::sendChar ( char  c)

encode a character into the envelope buffer

Parameters
cthe character to be sent
Returns
true if c was a morse-encodable character

Definition at line 253 of file CWGenerator.cxx.

References appendToOut(), dah, dah_len, dit, dit_len, first_iws_len, ics_len, in_digraph, inter_char_space, inter_word_space, iws_len, last_was_space, and morse_map.

Referenced by getCWSpeed(), and SoDa::CWTX::sendAvailChar().

◆ setCWSpeed()

void CWGenerator::setCWSpeed ( unsigned int  wpm)

set the speed of the cw stream in words per minute

Parameters
wpmwords per minute

Definition at line 146 of file CWGenerator.cxx.

References dah, dah_len, dit, dit_len, edge_sample_count, falling_edge, first_iws_len, ics_len, inter_word_space, iws_len, rising_edge, sample_rate, and words_per_minute.

Referenced by CWGenerator(), and SoDa::CWTX::execSetCommand().

Member Data Documentation

◆ bufs_per_sec

unsigned int SoDa::CWGenerator::bufs_per_sec
private

number of envelope buffers required per second.

Definition at line 127 of file CWGenerator.hxx.

Referenced by CWGenerator(), and readyForMore().

◆ cur_buf

SoDaBuf* SoDa::CWGenerator::cur_buf
private

the current envelope to be filled in

Definition at line 147 of file CWGenerator.hxx.

Referenced by appendToOut(), clearBuffer(), CWGenerator(), and flushBuffer().

◆ cur_buf_idx

unsigned int SoDa::CWGenerator::cur_buf_idx
private

where are we in the buffer?

Definition at line 148 of file CWGenerator.hxx.

Referenced by appendToOut(), clearBuffer(), CWGenerator(), and flushBuffer().

◆ cur_buf_len

unsigned int SoDa::CWGenerator::cur_buf_len
private

how much of the buffer is unfilled?

Definition at line 149 of file CWGenerator.hxx.

Referenced by appendToOut(), clearBuffer(), CWGenerator(), and flushBuffer().

◆ dah

float* SoDa::CWGenerator::dah
private

prototype dah buffer

Definition at line 132 of file CWGenerator.hxx.

Referenced by CWGenerator(), sendChar(), and setCWSpeed().

◆ dah_len

unsigned int SoDa::CWGenerator::dah_len
private

number of samples in prototype dah

Definition at line 133 of file CWGenerator.hxx.

Referenced by sendChar(), and setCWSpeed().

◆ dit

float* SoDa::CWGenerator::dit
private

prototype dit buffer

Definition at line 130 of file CWGenerator.hxx.

Referenced by CWGenerator(), sendChar(), and setCWSpeed().

◆ dit_len

unsigned int SoDa::CWGenerator::dit_len
private

number of samples in prototype dit

Definition at line 131 of file CWGenerator.hxx.

Referenced by sendChar(), and setCWSpeed().

◆ edge_sample_count

unsigned int SoDa::CWGenerator::edge_sample_count
private

edges are 'pre-built' this is the length of an edge, in samples

Definition at line 125 of file CWGenerator.hxx.

Referenced by CWGenerator(), and setCWSpeed().

◆ env_buf_len

unsigned int SoDa::CWGenerator::env_buf_len
private

the length of an envelope buffer

Definition at line 121 of file CWGenerator.hxx.

Referenced by CWGenerator(), and getFreeSoDaBuf().

◆ env_stream

DatMBox* SoDa::CWGenerator::env_stream
private

this is the stream we send envelope buffers into.

Definition at line 119 of file CWGenerator.hxx.

Referenced by appendToOut(), CWGenerator(), flushBuffer(), getFreeSoDaBuf(), and readyForMore().

◆ falling_edge

float* SoDa::CWGenerator::falling_edge
private

a gentle shape for the trailing edge of a pulse

Definition at line 142 of file CWGenerator.hxx.

Referenced by CWGenerator(), and setCWSpeed().

◆ first_iws_len

unsigned int SoDa::CWGenerator::first_iws_len
private

number of samples in prototype space between words

Definition at line 137 of file CWGenerator.hxx.

Referenced by sendChar(), and setCWSpeed().

◆ ics_len

unsigned int SoDa::CWGenerator::ics_len
private

number of samples in prototype space between characters

Definition at line 135 of file CWGenerator.hxx.

Referenced by sendChar(), and setCWSpeed().

◆ in_digraph

bool SoDa::CWGenerator::in_digraph
private

if true, we're sending a two-character (no inter-char space) sequence (like _AR)

Definition at line 152 of file CWGenerator.hxx.

Referenced by CWGenerator(), and sendChar().

◆ inter_char_space

float* SoDa::CWGenerator::inter_char_space
private

prototype space between characters

Definition at line 134 of file CWGenerator.hxx.

Referenced by CWGenerator(), and sendChar().

◆ inter_word_space

float* SoDa::CWGenerator::inter_word_space
private

prototype space between words

Definition at line 136 of file CWGenerator.hxx.

Referenced by CWGenerator(), sendChar(), and setCWSpeed().

◆ iws_len

unsigned int SoDa::CWGenerator::iws_len
private

if space is repeated, number of samples in prototype space between words

Definition at line 138 of file CWGenerator.hxx.

Referenced by sendChar(), and setCWSpeed().

◆ last_was_space

bool SoDa::CWGenerator::last_was_space
private

if true, next interword space should be a little short

Definition at line 153 of file CWGenerator.hxx.

Referenced by sendChar().

◆ morse_map

std::map< char, std::string > CWGenerator::morse_map
staticprivate

map from ascii character to dits-and-dahs

Definition at line 144 of file CWGenerator.hxx.

Referenced by CWGenerator(), initMorseMap(), and sendChar().

◆ rising_edge

float* SoDa::CWGenerator::rising_edge
private

a gentle shape for the leading edge of a pulse

Definition at line 141 of file CWGenerator.hxx.

Referenced by CWGenerator(), and setCWSpeed().

◆ sample_rate

double SoDa::CWGenerator::sample_rate
private

we need to know how long a sample is (in time)

Definition at line 120 of file CWGenerator.hxx.

Referenced by CWGenerator(), and setCWSpeed().

◆ words_per_minute

unsigned int SoDa::CWGenerator::words_per_minute
private

Definition at line 124 of file CWGenerator.hxx.

Referenced by getCWSpeed(), and setCWSpeed().


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