32 #include <sys/types.h> 68 unsigned int dit_samples = (
unsigned int) (round(
sample_rate * 2.6));
69 dit =
new float[dit_samples];
70 dah =
new float[dit_samples * 2];
149 if(wpm > 50) wpm = 50;
152 float dot_time_s = 1.20 / ((float) wpm);
153 unsigned int dot_samples = (int) round(
sample_rate * dot_time_s);
154 unsigned int dah_samples = dot_samples * 3;
164 for(j = 0; i < dot_samples; i++, j++) {
167 for(; i < dot_samples * 2; i++) {
178 for(j = 0; i < dah_samples; i++, j++) {
181 for(; i < dah_samples + dot_samples; i++) {
203 memcpy(&(dbuf[
cur_buf_idx]), v, svlen *
sizeof(
float));
204 cur_buf_idx += svlen;
210 memcpy(&(dbuf[cur_buf_idx]), v, remlen *
sizeof(
float));
213 cur_buf_idx += remlen;
280 for(std::string::iterator si = symb.begin();
286 else if(*si ==
'-') {
float * inter_char_space
prototype space between characters
unsigned int words_per_minute
unsigned int env_buf_len
the length of an envelope buffer
unsigned int bufs_per_sec
number of envelope buffers required per second.
bool in_digraph
if true, we're sending a two-character (no inter-char space) sequence (like _AR)
unsigned int cur_buf_len
how much of the buffer is unfilled?
float * dah
prototype dah buffer
unsigned int first_iws_len
number of samples in prototype space between words
void flushBuffer()
push the current buffer out to the transmitter, filling it with zeros
unsigned int getComplexMaxLen()
Return the maximum number of complex float values that this buffer can hold.
bool last_was_space
if true, next interword space should be a little short
float * inter_word_space
prototype space between words
float * getFloatBuf()
Return a pointer to the storage buffer of floats.
void setCWSpeed(unsigned int wpm)
set the speed of the cw stream in words per minute
float * dit
prototype dit buffer
double sample_rate
we need to know how long a sample is (in time)
float * rising_edge
a gentle shape for the leading edge of a pulse
bool sendChar(char c)
encode a character into the envelope buffer
void initMorseMap()
setup the mapping from ascii character to morse sequence
DatMBox * env_stream
this is the stream we send envelope buffers into.
unsigned int ics_len
number of samples in prototype space between characters
unsigned int dit_len
number of samples in prototype dit
SoDaBuf * getFreeSoDaBuf()
get an envelope that we can fill in
float * falling_edge
a gentle shape for the trailing edge of a pulse
void clearBuffer()
empty the current envelope, don't send it along to the TX unit
unsigned int inFlightCount()
unsigned int edge_sample_count
edges are 'pre-built' this is the length of an edge, in samples
SoDaBuf * cur_buf
the current envelope to be filled in
unsigned int dah_len
number of samples in prototype dah
bool readyForMore()
check envelope stream to see if we have less than 1 second's worth of stuff enqueued ...
bool setFloatLen(unsigned int nl)
set the length of the buffer (in number of floats.)
void appendToOut(const float *v, unsigned int vlen)
add a buffer of envelope pieces to the outgoing envelope buffer
unsigned int cur_buf_idx
where are we in the buffer?
CWGenerator(DatMBox *cw_env_stream, double _samp_rate, unsigned int _env_buf_len)
Constructor.
static std::map< char, std::string > morse_map
map from ascii character to dits-and-dahs
unsigned int iws_len
if space is repeated, number of samples in prototype space between words