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