morse.c File Reference

#include <stdlib.h>
#include <stdio.h>
#include <pthread.h>
#include <gsl/gsl_errno.h>
#include <gsl/gsl_fft_real.h>
#include <gsl/gsl_fft_halfcomplex.h>
#include "agc.h"
#include "dt_window.h"
#include "dglitch.h"
#include "morse.h"
#include "utility.h"
#include "fir_win.h"

Include dependency graph for morse.c:

Go to the source code of this file.

Data Structures

struct  IMorse
 Interface that GUI functions register to. More...
struct  ts_morse_2_char
 Morse code stream to ASCII character element. More...
struct  ts_morse_settings
struct  ts_morse_statistics
struct  ts_morse_element
struct  ts_morse_char
struct  ts_morse_data

Defines

#define REAL(z, i)   ((z)[i])
#define IMAG(z, i, length)   ((i) == 0 ? 0 : (z)[length-i])
#define THIRTY_SIX_WPM   (double)36.000
#define DIT_DUR_AT_36_WPM   (double)00.0325
#define WPM_SECONDS_PER_DIT   (double)(DIT_DUR_AT_36_WPM * THIRTY_SIX_WPM)
#define MIN_NUM_PACKS_PER_DIT   6
#define FFT_GRAPH_TOP   (double)100000.0
#define CW_ON_AMPLITUDE   (FFT_GRAPH_TOP * 0.51)
#define CW_OFF_AMPLITUDE   (FFT_GRAPH_TOP * 0.5)
#define MORSE_AGC_TYPE   AGC_LINEAR_PEAK_W_COMPUTED_GAIN_ON_CLIP
#define FFT_DATA_MAX_GAIN   (double)10.0
#define FFT_DATA_MIN_GAIN   (double)0.1
#define AGC_FULL_SCALE_DELAY_SECS   (double)3.0
#define FFT_NOISE_FLOOR   (double)50000.0
#define FFT_SCOPE_GAIN_UP_CRR_FACTOR   (double)0.025
#define FFT_SCOPE_GAIN_DOWN_CRR_FACTOR   (double)0.05
#define AUDIO_SEGMENTS_PER_STATUS_UPDATE   5
#define FALSE   0
#define TRUE   1
#define CLEAR_CHARACTER_STATUS   0x00u
#define END_OF_CHARACTER   0x01u
#define VALID_CW_ON_TONE_DETECTED   0x02u
#define VALID_CW_OFF_TONE_DETECTED   0x04u
#define CLEAR_WORD_STATUS   0x00u
#define END_OF_WORD   0x01u
#define SHORT_DAH_VS_DITS   (double)2.4000
#define LONG_DAH_VS_DITS   (double)3.6000
#define SHORT_DIT_VS_DAHS   (double)0.2667
#define LONG_DIT_VS_DAHS   (double)0.4000
#define SHORT_ELEMENT   (double)0.7500
#define LONG_ELEMENT   (double)1.2500
#define CHARACTER_SPACE_DITS   (double)2.5000
#define WORD_SPACE_DITS   (double)6.0000
#define MORSE_ELEMENT_HISTORY   5
#define DEBUG_DIT_DAH_DETECTION(a)
#define DEBUG_MORSE_STATISTICS(a)
#define DEBUG_MORSE_TIMING(a)
#define DEBUG_TONE_DETECTION(a)
#define DEBUG_RAW_FFT_ARRAY(a)
#define DEBUG_DGLITCHED_FFT_ARRAY(a)
#define DEBUG_DATA_COLLECTION_THREAD(a)
#define DEBUG_AUDIO_PP_THREAD(a)
#define DEBUG_MORSE_THREAD(a)
#define MORSE_CODE_DECODE_TABLE_SIZE   (sizeof(MORSE_CODE_DECODE_TABLE) / sizeof(struct ts_morse_2_char))
#define morse_debug_plot(a, b)

Typedefs

typedef struct ts_morse_charp_morse_char
typedef struct ts_morse_datap_morse_data

Enumerations

enum  te_cw { CW_ON, CW_OFF }
enum  te_morse_element_type { DAH, DIT }
enum  te_morse_threads { DATA_COLLECTION_THREAD = 0, AUDIO_POST_PROCESSING_THREAD, MORSE_CODE_DECODING_THREAD, NUMBER_OF_THREADS }

