forked from EliasOenal/multimon-ng
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gen.h
127 lines (113 loc) · 3.4 KB
/
gen.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
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
/*
* gen.h -- generate different test signals
*
* Copyright (C) 1997
* Thomas Sailer (sailer@ife.ee.ethz.ch, hb9jnx@hb9w.che.eu)
*
* 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 2 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* ---------------------------------------------------------------------- */
#define SAMPLE_RATE 22050
#define MS(x) ((float)(x)*SAMPLE_RATE/1000)
extern const int costabi[0x400];
#define COS(x) costabi[(((x)>>6)&0x3ffu)]
enum gen_type { gentype_dtmf, gentype_sine, gentype_zvei, gentype_hdlc, gentype_uart, gentype_clipfsk };
struct gen_params {
enum gen_type type;
int ampl;
union {
struct {
int duration;
int pause;
char str[256];
} dtmf;
struct {
int duration;
int freq;
} sine;
struct {
int duration;
int pause;
char str[256];
} zvei;
struct {
int modulation;
int txdelay;
int pktlen;
unsigned char pkt[256];
} uart;
struct {
int modulation;
int txdelay;
int pktlen;
unsigned char pkt[256];
} clipfsk;
struct {
int modulation;
int txdelay;
int pktlen;
unsigned char pkt[256];
} hdlc;
} p;
};
struct gen_state {
union {
struct {
int ch_idx;
int ph_row, ph_col, phinc_row, phinc_col;
int time, time2;
} dtmf;
struct {
int ph, phinc;
int time;
} sine;
struct {
int ch_idx;
int ph, phinc;
int time, time2;
} zvei;
struct {
int ch_idx, bitmask;
unsigned int ph, phinc, bitph;
unsigned int datalen;
unsigned char data[512];
} uart;
struct {
int ch_idx, bitmask;
unsigned int ph, phinc, bitph;
unsigned int datalen;
unsigned char data[512];
} clipfsk;
struct {
int lastb;
int ch_idx, bitmask;
unsigned int ph, phinc, bitph;
unsigned int datalen;
unsigned char data[512];
} hdlc;
} s;
};
extern void gen_init_dtmf(struct gen_params *p, struct gen_state *s);
extern int gen_dtmf(signed short *buf, int buflen, struct gen_params *p, struct gen_state *s);
extern void gen_init_sine(struct gen_params *p, struct gen_state *s);
extern int gen_sine(signed short *buf, int buflen, struct gen_params *p, struct gen_state *s);
extern void gen_init_zvei(struct gen_params *p, struct gen_state *s);
extern int gen_zvei(signed short *buf, int buflen, struct gen_params *p, struct gen_state *s);
extern void gen_init_uart(struct gen_params *p, struct gen_state *s);
extern int gen_uart(signed short *buf, int buflen, struct gen_params *p, struct gen_state *s);
extern void gen_init_clipfsk(struct gen_params *p, struct gen_state *s);
extern int gen_clipfsk(signed short *buf, int buflen, struct gen_params *p, struct gen_state *s);
extern void gen_init_hdlc(struct gen_params *p, struct gen_state *s);
extern int gen_hdlc(signed short *buf, int buflen, struct gen_params *p, struct gen_state *s);