3 This file is part of a program that implements a Software-Defined Radio.
5 Copyright (C) 2004 by Frank Brickle, AB2KT and Bob McGwier, N4HY
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.
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.
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
21 The authors can be reached by email at
29 The DTTS Microwave Society
36 //========================================================================
37 /* initialization and termination */
41 if (uni.meter.flag) { // reset metering completely
43 for (i = 0; i < RXMETERPTS; i++)
44 for (k = 0; k < MAXRX; k++)
45 uni.meter.rx.val[k][i] = uni.meter.rx.avg[k][i] = -200.0;
46 for (i = 0; i < TXMETERPTS; i++)
47 uni.meter.tx.val[i] = uni.meter.tx.avg[i] = -200.0;
52 reset_spectrum(void) {
54 reinit_spectrum(&uni.spec);
58 reset_counters(void) {
60 for (k = 0; k < uni.multirx.nrx; k++) rx[k].tick = 0;
64 //========================================================================
66 /* global and general info,
67 not specifically attached to
68 tx, rx, or scheduling */
73 uni.samplerate = loc.def.rate;
74 uni.buflen = loc.def.size;
75 uni.mode.sdr = loc.def.mode;
78 uni.wisdom.path = loc.path.wisdom;
79 uni.wisdom.bits = FFTW_OUT_OF_PLACE | FFTW_ESTIMATE;
81 FILE *f = fopen(uni.wisdom.path, "r");
85 char *line = (char *)malloc(WBUFLEN);
86 fgets(line, WBUFLEN, f);
87 if ((strlen(line) > WSTRLEN) &&
88 (fftw_import_wisdom_from_string(line) != FFTW_FAILURE))
89 uni.wisdom.bits = FFTW_OUT_OF_PLACE | FFTW_MEASURE | FFTW_USE_WISDOM;
99 uni.meter.rx.type = SIGNAL_STRENGTH;
100 uni.meter.tx.type = SIGNAL_STRENGTH;
105 uni.spec.buflen = uni.buflen;
106 uni.spec.scale = SPEC_PWR;
107 uni.spec.type = SPEC_POST_FILT;
108 uni.spec.size = loc.def.spec;
109 uni.spec.planbits = uni.wisdom.bits;
110 init_spectrum(&uni.spec);
112 // set which receiver is listening to commands
114 uni.multirx.nrx = loc.def.nrx;
116 // set mixing of input from aux ports
117 uni.mix.rx.flag = uni.mix.tx.flag = FALSE;
118 uni.mix.rx.gain = uni.mix.tx.gain = 1.0;
129 rx[k].iqfix = newCorrectIQ(0.0, 1.0);
130 rx[k].filt.coef = newFIR_Bandpass_COMPLEX(-4800.0,
134 rx[k].filt.ovsv = newFiltOvSv(FIRcoef(rx[k].filt.coef),
135 FIRsize(rx[k].filt.coef),
137 normalize_vec_COMPLEX(rx[k].filt.ovsv->zfvec,
138 rx[k].filt.ovsv->fftlen);
141 rx[k].filt.save = newvec_COMPLEX(rx[k].filt.ovsv->fftlen, "RX filter cache");
142 memcpy((char *) rx[k].filt.save,
143 (char *) rx[k].filt.ovsv->zfvec,
144 rx[k].filt.ovsv->fftlen * sizeof(COMPLEX));
147 /* note we overload the internal filter buffers
149 rx[k].buf.i = newCXB(FiltOvSv_fetchsize(rx[k].filt.ovsv),
150 FiltOvSv_fetchpoint(rx[k].filt.ovsv),
152 rx[k].buf.o = newCXB(FiltOvSv_storesize(rx[k].filt.ovsv),
153 FiltOvSv_storepoint(rx[k].filt.ovsv),
157 rx[k].osc.freq = -11025.0;
158 rx[k].osc.phase = 0.0;
159 rx[k].osc.gen = newOSC(uni.buflen,
164 "SDR RX Oscillator");
166 rx[k].agc.gen = newDigitalAgc(agcMED, // Mode
172 CXBsize(rx[k].buf.o), // BufSize
176 CXBbase(rx[k].buf.o));
177 rx[k].agc.flag = TRUE;
180 rx[k].am.gen = newAMD(48000.0, // REAL samprate
181 0.0, // REAL f_initial
182 -500.0, // REAL f_lobound,
183 500.0, // REAL f_hibound,
184 400.0, // REAL f_bandwid,
185 CXBsize(rx[k].buf.o), // int size,
186 CXBbase(rx[k].buf.o), // COMPLEX *ivec,
187 CXBbase(rx[k].buf.o), // COMPLEX *ovec,
188 AMdet, // AM Mode AMdet == rectifier,
189 // SAMdet == synchronous detector
190 "AM detector blew"); // char *tag
191 rx[k].fm.gen = newFMD(48000, // REAL samprate
192 0.0, // REAL f_initial
193 -6000.0, // REAL f_lobound
194 6000.0, // REAL f_hibound
195 10000.0, // REAL f_bandwid
196 CXBsize(rx[k].buf.o), // int size
197 CXBbase(rx[k].buf.o), // COMPLEX *ivec
198 CXBbase(rx[k].buf.o), // COMPLEX *ovec
199 "New FM Demod structure"); // char *error message;
201 /* noise reduction */
202 rx[k].anf.gen = new_lmsr(rx[k].buf.o, // CXB signal,
204 0.01, // REAL adaptation_rate,
205 0.00001, // REAL leakage,
206 45, // int adaptive_filter_size,
208 rx[k].anf.flag = FALSE;
209 rx[k].anr.gen = new_lmsr(rx[k].buf.o, // CXB signal,
211 0.01, // REAL adaptation_rate,
212 0.00001, // REAL leakage,
213 45, // int adaptive_filter_size,
215 rx[k].anr.flag = FALSE;
217 rx[k].nb.thresh = 3.3;
218 rx[k].nb.gen = new_noiseblanker(rx[k].buf.i, rx[k].nb.thresh);
219 rx[k].nb.flag = FALSE;
221 rx[k].nb_sdrom.thresh = 2.5;
222 rx[k].nb_sdrom.gen = new_noiseblanker(rx[k].buf.i, rx[k].nb_sdrom.thresh);
223 rx[k].nb_sdrom.flag = FALSE;
225 rx[k].spot.gen = newSpotToneGen(-12.0, // gain
232 rx[k].scl.pre.val = 1.0;
233 rx[k].scl.pre.flag = FALSE;
234 rx[k].scl.post.val = 1.0;
235 rx[k].scl.post.flag = FALSE;
237 memset((char *) &rx[k].squelch, 0, sizeof(rx[k].squelch));
238 rx[k].squelch.thresh = -30.0;
239 rx[k].squelch.power = 0.0;
240 rx[k].squelch.flag = rx[k].squelch.running = rx[k].squelch.set = FALSE;
241 rx[k].squelch.num = (int) (0.0395 * uni.samplerate + 0.5);
243 rx[k].mode = uni.mode.sdr;
244 rx[k].bin.flag = FALSE;
247 REAL pos = 0.5, // 0 <= pos <= 1, left->right
248 theta = (1.0 - pos) * M_PI / 2.0;
249 rx[k].azim = Cmplx(cos(theta), sin(theta));
261 tx.iqfix = newCorrectIQ(0.0, 1.0);
262 tx.filt.coef = newFIR_Bandpass_COMPLEX(300.0,
266 tx.filt.ovsv = newFiltOvSv(FIRcoef(tx.filt.coef),
267 FIRsize(tx.filt.coef),
269 normalize_vec_COMPLEX(tx.filt.ovsv->zfvec,
270 tx.filt.ovsv->fftlen);
273 tx.filt.save = newvec_COMPLEX(tx.filt.ovsv->fftlen, "TX filter cache");
274 memcpy((char *) tx.filt.save,
275 (char *) tx.filt.ovsv->zfvec,
276 tx.filt.ovsv->fftlen * sizeof(COMPLEX));
279 tx.buf.i = newCXB(FiltOvSv_fetchsize(tx.filt.ovsv),
280 FiltOvSv_fetchpoint(tx.filt.ovsv),
282 tx.buf.o = newCXB(FiltOvSv_storesize(tx.filt.ovsv),
283 FiltOvSv_storepoint(tx.filt.ovsv),
289 tx.osc.gen = newOSC(uni.buflen,
294 "SDR TX Oscillator");
296 tx.agc.gen = newDigitalAgc(agcFAST, // Mode
302 CXBsize(tx.buf.o), // BufSize
309 tx.spr.gen = newSpeechProc(0.4, 10.0, CXBbase(tx.buf.i), CXBsize(tx.buf.i));
313 tx.scl.pre.val = 1.0;
314 tx.scl.pre.flag = FALSE;
315 tx.scl.post.val = 1.0;
316 tx.scl.post.flag = FALSE;
318 tx.mode = uni.mode.sdr;
321 /* not much else to do for TX */
324 /* how the outside world sees it */
327 setup_workspace(void) {
332 for (k = 0; k < uni.multirx.nrx; k++) {
334 uni.multirx.act[k] = FALSE;
336 uni.multirx.act[0] = TRUE;
343 destroy_workspace(void) {
347 delSpeechProc(tx.spr.gen);
348 delDigitalAgc(tx.agc.gen);
350 delvec_COMPLEX(tx.filt.save);
351 delFiltOvSv(tx.filt.ovsv);
352 delFIR_Bandpass_COMPLEX(tx.filt.coef);
353 delCorrectIQ(tx.iqfix);
358 for (k = 0; k < uni.multirx.nrx; k++) {
359 delSpotToneGen(rx[k].spot.gen);
360 delDigitalAgc(rx[k].agc.gen);
361 del_nb(rx[k].nb_sdrom.gen);
362 del_nb(rx[k].nb.gen);
363 del_lmsr(rx[k].anf.gen);
364 del_lmsr(rx[k].anr.gen);
365 delAMD(rx[k].am.gen);
366 delFMD(rx[k].fm.gen);
367 delOSC(rx[k].osc.gen);
368 delvec_COMPLEX(rx[k].filt.save);
369 delFiltOvSv(rx[k].filt.ovsv);
370 delFIR_Bandpass_COMPLEX(rx[k].filt.coef);
371 delCorrectIQ(rx[k].iqfix);
377 finish_spectrum(&uni.spec);
380 //////////////////////////////////////////////////////////////////////////
382 //////////////////////////////////////////////////////////////////////////
384 //========================================================================
391 for (i = 0; i < CXBhave(buff); i++)
392 sum += Csqrmag(CXBdata(buff, i));
396 //========================================================================
399 // unfortunate duplication here, due to
403 do_rx_meter(int k, CXB buf, int tap) {
404 COMPLEX *vec = CXBbase(buf);
405 int i, len = CXBhave(buf);
407 uni.meter.rx.val[k][tap] = 0;
409 switch (uni.meter.rx.type) {
410 case AVG_SIGNAL_STRENGTH:
411 for (i = 0; i < len; i++)
412 uni.meter.rx.val[k][tap] += Csqrmag(vec[i]);
413 uni.meter.rx.val[k][tap] =
414 uni.meter.rx.avg[k][tap] =
415 0.9 * uni.meter.rx.avg[k][tap] + log10(uni.meter.rx.val[k][tap] + 1e-20);
417 case SIGNAL_STRENGTH:
418 for (i = 0; i < len; i++)
419 uni.meter.rx.val[k][tap] += Csqrmag(vec[i]);
420 uni.meter.rx.avg[k][tap] =
421 uni.meter.rx.val[k][tap] =
422 10.0 * log10(uni.meter.rx.val[k][tap] + 1e-20);
425 for(i = 0; i < len; i++)
426 uni.meter.rx.val[k][tap] = max(fabs(vec[i].re), uni.meter.rx.val[k][tap]);
427 uni.meter.rx.val[k][tap] = 20.0 * log10(uni.meter.rx.val[k][tap] + 1e-10);
430 for(i = 0; i < len; i++)
431 uni.meter.rx.val[k][tap] = max(fabs(vec[i].im), uni.meter.rx.val[k][tap]);
432 uni.meter.rx.val[k][tap] = 20.0 * log10(uni.meter.rx.val[k][tap] + 1e-10);
440 do_tx_meter(CXB buf, int tap) {
441 COMPLEX *vec = CXBbase(buf);
442 int i, len = CXBhave(buf);
444 uni.meter.tx.val[tap] = 0;
446 switch (uni.meter.tx.type) {
447 case AVG_SIGNAL_STRENGTH:
448 for (i = 0; i < len; i++)
449 uni.meter.tx.val[tap] += Csqrmag(vec[i]);
450 uni.meter.tx.val[tap] =
451 uni.meter.tx.avg[tap] =
452 0.9 * uni.meter.tx.avg[tap] + log10(uni.meter.tx.val[tap] + 1e-20);
454 case SIGNAL_STRENGTH:
455 for (i = 0; i < len; i++)
456 uni.meter.tx.val[tap] += Csqrmag(vec[i]);
457 uni.meter.tx.avg[tap] =
458 uni.meter.tx.val[tap] =
459 10.0 * log10(uni.meter.tx.val[tap] + 1e-20);
462 for(i = 0; i < len; i++)
463 uni.meter.tx.val[tap] = max(fabs(vec[i].re), uni.meter.tx.val[tap]);
464 uni.meter.tx.val[tap] = 20.0 * log10(uni.meter.tx.val[tap] + 1e-10);
467 for(i = 0; i < len; i++)
468 uni.meter.tx.val[tap] = max(fabs(vec[i].im), uni.meter.tx.val[tap]);
469 uni.meter.tx.val[tap] = 20.0 * log10(uni.meter.tx.val[tap] + 1e-10);
477 do_rx_spectrum(int k, CXB buf, int type) {
478 if (uni.spec.flag && k == uni.spec.rxk && type == uni.spec.type) {
479 memcpy((char *) &CXBdata(uni.spec.accum, uni.spec.fill),
480 (char *) CXBbase(buf),
482 uni.spec.fill = (uni.spec.fill + uni.spec.buflen) % uni.spec.size;
487 do_tx_spectrum(CXB buf) {
488 memcpy((char *) &CXBdata(uni.spec.accum, uni.spec.fill),
489 (char *) CXBbase(buf),
491 uni.spec.fill = (uni.spec.fill + uni.spec.buflen) % uni.spec.size;
494 //========================================================================
498 should_do_rx_squelch(int k) {
499 if (rx[k].squelch.flag) {
500 int i, n = CXBhave(rx[k].buf.o);
501 rx[k].squelch.power = 0.0;
502 for (i = 0; i < n; i++)
503 rx[k].squelch.power += Csqrmag(CXBdata(rx[k].buf.o, i));
504 return rx[k].squelch.thresh > 10.0 * log10(rx[k].squelch.power);
506 return rx[k].squelch.set = FALSE;
510 // slew into silence first time
514 rx[k].squelch.set = TRUE;
515 if (!rx[k].squelch.running) {
516 int i, m = rx[k].squelch.num, n = CXBhave(rx[k].buf.o) - m;
517 for (i = 0; i < m; i++)
518 CXBdata(rx[k].buf.o, i) = Cscl(CXBdata(rx[k].buf.o, i), 1.0 - (REAL) i / m);
519 memset((void *) (CXBbase(rx[k].buf.o) + m), 0, n * sizeof(COMPLEX));
520 rx[k].squelch.running = TRUE;
522 memset((void *) CXBbase(rx[k].buf.o), 0, CXBhave(rx[k].buf.o) * sizeof(COMPLEX));
526 // slew out from silence to full scale
530 if (rx[k].squelch.running) {
531 int i, m = rx[k].squelch.num;
532 for (i = 0; i < m; i++)
533 CXBdata(rx[k].buf.o, i) = Cscl(CXBdata(rx[k].buf.o, i), (REAL) i / m);
534 rx[k].squelch.running = FALSE;
538 /* pre-condition for (nearly) all RX modes */
542 int i, n = min(CXBhave(rx[k].buf.i), uni.buflen);
544 if (rx[k].scl.pre.flag)
545 for (i = 0; i < n; i++)
546 CXBdata(rx[k].buf.i, i) = Cscl(CXBdata(rx[k].buf.i, i),
549 if (rx[k].nb.flag) noiseblanker(rx[k].nb.gen);
550 if (rx[k].nb_sdrom.flag) SDROMnoiseblanker(rx[k].nb_sdrom.gen);
552 // metering for uncorrected values here
554 do_rx_meter(k, rx[k].buf.i, RXMETER_PRE_CONV);
556 correctIQ(rx[k].buf.i, rx[k].iqfix);
558 /* 2nd IF conversion happens here */
560 if (rx[k].osc.gen->Frequency != 0.0) {
561 ComplexOSC(rx[k].osc.gen);
562 for (i = 0; i < n; i++)
563 CXBdata(rx[k].buf.i, i) = Cmul(CXBdata(rx[k].buf.i, i),
564 OSCCdata(rx[k].osc.gen, i));
567 /* filtering, metering, spectrum, squelch, & AGC */
569 if (rx[k].mode == SPEC)
571 do_rx_spectrum(k, rx[k].buf.i, SPEC_SEMI_RAW);
575 do_rx_meter(k, rx[k].buf.i, RXMETER_PRE_FILT);
576 do_rx_spectrum(k, rx[k].buf.i, SPEC_PRE_FILT);
579 reset_OvSv(rx[k].filt.ovsv);
581 filter_OvSv(rx[k].filt.ovsv);
582 CXBhave(rx[k].buf.o) = CXBhave(rx[k].buf.i);
584 do_rx_meter(k, rx[k].buf.o, RXMETER_POST_FILT);
585 do_rx_spectrum(k, rx[k].buf.o, SPEC_POST_FILT);
587 if (should_do_rx_squelch(k))
590 else if (rx[k].agc.flag)
591 DigitalAgc(rx[k].agc.gen, rx[k].tick);
598 int i, n = CXBhave(rx[k].buf.o);
600 if (!rx[k].squelch.set) {
603 if (rx[k].spot.flag) {
604 // remember whether it's turned itself off during this pass
605 rx[k].spot.flag = SpotTone(rx[k].spot.gen);
606 for (i = 0; i < n; i++)
607 CXBdata(rx[k].buf.o, i) = Cadd(CXBdata(rx[k].buf.o, i),
608 CXBdata(rx[k].spot.gen->buf, i));
614 if (rx[k].scl.post.flag)
615 for (i = 0; i < n; i++)
616 CXBdata(rx[k].buf.o, i) = Cscl(CXBdata(rx[k].buf.o, i),
620 // position in stereo field
623 for (i = 0; i < n; i++)
624 CXBdata(rx[k].buf.o, i) = Cscl(rx[k].azim, CXBreal(rx[k].buf.o, i));
627 /* demod processing */
631 if (rx[k].anr.flag) lmsr_adapt(rx[k].anr.gen);
632 if (rx[k].anf.flag) lmsr_adapt(rx[k].anf.gen);
636 do_rx_AM(int k) { AMDemod(rx[k].am.gen); }
639 do_rx_FM(int k) { FMDemod(rx[k].fm.gen); }
646 memcpy(CXBbase(rx[k].buf.o),
647 CXBbase(rx[k].buf.i),
648 sizeof(COMPLEX) * CXBhave(rx[k].buf.i));
649 if (rx[k].agc.flag) DigitalAgc(rx[k].agc.gen, rx[k].tick);
654 int i, n = min(CXBhave(rx[k].buf.i), uni.buflen);
655 for (i = 0; i < n; i++) CXBdata(rx[k].buf.o, i) = cxzero;
658 /* overall dispatch for RX processing */
663 switch (rx[k].mode) {
668 case DSB: do_rx_SBCW(k); break;
670 case SAM: do_rx_AM(k); break;
671 case FMN: do_rx_FM(k); break;
672 case DRM: do_rx_DRM(k); break;
674 default: do_rx_SPEC(k); break;
679 //==============================================================
682 /* pre-condition for (nearly) all TX modes */
687 if (tx.scl.pre.flag) {
688 int i, n = CXBhave(tx.buf.i);
689 for (i = 0; i < n; i++)
690 CXBdata(tx.buf.i, i) = Cmplx(CXBreal(tx.buf.i, i) * tx.scl.pre.val, 0.0);
693 correctIQ(tx.buf.i, tx.iqfix);
695 if (tx.spr.flag) SpeechProcessor(tx.spr.gen);
697 if (tx.tick == 0) reset_OvSv(tx.filt.ovsv);
698 filter_OvSv(tx.filt.ovsv);
703 CXBhave(tx.buf.o) = CXBhave(tx.buf.i);
705 if (tx.agc.flag) DigitalAgc(tx.agc.gen, tx.tick);
707 // meter modulated signal
709 do_tx_meter(tx.buf.o, TXMETER_POST_MOD);
711 if (tx.scl.post.flag) {
712 int i, n = CXBhave(tx.buf.o);
713 for (i = 0; i < n; i++)
714 CXBdata(tx.buf.o, i) = Cscl(CXBdata(tx.buf.o, i), tx.scl.post.val);
718 do_tx_spectrum(tx.buf.o);
720 if (tx.osc.gen->Frequency != 0.0) {
722 ComplexOSC(tx.osc.gen);
723 for (i = 0; i < CXBhave(tx.buf.o); i++)
724 CXBdata(tx.buf.o, i) = Cmul(CXBdata(tx.buf.o, i), OSCCdata(tx.osc.gen, i));
728 /* modulator processing */
732 int i, n = min(CXBhave(tx.buf.o), uni.buflen);
734 if ((tx.norm = CXBnorm(tx.buf.o)) > 0.0)
735 for (i = 0; i < n; i++) {
736 tx.scl.dc = Cadd(Cscl(tx.scl.dc, 0.99),
737 Cscl(CXBdata(tx.buf.o, i), -0.01));
738 CXBdata(tx.buf.o, i) = Cadd(CXBdata(tx.buf.o, i), tx.scl.dc);
744 int i, n = min(CXBhave(tx.buf.o), uni.buflen);
746 if ((tx.norm = CXBnorm(tx.buf.o)) > 0.0)
747 for (i = 0; i < n; i++) {
748 tx.scl.dc = Cadd(Cscl(tx.scl.dc, 0.999),
749 Cscl(CXBdata(tx.buf.o, i), -0.001));
750 CXBreal(tx.buf.o, i) =
751 0.49995 + 0.49995 * (CXBreal(tx.buf.o, i) - tx.scl.dc.re);
752 CXBimag(tx.buf.o, i) = 0.0;
758 int i, n = min(CXBhave(tx.buf.o), uni.buflen);
759 if ((tx.norm = CXBnorm(tx.buf.o)) > 0.0)
760 for (i = 0; i < n; i++) {
761 tx.scl.dc = Cadd(Cscl(tx.scl.dc, 0.999),
762 Cscl(CXBdata(tx.buf.o, i), 0.001));
763 tx.osc.phase += (CXBreal(tx.buf.o, i) - tx.scl.dc.re) * CvtMod2Freq;
764 if (tx.osc.phase >= TWOPI) tx.osc.phase -= TWOPI;
765 if (tx.osc.phase < 0.0) tx.osc.phase += TWOPI;
766 CXBdata(tx.buf.o, i) =
767 Cscl(Cmplx(cos(tx.osc.phase), sin(tx.osc.phase)), 0.99999);
773 int i, n = min(CXBhave(tx.buf.i), uni.buflen);
774 for (i = 0; i < n; i++) CXBdata(tx.buf.o, i) = cxzero;
777 /* general TX processing dispatch */
787 case DSB: do_tx_SBCW(); break;
789 case SAM: do_tx_AM(); break;
790 case FMN: do_tx_FM(); break;
793 default: do_tx_NIL(); break;
798 //========================================================================
799 /* overall buffer processing;
800 come here when there are buffers to work on */
803 process_samples(float *bufl, float *bufr,
804 float *auxl, float *auxr,
808 switch (uni.mode.trx) {
812 // make copies of the input for all receivers
813 for (k = 0; k < uni.multirx.nrx; k++)
814 if (uni.multirx.act[k]) {
815 for (i = 0; i < n; i++)
816 CXBimag(rx[k].buf.i, i) = bufl[i], CXBreal(rx[k].buf.i, i) = bufr[i];
817 CXBhave(rx[k].buf.i) = n;
820 // prepare buffers for mixing
821 memset((char *) bufl, 0, n * sizeof(float));
822 memset((char *) bufr, 0, n * sizeof(float));
825 for (k = 0; k < uni.multirx.nrx; k++)
826 if (uni.multirx.act[k]) {
827 do_rx(k), rx[k].tick++;
829 for (i = 0; i < n; i++)
830 bufl[i] += (float)CXBimag(rx[k].buf.o, i),
831 bufr[i] += (float)CXBreal(rx[k].buf.o, i);
832 CXBhave(rx[k].buf.o) = n;
835 // late mixing of aux buffers
837 for (i = 0; i < n; i++)
838 bufl[i] += (float)(auxl[i] * uni.mix.rx.gain),
839 bufr[i] += (float)(auxr[i] * uni.mix.rx.gain);
845 // early mixing of aux buffers
847 for (i = 0; i < n; i++)
848 bufl[i] += (float)(auxl[i] * uni.mix.tx.gain),
849 bufr[i] += (float)(auxr[i] * uni.mix.tx.gain);
851 for (i = 0; i < n; i++)
852 CXBimag(tx.buf.i, i) = bufl[i], CXBreal(tx.buf.i, i) = bufr[i];
853 CXBhave(tx.buf.i) = n;
857 for (i = 0; i < n; i++)
858 bufl[i] = (float) CXBimag(tx.buf.o, i), bufr[i] = (float) CXBreal(tx.buf.o, i);
859 CXBhave(tx.buf.o) = n;