]> git.rkrishnan.org Git - dttsp.git/blob - jDttSP/sdrexport.h
Bug fixes to jsdr, keyer
[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     BOOLEAN flag, running, set;
151     int num;
152   } squelch;
153   SDRMODE mode;
154   struct { BOOLEAN flag; } bin;
155   long tick;
156   REAL norm;
157 } rx;
158
159 //------------------------------------------------------------------------
160 /* TX */ 
161 //------------------------------------------------------------------------
162 extern struct _tx {
163   struct {
164     CXB i, o;
165   } buf;
166   IQ iqfix;
167   struct {
168     REAL freq, phase;
169     OSC gen;
170   } osc;
171   struct {
172     ComplexFIR coef;
173     FiltOvSv ovsv;
174     COMPLEX *save;
175   } filt;
176   struct {
177     ComplexFIR coef;
178     FiltOvSv ovsv;
179     CXB in, out;
180   } fm;
181   struct {
182     DIGITALAGC gen;
183     BOOLEAN flag;
184   } agc;
185   struct {
186     SpeechProc gen;
187     BOOLEAN flag;
188   } spr;
189   struct {
190     COMPLEX dc;
191     struct {
192       REAL val;
193       BOOLEAN flag;
194     } pre, post;
195   } scl;
196   SDRMODE mode;
197   long tick;
198   REAL norm;
199 } tx;
200
201 //------------------------------------------------------------------------
202
203 typedef enum _runmode {
204   RUN_MUTE, RUN_PASS, RUN_PLAY, RUN_SWCH 
205 } RUNMODE;
206
207 extern struct _top {
208   pid_t pid;
209   uid_t uid;
210   
211   struct timeval start_tv;
212
213   BOOLEAN running, verbose;
214   RUNMODE state;
215   
216   // audio io
217   struct {
218     struct {
219       float *l, *r;
220     } buf;
221     struct {
222       unsigned int frames, bytes;
223     } size;
224   } hold;
225   struct {
226     char *path;
227     int fd;
228     FILE *fp;
229     char buff[4096];
230   } parm;
231   
232   struct {
233     char name[256];
234     jack_client_t *client;
235     struct {
236       struct {
237         jack_port_t *l, *r;
238       } i, o;
239     } port;
240     struct {
241       struct {
242         jack_ringbuffer_t *l, *r;
243       } i, o;
244     } ring;
245     jack_nframes_t size;
246     struct {
247       int cb;
248       struct {
249         int i, o;
250       } rb;
251       int xr;
252     } blow;
253   } jack;
254
255   // update io
256   // multiprocessing & synchronization
257   struct {
258     struct {
259       pthread_t id;
260     } trx, upd, mon;
261   } thrd;
262   struct {
263     struct {
264       sem_t sem;
265     } buf, upd, mon;
266   } sync;
267   
268   // TRX switching
269   struct {
270     struct {
271       int want, have;
272     } bfct;
273     struct {
274       TRXMODE next;
275     } trx;
276     struct {
277       RUNMODE last;
278     } run;
279     int fade, tail;
280   } swch;
281 } top;
282
283 #endif