Functions

static void data_collection (void *param)
static void audio_post_process (void *param)
static void morse_code (void *param)
static void free_all (void)
static void morse_create_fft_amp_array (p_morse_data morse_thread_data)
static void duration_2_morse_element (p_morse_data morse_thread_data)
static void check_for_eoc_eow (p_morse_data morse_thread_data)
static char * morse2txt (p_morse_char morse_char)
static void reset_morse_char (p_morse_char morse_char)
static void compute_morse_statistics (ts_morse_statistics *dit_dah, double duration)
static void add_element_2_morse_character (p_morse_data morse_thread_data)
static void morse_measure_fft_packet_timing (p_morse_data morse_thread_data)
static void morse_calculate_current_wpm (p_morse_data morse_thread_data)
static void morse_recompute_filter (void)
static void update_status (int32_t ffts, uint32_t samples, double wpm)
static void scope_plot (double *vector, uint32_t num_points)
static void display_character (char *character)
static void update_morse_statistics (p_morse_data morse_data_p)
int32_t morse_start_threads (void)
 Starts the data acquisition and morse code detector threads.
te_morse_thread_state morse_stop_threads (void)
void morse_set_filter_apply (te_morse_filter_enable apply)
void morse_set_agc_apply (te_morse_agc_enable agc_apply)
void morse_set_cw_frequency (int32_t freq)
void morse_set_filter_bandwidth (int32_t bw)
int32_t morse_get_filter_bandwidth (void)
void morse_set_filter_taps (uint32_t taps)
uint32_t morse_get_filter_taps (void)
uint32_t morse_get_tone_packet_size (void)
 Returns the current packet size for FFT tone detection.
void morse_set_tone_packet_size (int32_t tone_packet_size)
 Sets the FFT data packet size to be used for morse tone detection.
uint32_t morse_get_fft_data_size (void)
 Returns the array size for the FFT data.
void morse_set_fft_data_size (uint32_t fft_data_size)
 Sets the array data size for the FFT data array.
double morse_get_fft_graph_top (void)
 Returns the top (max amplitude) of the current FFT window.
p_audio_device morse_audio_rec_dev_get (void)
void morse_audio_sample_rate_set (int32_t Hertz)
int32_t morse_audio_sample_rate_get (void)
int32_t morse_audio_device_type_id_get (void)
void morse_audio_device_type_id_set (int32_t audio_device_type_id)
te_morse_thread_state morse_get_thread_state (void)
te_morse_plot_type morse_get_plot_type (void)
 Returns the current plot type, FFT, Scope, or NONE.
void morse_set_plot_type (te_morse_plot_type plt_type)
 Set the desired plot type, this usually comes from some GUI callback/event.
double morse_max_wpm_supported (double sample_frequency, double packet_length)
 Returns the maximum words per minute that can be supported, based on seletected audio settings. */.
void set_update_status_hndlr (UI_update_status hndlr)
void set_scope_plot_hndlr (UI_scope_plot hndlr)
void set_display_character_hndlr (UI_display_character hndlr)
void set_Morse_statistics_display_hndlr (UI_Morse_statistics hndlr)
void morse_initialize (void)
void morse_shutdown (void)

Variables

static IMorse user_interface
static te_morse_plot_type scope_or_fft = PLOT_FFT
const ts_morse_2_char MORSE_CODE_DECODE_TABLE []
static ts_morse_settings morse_settings
static ts_morse_data morse_thread
static double * fft_data
static double * audio_data
static volatile
te_morse_thread_state 
run = THREADS_NOT_RUNNING
static pthread_t tid [NUMBER_OF_THREADS]
static pthread_mutex_t m_audio_post_processing = PTHREAD_MUTEX_INITIALIZER
static pthread_cond_t audio_post_processing_complete = PTHREAD_COND_INITIALIZER
static int32_t fft_performed = 0
static int32_t samples_processed = 0


Define Documentation

#define AGC_FULL_SCALE_DELAY_SECS   (double)3.0

Definition at line 65 of file morse.c.

Referenced by morse_start_threads().

