aboutsummaryrefslogtreecommitdiffstats
path: root/src/common/ffsk.h
blob: 84fc52a1f7119609f4f284d7efc190de904db364 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include "../common/goertzel.h"

typedef struct ffsk {
	void			*inst;
	void (*receive_bit)(void *inst, int bit, double quality, double level);
	int			channel;		/* channel number */
	int			samplerate;		/* current sample rate */
	double			samples_per_bit;	/* number of samples for one bit (1200 Baud) */
	double			bits_per_sample;	/* fraction of a bit per sample */
	goertzel_t		goertzel[2];		/* filter for fsk decoding */
	int			polarity;		/* current polarity state of bit */
	sample_t		*filter_spl;		/* array to hold ring buffer for bit decoding */
	int			filter_size;		/* size of ring buffer */
	int			filter_pos;		/* position to write next sample */
	double			filter_step;		/* counts bit duration, to trigger decoding every 10th bit */
	int			filter_bit;		/* last bit state, so we detect a bit change */
	int			filter_sample;		/* count until it is time to sample bit */
	double			phaseshift65536;	/* how much the phase of fsk synbol changes per sample */
	double			phase65536;		/* current phase */
} ffsk_t;

void ffsk_global_init(double peak_fsk);
int ffsk_init(ffsk_t *ffsk, void *inst, void (*receive_bit)(void *inst, int bit, double quality, double level), int channel, int samplerate);
void ffsk_cleanup(ffsk_t *ffsk);
void ffsk_receive(ffsk_t *ffsk, sample_t *sample, int lenght);
int ffsk_render_frame(ffsk_t *ffsk, const char *frame, int length, sample_t *sample);