]> git.rkrishnan.org Git - dttsp.git/blob - jDttSP/sdrexport.h
9900339a820167a28e930039c578c64528746fc7
[dttsp.git] / jDttSP / sdrexport.h
1 /* sdrexport.h
2
3 This file is part of a program that implements a Software-Defined Radio.
4
5 Copyright (C) 2004 by Frank Brickle, AB2KT and Bob McGwier, N4HY
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20
21 The authors can be reached by email at
22
23 ab2kt@arrl.net
24 or
25 rwmcgwier@comcast.net
26
27 or by paper mail at
28
29 The DTTS Microwave Society
30 6 Kathleen Place
31 Bridgewater, NJ 08807
32 */  
33   
34 #ifndef _sdrexport_h
35 #define _sdrexport_h
36   
37 #include <common.h>
38
39 //------------------------------------------------------------------------
40 // max no. simultaneous receivers
41 #define MAXRX (4)
42 //------------------------------------------------------------------------
43 /* modulation types, modes */ 
44 typedef enum _sdrmode {
45   LSB,                          //  0
46   USB,                          //  1
47   DSB,                          //  2
48   CWL,                          //  3
49   CWU,                          //  4
50   FMN,                          //  5
51   AM,                           //  6
52   PSK,                          //  7
53   SPEC,                         //  8
54   RTTY,                         //  9
55   SAM,                          // 10
56   DRM                           // 11
57 } SDRMODE;
58
59 typedef enum _trxmode { RX, TX } TRXMODE;
60
61 //========================================================================
62 /* RX/TX both */ 
63 //------------------------------------------------------------------------
64 extern struct _uni {
65   REAL samplerate;
66   int buflen;
67
68   struct {
69     SDRMODE sdr;
70     TRXMODE trx;
71   } mode;
72
73   struct {
74     BOOLEAN flag;
75     struct {
76       char *path;
77       size_t size;
78       Chan c;
79     } chan;
80     REAL val, avgval;
81     METERTYPE type;
82   } meter;
83
84   struct {
85     BOOLEAN flag;
86     struct {
87       char *path;
88       size_t size;
89       Chan c;
90     } chan;
91     splitfld splt;
92   } update;
93
94   struct {
95     char *path;
96     int bits;
97   } wisdom;
98
99   struct {
100     BOOLEAN act[MAXRX];
101     int lis, nac, nrx;
102   } multirx;
103
104   struct {
105     struct {
106       BOOLEAN flag;
107       REAL gain;
108     } rx, tx;
109   } mix;
110
111   long tick;
112   
113 } uni;
114
115 //------------------------------------------------------------------------
116 /* RX */ 
117 //------------------------------------------------------------------------
118
119 extern struct _rx {
120   struct {
121     CXB i, o;
122   } buf;
123   IQ iqfix;
124   struct {
125     REAL freq, phase;
126     OSC gen;
127   } osc;
128   struct {
129     ComplexFIR coef;
130     FiltOvSv ovsv;
131     COMPLEX *save;
132   } filt;
133   struct {
134     REAL thresh;
135     NB gen;
136     BOOLEAN flag;
137   } nb;
138   struct {
139     REAL thresh;
140     NB gen;
141     BOOLEAN flag;
142   } nb_sdrom;
143   struct {
144     LMSR gen;
145     BOOLEAN flag;
146   } anr, anf;
147   struct {
148     DIGITALAGC gen;
149     BOOLEAN flag;
150   } agc;
151   struct { AMD gen; } am;
152   struct { FMD gen; } fm;
153   struct {
154     BOOLEAN flag;
155     SpotToneGen gen;
156   } spot;
157   struct {
158     struct {
159       REAL val;
160       BOOLEAN flag;
161     } pre, post;
162   } scl;
163   struct {
164     REAL thresh, power;
165     BOOLEAN flag, running, set;
166     int num;
167   } squelch;
168   SDRMODE mode;
169   struct { BOOLEAN flag; } bin;
170   REAL norm;
171   COMPLEX azim;
172   long tick;
173 } rx[MAXRX];
174
175 //------------------------------------------------------------------------
176 /* TX */ 
177 //------------------------------------------------------------------------
178 extern struct _tx {
179   struct {
180     CXB i, o;
181   } buf;
182   IQ iqfix;
183   struct {
184     REAL freq, phase;
185     OSC gen;
186   } osc;
187   struct {
188     ComplexFIR coef;
189     FiltOvSv ovsv;
190     COMPLEX *save;
191   } filt;
192   struct {
193     ComplexFIR coef;
194     FiltOvSv ovsv;
195     CXB in, out;
196   } fm;
197   struct {
198     DIGITALAGC gen;
199     BOOLEAN flag;
200   } agc;
201   struct {
202     SpeechProc gen;
203     BOOLEAN flag;
204   } spr;
205   struct {
206     COMPLEX dc;
207     struct {
208       REAL val;
209       BOOLEAN flag;
210     } pre, post;
211   } scl;
212   SDRMODE mode;
213   long tick;
214   REAL norm;
215 } tx;
216
217 //------------------------------------------------------------------------
218
219 typedef enum _runmode {
220   RUN_MUTE, RUN_PASS, RUN_PLAY, RUN_SWCH 
221 } RUNMODE;
222
223 extern struct _top {
224   pid_t pid;
225   uid_t uid;
226   
227   struct timeval start_tv;
228
229   BOOLEAN running, verbose;
230   RUNMODE state;
231   
232   // audio io
233   struct {
234     struct {
235       float *l, *r;
236     } aux, buf;
237     struct {
238       unsigned int frames, bytes;
239     } size;
240   } hold;
241   struct {
242     char *path;
243     int fd;
244     FILE *fp;
245     char buff[4096];
246   } parm;
247   
248   struct {
249     char name[256];
250     jack_client_t *client;
251     struct {
252       struct {
253         jack_port_t *l, *r;
254       } i, o;
255     } port;
256
257     // input only
258     struct {
259       struct {
260         jack_port_t *l, *r;
261       } i;
262     } auxp;
263
264     struct {
265       struct {
266         jack_ringbuffer_t *l, *r;
267       } i, o;
268     } ring;
269
270     struct {
271       struct {
272         jack_ringbuffer_t *l, *r;
273       } i, o;
274     } auxr;
275
276     jack_nframes_t size;
277     struct {
278       int cb;
279       struct {
280         int i, o;
281       } rb;
282       int xr;
283     } blow;
284   } jack;
285
286   // update io
287   // multiprocessing & synchronization
288   struct {
289     struct {
290       pthread_t id;
291     } trx, upd, mon;
292   } thrd;
293   struct {
294     struct {
295       sem_t sem;
296     } buf, upd, mon;
297   } sync;
298   
299   // TRX switching
300   struct {
301     struct {
302       int want, have;
303     } bfct;
304     struct {
305       TRXMODE next;
306     } trx;
307     struct {
308       RUNMODE last;
309     } run;
310     int fade, tail;
311   } swch;
312 } top;
313
314 #endif