From b86e88413d4c6ec428aaedb147f7675f28882fe4 Mon Sep 17 00:00:00 2001 From: drowe67 Date: Fri, 14 Jul 2023 12:36:50 +0930 Subject: clang-format -i applied to src unittest misc --- src/ofdm_internal.h | 389 +++++++++++++++++++++++++++------------------------- 1 file changed, 201 insertions(+), 188 deletions(-) (limited to 'src/ofdm_internal.h') diff --git a/src/ofdm_internal.h b/src/ofdm_internal.h index caa7876..a5b3c3f 100644 --- a/src/ofdm_internal.h +++ b/src/ofdm_internal.h @@ -36,39 +36,34 @@ #include "filter.h" #ifdef __cplusplus -extern "C" -{ +extern "C" { #endif #ifndef M_PI -#define M_PI 3.14159265358979323846f +#define M_PI 3.14159265358979323846f #endif -#define TAU (2.0f * M_PI) -#define ROT45 (M_PI / 4.0f) +#define TAU (2.0f * M_PI) +#define ROT45 (M_PI / 4.0f) #define MAX_UW_BITS 64 #define cmplx(value) (cosf(value) + sinf(value) * I) #define cmplxconj(value) (cosf(value) + sinf(value) * -I) /* modem state machine states */ -typedef enum { - search, - trial, - synced -} State; +typedef enum { search, trial, synced } State; typedef enum { - unsync, /* force sync state machine to lose sync, and search for new sync */ - autosync, /* falls out of sync automatically */ - manualsync /* fall out of sync only under operator control */ + unsync, /* force sync state machine to lose sync, and search for new sync */ + autosync, /* falls out of sync automatically */ + manualsync /* fall out of sync only under operator control */ } Sync; /* phase estimator bandwidth options */ typedef enum { - low_bw, /* can only track a narrow freq offset, but accurate */ - high_bw /* can track wider freq offset, but less accurate at low SNR */ + low_bw, /* can only track a narrow freq offset, but accurate */ + high_bw /* can track wider freq offset, but less accurate at low SNR */ } PhaseEstBandwidth; /* @@ -77,173 +72,182 @@ typedef enum { */ struct OFDM_CONFIG { - float tx_centre; /* TX Centre Audio Frequency */ - float rx_centre; /* RX Centre Audio Frequency */ - float fs; /* Sample Frequency */ - float rs; /* Symbol Rate */ - float ts; /* symbol duration */ - float tcp; /* Cyclic Prefix duration */ - float timing_mx_thresh; - - int nc; /* Number of carriers */ - int ns; /* Number of Symbol frames */ - int np; /* number of modem frames per packet */ - int bps; /* Bits per Symbol */ - int txtbits; /* number of auxiliary data bits */ - int nuwbits; /* number of unique word bits */ - int bad_uw_errors; - int ftwindowwidth; - int edge_pilots; - char *state_machine; /* name of sync state machine used for this mode */ - char *codename; /* name of LDPC code used with this mode */ - uint8_t tx_uw[MAX_UW_BITS]; /* user defined unique word */ - int amp_est_mode; - bool tx_bpf_en; /* default tx (mod) hilbert clipper BPF enable */ - bool rx_bpf_en; /* default rx (demod) input BPF enable */ - bool foff_limiter; /* tames freq offset updates in low SNR */ - float amp_scale; /* used to scale Tx waveform to approx FREEDV_PEAK with clipper off */ - float clip_gain1; /* gain we apply to Tx signal before clipping to control PAPR*/ - float clip_gain2; /* gain we apply to Tx signal after clipping and BBF to control peak level */ - bool clip_en; - char mode[16]; /* OFDM mode in string form */ - char *data_mode; - float fmin; - float fmax; + float tx_centre; /* TX Centre Audio Frequency */ + float rx_centre; /* RX Centre Audio Frequency */ + float fs; /* Sample Frequency */ + float rs; /* Symbol Rate */ + float ts; /* symbol duration */ + float tcp; /* Cyclic Prefix duration */ + float timing_mx_thresh; + + int nc; /* Number of carriers */ + int ns; /* Number of Symbol frames */ + int np; /* number of modem frames per packet */ + int bps; /* Bits per Symbol */ + int txtbits; /* number of auxiliary data bits */ + int nuwbits; /* number of unique word bits */ + int bad_uw_errors; + int ftwindowwidth; + int edge_pilots; + char *state_machine; /* name of sync state machine used for this mode */ + char *codename; /* name of LDPC code used with this mode */ + uint8_t tx_uw[MAX_UW_BITS]; /* user defined unique word */ + int amp_est_mode; + bool tx_bpf_en; /* default tx (mod) hilbert clipper BPF enable */ + bool rx_bpf_en; /* default rx (demod) input BPF enable */ + bool foff_limiter; /* tames freq offset updates in low SNR */ + float amp_scale; /* used to scale Tx waveform to approx FREEDV_PEAK with + clipper off */ + float clip_gain1; /* gain we apply to Tx signal before clipping to control + PAPR*/ + float clip_gain2; /* gain we apply to Tx signal after clipping and BBF to + control peak level */ + bool clip_en; + char mode[16]; /* OFDM mode in string form */ + char *data_mode; + float fmin; + float fmax; }; struct OFDM { - struct OFDM_CONFIG config; - - char mode[16]; /* mode in string form */ - /* - * See 700D Part 4 Acquisition blog post and ofdm_dev.m routines - * for how this was set - */ - float timing_mx_thresh; - - int nc; - int ns; /* NS-1 = data symbols between pilots */ - int bps; /* Bits per symbol */ - int m; /* duration of each symbol in samples */ - int ncp; /* duration of CP in samples */ - int np; /* number of modem frames per packet. In some modes we want */ - /* the total packet of data to span multiple modem frames, e.g. HF data */ - /* and/or when the FEC codeword is larger than the one */ - /* modem frame. In other modes (e.g. 700D/2020) Np=1, ie the modem frame */ - /* is the same length as the packet/FEC frame. */ - int ftwindowwidth; - int bitsperframe; /* total bits in all data symbols in modem frame */ - int bitsperpacket; /* total bits in all data symbols in a packet */ - int rowsperframe; - int samplespersymbol; - int samplesperframe; - int nrxbufhistory; /* extra storage at start of rxbuf to allow us to step back in time */ - int nrxbufmin; /* min number of samples we need in rxbuf to process a modem frame */ - int rxbufst; /* start of rxbuf window used for demod of current rx frame */ - int pre, post; /* pre-amble and post-amble detections */ - int max_samplesperframe; - int nuwframes; - int nrxbuf; - int ntxtbits; /* reserve bits/frame for aux text information */ - int nuwbits; /* number of unique word bits used to achieve packet frame sync */ - int bad_uw_errors; /* threshold for UW detection check */ - int uw_fails; /* number of times we exceeded bad_uw_errors and dropped sync */ - int edge_pilots; /* insert pilots at 1 and Nc+2, to support low bandwidth phase est */ - char *data_mode; /* "", "streaming", "burst" */ - int packetsperburst; /* for OFDM data modes, how many packets before we reset state machine */ - int amp_est_mode; /* amplitude estimtor algorithm */ - float amp_scale; - float clip_gain1; - float clip_gain2; - bool clip_en; - - float tx_centre; /* TX Center frequency */ - float rx_centre; /* RX Center frequency */ - float fs; /* Sample rate */ - float ts; /* Symbol cycle time */ - float rs; /* Symbol rate */ - float tcp; /* Cyclic prefix duration */ - float tpacket; /* time for one packet in ms */ - float inv_m; /* 1/m */ - float tx_nlower; /* TX lowest carrier freq */ - float rx_nlower; /* RX lowest carrier freq */ - float doc; /* division of radian circle */ - - float fmin; - float fmax; - - // Pointers - - struct quisk_cfFilter *tx_bpf; - struct quisk_cfFilter *rx_bpf; - - complex float *pilot_samples; - complex float *rxbuf; - complex float *pilots; - complex float **rx_sym; - complex float *rx_np; - complex float *tx_uw_syms; - COMP *tx_preamble; - COMP *tx_postamble; - - float *rx_amp; - float *aphase_est_pilot_log; - - uint8_t tx_uw[MAX_UW_BITS]; - int *uw_ind; - int *uw_ind_sym; - - // State enums - State sync_state; - State last_sync_state; - - // Sync enums - Sync sync_mode; - - // Phase enums - PhaseEstBandwidth phase_est_bandwidth; - - int phase_est_bandwidth_mode; - - // Complex - complex float foff_metric; - - // Float - float foff_est_gain; - bool foff_limiter; - float foff_est_hz; - float timing_mx; - float coarse_foff_est_hz; - float timing_norm; - float mean_amp; - - // Integer - int clock_offset_counter; - int verbose; - int sample_point; - int timing_est; - int timing_valid; - int ct_est; - int nin; - int uw_errors; - int sync_counter; - int frame_count; /* general purpose counter of modem frames */ - int packet_count; /* data mode: number of packets received so far */ - int modem_frame; /* increments for every modem frame in packet */ - - // Boolean - bool sync_start; - bool sync_end; - bool timing_en; - bool foff_est_en; - bool phase_est_en; - bool tx_bpf_en; - bool rx_bpf_en; - bool dpsk_en; - bool postambledetectoren; /* allows us to optionally disable the postamble detector */ - - char *codename; - char *state_machine; + struct OFDM_CONFIG config; + + char mode[16]; /* mode in string form */ + /* + * See 700D Part 4 Acquisition blog post and ofdm_dev.m routines + * for how this was set + */ + float timing_mx_thresh; + + int nc; + int ns; /* NS-1 = data symbols between pilots */ + int bps; /* Bits per symbol */ + int m; /* duration of each symbol in samples */ + int ncp; /* duration of CP in samples */ + int np; /* number of modem frames per packet. In some modes we want */ + /* the total packet of data to span multiple modem frames, e.g. HF data */ + /* and/or when the FEC codeword is larger than the one */ + /* modem frame. In other modes (e.g. 700D/2020) Np=1, ie the modem frame */ + /* is the same length as the packet/FEC frame. */ + int ftwindowwidth; + int bitsperframe; /* total bits in all data symbols in modem frame */ + int bitsperpacket; /* total bits in all data symbols in a packet */ + int rowsperframe; + int samplespersymbol; + int samplesperframe; + int nrxbufhistory; /* extra storage at start of rxbuf to allow us to step back + in time */ + int nrxbufmin; /* min number of samples we need in rxbuf to process a modem + frame */ + int rxbufst; /* start of rxbuf window used for demod of current rx frame */ + int pre, post; /* pre-amble and post-amble detections */ + int max_samplesperframe; + int nuwframes; + int nrxbuf; + int ntxtbits; /* reserve bits/frame for aux text information */ + int nuwbits; /* number of unique word bits used to achieve packet frame sync + */ + int bad_uw_errors; /* threshold for UW detection check */ + int uw_fails; /* number of times we exceeded bad_uw_errors and dropped sync */ + int edge_pilots; /* insert pilots at 1 and Nc+2, to support low bandwidth + phase est */ + char *data_mode; /* "", "streaming", "burst" */ + int packetsperburst; /* for OFDM data modes, how many packets before we reset + state machine */ + int amp_est_mode; /* amplitude estimtor algorithm */ + float amp_scale; + float clip_gain1; + float clip_gain2; + bool clip_en; + + float tx_centre; /* TX Center frequency */ + float rx_centre; /* RX Center frequency */ + float fs; /* Sample rate */ + float ts; /* Symbol cycle time */ + float rs; /* Symbol rate */ + float tcp; /* Cyclic prefix duration */ + float tpacket; /* time for one packet in ms */ + float inv_m; /* 1/m */ + float tx_nlower; /* TX lowest carrier freq */ + float rx_nlower; /* RX lowest carrier freq */ + float doc; /* division of radian circle */ + + float fmin; + float fmax; + + // Pointers + + struct quisk_cfFilter *tx_bpf; + struct quisk_cfFilter *rx_bpf; + + complex float *pilot_samples; + complex float *rxbuf; + complex float *pilots; + complex float **rx_sym; + complex float *rx_np; + complex float *tx_uw_syms; + COMP *tx_preamble; + COMP *tx_postamble; + + float *rx_amp; + float *aphase_est_pilot_log; + + uint8_t tx_uw[MAX_UW_BITS]; + int *uw_ind; + int *uw_ind_sym; + + // State enums + State sync_state; + State last_sync_state; + + // Sync enums + Sync sync_mode; + + // Phase enums + PhaseEstBandwidth phase_est_bandwidth; + + int phase_est_bandwidth_mode; + + // Complex + complex float foff_metric; + + // Float + float foff_est_gain; + bool foff_limiter; + float foff_est_hz; + float timing_mx; + float coarse_foff_est_hz; + float timing_norm; + float mean_amp; + + // Integer + int clock_offset_counter; + int verbose; + int sample_point; + int timing_est; + int timing_valid; + int ct_est; + int nin; + int uw_errors; + int sync_counter; + int frame_count; /* general purpose counter of modem frames */ + int packet_count; /* data mode: number of packets received so far */ + int modem_frame; /* increments for every modem frame in packet */ + + // Boolean + bool sync_start; + bool sync_end; + bool timing_en; + bool foff_est_en; + bool phase_est_en; + bool tx_bpf_en; + bool rx_bpf_en; + bool dpsk_en; + bool postambledetectoren; /* allows us to optionally disable the postamble + detector */ + + char *codename; + char *state_machine; }; /* Prototypes */ @@ -252,14 +256,22 @@ complex float qpsk_mod(int *); complex float qam16_mod(int *); void qpsk_demod(complex float, int *); void qam16_demod(complex float, int *); -void ofdm_txframe(struct OFDM *, complex float *, complex float []); -void ofdm_assemble_qpsk_modem_packet(struct OFDM *, uint8_t [], uint8_t [], uint8_t []); -void ofdm_assemble_qpsk_modem_packet_symbols(struct OFDM *, complex float [], COMP [], uint8_t []); -void ofdm_disassemble_qpsk_modem_packet(struct OFDM *, complex float rx_syms[], float rx_amps[], COMP [], float [], short []); -void ofdm_disassemble_qpsk_modem_packet_with_text_amps(struct OFDM *, complex float rx_syms[], float rx_amps[], COMP [], float [], short [], int*); -void ofdm_extract_uw(struct OFDM *ofdm, complex float rx_syms[], float rx_amps[], uint8_t rx_uw[]); -void ofdm_rand(uint16_t [], int); -void ofdm_rand_seed(uint16_t r[], int n, uint64_t seed) ; +void ofdm_txframe(struct OFDM *, complex float *, complex float[]); +void ofdm_assemble_qpsk_modem_packet(struct OFDM *, uint8_t[], uint8_t[], + uint8_t[]); +void ofdm_assemble_qpsk_modem_packet_symbols(struct OFDM *, complex float[], + COMP[], uint8_t[]); +void ofdm_disassemble_qpsk_modem_packet(struct OFDM *, complex float rx_syms[], + float rx_amps[], COMP[], float[], + short[]); +void ofdm_disassemble_qpsk_modem_packet_with_text_amps(struct OFDM *, + complex float rx_syms[], + float rx_amps[], COMP[], + float[], short[], int *); +void ofdm_extract_uw(struct OFDM *ofdm, complex float rx_syms[], + float rx_amps[], uint8_t rx_uw[]); +void ofdm_rand(uint16_t[], int); +void ofdm_rand_seed(uint16_t r[], int n, uint64_t seed); void ofdm_generate_payload_data_bits(uint8_t data_bits[], int n); void ofdm_generate_preamble(struct OFDM *ofdm, COMP *tx_preamble, int seed); int ofdm_get_phase_est_bandwidth_mode(struct OFDM *); @@ -268,7 +280,8 @@ void ofdm_clip(complex float tx[], float clip_thresh, int n); void ofdm_hilbert_clipper(struct OFDM *ofdm, complex float *tx, size_t n); float ofdm_esno_est_calc(complex float *rx_sym, int nsym); float ofdm_snr_from_esno(struct OFDM *ofdm, float EsNodB); -void ofdm_get_demod_stats(struct OFDM *ofdm, struct MODEM_STATS *stats, complex float *rx_syms, int Nsymsperpacket); +void ofdm_get_demod_stats(struct OFDM *ofdm, struct MODEM_STATS *stats, + complex float *rx_syms, int Nsymsperpacket); #ifdef __cplusplus } -- cgit v1.2.3 From 4c65d3728ad41566487e284a2410b537f5cfc56b Mon Sep 17 00:00:00 2001 From: drowe67 Date: Fri, 14 Jul 2023 13:11:18 +0930 Subject: clang-format messed up some #defione macros and re-ordered include files which broke the build. Building OK now and ctests passing --- src/HRA_112_112.h | 2 ++ src/HRA_56_56.h | 2 ++ src/HRAa_1536_512.h | 2 ++ src/HRAb_396_504.h | 2 ++ src/H_1024_2048_4f.h | 2 ++ src/H_128_256_5.h | 2 ++ src/H_16200_9720.h | 2 ++ src/H_212_158.h | 2 ++ src/H_256_512_4.h | 2 ++ src/H_256_768_22.h | 2 ++ src/H_4096_8192_3d.h | 2 ++ src/cohpsk_defs.h | 14 ++++----- src/fdmdv_internal.h | 78 ++++++++++++++++++------------------------------ src/freedv_fsk.c | 1 + src/freedv_vhf_framing.h | 2 ++ src/fsk.h | 2 ++ src/interp.h | 1 + src/lpcnet_freq.h | 2 ++ src/nlp.h | 1 + src/octave.h | 2 ++ src/ofdm_internal.h | 1 + src/pilots_coh.h | 7 +++-- src/postfilter.h | 2 ++ 23 files changed, 75 insertions(+), 60 deletions(-) (limited to 'src/ofdm_internal.h') diff --git a/src/HRA_112_112.h b/src/HRA_112_112.h index f3a1430..9eff476 100644 --- a/src/HRA_112_112.h +++ b/src/HRA_112_112.h @@ -12,6 +12,8 @@ #define HRA_112_112_DEC_TYPE 0 #define HRA_112_112_MAX_ITER 100 +#include + extern const uint16_t HRA_112_112_H_rows[]; extern const uint16_t HRA_112_112_H_cols[]; extern const float HRA_112_112_input[]; diff --git a/src/HRA_56_56.h b/src/HRA_56_56.h index 1b71beb..49b0da6 100644 --- a/src/HRA_56_56.h +++ b/src/HRA_56_56.h @@ -12,6 +12,8 @@ #define HRA_56_56_DEC_TYPE 0 #define HRA_56_56_MAX_ITER 100 +#include + extern const uint16_t HRA_56_56_H_rows[]; extern const uint16_t HRA_56_56_H_cols[]; extern const float HRA_56_56_input[]; diff --git a/src/HRAa_1536_512.h b/src/HRAa_1536_512.h index ee6c0de..7b0c58c 100644 --- a/src/HRAa_1536_512.h +++ b/src/HRAa_1536_512.h @@ -12,6 +12,8 @@ #define HRAa_1536_512_DEC_TYPE 0 #define HRAa_1536_512_MAX_ITER 100 +#include + extern const uint16_t HRAa_1536_512_H_rows[]; extern const uint16_t HRAa_1536_512_H_cols[]; extern const float HRAa_1536_512_input[]; diff --git a/src/HRAb_396_504.h b/src/HRAb_396_504.h index f5aad26..36eb5e2 100644 --- a/src/HRAb_396_504.h +++ b/src/HRAb_396_504.h @@ -12,6 +12,8 @@ #define HRAb_396_504_DEC_TYPE 0 #define HRAb_396_504_MAX_ITER 100 +#include + extern const uint16_t HRAb_396_504_H_rows[]; extern const uint16_t HRAb_396_504_H_cols[]; extern const float HRAb_396_504_input[]; diff --git a/src/H_1024_2048_4f.h b/src/H_1024_2048_4f.h index b71e49a..b4ae6ff 100644 --- a/src/H_1024_2048_4f.h +++ b/src/H_1024_2048_4f.h @@ -12,5 +12,7 @@ #define H_1024_2048_4f_DEC_TYPE 0 #define H_1024_2048_4f_MAX_ITER 100 +#include + extern const uint16_t H_1024_2048_4f_H_rows[]; extern const uint16_t H_1024_2048_4f_H_cols[]; diff --git a/src/H_128_256_5.h b/src/H_128_256_5.h index 1017982..e243c34 100644 --- a/src/H_128_256_5.h +++ b/src/H_128_256_5.h @@ -12,6 +12,8 @@ #define H_128_256_5_DEC_TYPE 0 #define H_128_256_5_MAX_ITER 100 +#include + extern const uint16_t H_128_256_5_H_rows[]; extern const uint16_t H_128_256_5_H_cols[]; extern const float H_128_256_5_input[]; diff --git a/src/H_16200_9720.h b/src/H_16200_9720.h index 72f6181..ab4832c 100644 --- a/src/H_16200_9720.h +++ b/src/H_16200_9720.h @@ -12,5 +12,7 @@ #define H_16200_9720_DEC_TYPE 0 #define H_16200_9720_MAX_ITER 100 +#include + extern const uint16_t H_16200_9720_H_rows[]; extern const uint16_t H_16200_9720_H_cols[]; diff --git a/src/H_212_158.h b/src/H_212_158.h index b8aa036..8e2e067 100644 --- a/src/H_212_158.h +++ b/src/H_212_158.h @@ -12,5 +12,7 @@ #define H_212_158_DEC_TYPE 0 #define H_212_158_MAX_ITER 100 +#include + extern const uint16_t H_212_158_H_rows[]; extern const uint16_t H_212_158_H_cols[]; diff --git a/src/H_256_512_4.h b/src/H_256_512_4.h index b8bbd32..d593461 100644 --- a/src/H_256_512_4.h +++ b/src/H_256_512_4.h @@ -12,6 +12,8 @@ #define H_256_512_4_DEC_TYPE 0 #define H_256_512_4_MAX_ITER 100 +#include + extern const uint16_t H_256_512_4_H_rows[]; extern const uint16_t H_256_512_4_H_cols[]; extern const float H_256_512_4_input[]; diff --git a/src/H_256_768_22.h b/src/H_256_768_22.h index 58cc632..38fce4e 100644 --- a/src/H_256_768_22.h +++ b/src/H_256_768_22.h @@ -12,6 +12,8 @@ #define H_256_768_22_DEC_TYPE 0 #define H_256_768_22_MAX_ITER 100 +#include + extern const uint16_t H_256_768_22_H_rows[]; extern const uint16_t H_256_768_22_H_cols[]; extern const float H_256_768_22_input[]; diff --git a/src/H_4096_8192_3d.h b/src/H_4096_8192_3d.h index a335c7f..95e22cd 100644 --- a/src/H_4096_8192_3d.h +++ b/src/H_4096_8192_3d.h @@ -12,6 +12,8 @@ #define H_4096_8192_3d_DEC_TYPE 0 #define H_4096_8192_3d_MAX_ITER 100 +#include + extern const uint16_t H_4096_8192_3d_H_rows[]; extern const uint16_t H_4096_8192_3d_H_cols[]; extern const float H_4096_8192_3d_input[]; diff --git a/src/cohpsk_defs.h b/src/cohpsk_defs.h index 968dfa5..a03bfe7 100644 --- a/src/cohpsk_defs.h +++ b/src/cohpsk_defs.h @@ -1,11 +1,9 @@ /* Generated by write_pilot_file() Octave function */ -#define NSYMROW 4 /* number of data symbols on each row (i.e. each carrier) */ -#define NS 4 /* number of data symbols between pilots */ -#define NPILOTSFRAME \ - 2 /* number of pilot symbols on each row */ -#define PILOTS_NC \ - 7 /* number of carriers */ +#define NSYMROW 4 /* number of data symbols on each row (i.e. each carrier) */ +#define NS 4 /* number of data symbols between pilots */ +#define NPILOTSFRAME 2 /* number of pilot symbols on each row */ +#define PILOTS_NC 7 /* number of carriers */ + +#define NSYMROWPILOT 6 /* length of row after pilots inserted */ -#define NSYMROWPILOT \ - 6 /* length of row after pilots inserted */ diff --git a/src/fdmdv_internal.h b/src/fdmdv_internal.h index 1c14ed4..cb3bea2 100644 --- a/src/fdmdv_internal.h +++ b/src/fdmdv_internal.h @@ -42,59 +42,39 @@ #ifndef PI #define PI 3.141592654 #endif -#define FS \ - 8000 /* sample rate in Hz */ -#define FS_VOICE_8K \ - 8000 /* speech sample rate, 8000 Hz */ -#define FS_VOICE_16K \ - 16000 /* speech sample rate, 16000 Hz */ -#define T \ - (1.0 / FS) /* sample period in seconds */ -#define RS \ - 50 /* symbol rate in Hz */ -#define NC \ - 20 /* max number of data carriers (plus one pilot in the centre) */ -#define NB \ - 2 /* Bits/symbol for QPSK modulation */ -#define RB \ - (NC * RS * NB) /* bit rate */ -#define M_FAC \ - (FS / RS) /* oversampling factor */ -#define NSYM \ - 6 /* number of symbols to filter over */ -#define NFILTER \ - (NSYM * M_FAC) /* size of tx/rx filters at sample rate M */ - -#define FSEP \ - 75 /* Default separation between carriers (Hz) */ - -#define NT \ - 5 /* number of symbols we estimate timing over */ -#define P \ - 4 /* oversample factor used for initial rx symbol filtering output */ -#define Q \ - (M_FAC / \ - 4) /* oversample factor used for initial rx symbol filtering input */ -#define NRXDEC \ - 31 /* number of taps in the rx decimation filter */ - -#define NPILOT_LUT \ - (4 * M_FAC) /* number of pilot look up table samples */ -#define NPILOTCOEFF \ - 30 /* number of FIR filter coeffs in LP filter */ -#define NPILOTBASEBAND \ - (NPILOTCOEFF + M_FAC + \ - M_FAC / P) /* number of pilot baseband samples reqd for pilot LPF */ -#define NPILOTLPF \ - (4 * M_FAC) /* number of samples we DFT pilot over, pilot est window */ +#define FS 8000 /* sample rate in Hz */ +#define FS_VOICE_8K 8000 /* speech sample rate, 8000 Hz */ +#define FS_VOICE_16K 16000 /* speech sample rate, 16000 Hz */ +#define T (1.0 / FS) /* sample period in seconds */ +#define RS 50 /* symbol rate in Hz */ +#define NC 20 /* max number of data carriers (plus one pilot in the centre) */ +#define NB 2 /* Bits/symbol for QPSK modulation */ +#define RB (NC * RS * NB) /* bit rate */ +#define M_FAC (FS / RS) /* oversampling factor */ +#define NSYM 6 /* number of symbols to filter over */ +#define NFILTER (NSYM * M_FAC) /* size of tx/rx filters at sample rate M */ + +#define FSEP 75 /* Default separation between carriers (Hz) */ + +#define NT 5 /* number of symbols we estimate timing over */ +#define P 4 /* oversampling for initial rx symbol filtering output */ +#define Q (M_FAC / 4) /* oversampling for initial rx symbol filtering input */ +#define NRXDEC 31 /* number of taps in the rx decimation filter */ + +#define NPILOT_LUT (4 * M_FAC) /* number of pilot look up table samples */ +#define NPILOTCOEFF 30 /* number of FIR filter coeffs in LP filter */ +/* number of pilot baseband samples reqd for pilot LPF */ +#define NPILOTBASEBAND (NPILOTCOEFF + M_FAC + M_FAC / P) +/* number of samples we DFT pilot over, pilot est window */ +#define NPILOTLPF (4 * M_FAC) #define MPILOTFFT 256 #define NSYNC_MEM 6 -#define NRX_FDM_MEM \ - (NFILTER + M_FAC + M_FAC / P) /* size of rx filter memory */ -#define NRXDECMEM \ - (NRXDEC + M_FAC + M_FAC / P) /* size of rx decimation filter memory */ +/* size of rx filter memory */ +#define NRX_FDM_MEM (NFILTER + M_FAC + M_FAC / P) +/* size of rx decimation filter memory */ +#define NRXDECMEM (NRXDEC + M_FAC + M_FAC / P) /* averaging filter coeffs */ diff --git a/src/freedv_fsk.c b/src/freedv_fsk.c index edd0bfd..0613263 100644 --- a/src/freedv_fsk.c +++ b/src/freedv_fsk.c @@ -17,6 +17,7 @@ #include #include "codec2.h" +#include "comp.h" #include "comp_prim.h" #include "debug_alloc.h" #include "fmfsk.h" diff --git a/src/freedv_vhf_framing.h b/src/freedv_vhf_framing.h index 9cad31b..6f18d33 100644 --- a/src/freedv_vhf_framing.h +++ b/src/freedv_vhf_framing.h @@ -37,6 +37,8 @@ #ifndef _FREEDV_VHF_FRAMING_H #define _FREEDV_VHF_FRAMING_H +#include + #include "freedv_data_channel.h" /* Standard frame type */ diff --git a/src/fsk.h b/src/fsk.h index f77d39f..1b4dfdc 100644 --- a/src/fsk.h +++ b/src/fsk.h @@ -48,6 +48,8 @@ octave/fsk_horus.m #define FSK_DEFAULT_NSYM 50 /* See Nsym below */ #define FSK_NONE -1 /* unused parameter */ +#undef P /* avoid clash with #define P in fdmdv_internal.h */ + struct FSK { /* Static parameters set up by fsk_init */ int Ndft; /* freq offset est fft */ diff --git a/src/interp.h b/src/interp.h index bb72d5b..276edd9 100644 --- a/src/interp.h +++ b/src/interp.h @@ -28,6 +28,7 @@ #ifndef __INTERP__ #define __INTERP__ +#include "defines.h" #include "kiss_fft.h" void interpolate(MODEL *interp, MODEL *prev, MODEL *next); diff --git a/src/lpcnet_freq.h b/src/lpcnet_freq.h index ac928b8..af406d8 100644 --- a/src/lpcnet_freq.h +++ b/src/lpcnet_freq.h @@ -36,6 +36,8 @@ #define LPCNET_FREQ_MAX_BANDS 18 +#include "comp.h" + int lpcnet_compute_band_energy(float *bandE, float *bandCentrekHz, COMP *Sw, float Fs, int Nfft); diff --git a/src/nlp.h b/src/nlp.h index e8ce8d8..4b56c4f 100644 --- a/src/nlp.h +++ b/src/nlp.h @@ -29,6 +29,7 @@ #define __NLP__ #include "comp.h" +#include "defines.h" void *nlp_create(C2CONST *c2const); void nlp_destroy(void *nlp_state); diff --git a/src/octave.h b/src/octave.h index 03eca26..8ecac9c 100644 --- a/src/octave.h +++ b/src/octave.h @@ -29,6 +29,8 @@ #ifndef __OCTAVE__ #define __OCTAVE__ +#include + #include "comp.h" void octave_save_int(FILE *f, char name[], int data[], int rows, int cols); diff --git a/src/ofdm_internal.h b/src/ofdm_internal.h index a5b3c3f..8007934 100644 --- a/src/ofdm_internal.h +++ b/src/ofdm_internal.h @@ -30,6 +30,7 @@ #include #include +#include #include #include "codec2_ofdm.h" diff --git a/src/pilots_coh.h b/src/pilots_coh.h index b905879..9271195 100644 --- a/src/pilots_coh.h +++ b/src/pilots_coh.h @@ -1,5 +1,6 @@ /* Generated by write_pilot_file() Octave function */ -float pilots_coh[][PILOTS_NC] = { - {1.000000, -1.000000, 1.000000, -1.000000, 1.000000, -1.000000, -1.000000}, - {-1.000000, 1.000000, 1.000000, -1.000000, 1.000000, 1.000000, 1.000000}}; \ No newline at end of file +float pilots_coh[][PILOTS_NC]={ + { 1.000000, -1.000000, 1.000000, -1.000000, 1.000000, -1.000000, -1.000000}, + { -1.000000, 1.000000, 1.000000, -1.000000, 1.000000, 1.000000, 1.000000} +}; \ No newline at end of file diff --git a/src/postfilter.h b/src/postfilter.h index 156714e..ecf7f39 100644 --- a/src/postfilter.h +++ b/src/postfilter.h @@ -28,6 +28,8 @@ #ifndef __POSTFILTER__ #define __POSTFILTER__ +#include "defines.h" + void postfilter(MODEL *model, float *bg_est); #endif -- cgit v1.2.3