#define AUDIO_SEGMENTS_PER_STATUS_UPDATE   5

Definition at line 70 of file morse.c.

Referenced by update_morse_statistics(), and update_status().

#define CHARACTER_SPACE_DITS   (double)2.5000

Definition at line 96 of file morse.c.

Referenced by check_for_eoc_eow().

#define CLEAR_CHARACTER_STATUS   0x00u

Definition at line 79 of file morse.c.

Referenced by reset_morse_char().

#define CLEAR_WORD_STATUS   0x00u

Definition at line 85 of file morse.c.

#define CW_OFF_AMPLITUDE   (FFT_GRAPH_TOP * 0.5)

Todo:
Change based on rolling average of packet amplitude array.

Definition at line 61 of file morse.c.

Referenced by morse_measure_fft_packet_timing().

#define CW_ON_AMPLITUDE   (FFT_GRAPH_TOP * 0.51)

Todo:
Change based on rolling average of packet amplitude array.

Definition at line 59 of file morse.c.

Referenced by morse_measure_fft_packet_timing().

#define DEBUG_AUDIO_PP_THREAD (  ) 

Definition at line 111 of file morse.c.

Referenced by audio_post_process().

#define DEBUG_DATA_COLLECTION_THREAD (  ) 

Definition at line 110 of file morse.c.

Referenced by data_collection().

#define DEBUG_DGLITCHED_FFT_ARRAY (  ) 

Definition at line 109 of file morse.c.

Referenced by morse_measure_fft_packet_timing().

#define DEBUG_DIT_DAH_DETECTION (  ) 

Definition at line 104 of file morse.c.

Referenced by check_for_eoc_eow(), and duration_2_morse_element().

#define DEBUG_MORSE_STATISTICS (  ) 

Definition at line 105 of file morse.c.

Referenced by compute_morse_statistics().

#define DEBUG_MORSE_THREAD (  ) 

Definition at line 112 of file morse.c.

Referenced by morse_code().

#define DEBUG_MORSE_TIMING (  ) 

Definition at line 106 of file morse.c.

Referenced by morse_measure_fft_packet_timing().

#define DEBUG_RAW_FFT_ARRAY (  ) 

Definition at line 108 of file morse.c.

Referenced by morse_create_fft_amp_array().

#define DEBUG_TONE_DETECTION (  ) 

Definition at line 107 of file morse.c.

Referenced by morse_create_fft_amp_array().

#define DIT_DUR_AT_36_WPM   (double)00.0325

This is the duration of a dit morse element in seconds at 36 words per minute. The units are Seconds/dit @ 36wpm.

Definition at line 47 of file morse.c.

#define END_OF_CHARACTER   0x01u

Definition at line 80 of file morse.c.

Referenced by check_for_eoc_eow().

#define END_OF_WORD   0x01u

Definition at line 86 of file morse.c.

Referenced by check_for_eoc_eow().

#define FALSE   0

#define FFT_DATA_MAX_GAIN   (double)10.0

Definition at line 63 of file morse.c.

Referenced by morse_start_threads().

#define FFT_DATA_MIN_GAIN   (double)0.1

Definition at line 64 of file morse.c.

Referenced by morse_start_threads().

#define FFT_GRAPH_TOP   (double)100000.0

Maximum value of the FFT graph display.

Definition at line 57 of file morse.c.

Referenced by morse_get_fft_graph_top(), and morse_start_threads().

#define FFT_NOISE_FLOOR   (double)50000.0

Definition at line 66 of file morse.c.

Referenced by morse_start_threads().

#define FFT_SCOPE_GAIN_DOWN_CRR_FACTOR   (double)0.05

Definition at line 68 of file morse.c.

Referenced by morse_start_threads().

#define FFT_SCOPE_GAIN_UP_CRR_FACTOR   (double)0.025

Definition at line 67 of file morse.c.

#define IMAG ( z,
i,
length   )     ((i) == 0 ? 0 : (z)[length-i])

Definition at line 41 of file morse.c.

Referenced by morse_create_fft_amp_array().

#define LONG_DAH_VS_DITS   (double)3.6000

Definition at line 89 of file morse.c.

Referenced by duration_2_morse_element().

