forked from OpenResearchInstitute/ka9q-radio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathosc.h
43 lines (31 loc) · 782 Bytes
/
osc.h
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#ifndef _OSC_H
#define _OSC_H 1
#define _GNU_SOURCE 1
#include <pthread.h>
#include <math.h>
#include <complex.h>
struct osc {
double freq;
double rate;
complex double phasor;
complex double phasor_step;
complex double phasor_step_step;
pthread_mutex_t mutex;
int steps; // Steps since last normalize
};
struct pll {
float samptime;
struct osc vco;
float integrator_gain;
float prop_gain;
float integrator;
};
// Osc functions
void set_osc(struct osc *osc,double f,double r);
complex double step_osc(struct osc *osc);
void renorm_osc(struct osc *osc);
int is_phasor_init(const complex double x);
// PLL functions
void init_pll(struct pll *pll,float bw,float damping,double freq,float samprate);
float run_pll(struct pll *pll,float phase);
#endif