aboutsummaryrefslogtreecommitdiffstats
path: root/src/rtfwk/common.h
blob: 54e65f43a974195620f17a3aead27ddbca4f9440 (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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/* GMR-1 RT framework: Common definitions */

/* (C) 2011-2016 by Sylvain Munaut <tnt@246tNt.com>
 * All Rights Reserved
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * 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 Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef __RTFWK_COMMON_H__
#define __RTFWK_COMMON_H__

#include <math.h>

#include <osmocom/dsp/cxvec.h>
#include <osmocom/dsp/cxvec_math.h>

#include <osmocom/gmr1/sdr/defs.h>

#include "sampbuf.h"


struct gsmtap_inst;
struct gmr1_pi4cxpsk_burst;


struct app_state
{
	/* Sample source */
	struct sample_buf *buf;

	int arfcn[MAX_CHANS];
	char *filename[MAX_CHANS];

	/* Params */
	int n_chans;
	int sps;

	/* GSMTap */
	struct gsmtap_inst *gti;
};


int
win_map(struct osmo_cxvec *win,
        float complex *data, int data_len,
        int begin, int win_len);

int
burst_map(struct osmo_cxvec *burst,
          float complex *data, int data_len, int base_align, int sps,
          struct gmr1_pi4cxpsk_burst *burst_type, int tn, int win);

float
burst_energy(struct osmo_cxvec *burst);


static inline float
to_hz(float f_rps)
{
	return (GMR1_SYM_RATE * f_rps) / (2.0f * M_PIf);
}

static inline float
to_db(float v)
{
	return 10.0f * log10f(v);
}


#endif /* __RTFWK_COMMON_H__ */