#define LONG_DIT_VS_DAHS   (double)0.4000

Definition at line 91 of file morse.c.

Referenced by duration_2_morse_element().

#define LONG_ELEMENT   (double)1.2500

Definition at line 94 of file morse.c.

Referenced by duration_2_morse_element().

#define MIN_NUM_PACKS_PER_DIT   6

The minumum number of packets that will make up a dit. This limit is used to control transient noise immunity.

Definition at line 54 of file morse.c.

Referenced by morse_max_wpm_supported(), and morse_start_threads().

#define MORSE_AGC_TYPE   AGC_LINEAR_PEAK_W_COMPUTED_GAIN_ON_CLIP

Definition at line 62 of file morse.c.

Referenced by morse_start_threads().

#define MORSE_CODE_DECODE_TABLE_SIZE   (sizeof(MORSE_CODE_DECODE_TABLE) / sizeof(struct ts_morse_2_char))

Definition at line 215 of file morse.c.

Referenced by morse2txt().

#define morse_debug_plot ( a,
 ) 

Definition at line 410 of file morse.c.

Referenced by morse_create_fft_amp_array(), and morse_measure_fft_packet_timing().

#define MORSE_ELEMENT_HISTORY   5

Definition at line 99 of file morse.c.

Referenced by compute_morse_statistics().

#define REAL ( z,
 )     ((z)[i])

Needed to unpack the in place radix2 FFT terms 0 to N/2 - 1

Definition at line 40 of file morse.c.

Referenced by morse_create_fft_amp_array().

#define SHORT_DAH_VS_DITS   (double)2.4000

Definition at line 88 of file morse.c.

Referenced by duration_2_morse_element().

#define SHORT_DIT_VS_DAHS   (double)0.2667

Definition at line 90 of file morse.c.

Referenced by duration_2_morse_element().

#define SHORT_ELEMENT   (double)0.7500

Definition at line 93 of file morse.c.

Referenced by duration_2_morse_element().

#define THIRTY_SIX_WPM   (double)36.000

Definition at line 43 of file morse.c.

#define TRUE   1

#define VALID_CW_OFF_TONE_DETECTED   0x04u

Definition at line 82 of file morse.c.

Referenced by check_for_eoc_eow(), and morse_measure_fft_packet_timing().

#define VALID_CW_ON_TONE_DETECTED   0x02u

Definition at line 81 of file morse.c.

Referenced by check_for_eoc_eow(), and morse_measure_fft_packet_timing().

#define WORD_SPACE_DITS   (double)6.0000

Definition at line 97 of file morse.c.

Referenced by check_for_eoc_eow().

#define WPM_SECONDS_PER_DIT   (double)(DIT_DUR_AT_36_WPM * THIRTY_SIX_WPM)

Words per minute seconds per dit.

Definition at line 49 of file morse.c.

Referenced by morse_calculate_current_wpm(), and morse_max_wpm_supported().


Typedef Documentation

typedef struct ts_morse_char * p_morse_char

typedef struct ts_morse_data * p_morse_data


Enumeration Type Documentation

enum te_cw

CW level detection states. CW_ON, tone is present CW_OFF, tone is not present

Enumerator:
CW_ON 
CW_OFF 

Definition at line 221 of file morse.c.

Basic Morse elements.

Enumerator:
DAH 
DIT 

Definition at line 224 of file morse.c.

Number of threads in morse2txt.

Enumerator:
DATA_COLLECTION_THREAD  Collects data from soundcard.
AUDIO_POST_PROCESSING_THREAD  Scales raw data from soundcard.
MORSE_CODE_DECODING_THREAD  Decodes Morse.
NUMBER_OF_THREADS 

Definition at line 346 of file morse.c.


Function Documentation

static void add_element_2_morse_character ( p_morse_data  morse_thread_data  )  [static]

Add a dit or dah element to the current character being decoded.

Parameters:
morse_thread_data Morse decoding thread data.
See also:
p_morse_data

Definition at line 863 of file morse.c.

References DAH, ts_morse_element::dah_or_dit, ts_morse_char::dit_dahs, ts_morse_char::element_position_mask, ts_morse_char::elements, ts_morse_data::morse_char, and ts_morse_data::morse_element.

