SoDaRadio-5.0.3-master:8901fb5
|
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... | |
SoDaBuf * | getFreeSoDaBuf () |
get an envelope that we can fill in More... | |
void | initMorseMap () |
setup the mapping from ascii character to morse sequence More... | |
Private Attributes | |
DatMBox * | env_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... | |
SoDaBuf * | cur_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... | |
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.
CWGenerator::CWGenerator | ( | DatMBox * | cw_env_stream, |
double | _samp_rate, | ||
unsigned int | _env_buf_len | ||
) |
Constructor.
cw_env_stream | envelope stream from text-to-CW converter |
_samp_rate | sample rate for outbound envelope |
_env_buf_len | length 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().
|
private |
add a buffer of envelope pieces to the outgoing envelope buffer
v | vector of floating point envelope amplitudes |
vlen | length 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().
|
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().
|
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().
|
inline |
tell us what the current CW speed is
Definition at line 64 of file CWGenerator.hxx.
References appendToOut(), clearBuffer(), flushBuffer(), readyForMore(), sendChar(), and words_per_minute.
|
inlineprivate |
get an envelope that we can fill in
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().
|
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().
bool CWGenerator::readyForMore | ( | ) |
check envelope stream to see if we have less than 1 second's worth of stuff enqueued
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().
bool CWGenerator::sendChar | ( | char | c | ) |
encode a character into the envelope buffer
c | the character to be sent |
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().
void CWGenerator::setCWSpeed | ( | unsigned int | wpm | ) |
set the speed of the cw stream in words per minute
wpm | words 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().
|
private |
number of envelope buffers required per second.
Definition at line 127 of file CWGenerator.hxx.
Referenced by CWGenerator(), and readyForMore().
|
private |
the current envelope to be filled in
Definition at line 147 of file CWGenerator.hxx.
Referenced by appendToOut(), clearBuffer(), CWGenerator(), and flushBuffer().
|
private |
where are we in the buffer?
Definition at line 148 of file CWGenerator.hxx.
Referenced by appendToOut(), clearBuffer(), CWGenerator(), and flushBuffer().
|
private |
how much of the buffer is unfilled?
Definition at line 149 of file CWGenerator.hxx.
Referenced by appendToOut(), clearBuffer(), CWGenerator(), and flushBuffer().
|
private |
prototype dah buffer
Definition at line 132 of file CWGenerator.hxx.
Referenced by CWGenerator(), sendChar(), and setCWSpeed().
|
private |
number of samples in prototype dah
Definition at line 133 of file CWGenerator.hxx.
Referenced by sendChar(), and setCWSpeed().
|
private |
prototype dit buffer
Definition at line 130 of file CWGenerator.hxx.
Referenced by CWGenerator(), sendChar(), and setCWSpeed().
|
private |
number of samples in prototype dit
Definition at line 131 of file CWGenerator.hxx.
Referenced by sendChar(), and setCWSpeed().
|
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().
|
private |
the length of an envelope buffer
Definition at line 121 of file CWGenerator.hxx.
Referenced by CWGenerator(), and getFreeSoDaBuf().
|
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().
|
private |
a gentle shape for the trailing edge of a pulse
Definition at line 142 of file CWGenerator.hxx.
Referenced by CWGenerator(), and setCWSpeed().
|
private |
number of samples in prototype space between words
Definition at line 137 of file CWGenerator.hxx.
Referenced by sendChar(), and setCWSpeed().
|
private |
number of samples in prototype space between characters
Definition at line 135 of file CWGenerator.hxx.
Referenced by sendChar(), and setCWSpeed().
|
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().
|
private |
prototype space between characters
Definition at line 134 of file CWGenerator.hxx.
Referenced by CWGenerator(), and sendChar().
|
private |
prototype space between words
Definition at line 136 of file CWGenerator.hxx.
Referenced by CWGenerator(), sendChar(), and setCWSpeed().
|
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().
|
private |
if true, next interword space should be a little short
Definition at line 153 of file CWGenerator.hxx.
Referenced by sendChar().
|
staticprivate |
map from ascii character to dits-and-dahs
Definition at line 144 of file CWGenerator.hxx.
Referenced by CWGenerator(), initMorseMap(), and sendChar().
|
private |
a gentle shape for the leading edge of a pulse
Definition at line 141 of file CWGenerator.hxx.
Referenced by CWGenerator(), and setCWSpeed().
|
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().
|
private |
Definition at line 124 of file CWGenerator.hxx.
Referenced by getCWSpeed(), and setCWSpeed().