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