]> git.rkrishnan.org Git - dttsp.git/blob - jDttSP/win/update.c
Initial revision
[dttsp.git] / jDttSP / win / update.c
1 /* update.c
2
3 common defs and code for parm update 
4    
5 This file is part of a program that implements a Software-Defined Radio.
6
7 Copyright (C) 2004 by Frank Brickle, AB2KT and Bob McGwier, N4HY
8
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
22
23 The authors can be reached by email at
24
25 ab2kt@arrl.net
26 or
27 rwmcgwier@comcast.net
28
29 or by paper mail at
30
31 The DTTS Microwave Society
32 6 Kathleen Place
33 Bridgewater, NJ 08807
34 */
35
36 #include <common.h>
37
38 ////////////////////////////////////////////////////////////////////////////
39
40 PRIVATE REAL
41 dB2lin(REAL dB) { return pow(10.0, dB / 20.0); }
42
43
44 PRIVATE int
45 setRXFilter(int n, char **p) {
46   REAL low_frequency  = atof(p[0]),
47        high_frequency = atof(p[1]);
48   int ncoef = uni.buflen + 1;
49   int i, fftlen = 2 * uni.buflen;
50   fftw_plan ptmp;
51   COMPLEX *zcvec;
52
53   if (fabs(low_frequency) >= 0.5 * uni.samplerate) return -1;
54   if (fabs(high_frequency) >= 0.5 * uni.samplerate) return -2;
55   if ((low_frequency + 10) >= high_frequency) return -3;
56   delFIR_COMPLEX(rx.filt.coef);
57
58   rx.filt.coef = newFIR_Bandpass_COMPLEX(low_frequency,
59                                          high_frequency,
60                                          uni.samplerate,
61                                          ncoef);
62
63   zcvec = newvec_COMPLEX(fftlen, "filter z vec in setFilter");
64   ptmp = fftw_create_plan(fftlen, FFTW_FORWARD, FFTW_OUT_OF_PLACE);
65 #ifdef LHS
66   for (i = 0; i < ncoef; i++) zcvec[i] = rx.filt.coef->coef[i];
67 #else
68   for (i = 0; i < ncoef; i++) zcvec[fftlen - ncoef + i] = rx.filt.coef->coef[i];
69 #endif
70   fftw_one(ptmp, (fftw_complex *) zcvec, (fftw_complex *) rx.filt.ovsv->zfvec);
71   fftw_destroy_plan(ptmp);
72   delvec_COMPLEX(zcvec);
73   memcpy((char *) rx.filt.save,
74          (char *) rx.filt.ovsv->zfvec,
75          rx.filt.ovsv->fftlen * sizeof(COMPLEX));
76
77   return 0;
78 }
79
80
81 PRIVATE int
82 setTXFilter(int n, char **p) {
83   REAL low_frequency  = atof(p[0]),
84        high_frequency = atof(p[1]);
85   int ncoef = uni.buflen + 1;
86   int i, fftlen = 2 * uni.buflen;
87   fftw_plan ptmp;
88   COMPLEX *zcvec;
89
90   if (fabs(low_frequency) >= 0.5 * uni.samplerate) return -1;
91   if (fabs(high_frequency) >= 0.5 * uni.samplerate) return -2;
92   if ((low_frequency + 10) >= high_frequency) return -3;
93   delFIR_COMPLEX(tx.filt.coef);
94   tx.filt.coef = newFIR_Bandpass_COMPLEX(low_frequency,
95                                         high_frequency,
96                                         uni.samplerate,
97                                         ncoef);
98   
99   zcvec = newvec_COMPLEX(fftlen, "filter z vec in setFilter");
100   ptmp = fftw_create_plan(fftlen, FFTW_FORWARD, FFTW_OUT_OF_PLACE);
101 #ifdef LHS
102   for (i = 0; i < ncoef; i++) zcvec[i] = tx.filt.coef->coef[i];
103 #else
104   for (i = 0; i < ncoef; i++) zcvec[fftlen - ncoef + i] = tx.filt.coef->coef[i];
105 #endif
106   fftw_one(ptmp, (fftw_complex *) zcvec, (fftw_complex *) tx.filt.ovsv->zfvec);
107   fftw_destroy_plan(ptmp);
108   delvec_COMPLEX(zcvec);
109   memcpy((char *) tx.filt.save,
110          (char *) tx.filt.ovsv->zfvec,
111          tx.filt.ovsv->fftlen * sizeof(COMPLEX));
112
113   return 0;
114 }
115
116 PRIVATE int
117 setFilter(int n, char **p) {
118   if (n == 2) return setRXFilter(n, p);
119   else {
120     int trx = atoi(p[2]);
121     if      (trx == RX) return setRXFilter(n, p);
122     else if (trx == TX) return setTXFilter(n, p);
123     else                return -1;
124   }
125 }
126
127 // setMode <mode> [TRX]
128
129 PRIVATE int
130 setMode(int n, char **p) {
131   int mode = atoi(p[0]);
132   if (n > 1) {
133     int trx = atoi(p[1]);
134     switch (trx) {
135     case TX: tx.mode = mode; break;
136     case RX: 
137     default: rx.mode = mode; break;
138     }
139   } else
140     tx.mode = rx.mode = uni.mode.sdr = mode;
141   if (rx.mode == AM) rx.am.gen->mode = AMdet;
142   if (rx.mode == SAM) rx.am.gen->mode = SAMdet;
143   return 0;
144 }
145
146 // setOsc <freq> [TRX]
147 PRIVATE int
148 setOsc(int n, char **p) {
149   REAL newfreq = atof(p[0]);
150 //  fprintf(stderr,"freq =%lf, samplerate = %lf\n",newfreq,uni.samplerate);
151   if (fabs(newfreq) >= 0.5 * uni.samplerate) return -1;
152   newfreq *= 2.0 * M_PI / uni.samplerate;
153   if (n > 1) {
154     int trx = atoi(p[1]);
155     switch (trx) {
156     case TX: tx.osc.gen->Frequency = newfreq; break;
157     case RX:
158     default: rx.osc.gen->Frequency = newfreq; break;
159     }
160   } else
161     tx.osc.gen->Frequency = rx.osc.gen->Frequency = newfreq;
162   return 0;
163 }
164
165 PRIVATE int
166 setSampleRate(int n, char **p) {
167   REAL samplerate = atof(p[0]);
168   uni.samplerate = samplerate;
169   return 0;
170 }
171
172 PRIVATE int
173 setNR(int n, char **p) {
174   rx.anr.flag = atoi(p[0]);
175   return 0;
176 }
177
178 PRIVATE int
179 setANF(int n, char **p) {
180   rx.anf.flag = atoi(p[0]);
181   return 0;
182 }
183
184 PRIVATE int
185 setNB(int n, char **p) {
186   rx.nb.flag = atoi(p[0]);
187   return 0;
188 }
189
190 PRIVATE int
191 setNBvals(int n, char **p) {
192  REAL threshold = atof(p[0]);
193   rx.nb.gen->threshold = rx.nb.thresh = threshold;
194   return 0;
195 }
196
197 PRIVATE int
198 setSDROM(int n, char **p) {
199   rx.nb_sdrom.flag = atoi(p[0]);
200   return 0;
201 }
202
203 PRIVATE int
204 setSDROMvals(int n, char **p) {
205  REAL threshold = atof(p[0]);
206   rx.nb_sdrom.gen->threshold = rx.nb_sdrom.thresh = threshold;
207   return 0;
208 }
209
210 PRIVATE int
211 setBIN(int n, char **p) {
212   rx.bin.flag = atoi(p[0]);
213   return 0;
214 }
215
216 PRIVATE
217 // setfixedAGC <gain> [TRX]
218 int
219 setfixedAGC(int n, char **p) {
220   REAL gain = atof(p[0]);
221   if (n > 1) {
222     int trx = atoi(p[1]);
223     switch(trx) {
224     case TX: tx.agc.gen->AgcFixedGain = gain; break;
225     case RX:
226     default: rx.agc.gen->AgcFixedGain = gain; break;
227     }
228   } else
229     tx.agc.gen->AgcFixedGain = rx.agc.gen->AgcFixedGain = gain;
230   return 0;
231 }
232
233 PRIVATE int
234 setTXAGC(int n, char **p) {
235   int setit = atoi(p[0]);
236   switch (setit) {
237   case agcOFF:
238     tx.agc.gen->AgcMode = agcOFF;
239     tx.agc.flag = FALSE;
240     break;
241   case agcSLOW:
242     tx.agc.gen->AgcMode = agcSLOW;
243     tx.agc.gen->Hang = 10;
244     tx.agc.flag = TRUE;
245     break;
246   case agcMED:
247     tx.agc.gen->AgcMode = agcMED;
248     tx.agc.gen->Hang = 6;
249     tx.agc.flag = TRUE;
250     break;
251   case agcFAST:
252     tx.agc.gen->AgcMode = agcFAST;
253     tx.agc.gen->Hang = 3;
254     tx.agc.flag = TRUE;
255     break;
256   case agcLONG:
257     tx.agc.gen->AgcMode = agcLONG;
258     tx.agc.gen->Hang = 23;
259     tx.agc.flag = TRUE;
260     break;
261   }
262   return 0;
263 }
264
265 PRIVATE int
266 setTXAGCCompression(int n, char **p) {
267   REAL txcompression = atof(p[0]);
268   tx.agc.gen->MaxGain = pow(10.0 , txcompression * 0.05);
269   return 0;
270 }
271
272 PRIVATE int
273 setTXAGCFF(int n, char **p) {
274         int setit = atoi(p[0]);
275         tx.spr.flag = setit;
276         return 0;
277 }
278
279 PRIVATE int
280 setTXAGCFFCompression(int n, char **p) {
281   REAL txcompression = atof(p[0]);
282   tx.spr.gen->MaxGain = pow(10.0 , txcompression * 0.05);
283   return 0;
284 }
285
286 PRIVATE int
287 setTXAGCHang(int n, char **p) {
288   int hang = atoi(p[0]);
289   tx.agc.gen->Hang =
290     (int) max(1, min(23, ((REAL) hang) * uni.samplerate / (1000.0 * uni.buflen)));
291   return 0;
292 }
293
294 PRIVATE int
295 setTXAGCLimit(int n, char **p) {
296   REAL limit = atof(p[0]);
297   tx.agc.gen->AgcLimit = 0.001 * limit;
298   return 0;
299 }
300
301 PRIVATE int
302 setTXSpeechCompression(int n, char **p) {
303   tx.spr.flag = atoi(p[0]);
304   return 0;
305 }
306
307 PRIVATE int
308 setTXSpeechCompressionGain(int n, char **p) {
309   tx.spr.gen->MaxGain = dB2lin(atof(p[0]));
310   return 0;
311 }
312
313 //============================================================
314
315 PRIVATE int
316 f2x(REAL f) {
317   REAL fix = tx.filt.ovsv->fftlen * f / uni.samplerate;
318   return (int) (fix + 0.5);
319 }
320
321 //------------------------------------------------------------
322
323 PRIVATE void
324 apply_txeq_band(REAL lof, REAL dB, REAL hif) {
325   int i,
326       lox = f2x(lof),
327       hix = f2x(hif),
328           l = tx.filt.ovsv->fftlen;
329   REAL g = dB2lin(dB);
330   COMPLEX *src = tx.filt.save,
331           *trg = tx.filt.ovsv->zfvec;
332    for (i = lox; i < hix; i++) {
333     trg[i] = Cscl(src[i], g);
334     if (i) {
335       int j = l - i;
336       trg[j] = Cscl(src[j], g);
337     }
338   }
339 }
340
341 // typical:
342 // 0 dB1 75 dB2 150 dB3 300 dB4 600 dB5 1200 dB6 2000 dB7 2800 dB8 3600
343 // approximates W2IHY bandcenters.
344 // no args, revert to no EQ.
345 PRIVATE int
346 setTXEQ(int n, char **p) {
347   if (n < 3) {
348     // revert to no EQ
349     memcpy((char *) tx.filt.ovsv->zfvec,
350            (char *) tx.filt.save,
351            tx.filt.ovsv->fftlen * sizeof(COMPLEX));
352     return 0;
353   } else {
354     int i;
355     REAL lof = atof(p[0]);
356     for (i = 0; i < n - 2; i += 2) {
357       REAL dB = atof(p[i + 1]),
358            hif = atof(p[i + 2]);
359       if (lof < 0.0 || hif <= lof) return -1;
360       apply_txeq_band(lof, dB, hif);
361       lof = hif;
362     }
363     return 0;
364   }
365 }
366
367 //------------------------------------------------------------
368
369 PRIVATE void
370 apply_rxeq_band(REAL lof, REAL dB, REAL hif) {
371   int i,
372       lox = f2x(lof),
373       hix = f2x(hif),
374       l = rx.filt.ovsv->fftlen;
375   REAL g = dB2lin(dB);
376   COMPLEX *src = rx.filt.save,
377           *trg = rx.filt.ovsv->zfvec;
378   for (i = lox; i < hix; i++) {
379     trg[i] = Cscl(src[i], g);
380     if (i) {
381       int j = l - i;
382       trg[j] = Cscl(src[j], g);
383     }
384   }
385 }
386
387 PRIVATE int
388 setRXEQ(int n, char **p) {
389   if (n < 3) {
390     // revert to no EQ
391     memcpy((char *) rx.filt.ovsv->zfvec,
392            (char *) rx.filt.save,
393            rx.filt.ovsv->fftlen * sizeof(COMPLEX));
394     return 0;
395   } else {
396     int i;
397     REAL lof = atof(p[0]);
398     for (i = 0; i < n - 2; i += 2) {
399       REAL dB = atof(p[i + 1]),
400            hif = atof(p[i + 2]);
401       if (lof < 0.0 || hif <= lof) return -1;
402       apply_rxeq_band(lof, dB, hif);
403       lof = hif;
404     }
405     return 0;
406   }
407 }
408
409 //============================================================
410 PRIVATE int
411 setRXAGC(int n, char **p) {
412   int setit = atoi(p[0]);
413   switch (setit) {
414   case agcOFF:
415     rx.agc.gen->AgcMode = agcOFF;
416     rx.agc.flag = TRUE;
417     break;
418   case agcSLOW:
419     rx.agc.gen->AgcMode = agcSLOW;
420     rx.agc.gen->Hang = 10;
421     rx.agc.flag = TRUE;
422     break;
423   case agcMED:
424     rx.agc.gen->AgcMode = agcMED;
425     rx.agc.gen->Hang = 6;
426     rx.agc.flag = TRUE;
427     break;
428   case agcFAST:
429     rx.agc.gen->AgcMode = agcFAST;
430     rx.agc.gen->Hang = 3;
431     rx.agc.flag = TRUE;
432     break;
433   case agcLONG:
434     rx.agc.gen->AgcMode = agcLONG;
435     rx.agc.gen->Hang = 23;
436     rx.agc.flag = TRUE;
437     break;
438   }
439   return 0;
440 }
441
442 PRIVATE int
443 setANFvals(int n, char **p) {
444   int taps  = atoi(p[0]),
445       delay = atoi(p[1]);
446   REAL gain = atof(p[2]),
447        leak = atof(p[3]);
448   rx.anf.gen->adaptive_filter_size = taps;
449   rx.anf.gen->delay = delay;
450   rx.anf.gen->adaptation_rate = gain;
451   rx.anf.gen->leakage = leak;
452   return 0;
453 }
454
455 PRIVATE int
456 setNRvals(int n, char **p) {
457   int taps  = atoi(p[0]),
458       delay = atoi(p[1]);
459   REAL gain = atof(p[2]),
460        leak = atof(p[3]);
461   rx.anr.gen->adaptive_filter_size = taps;
462   rx.anr.gen->delay = delay;
463   rx.anr.gen->adaptation_rate = gain;
464   rx.anr.gen->leakage = leak;
465   return 0;
466 }
467
468 PRIVATE int
469 setcorrectIQ(int n, char **p) {
470   int phaseadjustment = atoi(p[0]),
471       gainadjustment  = atoi(p[1]);
472   rx.iqfix->phase = 0.001 * (REAL) phaseadjustment;
473   rx.iqfix->gain  = 1.0+ 0.001 * (REAL) gainadjustment;
474   return 0;
475 }
476
477 PRIVATE int
478 setcorrectIQphase(int n, char **p) {
479   int phaseadjustment = atoi(p[0]);
480   rx.iqfix->phase = 0.001 * (REAL) phaseadjustment;
481   return 0;
482 }
483
484 PRIVATE int
485 setcorrectIQgain(int n, char **p) {
486   int gainadjustment = atoi(p[0]);
487   rx.iqfix->gain = 1.0 + 0.001 * (REAL) gainadjustment;
488   return 0;
489 }
490
491 PRIVATE int
492 setSquelch(int n, char **p) {
493   rx.squelch.thresh = -atof(p[0]);
494   return 0;
495 }
496
497 PRIVATE int
498 setMeterOffset(int n, char **p) {
499   rx.squelch.offset.meter = atof(p[0]);
500   return 0;
501 }
502
503 PRIVATE int
504 setATTOffset(int n, char **p) {
505   rx.squelch.offset.att = atof(p[0]);
506   return 0;
507 }
508
509 PRIVATE int
510 setGainOffset(int n, char **p) {
511   rx.squelch.offset.gain = atof(p[0]);
512   return 0;
513 }
514
515 PRIVATE int
516 setSquelchSt(int n, char **p) {
517   rx.squelch.flag = atoi(p[0]);
518   return 0;
519 }
520
521 PRIVATE int
522 setTRX(int n, char **p) {
523   uni.mode.trx = atoi(p[0]);
524   return 0;
525 }
526
527 PRIVATE int
528 setRunState(int n, char **p) {
529   RUNMODE rs = (RUNMODE) atoi(p[0]);
530   top.state = rs;
531   return 0;
532 }
533
534 PRIVATE int
535 setSpotToneVals(int n, char **p) {
536   REAL gain  = atof(p[0]),
537        freq  = atof(p[1]),
538        rise  = atof(p[2]),
539        fall  = atof(p[3]);
540   setSpotToneGenVals(rx.spot.gen, gain, freq, rise, fall);
541   return 0;
542 }
543
544 PRIVATE int
545 setSpotTone(int n, char **p) {
546   if (atoi(p[0])) {
547     SpotToneOn(rx.spot.gen);
548     rx.spot.flag = TRUE;
549   } else
550     SpotToneOff(rx.spot.gen);
551   return 0;
552 }
553
554 PRIVATE int
555 setRXPreScl(int n, char **p) {
556   rx.scl.pre.flag = atoi(p[0]);
557   return 0;
558 }
559
560 PRIVATE int
561 setRXPreSclVal(int n, char **p) {
562   rx.scl.pre.val = dB2lin(atof(p[0]));
563   return 0;
564 }
565
566 PRIVATE int
567 setTXPreScl(int n, char **p) {
568   tx.scl.pre.flag = atoi(p[0]);
569   return 0;
570 }
571
572 PRIVATE int
573 setTXPreSclVal(int n, char **p) {
574   tx.scl.pre.val = dB2lin(atof(p[0]));
575   return 0;
576 }
577
578 PRIVATE int
579 setRXPostScl(int n, char **p) {
580   rx.scl.post.flag = atoi(p[0]);
581   return 0;
582 }
583
584 PRIVATE int
585 setRXPostSclVal(int n, char **p) {
586   rx.scl.post.val = dB2lin(atof(p[0]));
587   return 0;
588 }
589
590 PRIVATE int
591 setTXPostScl(int n, char **p) {
592   tx.scl.post.flag = atoi(p[0]);
593   return 0;
594 }
595
596 PRIVATE int
597 setTXPostSclVal(int n, char **p) {
598   tx.scl.post.val = dB2lin(atof(p[0]));
599   return 0;
600 }
601
602 PRIVATE int
603 setFinished(int n, char **p) {
604   top.running = FALSE;
605   return 0;
606 }
607
608 PRIVATE int
609 setPWSmode(int n,char **p) {
610     int setit = atoi(p[0]);
611         uni.powerspectrum.pws->Mode = setit;
612         return 0;
613 }
614
615 PRIVATE int
616 setPWSSubmode(int n,char **p) {
617     int setit = atoi(p[0]);
618         uni.powerspectrum.pws->SubMode = setit;
619         return 0;
620 }
621
622 // next-trx-mode [nbufs-to-zap]
623 PRIVATE int
624 setSWCH(int n, char **p) {
625   top.swch.trx.next = atoi(p[0]);
626   if (n > 1) top.swch.bfct.want = atoi(p[1]);
627   else top.swch.bfct.want = 0;
628   top.swch.bfct.have = 0;
629   top.swch.run.last = top.state;
630   top.state = RUN_SWCH;
631   return 0;
632 }
633
634 //========================================================================
635
636 #include <thunk.h>
637
638 CTE update_cmds[] = {
639   {"setANF", setANF},
640   {"setANFvals", setANFvals},
641   {"setATTOffset", setATTOffset},
642   {"setBIN", setBIN},
643   {"setcorrectIQ", setcorrectIQ},
644   {"setcorrectIQgain", setcorrectIQgain},
645   {"setcorrectIQphase", setcorrectIQphase},
646   {"setFilter", setFilter},
647   {"setfixedAGC", setfixedAGC},
648   {"setGainOffset", setGainOffset},
649   {"setMeterOffset", setMeterOffset},
650   {"setMode", setMode},
651   {"setNB", setNB},
652   {"setNBvals", setNBvals},
653   {"setNR", setNR},
654   {"setNRvals", setNRvals},
655   {"setOsc", setOsc},
656   {"setRXAGC", setRXAGC},
657   {"setRunState", setRunState},
658   {"setSampleRate", setSampleRate},
659   {"setSquelch", setSquelch},
660   {"setSquelchSt", setSquelchSt},
661   {"setTXAGC", setTXAGC},
662   {"setTXAGCCompression", setTXAGCCompression},
663   {"setTXAGCFFCompression",setTXAGCFFCompression},
664   {"setTXAGCHang", setTXAGCHang},
665   {"setTXAGCLimit", setTXAGCLimit},
666   {"setTXSpeechCompression", setTXSpeechCompression},
667   {"setTXSpeechCompressionGain", setTXSpeechCompressionGain},
668   {"setRXEQ", setRXEQ},
669   {"setTXEQ", setTXEQ},
670   {"setTRX", setTRX},
671   {"setRXPreScl", setRXPreScl},
672   {"setRXPreSclVal", setRXPreSclVal},
673   {"setTXPreScl", setTXPreScl},
674   {"setTXPreSclVal", setTXPreSclVal},
675   {"setRXPostScl", setRXPostScl},
676   {"setRXPostSclVal", setRXPostSclVal},
677   {"setTXPostScl", setTXPostScl},
678   {"setTXPostSclVal", setTXPostSclVal},
679   {"setFinished", setFinished},
680   {"setSWCH", setSWCH},
681   {"setSpotToneVals", setSpotToneVals},
682   {"setSpotTone", setSpotTone},
683   {"setPWSmode", setPWSmode},
684   {"setPWSSubmode",setPWSSubmode},
685   {"setSDROM", setSDROM},
686   {"setSDROMvals",setSDROMvals},
687   { 0, 0 }
688 };
689
690 //........................................................................
691
692 int do_update(char *str) {
693   
694   SPLIT splt = &uni.update.splt;
695   
696   split(splt, str);
697   
698   if (NF(splt) < 1) return -1;
699   else {
700     Thunk thk = Thunk_lookup(update_cmds, F(splt, 0));
701     if (!thk) {
702       fprintf(stderr,"-1\n");
703       return -1;
704     } else {
705       int val;
706       WaitForSingleObject(top.sync.upd.sem,INFINITE);
707       val = (*thk)(NF(splt) - 1, Fptr(splt, 1));
708       ReleaseSemaphore(top.sync.upd.sem,1L,NULL);
709       return val;
710     }
711   }
712 }
713
714 BOOLEAN newupdates() {
715   WaitForSingleObject(top.sync.upd2.sem,INFINITE);
716   return TRUE;
717 }
718
719 PRIVATE void
720 sendcommand(char *str) {
721   putChan_nowait(uni.update.chan.c,str,strlen(str)+1);;
722   ReleaseSemaphore(top.sync.upd2.sem,1L,NULL);
723   Sleep(0);
724 }
725
726 #ifdef PROCESSVERS
727 DttSP_EXP int
728 changeMode(SDRMODE mode) {
729   char str[128];
730   switch(mode) {
731   case LSB:
732     sprintf(str,"setMode %d",LSB);
733     sendcommand(str);
734     break;
735   case USB:
736     sprintf(str,"setMode %d",USB);
737     sendcommand(str);
738     break;
739   case DSB:
740     sprintf(str,"setMode %d",DSB);
741     sendcommand(str);
742     break;
743   case CWL:
744     sprintf(str,"setMode %d",CWL);
745     sendcommand(str);
746     break;
747   case CWU:
748     sprintf(str,"setMode %d",CWU);
749     sendcommand(str);
750     break;
751   case AM:
752     sprintf(str,"setMode %d",AM);
753     sendcommand(str);
754     break;
755   case PSK:
756     sprintf(str,"setMode %d",PSK);
757     sendcommand(str);
758     break;
759   case SPEC:
760     sprintf(str,"setMode %d",SPEC);
761     sendcommand(str);
762     break;
763   case RTTY:
764     sprintf(str,"setMode %d",RTTY);
765     sendcommand(str);
766     break;
767   case SAM:
768     sprintf(str,"setMode %d",SAM);
769     sendcommand(str);
770     break;
771   case DRM:
772     sprintf(str,"setMode %d",DRM);
773     sendcommand(str);
774     break;
775   default:
776     break;
777   }
778   return 0;
779 }
780
781 DttSP_EXP int
782 changeOsc(REAL newfreq){
783   char str[64];
784   if (fabs(newfreq) >= 0.5* uni.samplerate) return -1;
785   sprintf(str,"setOsc %lf RX",newfreq);
786   sendcommand(str);
787   return 0;
788 }
789
790 DttSP_EXP int
791 changeTXOsc(REAL newfreq){
792   char str[64];
793   if (fabs(newfreq) >= 0.5* uni.samplerate) return -1;
794   sprintf(str,"setOsc %lf TX",newfreq);
795   sendcommand(str);
796   return 0;
797 }
798
799 DttSP_EXP int
800 changeSampleRate(REAL newSampleRate) {
801   char str[64];
802   sprintf(str,"setSampleRate %9.0lf",newSampleRate);
803   sendcommand(str);
804   return 0;
805 }
806
807 DttSP_EXP void changeNR(int setit) {
808   char str[64];
809   sprintf(str,"setNR %d",setit);
810   sendcommand(str);
811 }
812
813 DttSP_EXP void changeANF(int setit) {
814   char str[64];
815   sprintf(str,"setANF %d",setit);
816   sendcommand(str);
817 }
818
819 DttSP_EXP void changeNB(int setit) {
820   char str[64];
821   sprintf(str,"setNB %d",setit);
822   sendcommand(str);
823 }
824
825 DttSP_EXP void changeNBvals(REAL threshold) {
826   char str[64];
827   sprintf(str,"setNBvals %lf",threshold);
828   sendcommand(str);     
829 }
830
831
832 DttSP_EXP void changeBIN(int setit) {
833   char str[64];
834   sprintf(str,"setBIN %d",setit);
835   sendcommand(str);
836 }
837
838 DttSP_EXP void changeAGC(AGCMODE setit) {
839   char str[64];
840   switch (setit) {
841   case agcOFF:
842     sprintf(str,"setRXAGC %d",agcOFF);
843     break;
844   case agcLONG:
845     sprintf(str,"setRXAGC %d",agcLONG);
846     break;
847   case agcSLOW:
848     sprintf(str,"setRXAGC %d",agcSLOW);
849     break;
850   case agcMED:
851     sprintf(str,"setRXAGC %d",agcMED);
852     break;
853   case agcFAST:
854     sprintf(str,"setRXAGC %d",agcFAST);
855     break;
856   }
857   sendcommand(str);
858 }
859
860 DttSP_EXP void changeANFvals(int taps, int delay, REAL gain, REAL leak) {
861   char str[128];
862   sprintf(str,"setANFvals %3d %3d %9.7lf %9.7lf",taps,delay,gain,leak);
863   sendcommand(str);
864 }
865
866 DttSP_EXP void changeNRvals(int taps, int delay, REAL gain, REAL leak) {
867   char str[128];
868   sprintf(str,"setNRvals %3d %3d %9.7lf %9.7lf",taps,delay,gain,leak);
869   sendcommand(str);
870 }
871
872 DttSP_EXP void setcorrectIQcmd(int phaseadjustment,int gainadjustment) {
873   char str[64];
874   sprintf(str,"setcorrectIQ %d %d",phaseadjustment,gainadjustment);
875   sendcommand(str);
876 }
877
878 DttSP_EXP void changecorrectIQphase(int phaseadjustment){
879   char str[64];
880   sprintf(str,"setcorrectIQphase %d",phaseadjustment);
881   sendcommand(str);
882 }
883
884 DttSP_EXP void changecorrectIQgain(int gainadjustment){
885   char str[64];
886   sprintf(str,"setcorrectIQgain %d",gainadjustment);
887   sendcommand(str);
888 }
889
890 DttSP_EXP int
891 changeFilter(REAL low_frequency,REAL high_frequency,int ncoef, TRXMODE trx) {
892   char str[64];
893   if (trx == RX)  sprintf(str,"setFilter %6.0lf %6.0lf RX",low_frequency,high_frequency);
894   else sprintf(str,"setFilter %6.0lf %6.0lf TX",low_frequency,high_frequency);
895   sendcommand(str);
896   return 0;
897 }
898
899 DttSP_EXP void
900 changePWSmode(PWSMODE setit) {
901   char str[64];
902   switch (setit) {
903   case PREFILTER:
904     sprintf(str,"setPWSmode %d",PREFILTER);
905     break;
906   case POSTFILTER:
907     sprintf(str,"setPWSmode %d",POSTFILTER);
908     break;
909   case AUDIO:
910     sprintf(str,"setPWSmode %d",AUDIO);
911     break;
912   default:
913     return;
914   }
915   sendcommand(str);
916 }
917
918 DttSP_EXP void
919 changePWSsubmode(PWSSUBMODE setit) {
920   char str[64];
921   switch (setit) {
922   case SPECTRUM:
923     sprintf(str,"setPWSSubmode %d",SPECTRUM);
924     break;
925   case PHASE:
926     sprintf(str,"setPWSSubmode %d",PHASE);
927     break;
928   case SCOPE:
929     sprintf(str,"setPWSSubmode %d",SCOPE);
930     break;
931   case PHASE2:
932     sprintf(str,"setPWSSubmode %d",PHASE);
933     break;
934   case WATERFALL:
935     sprintf(str,"setPWSSubmode %d",WATERFALL);
936     break;
937   case HISTOGRAM:
938     sprintf(str,"setPWSSubmode %d",HISTOGRAM);
939     break;
940   default:
941     return;
942   }
943   sendcommand(str);
944 }
945
946 DttSP_EXP void
947 changeWindow(Windowtype Windowset){
948 }
949
950 DttSP_EXP void
951 oldsetTXEQ(int *txeq) {
952   char str[256];
953   sprintf(str,
954           "setTXEQ 0 %d 450 %d 800 %d 1150 %d 1450 %d 1800 %d 2150 %d 2450 %d 2800 %d 3600",
955           txeq[0],
956           txeq[1],
957           txeq[2],
958           txeq[3],
959           txeq[4],
960           txeq[5],
961           txeq[6],
962           txeq[7],
963           txeq[8]);
964   sendcommand(str);
965 }
966
967 DttSP_EXP void
968 changeTXAGCCompression(double txc) {
969   char str[64];
970   sprintf(str,"setTXAGCCompression %lf",txc);
971   sendcommand(str);
972 }
973
974 DttSP_EXP void
975 changeTXAGCFFCompression(double txc) {
976   char str[64];
977   sprintf(str,"setTXAGCFFCompression %lf",txc);
978   sendcommand(str);
979 }
980
981 DttSP_EXP void oldsetGainOffset(float val) {
982   char str[64];
983   sprintf(str,"setGainOffset %f",val);
984   sendcommand(str);
985 }
986
987 DttSP_EXP void setTXScale(REAL scale) {
988   char str[32];
989   sprintf(str,"setTXPreScl 1 ");
990   sendcommand(str);
991   Sleep(0);
992   sprintf(str,"setTXPreSclVal %lf",20.0*log10(scale));
993   sendcommand(str);
994 }
995
996 DttSP_EXP void oldsetATTOffset(float val){
997   char str[64];
998   sprintf(str,"setATTOffset %f",val);
999   sendcommand(str);
1000 }
1001
1002 DttSP_EXP setRXScale(float val) {
1003   char str[64];
1004   sprintf(str,"setRXPostScl 1");
1005   sendcommand(str);
1006   Sleep(0);
1007   sprintf(str,"setRXPostSclVal %f",val);
1008   sendcommand(str);
1009 }
1010
1011 DttSP_EXP oldsetMeterOffset(float val){
1012   char str[64];
1013   sprintf(str,"setMeterOffset %f",val);
1014   sendcommand(str);
1015 }
1016
1017 DttSP_EXP changeSquelch(float setit) {
1018   char str[64];
1019   sprintf(str,"setSquelch %f",setit);
1020   sendcommand(str);
1021 }
1022
1023 DttSP_EXP changeSquelchSt(BOOLEAN setit) {
1024   char str[64];
1025   sprintf(str,"setSquelch %d",setit);
1026   sendcommand(str);
1027 }
1028
1029 DttSP_EXP void changeSDROM(BOOLEAN setit) {   
1030   char str[64];
1031   sprintf(str,"setSDROM %d",setit);
1032   sendcommand(str);
1033 }
1034
1035 DttSP_EXP void changeSDROMvals(REAL threshold) {
1036   char str[64];
1037   sprintf(str,"setSDROMvals %lf",threshold);
1038   sendcommand(str);
1039 }
1040
1041
1042 #endif   // END PROCESSVERS
1043
1044
1045
1046 #ifdef DLLVERS
1047 DttSP_EXP int
1048 changeMode(SDRMODE mode) {
1049   switch(mode) {
1050   case LSB:
1051   case USB:
1052   case DSB:
1053   case CWL:
1054   case CWU:
1055   case FMN:
1056   case AM:
1057   case PSK:
1058   case SPEC:
1059   case RTTY:
1060   case SAM:
1061   case DRM:
1062     WaitForSingleObject(top.sync.upd.sem,INFINITE);
1063     rx.mode = tx.mode = uni.mode.sdr = mode;
1064     if (mode == SAM) rx.am.gen->mode = SAMdet;
1065     if (mode == AM)  rx.am.gen->mode = AMdet;
1066     ReleaseSemaphore(top.sync.upd.sem,1L,NULL);
1067     break;
1068   default:
1069     break;
1070   }
1071   return 0;
1072 }
1073
1074 DttSP_EXP int
1075 changeOsc(REAL newfreq){
1076   if (fabs(newfreq) >= 0.5* uni.samplerate) return -1;
1077   WaitForSingleObject(top.sync.upd.sem,INFINITE);
1078   rx.osc.gen->Frequency = rx.osc.freq = 2.0*M_PI*newfreq/uni.samplerate;
1079   ReleaseSemaphore(top.sync.upd.sem,1L,NULL);
1080   return 0;
1081 }
1082
1083 DttSP_EXP int
1084 changeTXOsc(REAL newfreq){
1085   if (fabs(newfreq) >= 0.5* uni.samplerate) return -1;
1086   WaitForSingleObject(top.sync.upd.sem,INFINITE);
1087   tx.osc.gen->Frequency = tx.osc.freq = 2.0*M_PI*newfreq/uni.samplerate;
1088   ReleaseSemaphore(top.sync.upd.sem,1L,NULL);
1089   return 0;
1090 }
1091
1092 DttSP_EXP int
1093 changeSampleRate(REAL newSampleRate) {
1094   WaitForSingleObject(top.sync.upd.sem,INFINITE);
1095   uni.samplerate = newSampleRate;
1096   ReleaseSemaphore(top.sync.upd.sem,1L,NULL);
1097   return 0;
1098 }
1099
1100 DttSP_EXP void changeNR(BOOLEAN setit) {
1101   WaitForSingleObject(top.sync.upd.sem,INFINITE);
1102   rx.anr.flag = setit;
1103   ReleaseSemaphore(top.sync.upd.sem,1L,NULL);
1104 }
1105
1106 DttSP_EXP void changeANF(BOOLEAN setit) {
1107   WaitForSingleObject(top.sync.upd.sem,INFINITE);
1108   rx.anf.flag = setit;
1109   ReleaseSemaphore(top.sync.upd.sem,1L,NULL);
1110 }
1111
1112 DttSP_EXP void changeNB(BOOLEAN setit) {
1113   WaitForSingleObject(top.sync.upd.sem,INFINITE);
1114   rx.nb.flag = setit;
1115   ReleaseSemaphore(top.sync.upd.sem,1L,NULL);
1116 }
1117
1118 DttSP_EXP void changeNBvals(REAL threshold) {
1119   WaitForSingleObject(top.sync.upd.sem,INFINITE);
1120   rx.nb.gen->threshold = rx.nb.thresh = threshold;
1121   ReleaseSemaphore(top.sync.upd.sem,1L,NULL);
1122 }
1123
1124 DttSP_EXP void changeSDROM(BOOLEAN setit) {
1125   WaitForSingleObject(top.sync.upd.sem,INFINITE);
1126   rx.nb_sdrom.flag = setit;
1127   ReleaseSemaphore(top.sync.upd.sem,1L,NULL);
1128 }
1129
1130 DttSP_EXP void changeSDROMvals(REAL threshold) {
1131   WaitForSingleObject(top.sync.upd.sem,INFINITE);
1132   rx.nb_sdrom.gen->threshold = rx.nb_sdrom.thresh = threshold;
1133   ReleaseSemaphore(top.sync.upd.sem,1L,NULL);
1134 }
1135
1136
1137 DttSP_EXP void changeBIN(BOOLEAN setit) {
1138   WaitForSingleObject(top.sync.upd.sem,INFINITE);
1139   rx.bin.flag= setit;
1140   ReleaseSemaphore(top.sync.upd.sem,1L,NULL);
1141 }
1142
1143 DttSP_EXP void changeAGC(AGCMODE setit) {
1144   switch (setit) {
1145   case agcOFF:
1146     WaitForSingleObject(top.sync.upd.sem,INFINITE);
1147     rx.agc.gen->AgcMode = setit;
1148     ReleaseSemaphore(top.sync.upd.sem,1L,NULL);
1149     break;
1150   case agcLONG:
1151     WaitForSingleObject(top.sync.upd.sem,INFINITE);
1152     rx.agc.gen->AgcMode = setit;
1153     rx.agc.gen->Hang = 23;
1154     ReleaseSemaphore(top.sync.upd.sem,1L,NULL);
1155     break;
1156   case agcSLOW:
1157     WaitForSingleObject(top.sync.upd.sem,INFINITE);
1158     rx.agc.gen->AgcMode = setit;
1159     rx.agc.gen->Hang = 7;
1160     ReleaseSemaphore(top.sync.upd.sem,1L,NULL);
1161     break;
1162   case agcMED:
1163     WaitForSingleObject(top.sync.upd.sem,INFINITE);
1164     rx.agc.gen->AgcMode = setit;
1165     rx.agc.gen->Hang = 4;
1166     ReleaseSemaphore(top.sync.upd.sem,1L,NULL);
1167     break;
1168   case agcFAST:
1169     WaitForSingleObject(top.sync.upd.sem,INFINITE);
1170     rx.agc.gen->AgcMode = setit;
1171     rx.agc.gen->Hang = 2;
1172     ReleaseSemaphore(top.sync.upd.sem,1L,NULL);
1173     break;
1174   default:
1175     break;
1176   }
1177 }
1178
1179 DttSP_EXP void changefixedAGC(REAL fixed_agc) {
1180   WaitForSingleObject(top.sync.upd.sem,INFINITE);
1181   rx.agc.gen->AgcFixedGain = dB2lin(fixed_agc);
1182   ReleaseSemaphore(top.sync.upd.sem,1L,NULL);
1183 }
1184
1185 DttSP_EXP void changemaxAGC(REAL max_agc) {
1186   WaitForSingleObject(top.sync.upd.sem,INFINITE);
1187   rx.agc.gen->MaxGain = dB2lin(max_agc);
1188   ReleaseSemaphore(top.sync.upd.sem,1L,NULL);
1189 }
1190
1191 DttSP_EXP void changeRXAGCAttackTimeScale(int limit) {
1192   WaitForSingleObject(top.sync.upd.sem,INFINITE);
1193   rx.agc.gen->AgcAttackTimeScale = limit;
1194   ReleaseSemaphore(top.sync.upd.sem,1L,NULL);
1195
1196 }
1197
1198 DttSP_EXP void changeRXAGCHang(int limit) {
1199   WaitForSingleObject(top.sync.upd.sem,INFINITE);
1200   rx.agc.gen->Hang = limit;
1201   ReleaseSemaphore(top.sync.upd.sem,1L,NULL);
1202
1203 }
1204
1205 DttSP_EXP void changeRXAGCLimit(int limit){
1206   WaitForSingleObject(top.sync.upd.sem,INFINITE);
1207   rx.agc.gen->AgcLimit = 0.001 * (double)limit;
1208   ReleaseSemaphore(top.sync.upd.sem,1L,NULL);
1209 }
1210
1211 DttSP_EXP void changeANFvals(int taps, int delay, REAL gain, REAL leak) {
1212   WaitForSingleObject(top.sync.upd.sem,INFINITE);
1213   rx.anf.gen->adaptation_rate = gain;
1214   rx.anf.gen->adaptive_filter_size = taps;
1215   rx.anf.gen->delay = delay;
1216   rx.anf.gen->leakage = leak;
1217   ReleaseSemaphore(top.sync.upd.sem,1L,NULL);
1218 }
1219
1220 DttSP_EXP void changeNRvals(int taps, int delay, REAL gain, REAL leak) {
1221   WaitForSingleObject(top.sync.upd.sem,INFINITE);
1222   rx.anr.gen->adaptation_rate = gain;
1223   rx.anr.gen->adaptive_filter_size = taps;
1224   rx.anr.gen->delay = delay;
1225   rx.anr.gen->leakage = leak;
1226   ReleaseSemaphore(top.sync.upd.sem,1L,NULL);
1227 }
1228
1229 DttSP_EXP void
1230 setcorrectIQcmd(int phaseadjustment,int gainadjustment) {
1231   WaitForSingleObject(top.sync.upd.sem,INFINITE);
1232   rx.iqfix->phase = 0.001 * (REAL) phaseadjustment; 
1233   rx.iqfix->gain  = 1.0 + 0.001 * (REAL) gainadjustment;
1234   ReleaseSemaphore(top.sync.upd.sem,1L,NULL);
1235 }
1236
1237 DttSP_EXP void
1238 changecorrectIQphase(int phaseadjustment) {
1239   WaitForSingleObject(top.sync.upd.sem,INFINITE);
1240   rx.iqfix->phase = 0.001 * (REAL) phaseadjustment; 
1241   ReleaseSemaphore(top.sync.upd.sem,1L,NULL);
1242 }
1243
1244 DttSP_EXP void
1245 changecorrectIQgain(int gainadjustment) {
1246   WaitForSingleObject(top.sync.upd.sem,INFINITE);
1247   rx.iqfix->gaina = 1.0 + 0.001 * (REAL) gainadjustment;
1248   ReleaseSemaphore(top.sync.upd.sem,1L,NULL);
1249 }
1250
1251 DttSP_EXP int
1252 changeFilter(REAL low_frequency,REAL high_frequency,int ncoef, TRXMODE trx) {
1253   int i, fftlen = 2 * uni.buflen;
1254   fftw_plan ptmp;
1255   COMPLEX *zcvec;
1256   ncoef = uni.buflen + 1;
1257
1258   if (fabs(low_frequency) >= 0.5 * uni.samplerate) return -1;
1259   if (fabs(high_frequency) >= 0.5 * uni.samplerate) return -2;
1260   if ((low_frequency + 10) >= high_frequency) return -3;
1261   WaitForSingleObject(top.sync.upd.sem,INFINITE);
1262   if (trx == RX) {
1263     delFIR_COMPLEX(rx.filt.coef);
1264
1265     rx.filt.coef = newFIR_Bandpass_COMPLEX(low_frequency,
1266                                            high_frequency,
1267                                            uni.samplerate,
1268                                            ncoef + 1);
1269
1270     zcvec = newvec_COMPLEX(fftlen, "filter z vec in setFilter");
1271     ptmp = fftw_create_plan(fftlen, FFTW_FORWARD, FFTW_OUT_OF_PLACE);
1272 #ifdef LHS
1273     for (i = 0; i < ncoef; i++) zcvec[i] = rx.filt.coef->coef[i];
1274 #else
1275     for (i = 0; i < ncoef; i++) zcvec[fftlen - ncoef + i] = rx.filt.coef->coef[i];
1276 #endif
1277     fftw_one(ptmp, (fftw_complex *) zcvec, (fftw_complex *) rx.filt.ovsv->zfvec);
1278     fftw_destroy_plan(ptmp);
1279     delvec_COMPLEX(zcvec);
1280     memcpy((char *) rx.filt.save,
1281            (char *) rx.filt.ovsv->zfvec,
1282            rx.filt.ovsv->fftlen * sizeof(COMPLEX));
1283   } else {
1284     delFIR_COMPLEX(tx.filt.coef);
1285
1286     tx.filt.coef = newFIR_Bandpass_COMPLEX(low_frequency,
1287                                            high_frequency,
1288                                            uni.samplerate,
1289                                            ncoef + 1);
1290
1291     zcvec = newvec_COMPLEX(fftlen, "filter z vec in setFilter");
1292     ptmp = fftw_create_plan(fftlen, FFTW_FORWARD, FFTW_OUT_OF_PLACE);
1293 #ifdef LHS
1294     for (i = 0; i < ncoef; i++) zcvec[i] = tx.filt.coef->coef[i];
1295 #else
1296     for (i = 0; i < ncoef; i++) zcvec[fftlen - ncoef + i] = tx.filt.coef->coef[i];
1297 #endif
1298     fftw_one(ptmp, (fftw_complex *) zcvec, (fftw_complex *) tx.filt.ovsv->zfvec);
1299     fftw_destroy_plan(ptmp);
1300     delvec_COMPLEX(zcvec);
1301     memcpy((char *) tx.filt.save,
1302            (char *) tx.filt.ovsv->zfvec,
1303            tx.filt.ovsv->fftlen * sizeof(COMPLEX));
1304
1305   }
1306   ReleaseSemaphore(top.sync.upd.sem,1L,NULL);
1307   return 0;
1308 }
1309
1310 DttSP_EXP void
1311 changePWSmode(PWSMODE setit) {
1312   WaitForSingleObject(top.sync.upd.sem,INFINITE);
1313   uni.powerspectrum.pws->Mode = setit;
1314   ReleaseSemaphore(top.sync.upd.sem,1L,NULL);
1315
1316 }
1317
1318 DttSP_EXP void
1319 changePWSsubmode(PWSSUBMODE setit) {
1320   WaitForSingleObject(top.sync.upd.sem,INFINITE);
1321   uni.powerspectrum.pws->SubMode = setit;
1322   ReleaseSemaphore(top.sync.upd.sem,1L,NULL);
1323 }
1324
1325 DttSP_EXP void
1326 changeWindow(Windowtype Windowset){
1327 }
1328
1329 DttSP_EXP void
1330 oldsetTXEQ(int *txeq) {
1331   WaitForSingleObject(top.sync.upd.sem,INFINITE);
1332   apply_txeq_band(0.0   ,txeq[ 0],120.0);
1333   apply_txeq_band(120.0 ,txeq[ 1],230.0);
1334   apply_txeq_band(230.0 ,txeq[ 2],450.0);
1335   apply_txeq_band(450.0 ,txeq[ 3],800.0);
1336   apply_txeq_band(800.0 ,txeq[ 4],1150.0);
1337   apply_txeq_band(1150.0,txeq[ 5],1450.0);
1338   apply_txeq_band(1450.0,txeq[ 6],1800.0);
1339   apply_txeq_band(1800.0,txeq[ 7],2150.0);
1340   apply_txeq_band(2150.0,txeq[ 8],2450.0);
1341   apply_txeq_band(2450.0,txeq[ 9],2800.0);
1342   apply_txeq_band(2800.0,txeq[10],3250.0);
1343   apply_txeq_band(3250.0,txeq[11],6000.0);
1344   ReleaseSemaphore(top.sync.upd.sem,1L,NULL);
1345 }
1346
1347 DttSP_EXP void
1348 changeTXAGCCompression(double txc) {
1349   WaitForSingleObject(top.sync.upd.sem,INFINITE);
1350   tx.agc.gen->MaxGain = pow(10.0 , txc * 0.05);
1351   ReleaseSemaphore(top.sync.upd.sem,1L,NULL);
1352 }
1353
1354 DttSP_EXP void
1355 changeTXAGCFF(BOOLEAN setit) {
1356   WaitForSingleObject(top.sync.upd.sem,INFINITE);
1357   tx.spr.flag = setit;
1358   ReleaseSemaphore(top.sync.upd.sem,1L,NULL);
1359 }
1360
1361 DttSP_EXP void
1362 changeTXAGCLimit(int setit) {
1363   WaitForSingleObject(top.sync.upd.sem,INFINITE);
1364   tx.agc.gen->AgcLimit = 0.001*(REAL)setit;
1365   ReleaseSemaphore(top.sync.upd.sem,1L,NULL);
1366 }
1367
1368 DttSP_EXP void
1369 changeTXAGCHang(int hang) {
1370   WaitForSingleObject(top.sync.upd.sem,INFINITE);
1371   tx.agc.gen->Hang = (int)max(1,min(23,((REAL)hang) * uni.samplerate /(1000.0*uni.buflen)));
1372   ReleaseSemaphore(top.sync.upd.sem,1L,NULL);
1373 }
1374
1375 DttSP_EXP void
1376 changeTXAGCFFCompression(REAL txc) {
1377   WaitForSingleObject(top.sync.upd.sem,INFINITE);
1378   tx.spr.gen->MaxGain = pow(10.0 , txc * 0.05);
1379   ReleaseSemaphore(top.sync.upd.sem,1L,NULL);
1380 }
1381
1382 DttSP_EXP void setTXScale(REAL scale) {
1383   WaitForSingleObject(top.sync.upd.sem,INFINITE);
1384   tx.scl.post.flag = TRUE;
1385   tx.scl.post.val = scale;
1386   ReleaseSemaphore(top.sync.upd.sem,1L,NULL);
1387 }
1388
1389 DttSP_EXP void oldsetGainOffset(float val) {
1390   WaitForSingleObject(top.sync.upd.sem,INFINITE);
1391   rx.squelch.offset.gain = (REAL)val;
1392   ReleaseSemaphore(top.sync.upd.sem,1L,NULL);
1393 }
1394
1395 DttSP_EXP void oldsetATTOffset(float val){
1396   WaitForSingleObject(top.sync.upd.sem,INFINITE);
1397   rx.squelch.offset.att = (REAL)val;
1398   ReleaseSemaphore(top.sync.upd.sem,1L,NULL);
1399 }
1400
1401 DttSP_EXP oldsetMeterOffset(float val){
1402   WaitForSingleObject(top.sync.upd.sem,INFINITE);
1403   rx.squelch.offset.meter = (REAL)val;
1404   ReleaseSemaphore(top.sync.upd.sem,1L,NULL);
1405 }
1406
1407
1408 DttSP_EXP setRXScale(REAL val) {
1409   WaitForSingleObject(top.sync.upd.sem,INFINITE);
1410   rx.scl.post.flag = TRUE;
1411   rx.scl.post.val = val;
1412   ReleaseSemaphore(top.sync.upd.sem,1L,NULL);
1413 }
1414
1415 DttSP_EXP changeSquelch(int setit) {
1416   WaitForSingleObject(top.sync.upd.sem,INFINITE);
1417   rx.squelch.thresh = -(REAL)setit;     
1418   ReleaseSemaphore(top.sync.upd.sem,1L,NULL);
1419 }
1420
1421 DttSP_EXP changeSquelchSt(BOOLEAN setit) {
1422   WaitForSingleObject(top.sync.upd.sem,INFINITE);
1423   rx.squelch.flag = setit;
1424   ReleaseSemaphore(top.sync.upd.sem,1L,NULL);
1425
1426 }
1427
1428 DttSP_EXP void oldsetTRX(TRXMODE setit) {
1429   WaitForSingleObject(top.sync.upd.sem,INFINITE);
1430   /*    top.swch.trx.next = setit;
1431         top.swch.bfct.want = 2;
1432         top.swch.bfct.have = 0;
1433         top.swch.run.last = top.state;
1434         top.state = RUN_SWCH; */
1435   uni.mode.trx = setit;
1436   ReleaseSemaphore(top.sync.upd.sem,1L,NULL);
1437 }
1438 #endif    //  END DLLVERS
1439
1440
1441