#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"
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_char * | p_morse_char |
typedef struct ts_morse_data * | p_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 AGC_FULL_SCALE_DELAY_SECS (double)3.0 |
#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 |
#define CLEAR_CHARACTER_STATUS 0x00u |
#define CW_OFF_AMPLITUDE (FFT_GRAPH_TOP * 0.5) |
Definition at line 61 of file morse.c.
Referenced by morse_measure_fft_packet_timing().
#define CW_ON_AMPLITUDE (FFT_GRAPH_TOP * 0.51) |
Definition at line 59 of file morse.c.
Referenced by morse_measure_fft_packet_timing().
#define DEBUG_AUDIO_PP_THREAD | ( | a | ) |
#define DEBUG_DATA_COLLECTION_THREAD | ( | a | ) |
#define DEBUG_DGLITCHED_FFT_ARRAY | ( | a | ) |
#define DEBUG_DIT_DAH_DETECTION | ( | a | ) |
Definition at line 104 of file morse.c.
Referenced by check_for_eoc_eow(), and duration_2_morse_element().
#define DEBUG_MORSE_STATISTICS | ( | a | ) |
#define DEBUG_MORSE_THREAD | ( | a | ) |
#define DEBUG_MORSE_TIMING | ( | a | ) |
#define DEBUG_RAW_FFT_ARRAY | ( | a | ) |
#define DEBUG_TONE_DETECTION | ( | a | ) |
#define DIT_DUR_AT_36_WPM (double)00.0325 |
#define END_OF_CHARACTER 0x01u |
#define END_OF_WORD 0x01u |
#define FALSE 0 |
Definition at line 74 of file morse.c.
Referenced by create_MainWindow(), create_morse2txt_properties(), create_stats_window(), gui_append_character_2_morse_text(), on_MainWindow_delete_event(), on_morse2txt_properties_show(), on_startbutton_clicked(), on_statistics_activate(), on_stats_window_delete_event(), and statistics_window_deleted_handler().
#define FFT_DATA_MAX_GAIN (double)10.0 |
#define FFT_DATA_MIN_GAIN (double)0.1 |
#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 |
#define FFT_SCOPE_GAIN_DOWN_CRR_FACTOR (double)0.05 |
#define IMAG | ( | z, | |||
i, | |||||
length | ) | ((i) == 0 ? 0 : (z)[length-i]) |
#define LONG_DAH_VS_DITS (double)3.6000 |
#define LONG_DIT_VS_DAHS (double)0.4000 |
#define LONG_ELEMENT (double)1.2500 |
#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 |
#define MORSE_CODE_DECODE_TABLE_SIZE (sizeof(MORSE_CODE_DECODE_TABLE) / sizeof(struct ts_morse_2_char)) |
#define morse_debug_plot | ( | a, | |||
b | ) |
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 |
#define REAL | ( | z, | |||
i | ) | ((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 |
#define SHORT_DIT_VS_DAHS (double)0.2667 |
#define SHORT_ELEMENT (double)0.7500 |
#define TRUE 1 |
Definition at line 75 of file morse.c.
Referenced by create_MainWindow(), create_morse2txt_properties(), create_pixbuf(), create_pixmap(), interface_activate_bw_chk_item(), on_agc_apply_btn_toggled(), on_enable_fir_button_toggled(), on_startbutton_clicked(), on_statistics_activate(), and threads_stop().
#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 |
#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 struct ts_morse_char * p_morse_char |
typedef struct ts_morse_data * p_morse_data |
enum te_cw |
enum te_morse_threads |
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.
morse_thread_data | Morse decoding thread 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] |
Audio post processing thread.
Definition at line 567 of file morse.c.
References AUDIO_BUFFER_SEGMENTS, audio_capture_wait(), audio_data, audio_device_samples_get(), audio_post_processing_complete, audio_raw2double(), ts_morse_settings::audio_rec_dev, BUFFER_SEGMENT_1, DEBUG_AUDIO_PP_THREAD, PLOT_SCOPE, run, samples_processed, scope_or_fft, scope_plot(), THREADS_RUNNING, and ts_morse_settings::tone_packet_size.
Referenced by morse_start_threads().
static void check_for_eoc_eow | ( | p_morse_data | morse_thread_data | ) | [static] |
Looks for a morse end of character or end of word.
morse_thread_data | Pointer to morse decoding thread data. |
Definition at line 776 of file morse.c.
References ts_morse_statistics::avg_duration, ts_morse_char::char_status, CHARACTER_SPACE_DITS, ts_morse_data::cw_off_duration, DEBUG_DIT_DAH_DETECTION, display_character(), ts_morse_data::dit_statistics, END_OF_CHARACTER, END_OF_WORD, morse2txt(), ts_morse_data::morse_char, reset_morse_char(), VALID_CW_OFF_TONE_DETECTED, VALID_CW_ON_TONE_DETECTED, WORD_SPACE_DITS, and ts_morse_char::word_status.
Referenced by morse_measure_fft_packet_timing().
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.
dit_dah | Morse statistics. | |
duration | Duration of last detected . |
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().
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] |
Measures the duration of morse elements.
morse_thread_data | Pointer to morse decoding thread data. |
Definition at line 823 of file morse.c.
References ts_morse_statistics::avg_duration, compute_morse_statistics(), ts_morse_data::cw_on_duration, DAH, ts_morse_element::dah_or_dit, ts_morse_data::dah_statistics, DEBUG_DIT_DAH_DETECTION, DIT, ts_morse_data::dit_statistics, ts_morse_element::duration, LONG_DAH_VS_DITS, LONG_DIT_VS_DAHS, LONG_ELEMENT, ts_morse_data::morse_element, ts_morse_element::previous_duration, SHORT_DAH_VS_DITS, SHORT_DIT_VS_DAHS, and SHORT_ELEMENT.
Referenced by morse_measure_fft_packet_timing().
static void free_all | ( | void | ) | [static] |
Close audio device, and free all objects.
Definition at line 535 of file morse.c.
References agc_destroy(), audio_close(), audio_data, ts_morse_settings::audio_rec_dev, dglitch_destroy(), ts_morse_data::dt_w, dt_window_destroy(), ts_morse_data::fft_amp_pa, fft_data, ts_morse_data::fir_filter, fwin_destroy(), ts_morse_data::packet_amp_array_dg, and ts_morse_data::scope_gain.
Referenced by morse_start_threads(), and morse_stop_threads().
static char * morse2txt | ( | p_morse_char | morse_char | ) | [static] |
Converts a morse element "bit map" to a ASCII character.
morse_char | Decoded bit representation of a Morse character. |
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.
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.
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 | ) |
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.
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.
morse_thread_data | Pointer to morse decoding thread data. |
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] |
Morse de-coding thread.
Definition at line 594 of file morse.c.
References ts_morse_data::apply_fir, audio_data, audio_device_samples_get(), audio_post_processing_complete, ts_morse_settings::audio_rec_dev, DEBUG_MORSE_THREAD, dglitch_apply(), ts_morse_data::fft_amp_pa, ts_morse_settings::fft_amp_pa_size, fft_performed, ts_morse_data::fir_filter, fwin_apply(), m_audio_post_processing, morse_calculate_current_wpm(), morse_create_fft_amp_array(), MORSE_ENABLE_FILTER, morse_measure_fft_packet_timing(), ts_morse_data::packet_amp_array_dg, run, samples_processed, THREADS_RUNNING, update_morse_statistics(), update_status(), and ts_morse_data::words_per_minute.
Referenced by morse_start_threads().
static void morse_create_fft_amp_array | ( | p_morse_data | morse_thread_data | ) | [static] |
Definition at line 631 of file morse.c.
References agc_update(), ts_morse_data::apply_agc, audio_data, audio_device_samples_get(), ts_morse_settings::audio_rec_dev, ts_morse_data::cw_frequency, DEBUG_RAW_FFT_ARRAY, DEBUG_TONE_DETECTION, ts_morse_data::dt_w, dt_window_apply(), ts_morse_data::fft_amp_pa, fft_data, ts_morse_data::fft_data_gain, ts_morse_settings::fft_data_size, fft_performed, IMAG, morse_debug_plot, MORSE_ENABLE_AGC, PLOT_FFT, REAL, ts_morse_data::scope_gain, scope_or_fft, scope_plot(), and ts_morse_settings::tone_packet_size.
Referenced by morse_code().
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().
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] |
Measures the duration of a fft tone packet, detects presence of tone.
morse_thread_data | Pointer to morse decoding thread data. |
Definition at line 679 of file morse.c.
References add_element_2_morse_character(), ts_morse_char::char_status, check_for_eoc_eow(), CW_OFF, CW_OFF_AMPLITUDE, ts_morse_data::cw_off_duration, CW_ON, CW_ON_AMPLITUDE, ts_morse_data::cw_on_duration, DEBUG_DGLITCHED_FFT_ARRAY, DEBUG_MORSE_TIMING, ts_morse_element::duration, duration_2_morse_element(), ts_morse_data::fft_amp_pa, ts_morse_settings::fft_amp_pa_size, ts_morse_data::fft_data_gain, ts_morse_settings::minimum_tone_duration, ts_morse_data::morse_char, morse_debug_plot, ts_morse_data::morse_element, ts_morse_data::state, ts_morse_settings::tone_packet_duration, VALID_CW_OFF_TONE_DETECTED, and VALID_CW_ON_TONE_DETECTED.
Referenced by morse_code().
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().
void morse_set_agc_apply | ( | te_morse_agc_enable | agc_apply | ) |
Enables or disables AGC.
agc_apply | AGC apply. |
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().
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.
apply | Filter apply. |
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().
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().
int32_t morse_start_threads | ( | void | ) |
Starts the data acquisition and morse code detector threads.
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().
te_morse_thread_state morse_stop_threads | ( | void | ) |
Stops the data acquisition and morse code detector threads.
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().
static void reset_morse_char | ( | p_morse_char | morse_char | ) | [static] |
Resets the bit representation of a Morse character, ready for new character.
morse_char | Morse bit representation of ASCII character, as timed elements. |
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] |
Interface function for displaying Morse Statistics.
Definition at line 1059 of file morse.c.
References AUDIO_SEGMENTS_PER_STATUS_UPDATE, morse_stats_ts::avg_dah_dur, morse_stats_ts::avg_dit_dur, ts_morse_statistics::avg_duration, IMorse::cb_Morse_statistics, morse_stats_ts::dah_dit_ratio, ts_morse_data::dah_statistics, ts_morse_data::dit_statistics, ts_morse_data::words_per_minute, and morse_stats_ts::wpm.
Referenced by morse_code().
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().
double* audio_data [static] |
Definition at line 341 of file morse.c.
Referenced by audio_loopback_convert_thr(), audio_post_process(), free_all(), morse_code(), morse_create_fft_amp_array(), and morse_start_threads().
pthread_cond_t audio_post_processing_complete = PTHREAD_COND_INITIALIZER [static] |
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] |
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] |
Morse code stream to acsii conversion table. An array of ts_morse_2_char structs.
ts_morse_settings morse_settings [static] |
ts_morse_data morse_thread [static] |
volatile te_morse_thread_state run = THREADS_NOT_RUNNING [static] |
Definition at line 343 of file morse.c.
Referenced by audio_post_process(), data_collection(), morse_code(), morse_get_thread_state(), morse_start_threads(), and morse_stop_threads().
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] |
Definition at line 135 of file morse.c.
Referenced by audio_post_process(), morse_create_fft_amp_array(), morse_get_plot_type(), and morse_set_plot_type().
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().
IMorse user_interface [static] |