Referenced by morse_measure_fft_packet_timing().

static void audio_post_process ( void *  param  )  [static]

static void check_for_eoc_eow ( p_morse_data  morse_thread_data  )  [static]

static void compute_morse_statistics ( ts_morse_statistics dit_dah,
double  duration 
) [static]

Convers and adapts to varying Morse receive speeds, within limits of samplerate and bandwidth.

Parameters:
dit_dah Morse statistics.
duration Duration of last detected .
See also:
ts_morse_statistics

Definition at line 910 of file morse.c.

References ts_morse_statistics::avg_duration, DEBUG_MORSE_STATISTICS, ts_morse_statistics::duration_history, MORSE_ELEMENT_HISTORY, and ts_morse_statistics::samples.

Referenced by duration_2_morse_element().

static void data_collection ( void *  param  )  [static]

Audio collection data thread.

Definition at line 549 of file morse.c.

References AUDIO_BUFFER_SEGMENTS, audio_capture(), ts_morse_settings::audio_rec_dev, BUFFER_SEGMENT_1, DEBUG_DATA_COLLECTION_THREAD, run, and THREADS_RUNNING.

Referenced by morse_start_threads().

Here is the call graph for this function:

static void display_character ( char *  character  )  [static]

Interface handler to display a received character on the GUI.

Definition at line 1046 of file morse.c.

References IMorse::cb_display_character.

Referenced by check_for_eoc_eow().

static void duration_2_morse_element ( p_morse_data  morse_thread_data  )  [static]

static void free_all ( void   )  [static]

static char * morse2txt ( p_morse_char  morse_char  )  [static]

Converts a morse element "bit map" to a ASCII character.

Parameters:
morse_char Decoded bit representation of a Morse character.
See also:
p_morse_char

MORSE_CODE_DECODE_TABLE

Definition at line 889 of file morse.c.

References ts_morse_2_char::character, ts_morse_char::dit_dahs, ts_morse_char::elements, and MORSE_CODE_DECODE_TABLE_SIZE.

Referenced by check_for_eoc_eow().

int32_t morse_audio_device_type_id_get ( void   ) 

Get the current audio device type Id.

Returns:
The audio devicetype ID.

Definition at line 979 of file morse.c.

References ts_morse_settings::audio_type_id.

Referenced by on_morse2txt_properties_show(), and save_config_file().

void morse_audio_device_type_id_set ( int32_t  audio_device_type_id  ) 

Set the current audio device type Id.

Parameters:
audio_device_type_id The Id of the audio device type..

Definition at line 986 of file morse.c.

References ts_morse_settings::audio_type_id.

Referenced by load_config_file(), and on_morse2txt_properties_apply().

p_audio_device morse_audio_rec_dev_get ( void   ) 

Returns pointer to the audio record device.

Definition at line 970 of file morse.c.

References ts_morse_settings::audio_rec_dev.

Referenced by load_config_file(), on_morse2txt_properties_apply(), on_morse2txt_properties_show(), and save_config_file().

int32_t morse_audio_sample_rate_get ( void   ) 

Note:
This assumes record and playback are at the same rate. The audio API could support multiple cards at different rates, but that capability will not be used for now.

Definition at line 976 of file morse.c.

References ts_morse_settings::sample_frequency.

Referenced by on_morse2txt_properties_show(), and save_config_file().

void morse_audio_sample_rate_set ( int32_t  Hertz  ) 

Set the audio sample rate.

Parameters:
Hertz The desired sample rate in Hertz.

Definition at line 971 of file morse.c.

References ts_morse_settings::sample_frequency.

Referenced by load_config_file(), and on_morse2txt_properties_apply().

static void morse_calculate_current_wpm ( p_morse_data  morse_thread_data  )  [static]

Calculates the current received Morse speed in Words per Minute.

Parameters:
morse_thread_data Pointer to morse decoding thread data.
See also:
p_morse_data

DIT_DUR_AT_36_WPM

WPM_SECONDS_PER_DIT

Definition at line 761 of file morse.c.

References ts_morse_statistics::avg_duration, ts_morse_data::dit_statistics, ts_morse_data::words_per_minute, and WPM_SECONDS_PER_DIT.

