2011-06-08 23:00:22 +02:00
|
|
|
/*
|
|
|
|
* fsk.h
|
|
|
|
*
|
|
|
|
* Copyright (C) 2011 Kamal Mostafa <kamal@whence.com>
|
|
|
|
*
|
2011-06-23 02:10:50 +02:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
2011-06-08 23:00:22 +02:00
|
|
|
*
|
2011-06-23 02:10:50 +02:00
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2011-06-08 23:00:22 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define USE_FFT // leave this enabled; its presently the only choice
|
|
|
|
|
|
|
|
#ifdef USE_FFT
|
|
|
|
#include <fftw3.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
typedef struct fsk_plan fsk_plan;
|
|
|
|
|
|
|
|
struct fsk_plan {
|
|
|
|
float sample_rate;
|
|
|
|
float f_mark;
|
|
|
|
float f_space;
|
|
|
|
float filter_bw;
|
|
|
|
unsigned int n_data_bits;
|
|
|
|
|
|
|
|
unsigned int n_frame_bits;
|
|
|
|
#ifdef USE_FFT
|
|
|
|
int fftsize;
|
|
|
|
unsigned int nbands;
|
2011-06-22 05:27:51 +02:00
|
|
|
float band_width;
|
2011-06-08 23:00:22 +02:00
|
|
|
unsigned int b_mark;
|
|
|
|
unsigned int b_space;
|
|
|
|
fftwf_plan fftplan;
|
|
|
|
float *fftin;
|
|
|
|
fftwf_complex *fftout;
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
fsk_plan *
|
|
|
|
fsk_plan_new(
|
|
|
|
float sample_rate,
|
|
|
|
float f_mark,
|
|
|
|
float f_space,
|
|
|
|
float filter_bw,
|
|
|
|
unsigned int n_data_bits
|
|
|
|
);
|
|
|
|
|
|
|
|
void
|
|
|
|
fsk_plan_destroy( fsk_plan *fskp );
|
|
|
|
|
|
|
|
/* returns confidence value [0.0 to 1.0] */
|
|
|
|
float
|
|
|
|
fsk_find_frame( fsk_plan *fskp, float *samples, unsigned int frame_nsamples,
|
|
|
|
unsigned int try_max_nsamples,
|
|
|
|
unsigned int try_step_nsamples,
|
|
|
|
unsigned int *bits_outp,
|
|
|
|
unsigned int *frame_start_outp
|
|
|
|
);
|
|
|
|
|
|
|
|
int
|
|
|
|
fsk_detect_carrier(fsk_plan *fskp, float *samples, unsigned int nsamples,
|
|
|
|
float min_mag_threshold );
|
|
|
|
|
|
|
|
void
|
|
|
|
fsk_set_tones_by_bandshift( fsk_plan *fskp, unsigned int b_mark, int b_shift );
|
|
|
|
|
|
|
|
|
|
|
|
// FIXME move this?:
|
|
|
|
//#define FSK_DEBUG
|
|
|
|
#ifdef FSK_DEBUG
|
|
|
|
# define debug_log(format, args...) fprintf(stderr, format, ## args)
|
|
|
|
#else
|
|
|
|
# define debug_log(format, args...)
|
|
|
|
#endif
|
|
|
|
|