2019-04-08 10:53:12 +00:00
|
|
|
|
|
|
|
|
|
|
|
#include <math.h>
|
|
|
|
#include <complex.h>
|
|
|
|
|
2020-05-23 07:06:20 +00:00
|
|
|
#ifndef M_PI
|
|
|
|
#define M_PI (3.1415926535897932384626433832795)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2019-04-08 10:53:12 +00:00
|
|
|
typedef unsigned char ui8_t;
|
|
|
|
typedef unsigned short ui16_t;
|
|
|
|
typedef unsigned int ui32_t;
|
|
|
|
typedef char i8_t;
|
|
|
|
typedef short i16_t;
|
|
|
|
typedef int i32_t;
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
int sr; // sample_rate
|
|
|
|
int LOG2N;
|
|
|
|
int N;
|
|
|
|
int N2;
|
|
|
|
float *xn;
|
|
|
|
float complex *ew;
|
|
|
|
float complex *Fm;
|
|
|
|
float complex *X;
|
|
|
|
float complex *Z;
|
|
|
|
float complex *cx;
|
|
|
|
float complex *win; // float real
|
|
|
|
} dft_t;
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
FILE *fp;
|
|
|
|
//
|
|
|
|
int sr; // sample_rate
|
|
|
|
int bps; // bits/sample
|
|
|
|
int nch; // channels
|
|
|
|
int ch; // select channel
|
|
|
|
//
|
|
|
|
int symlen;
|
|
|
|
int symhd;
|
|
|
|
float sps; // samples per symbol
|
|
|
|
float _spb; // samples per bit
|
|
|
|
float br; // baud rate
|
|
|
|
//
|
|
|
|
ui32_t sample_in;
|
|
|
|
ui32_t sample_out;
|
|
|
|
ui32_t delay;
|
|
|
|
ui32_t sc;
|
|
|
|
int buffered;
|
|
|
|
int L;
|
|
|
|
int M;
|
|
|
|
int K;
|
|
|
|
float *match;
|
|
|
|
float *bufs;
|
|
|
|
float mv;
|
|
|
|
ui32_t mv_pos;
|
|
|
|
//
|
|
|
|
int N_norm;
|
|
|
|
int Nvar;
|
|
|
|
float xsum;
|
|
|
|
float qsum;
|
|
|
|
float *xs;
|
|
|
|
float *qs;
|
|
|
|
|
|
|
|
// IQ-data
|
|
|
|
int opt_iq;
|
2020-11-28 05:23:33 +00:00
|
|
|
int opt_iqdc;
|
2019-04-08 10:53:12 +00:00
|
|
|
int N_IQBUF;
|
|
|
|
float complex *rot_iqbuf;
|
2019-05-18 07:10:21 +00:00
|
|
|
float complex F1sum;
|
|
|
|
float complex F2sum;
|
2019-04-08 10:53:12 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
char *rawbits;
|
|
|
|
char *hdr;
|
|
|
|
int hdrlen;
|
|
|
|
|
|
|
|
//
|
|
|
|
float BT; // bw/time (ISI)
|
|
|
|
float h; // modulation index
|
|
|
|
|
|
|
|
// DFT
|
|
|
|
dft_t DFT;
|
|
|
|
|
2019-10-04 13:08:38 +00:00
|
|
|
// dc offset
|
|
|
|
int opt_dc;
|
|
|
|
int locked;
|
|
|
|
double dc;
|
|
|
|
double Df;
|
|
|
|
double dDf;
|
2019-04-08 10:53:12 +00:00
|
|
|
|
|
|
|
ui32_t sample_posframe;
|
|
|
|
ui32_t sample_posnoise;
|
|
|
|
|
|
|
|
double V_noise;
|
|
|
|
double V_signal;
|
|
|
|
double SNRdB;
|
|
|
|
|
2019-09-21 08:32:13 +00:00
|
|
|
// decimate
|
2019-10-04 13:08:38 +00:00
|
|
|
int opt_IFmin;
|
2019-09-10 11:12:36 +00:00
|
|
|
int decM;
|
|
|
|
ui32_t sr_base;
|
|
|
|
ui32_t dectaps;
|
|
|
|
ui32_t sample_dec;
|
|
|
|
ui32_t lut_len;
|
|
|
|
float complex *decXbuffer;
|
|
|
|
float complex *decMbuf;
|
|
|
|
float complex *ex; // exp_lut
|
|
|
|
double xlt_fq;
|
|
|
|
|
2019-09-21 08:32:13 +00:00
|
|
|
// IF: lowpass
|
|
|
|
int opt_lp;
|
|
|
|
int lpIQ_bw;
|
2019-10-04 13:08:38 +00:00
|
|
|
float lpIQ_fbw;
|
2019-09-21 08:32:13 +00:00
|
|
|
int lpIQtaps; // ui32_t
|
2019-10-04 13:08:38 +00:00
|
|
|
float *ws_lpIQ0;
|
|
|
|
float *ws_lpIQ1;
|
2019-09-21 08:32:13 +00:00
|
|
|
float *ws_lpIQ;
|
|
|
|
float complex *lpIQ_buf;
|
|
|
|
|
2019-10-04 13:08:38 +00:00
|
|
|
// FM: lowpass
|
|
|
|
int lpFM_bw;
|
|
|
|
int lpFMtaps; // ui32_t
|
|
|
|
float *ws_lpFM;
|
|
|
|
float *lpFM_buf;
|
|
|
|
float *fm_buffer;
|
|
|
|
|
2019-04-08 10:53:12 +00:00
|
|
|
} dsp_t;
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
int sr; // sample_rate
|
|
|
|
int bps; // bits_sample bits/sample
|
|
|
|
int nch; // channels
|
|
|
|
int sel_ch; // select wav channel
|
|
|
|
} pcm_t;
|
|
|
|
|
|
|
|
|
2020-05-23 07:06:20 +00:00
|
|
|
typedef struct {
|
|
|
|
ui8_t hb;
|
|
|
|
float sb;
|
|
|
|
} hsbit_t;
|
|
|
|
|
|
|
|
|
2020-06-20 04:35:13 +00:00
|
|
|
typedef struct {
|
|
|
|
char *hdr;
|
|
|
|
char *buf;
|
|
|
|
float *sbuf;
|
|
|
|
int len;
|
|
|
|
int bufpos;
|
|
|
|
float thb;
|
|
|
|
float ths;
|
|
|
|
} hdb_t;
|
|
|
|
|
2019-04-08 10:53:12 +00:00
|
|
|
|
|
|
|
float read_wav_header(pcm_t *, FILE *);
|
|
|
|
int f32buf_sample(dsp_t *, int);
|
|
|
|
int read_slbit(dsp_t *, int*, int, int, int, float, int);
|
2020-06-20 04:35:13 +00:00
|
|
|
int read_softbit(dsp_t *, hsbit_t *, int, int, int, float, int);
|
|
|
|
int read_softbit2p(dsp_t *dsp, hsbit_t *shb, int inv, int ofs, int pos, float l, int spike, hsbit_t *shb1);
|
2019-04-08 10:53:12 +00:00
|
|
|
|
|
|
|
int init_buffers(dsp_t *);
|
|
|
|
int free_buffers(dsp_t *);
|
|
|
|
|
|
|
|
int find_header(dsp_t *, float, int, int, int);
|
|
|
|
|
2020-06-20 04:35:13 +00:00
|
|
|
int f32soft_read(FILE *fp, float *s);
|
|
|
|
int find_binhead(FILE *fp, hdb_t *hdb, float *score);
|
|
|
|
int find_softbinhead(FILE *fp, hdb_t *hdb, float *score);
|
|
|
|
|
|
|
|
|