Referenced by morse_code().

static void morse_code ( void *  param  )  [static]

static void morse_create_fft_amp_array ( p_morse_data  morse_thread_data  )  [static]

uint32_t morse_get_fft_data_size ( void   ) 

Returns the array size for the FFT data.

Definition at line 967 of file morse.c.

References ts_morse_settings::fft_data_size.

Referenced by get_fft_data_size(), on_morse2txt_properties_apply(), and on_scope_fft_button_clicked().

double morse_get_fft_graph_top ( void   ) 

Returns the top (max amplitude) of the current FFT window.

Definition at line 969 of file morse.c.

References FFT_GRAPH_TOP.

Referenced by get_fft_graph_top(), on_morse2txt_properties_apply(), and on_scope_fft_button_clicked().

int32_t morse_get_filter_bandwidth ( void   ) 

Get the bandwidth of the FIR window filter.

Definition at line 962 of file morse.c.

References ts_morse_data::filter_bandwidth.

Referenced by main(), and save_config_file().

uint32_t morse_get_filter_taps ( void   ) 

Get the number of taps in the FIR window filter.

Definition at line 964 of file morse.c.

References ts_morse_data::filter_taps.

Referenced by on_morse2txt_properties_show(), and save_config_file().

te_morse_plot_type morse_get_plot_type ( void   ) 

Returns the current plot type, FFT, Scope, or NONE.

Definition at line 1000 of file morse.c.

References scope_or_fft.

Referenced by on_scope_fft_button_clicked().

te_morse_thread_state morse_get_thread_state ( void   ) 

Returns the current state of the morse threads.

Definition at line 995 of file morse.c.

References run.

Referenced by on_startbutton_clicked().

uint32_t morse_get_tone_packet_size ( void   ) 

Returns the current packet size for FFT tone detection.

Definition at line 965 of file morse.c.

References ts_morse_settings::tone_packet_size.

Referenced by get_tone_packet_size(), load_config_file(), on_morse2txt_properties_apply(), on_morse2txt_properties_show(), on_scope_fft_button_clicked(), and save_config_file().

void morse_initialize ( void   ) 

Morse Constructor Make sure all interfaces are NULL to start, this must be called before running morse.

Definition at line 1088 of file morse.c.

References audio_create(), AUDIO_DEVICE_RECORD, ts_morse_settings::audio_rec_dev, ts_morse_settings::audio_type_id, IMorse::cb_display_character, IMorse::cb_Morse_statistics, IMorse::cb_morse_status, IMorse::cb_scope_plot, and IMorse::debug_plot.

Referenced by main().

Here is the call graph for this function:

double morse_max_wpm_supported ( double  sample_frequency,
double  packet_length 
)

Returns the maximum words per minute that can be supported, based on seletected audio settings. */.

Definition at line 1010 of file morse.c.

References MIN_NUM_PACKS_PER_DIT, and WPM_SECONDS_PER_DIT.

Referenced by on_morse2txt_properties_show(), and widget_in_property_box_changed().

static void morse_measure_fft_packet_timing ( p_morse_data  morse_thread_data  )  [static]

static void morse_recompute_filter ( void   )  [static]

Recompute FIR filter coefecients when different frequency or bandwidth is selected.

Definition at line 936 of file morse.c.

References ts_morse_data::cw_frequency, ts_morse_settings::fft_freq_step, ts_morse_data::filter_bandwidth, ts_morse_data::fir_filter, and fwin_change_freq().

Referenced by morse_set_cw_frequency(), morse_set_filter_bandwidth(), and morse_start_threads().

Here is the call graph for this function:

void morse_set_agc_apply ( te_morse_agc_enable  agc_apply  ) 

Enables or disables AGC.

Parameters:
agc_apply AGC apply.
See also:
te_morse_filter_enable

Definition at line 951 of file morse.c.

References ts_morse_data::apply_agc.

Referenced by on_agc_apply_btn_toggled().

void morse_set_cw_frequency ( int32_t  freq  ) 

Set the desired CW frequency to decode.

Definition at line 952 of file morse.c.

References ts_morse_data::cw_frequency, and morse_recompute_filter().

Referenced by on_adjustment_release_event().

Here is the call graph for this function:

