]> git.rkrishnan.org Git - dttsp.git/blob - jDttSP/sdrexport.h
Initial revision
[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 /* modulation types, modes */ 
41 typedef enum _sdrmode {
42   LSB,                          //  0
43   USB,                          //  1
44   DSB,                          //  2
45   CWL,                          //  3
46   CWU,                          //  4
47   FMN,                          //  5
48   AM,                           //  6
49   PSK,                          //  7
50   SPEC,                         //  8
51   RTTY,                         //  9
52   SAM,                          // 10
53   DRM                           // 11
54 } SDRMODE;
55
56 typedef enum _trxmode { RX, TX } TRXMODE;
57
58 //========================================================================
59 /* RX/TX both */ 
60 //------------------------------------------------------------------------
61 extern struct _uni {
62   REAL samplerate;
63   int buflen;
64
65   struct {
66     SDRMODE sdr;
67     TRXMODE trx;
68   } mode;
69
70   struct {
71     BOOLEAN flag;
72     struct {
73       char *path;
74       size_t size;
75       Chan c;
76     } chan;
77     REAL val, avgval;
78     METERTYPE type;
79   } meter;
80
81   struct {
82     BOOLEAN flag;
83     struct {
84       char *path;
85       size_t size;
86       Chan c;
87     } chan;
88     splitfld splt;
89   } update;
90
91   struct {
92     char *path;
93     int bits;
94   } wisdom;
95
96   long tick;
97   
98 } uni;
99
100 //------------------------------------------------------------------------
101 /* RX */ 
102 //------------------------------------------------------------------------
103
104 extern struct _rx {
105   struct {
106     CXB i, o;
107   } buf;
108   IQ iqfix;
109   struct {
110     REAL freq, phase;
111     OSC gen;
112   } osc;
113   struct {
114     ComplexFIR coef;
115     FiltOvSv ovsv;
116     COMPLEX *save;
117   } filt;
118   struct {
119     REAL thresh;
120     NB gen;
121     BOOLEAN flag;
122   } nb;
123   struct {
124     REAL thresh;
125     NB gen;
126     BOOLEAN flag;
127   } nb_sdrom;
128   struct {
129     LMSR gen;
130     BOOLEAN flag;
131   } anr, anf;
132   struct {
133     DIGITALAGC gen;
134     BOOLEAN flag;
135   } agc;
136   struct { AMD gen; } am;
137   struct { FMD gen; } fm;
138   struct {
139     BOOLEAN flag;
140     SpotToneGen gen;
141   } spot;
142   struct {
143     struct {
144       REAL val;
145       BOOLEAN flag;
146     } pre, post;
147   } scl;
148   struct {
149     REAL thresh, power;
150     struct {
151       REAL meter, att, gain;
152     } offset;
153     BOOLEAN flag, running, set;
154     int num;
155   } squelch;
156   SDRMODE mode;
157   struct { BOOLEAN flag; } bin;
158   long tick;
159 } rx;
160
161 //------------------------------------------------------------------------
162 /* TX */ 
163 //------------------------------------------------------------------------
164 extern struct _tx {
165   struct {
166     CXB i, o;
167   } buf;
168   IQ iqfix;
169   struct {
170     REAL freq, phase;
171     OSC gen;
172   } osc;
173   struct {
174     ComplexFIR coef;
175     FiltOvSv ovsv;
176     COMPLEX *save;
177   } filt;
178   struct {
179     ComplexFIR coef;
180     FiltOvSv ovsv;
181     CXB in, out;
182   } fm;
183   struct {
184     DIGITALAGC gen;
185     BOOLEAN flag;
186   } agc;
187   struct {
188     SpeechProc gen;
189     BOOLEAN flag;
190   } spr;
191   struct {
192     COMPLEX dc;
193     struct {
194       REAL val;
195       BOOLEAN flag;
196     } pre, post;
197   } scl;
198   SDRMODE mode;
199   long tick;
200 } tx;
201
202 //------------------------------------------------------------------------
203
204 typedef enum _runmode {
205   RUN_MUTE, RUN_PASS, RUN_PLAY, RUN_SWCH 
206 } RUNMODE;
207
208 extern struct _top {
209   pid_t pid;
210   uid_t uid;
211   
212   struct timeval start_tv;
213
214   BOOLEAN running, verbose;
215   RUNMODE state;
216   
217   // audio io
218   struct {
219     struct {
220       float *l, *r;
221     } buf;
222     struct {
223       unsigned int frames, bytes;
224     } size;
225   } hold;
226   struct {
227     char *path;
228     int fd;
229     FILE *fp;
230     char buff[4096];
231   } parm;
232   
233   struct {
234     char name[256];
235     jack_client_t *client;
236     struct {
237       struct {
238         jack_port_t *l, *r;
239       } i, o;
240     } port;
241     struct {
242       struct {
243         jack_ringbuffer_t *l, *r;
244       } i, o;
245     } ring;
246     jack_nframes_t size;
247     struct {
248       int cb;
249       struct {
250         int i, o;
251       } rb;
252       int xr;
253     } blow;
254   } jack;
255
256   // update io
257   // multiprocessing & synchronization
258   struct {
259     struct {
260       pthread_t id;
261     } trx, upd, mon;
262   } thrd;
263   struct {
264     struct {
265       sem_t sem;
266     } buf, upd, mon;
267   } sync;
268   
269   // TRX switching
270   struct {
271     struct {
272       int want, have;
273     } bfct;
274     struct {
275       TRXMODE next;
276     } trx;
277     struct {
278       RUNMODE last;
279     } run;
280     int fade, tail;
281   } swch;
282 } top;
283
284 #endif