aboutsummaryrefslogtreecommitdiffstats
path: root/src/libam/am.h
blob: e9e9889ccdee9e9b822d8d8b30aefb93cadfdc44 (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
#include "../libfilter/iir_filter.h"

typedef struct am_mod {
	double	phasestep;	/* angle to rotate vector per sample */
	double	phase;		/* current phase */
	double	gain;		/* gain to be multiplied to amplitude */
	double	bias;		/* DC offset to add (carrier amplitude) */
} am_mod_t;

int am_mod_init(am_mod_t *mod, double samplerate, double offset, double gain, double bias);
void am_mod_exit(am_mod_t *mod);
void am_modulate_complex(am_mod_t *mod, sample_t *amplitude, int num, float *baseband);

typedef struct am_demod {
	double	phasestep;	/* angle to rotate vector per sample */
	double	phase;		/* current rotation phase (used to shift) */
	double	last_phase;	/* last phase of FM (used to demodulate) */
	iir_filter_t lp[3];	/* filters received IQ signal/carrier */
	double	gain;		/* gain to be expected from amplitude */
	double	bias;		/* DC offset to be expected (carrier amplitude) */
} am_demod_t;

int am_demod_init(am_demod_t *demod, double samplerate, double offset, double gain, double bias);
void am_demod_exit(am_demod_t *demod);
void am_demodulate_complex(am_demod_t *demod, sample_t *amplitude, int length, float *baseband, sample_t *I, sample_t *Q, sample_t *carrier);