void morse_set_fft_data_size ( uint32_t  fft_data_size  ) 

Sets the array data size for the FFT data array.

Definition at line 968 of file morse.c.

References ts_morse_settings::fft_data_size.

Referenced by load_config_file(), and on_morse2txt_properties_apply().

void morse_set_filter_apply ( te_morse_filter_enable  apply  ) 

Enables or disables filter.

Parameters:
apply Filter apply.
See also:
te_morse_filter_enable

Definition at line 950 of file morse.c.

References ts_morse_data::apply_fir.

Referenced by on_enable_fir_button_toggled().

void morse_set_filter_bandwidth ( int32_t  bw  ) 

Set the bandwidth of the FIR window filter.

Definition at line 957 of file morse.c.

References ts_morse_data::filter_bandwidth, and morse_recompute_filter().

Referenced by load_config_file(), and on_filter_bw_activate().

Here is the call graph for this function:

void morse_set_filter_taps ( uint32_t  taps  ) 

Set the number of taps in the FIR window filter.

Definition at line 963 of file morse.c.

References ts_morse_data::filter_taps.

Referenced by load_config_file(), and on_morse2txt_properties_apply().

void morse_set_plot_type ( te_morse_plot_type  plt_type  ) 

Set the desired plot type, this usually comes from some GUI callback/event.

Definition at line 1004 of file morse.c.

References scope_or_fft.

Referenced by on_scope_fft_button_clicked().

void morse_set_tone_packet_size ( int32_t  tone_packet_size  ) 

Sets the FFT data packet size to be used for morse tone detection.

Definition at line 966 of file morse.c.

References ts_morse_settings::tone_packet_size.

Referenced by load_config_file(), and on_morse2txt_properties_apply().

void morse_shutdown ( void   ) 

Morse Destructor

Definition at line 1100 of file morse.c.

References audio_destroy(), and ts_morse_settings::audio_rec_dev.

Referenced by main().

Here is the call graph for this function:

int32_t morse_start_threads ( void   ) 

Starts the data acquisition and morse code detector threads.

Note:
Goto's are bad? I'm sure that's what you were taught... It does yield a unified exit strategy for a function though, without explicit multiple exit points. No need to "nest" all of the above if statements as well.

Definition at line 413 of file morse.c.

References agc_create(), ts_morse_data::agc_dg, AGC_FULL_SCALE_DELAY_SECS, audio_data, audio_device_samples_get(), audio_open(), audio_post_process(), AUDIO_POST_PROCESSING_THREAD, ts_morse_settings::audio_rec_dev, audio_sample_rate_get(), ts_morse_data::dah_statistics, data_collection(), DATA_COLLECTION_THREAD, DG_MEDIAN, dglitch_create(), ts_morse_data::dit_statistics, DT_HAMMING_WINDOW, ts_morse_data::dt_w, dt_window_create(), ts_morse_data::fft_amp_pa, ts_morse_settings::fft_amp_pa_size, fft_data, FFT_DATA_MAX_GAIN, FFT_DATA_MIN_GAIN, ts_morse_settings::fft_freq_step, FFT_GRAPH_TOP, FFT_NOISE_FLOOR, fft_performed, FFT_SCOPE_GAIN_DOWN_CRR_FACTOR, ts_morse_data::filter_taps, ts_morse_data::fir_filter, free_all(), FW_BANDPASS, FW_BLACKMAN, fwin_create(), MIN_NUM_PACKS_PER_DIT, ts_morse_settings::minimum_tone_duration, MORSE_AGC_TYPE, morse_code(), MORSE_CODE_DECODING_THREAD, morse_recompute_filter(), ts_morse_data::packet_amp_array_dg, run, ts_morse_settings::sample_frequency, ts_morse_statistics::samples, samples_processed, ts_morse_data::scope_gain, THREADS_NOT_RUNNING, THREADS_RUNNING, THREADS_STARTING, tid, ts_morse_settings::tone_packet_duration, and ts_morse_settings::tone_packet_size.

Referenced by on_startbutton_clicked().

Here is the call graph for this function:

te_morse_thread_state morse_stop_threads ( void   ) 

Stops the data acquisition and morse code detector threads.

