]> git.rkrishnan.org Git - dttsp.git/blob - jDttSP/sdrexport.h
Major update
[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 <fromsys.h>
38 #include <defs.h>
39 #include <banal.h>
40 #include <splitfields.h>
41 #include <datatypes.h>
42 #include <bufvec.h>
43 #include <cxops.h>
44 #include <ringb.h>
45 #include <chan.h>
46 #include <lmadf.h>
47 #include <fftw.h>
48 #include <ovsv.h>
49 #include <filter.h>
50 #include <oscillator.h>
51 #include <digitalagc.h>
52 #include <am_demod.h>
53 #include <fm_demod.h>
54 #include <noiseblanker.h>
55 #include <correctIQ.h>
56 #include <crc16.h>
57 #include <speechproc.h>
58 #include <spottone.h>
59 #include <update.h>
60 #include <local.h>
61 #include <meter.h>
62 #include <spectrum.h>
63
64 //------------------------------------------------------------------------
65 // max no. simultaneous receivers
66 #ifndef MAXRX
67 #define MAXRX (4)
68 #endif
69
70 //========================================================================
71 /* RX/TX both */ 
72 //------------------------------------------------------------------------
73 extern struct _uni {
74   REAL samplerate;
75   int buflen;
76
77   struct {
78     SDRMODE sdr;
79     TRXMODE trx;
80   } mode;
81
82   MeterBlock meter;
83   SpecBlock spec;
84
85   struct {
86     BOOLEAN flag;
87     struct {
88       char *path;
89       size_t size;
90       Chan c;
91     } chan;
92     splitfld splt;
93   } update;
94
95   struct {
96     char *path;
97     int bits;
98   } wisdom;
99
100   struct {
101     BOOLEAN act[MAXRX];
102     int lis, nac, nrx;
103   } multirx;
104
105   struct {
106     struct {
107       BOOLEAN flag;
108       REAL gain;
109     } rx, tx;
110   } mix;
111
112   int cpdlen;
113
114   long tick;
115   
116 } uni;
117
118 //------------------------------------------------------------------------
119 /* RX */ 
120 //------------------------------------------------------------------------
121
122 extern struct _rx {
123   struct {
124     CXB i, o;
125   } buf;
126   IQ iqfix;
127   struct {
128     REAL freq, phase;
129     OSC gen;
130   } osc;
131   struct {
132     ComplexFIR coef;
133     FiltOvSv ovsv;
134     COMPLEX *save;
135   } filt;
136   struct {
137     REAL thresh;
138     NB gen;
139     BOOLEAN flag;
140   } nb;
141   struct {
142     REAL thresh;
143     NB gen;
144     BOOLEAN flag;
145   } nb_sdrom;
146   struct {
147     LMSR gen;
148     BOOLEAN flag;
149   } anr, anf;
150   struct {
151     DIGITALAGC gen;
152     BOOLEAN flag;
153   } agc;
154   struct { AMD gen; } am;
155   struct { FMD gen; } fm;
156   struct {
157     BOOLEAN flag;
158     SpotToneGen gen;
159   } spot;
160   struct {
161     struct {
162       REAL val;
163       BOOLEAN flag;
164     } pre, post;
165   } scl;
166   struct {
167     REAL thresh, power;
168     BOOLEAN flag, running, set;
169     int num;
170   } squelch;
171
172   struct {
173     BOOLEAN flag;
174     WSCompander gen;
175   } cpd;
176
177   SDRMODE mode;
178   struct { BOOLEAN flag; } bin;
179   REAL norm;
180   COMPLEX azim;
181   long tick;
182 } rx[MAXRX];
183
184 //------------------------------------------------------------------------
185 /* TX */ 
186 //------------------------------------------------------------------------
187 extern struct _tx {
188
189   struct {
190     CXB i, o;
191   } buf;
192
193   IQ iqfix;
194
195   struct {
196     BOOLEAN flag;
197     DCBlocker gen;
198   } dcb;
199
200   struct {
201     REAL freq, phase;
202     OSC gen;
203   } osc;
204
205   struct {
206     ComplexFIR coef;
207     FiltOvSv ovsv;
208     COMPLEX *save;
209   } filt;
210
211   struct {
212     SpeechProc gen;
213     BOOLEAN flag;
214   } spr;
215
216   struct {
217     BOOLEAN flag;
218     WSCompander gen;
219   } cpd;
220
221   struct {
222     ComplexFIR coef;
223     FiltOvSv ovsv;
224     CXB in, out;
225   } fm;
226
227   struct {
228     DIGITALAGC gen;
229     BOOLEAN flag;
230   } agc;
231
232   struct {
233     COMPLEX dc;
234     struct {
235       REAL val;
236       BOOLEAN flag;
237     } pre, post;
238   } scl;
239
240   SDRMODE mode;
241   long tick;
242   REAL norm;
243 } tx;
244
245 //------------------------------------------------------------------------
246
247 typedef enum _runmode {
248   RUN_MUTE, RUN_PASS, RUN_PLAY, RUN_SWCH 
249 } RUNMODE;
250
251 extern struct _top {
252   pid_t pid;
253   uid_t uid;
254   
255   struct timeval start_tv;
256
257   BOOLEAN running, verbose;
258   RUNMODE state;
259   
260   // audio io
261   struct {
262     struct {
263       float *l, *r;
264     } aux, buf;
265     struct {
266       unsigned int frames, bytes;
267     } size;
268   } hold;
269
270   struct {
271     char *path;
272     int fd;
273     FILE *fp;
274     char buff[4096];
275   } parm;
276
277   struct {
278     struct {
279       char *path;
280       FILE *fp;
281     } mtr, spec;
282   } meas;
283   
284   struct {
285     char name[256];
286     jack_client_t *client;
287     struct {
288       struct {
289         jack_port_t *l, *r;
290       } i, o;
291     } port;
292
293     // input only
294     struct {
295       struct {
296         jack_port_t *l, *r;
297       } i;
298     } auxp;
299
300     struct {
301       struct {
302         jack_ringbuffer_t *l, *r;
303       } i, o;
304     } ring;
305
306     struct {
307       struct {
308         jack_ringbuffer_t *l, *r;
309       } i, o;
310     } auxr;
311
312     jack_nframes_t size;
313     struct {
314       int cb;
315       struct {
316         int i, o;
317       } rb;
318       int xr;
319     } blow;
320   } jack;
321
322   // update io
323   // multiprocessing & synchronization
324   struct {
325     struct {
326       pthread_t id;
327     } trx, upd, mon, pws, mtr;
328   } thrd;
329
330   struct {
331     struct {
332       sem_t sem;
333     } buf, upd, mon, pws, mtr;
334   } sync;
335   
336   // TRX switching
337   struct {
338     struct {
339       int want, have;
340     } bfct;
341     struct {
342       TRXMODE next;
343     } trx;
344     struct {
345       RUNMODE last;
346     } run;
347     int fade, tail;
348   } swch;
349
350 } top;
351
352 #endif