See also:
te_morse_thread_state

Definition at line 522 of file morse.c.

References AUDIO_POST_PROCESSING_THREAD, DATA_COLLECTION_THREAD, free_all(), MORSE_CODE_DECODING_THREAD, run, THREADS_CANCELING, THREADS_NOT_RUNNING, THREADS_RUNNING, and tid.

Referenced by threads_stop().

Here is the call graph for this function:

static void reset_morse_char ( p_morse_char  morse_char  )  [static]

Resets the bit representation of a Morse character, ready for new character.

Parameters:
morse_char Morse bit representation of ASCII character, as timed elements.
See also:
p_morse_char

Definition at line 876 of file morse.c.

References ts_morse_char::char_status, CLEAR_CHARACTER_STATUS, ts_morse_char::dit_dahs, ts_morse_char::element_position_mask, and ts_morse_char::elements.

Referenced by check_for_eoc_eow().

static void scope_plot ( double *  vector,
uint32_t  num_points 
) [static]

Interface handler that plots a graph on the GUI.

Definition at line 1036 of file morse.c.

References IMorse::cb_scope_plot.

Referenced by audio_post_process(), and morse_create_fft_amp_array().

void set_display_character_hndlr ( UI_display_character  hndlr  ) 

register display character handler.

Definition at line 1084 of file morse.c.

References IMorse::cb_display_character.

Referenced by init_gui_interface_hooks().

void set_Morse_statistics_display_hndlr ( UI_Morse_statistics  hndlr  ) 

register Morse statistics display handler.

Definition at line 1086 of file morse.c.

References IMorse::cb_Morse_statistics.

Referenced by init_gui_interface_hooks().

void set_scope_plot_hndlr ( UI_scope_plot  hndlr  ) 

register plot handler.

Definition at line 1082 of file morse.c.

References IMorse::cb_scope_plot.

Referenced by init_gui_interface_hooks().

void set_update_status_hndlr ( UI_update_status  hndlr  ) 

register status bar GUI handler.

Definition at line 1080 of file morse.c.

References IMorse::cb_morse_status.

Referenced by init_gui_interface_hooks().

static void update_morse_statistics ( p_morse_data  morse_data_p  )  [static]

static void update_status ( int32_t  ffts,
uint32_t  samples,
double  wpm 
) [static]

Interface handler for GUI status

Definition at line 1018 of file morse.c.

References AUDIO_SEGMENTS_PER_STATUS_UPDATE, and IMorse::cb_morse_status.

Referenced by morse_code().


Variable Documentation

double* audio_data [static]

pthread_cond_t audio_post_processing_complete = PTHREAD_COND_INITIALIZER [static]

Definition at line 359 of file morse.c.

Referenced by audio_post_process(), and morse_code().

double* fft_data [static]

Definition at line 340 of file morse.c.

Referenced by free_all(), morse_create_fft_amp_array(), and morse_start_threads().

int32_t fft_performed = 0 [static]

Todo:
  • If multiple morse threads are running, these can no longer have local global scope.

Definition at line 362 of file morse.c.

Referenced by morse_code(), morse_create_fft_amp_array(), and morse_start_threads().

pthread_mutex_t m_audio_post_processing = PTHREAD_MUTEX_INITIALIZER [static]

Definition at line 358 of file morse.c.

Referenced by morse_code().

Morse code stream to acsii conversion table. An array of ts_morse_2_char structs.

See also:
ts_morse_2_char

Definition at line 159 of file morse.c.

Definition at line 334 of file morse.c.

Definition at line 337 of file morse.c.

volatile te_morse_thread_state run = THREADS_NOT_RUNNING [static]

int32_t samples_processed = 0 [static]

Definition at line 363 of file morse.c.

Referenced by audio_post_process(), morse_code(), and morse_start_threads().

te_morse_plot_type scope_or_fft = PLOT_FFT [static]

pthread_t tid[NUMBER_OF_THREADS] [static]

Array of thread ID's.

Definition at line 356 of file morse.c.

Referenced by morse_start_threads(), and morse_stop_threads().

Definition at line 133 of file morse.c.


Generated on Mon Jun 22 21:39:31 2009 for morse2txt by  doxygen 1.5.6