2024-06-16 05:31:13 -04:00
|
|
|
/* RXA.c
|
|
|
|
|
|
|
|
This file is part of a program that implements a Software-Defined Radio.
|
|
|
|
|
|
|
|
Copyright (C) 2013, 2014, 2015, 2016, 2023 Warren Pratt, NR0V
|
|
|
|
Copyright (C) 2024 Edouard Griffiths, F4EXB Adapted to SDRangel
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
|
|
|
The author can be reached by email at
|
|
|
|
|
|
|
|
warren@wpratt.com
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "comm.hpp"
|
|
|
|
|
|
|
|
#include "RXA.hpp"
|
|
|
|
#include "amd.hpp"
|
|
|
|
#include "meter.hpp"
|
|
|
|
#include "shift.hpp"
|
|
|
|
#include "resample.hpp"
|
|
|
|
#include "bandpass.hpp"
|
|
|
|
#include "bps.hpp"
|
|
|
|
#include "nbp.hpp"
|
2024-07-02 18:52:16 -04:00
|
|
|
#include "snba.hpp"
|
|
|
|
#include "bpsnba.hpp"
|
2024-06-16 05:31:13 -04:00
|
|
|
#include "sender.hpp"
|
|
|
|
#include "amsq.hpp"
|
|
|
|
#include "fmd.hpp"
|
|
|
|
#include "fmsq.hpp"
|
|
|
|
#include "eq.hpp"
|
|
|
|
#include "anf.hpp"
|
|
|
|
#include "anr.hpp"
|
|
|
|
#include "emnr.hpp"
|
|
|
|
#include "patchpanel.hpp"
|
|
|
|
#include "siphon.hpp"
|
|
|
|
#include "cblock.hpp"
|
|
|
|
#include "ssql.hpp"
|
|
|
|
#include "iir.hpp"
|
2024-07-12 21:20:26 -04:00
|
|
|
#include "fircore.hpp"
|
2024-06-16 05:31:13 -04:00
|
|
|
#include "wcpAGC.hpp"
|
2024-06-29 14:03:13 -04:00
|
|
|
#include "anb.hpp"
|
|
|
|
#include "nob.hpp"
|
2024-06-16 05:31:13 -04:00
|
|
|
|
|
|
|
namespace WDSP {
|
|
|
|
|
|
|
|
RXA* RXA::create_rxa (
|
|
|
|
int in_rate, // input samplerate
|
|
|
|
int out_rate, // output samplerate
|
|
|
|
int dsp_rate, // sample rate for mainstream dsp processing
|
2024-06-21 09:33:35 -04:00
|
|
|
int dsp_size // number complex samples processed per buffer in mainstream dsp processing
|
2024-06-16 05:31:13 -04:00
|
|
|
)
|
|
|
|
{
|
|
|
|
RXA* rxa = new RXA;
|
|
|
|
|
|
|
|
rxa->in_rate = in_rate;
|
|
|
|
rxa->out_rate = out_rate;
|
|
|
|
rxa->dsp_rate = dsp_rate;
|
|
|
|
rxa->dsp_size = dsp_size;
|
2024-06-21 09:33:35 -04:00
|
|
|
|
|
|
|
if (in_rate >= dsp_rate)
|
|
|
|
rxa->dsp_insize = dsp_size * (in_rate / dsp_rate);
|
|
|
|
else
|
|
|
|
rxa->dsp_insize = dsp_size / (dsp_rate / in_rate);
|
|
|
|
|
|
|
|
if (out_rate >= dsp_rate)
|
|
|
|
rxa->dsp_outsize = dsp_size * (out_rate / dsp_rate);
|
|
|
|
else
|
|
|
|
rxa->dsp_outsize = dsp_size / (dsp_rate / out_rate);
|
2024-06-16 05:31:13 -04:00
|
|
|
|
|
|
|
rxa->mode = RXA_LSB;
|
2024-06-24 21:50:48 -04:00
|
|
|
rxa->inbuff = new float[1 * rxa->dsp_insize * 2]; // (float *) malloc0 (1 * ch.dsp_insize * sizeof (complex));
|
|
|
|
rxa->outbuff = new float[1 * rxa->dsp_outsize * 2]; // (float *) malloc0 (1 * ch.dsp_outsize * sizeof (complex));
|
|
|
|
rxa->midbuff = new float[2 * rxa->dsp_size * 2]; // (float *) malloc0 (2 * ch.dsp_size * sizeof (complex));
|
2024-07-12 21:53:57 -04:00
|
|
|
std::fill(rxa->meter, rxa->meter + RXA_METERTYPE_LAST, 0);
|
2024-06-16 05:31:13 -04:00
|
|
|
|
2024-06-29 14:03:13 -04:00
|
|
|
// Noise blanker (ANB or "NB")
|
2024-07-23 02:06:13 -04:00
|
|
|
rxa->anb = new ANB(
|
2024-06-29 14:03:13 -04:00
|
|
|
0, // run
|
|
|
|
rxa->dsp_insize, // input buffer size
|
|
|
|
rxa->inbuff, // pointer to input buffer
|
|
|
|
rxa->inbuff, // pointer to output buffer
|
|
|
|
rxa->in_rate, // samplerate
|
|
|
|
0.0001, // tau
|
|
|
|
0.0001, // hang time
|
|
|
|
0.0001, // advance time
|
|
|
|
0.05, // back tau
|
2024-06-30 16:16:30 -04:00
|
|
|
30 // thershold
|
2024-06-29 14:03:13 -04:00
|
|
|
);
|
|
|
|
// Noise blanker (NOB or "NB2")
|
2024-07-23 02:06:13 -04:00
|
|
|
rxa->nob = new NOB(
|
2024-06-29 14:03:13 -04:00
|
|
|
0, // run
|
|
|
|
rxa->dsp_insize, // input buffer size
|
|
|
|
rxa->inbuff, // pointer to input buffer
|
|
|
|
rxa->inbuff, // pointer to output buffer
|
|
|
|
rxa->in_rate, // samplerate
|
|
|
|
0, // mode (zero)
|
|
|
|
0.0001, // advance slew time
|
|
|
|
0.0001, // advance time
|
|
|
|
0.0001, // hang slew time
|
|
|
|
0.0001, // hang time
|
|
|
|
0.025, // max_imp_seq_time:
|
|
|
|
0.05, // back tau
|
|
|
|
30
|
|
|
|
);
|
|
|
|
|
2024-06-24 04:20:14 -04:00
|
|
|
// Ftequency shifter - shift to select a slice of spectrum
|
2024-07-23 22:33:42 -04:00
|
|
|
rxa->shift = new SHIFT(
|
2024-07-11 23:00:12 -04:00
|
|
|
0, // run
|
2024-06-24 04:20:14 -04:00
|
|
|
rxa->dsp_insize, // input buffer size
|
2024-06-16 05:31:13 -04:00
|
|
|
rxa->inbuff, // pointer to input buffer
|
|
|
|
rxa->inbuff, // pointer to output buffer
|
2024-06-24 04:20:14 -04:00
|
|
|
rxa->in_rate, // samplerate
|
|
|
|
0.0); // amount to shift (Hz)
|
2024-06-16 05:31:13 -04:00
|
|
|
|
2024-06-24 04:20:14 -04:00
|
|
|
// Input resampler - resample to dsp rate for main processing
|
2024-07-23 22:33:42 -04:00
|
|
|
rxa->rsmpin = new RESAMPLE(
|
2024-06-24 04:20:14 -04:00
|
|
|
0, // run - will be turned ON below if needed
|
|
|
|
rxa->dsp_insize, // input buffer size
|
2024-06-16 05:31:13 -04:00
|
|
|
rxa->inbuff, // pointer to input buffer
|
|
|
|
rxa->midbuff, // pointer to output buffer
|
2024-06-24 04:20:14 -04:00
|
|
|
rxa->in_rate, // input samplerate
|
|
|
|
rxa->dsp_rate, // output samplerate
|
|
|
|
0.0, // select cutoff automatically
|
|
|
|
0, // select ncoef automatically
|
|
|
|
1.0); // gain
|
2024-06-16 05:31:13 -04:00
|
|
|
|
2024-06-24 04:20:14 -04:00
|
|
|
// Input meter - ADC
|
2024-07-24 09:32:21 -04:00
|
|
|
rxa->adcmeter = new METER(
|
2024-06-24 04:20:14 -04:00
|
|
|
0, // run
|
|
|
|
0, // optional pointer to another 'run'
|
|
|
|
rxa->dsp_size, // size
|
2024-06-16 05:31:13 -04:00
|
|
|
rxa->midbuff, // pointer to buffer
|
2024-06-24 04:20:14 -04:00
|
|
|
rxa->dsp_rate, // samplerate
|
|
|
|
0.100, // averaging time constant
|
|
|
|
0.100, // peak decay time constant
|
2024-06-16 05:31:13 -04:00
|
|
|
rxa->meter, // result vector
|
2024-06-24 04:20:14 -04:00
|
|
|
RXA_ADC_AV, // index for average value
|
|
|
|
RXA_ADC_PK, // index for peak value
|
2024-07-12 21:53:57 -04:00
|
|
|
-1, // index for gain value - disabled
|
2024-06-24 04:20:14 -04:00
|
|
|
0); // pointer for gain computation
|
|
|
|
|
|
|
|
// Notched bandpass section
|
2024-06-16 05:31:13 -04:00
|
|
|
|
|
|
|
// notch database
|
2024-07-24 14:29:55 -04:00
|
|
|
rxa->ndb = new NOTCHDB (
|
2024-06-24 04:20:14 -04:00
|
|
|
0, // master run for all nbp's
|
|
|
|
1024); // max number of notches
|
2024-06-16 05:31:13 -04:00
|
|
|
|
|
|
|
// notched bandpass
|
2024-07-24 14:29:55 -04:00
|
|
|
rxa->nbp0 = new NBP (
|
2024-06-24 04:20:14 -04:00
|
|
|
1, // run, always runs
|
|
|
|
0, // run the notches
|
|
|
|
0, // position
|
|
|
|
rxa->dsp_size, // buffer size
|
|
|
|
std::max(2048, rxa->dsp_size), // number of coefficients
|
|
|
|
0, // minimum phase flag
|
2024-06-16 05:31:13 -04:00
|
|
|
rxa->midbuff, // pointer to input buffer
|
|
|
|
rxa->midbuff, // pointer to output buffer
|
2024-06-24 04:20:14 -04:00
|
|
|
-4150.0, // lower filter frequency
|
|
|
|
-150.0, // upper filter frequency
|
|
|
|
rxa->dsp_rate, // sample rate
|
|
|
|
0, // wintype
|
|
|
|
1.0, // gain
|
|
|
|
1, // auto-increase notch width
|
|
|
|
1025, // max number of passbands
|
2024-07-22 18:39:21 -04:00
|
|
|
rxa->ndb); // addr of database pointer
|
2024-06-16 05:31:13 -04:00
|
|
|
|
|
|
|
// bandpass for snba
|
2024-07-24 17:11:29 -04:00
|
|
|
rxa->bpsnba = new BPSNBA (
|
2024-06-24 04:20:14 -04:00
|
|
|
0, // bpsnba run flag
|
|
|
|
0, // run the notches
|
|
|
|
0, // position
|
|
|
|
rxa->dsp_size, // size
|
|
|
|
std::max(2048, rxa->dsp_size), // number of filter coefficients
|
|
|
|
0, // minimum phase flag
|
2024-06-16 05:31:13 -04:00
|
|
|
rxa->midbuff, // input buffer
|
|
|
|
rxa->midbuff, // output buffer
|
2024-06-24 04:20:14 -04:00
|
|
|
rxa->dsp_rate, // samplerate
|
|
|
|
+ 250.0, // abs value of cutoff nearest zero
|
|
|
|
+ 5700.0, // abs value of cutoff farthest zero
|
|
|
|
- 5700.0, // current low frequency
|
|
|
|
- 250.0, // current high frequency
|
|
|
|
0, // wintype
|
|
|
|
1.0, // gain
|
|
|
|
1, // auto-increase notch width
|
|
|
|
1025, // max number of passbands
|
2024-07-22 18:39:21 -04:00
|
|
|
rxa->ndb); // addr of database pointer
|
2024-06-16 05:31:13 -04:00
|
|
|
|
2024-06-24 04:20:14 -04:00
|
|
|
// Post filter display send - send spectrum display (after S-meter in the block diagram)
|
2024-07-24 17:30:41 -04:00
|
|
|
rxa->sender = new SENDER (
|
2024-06-16 05:31:13 -04:00
|
|
|
0, // run
|
2024-06-24 04:20:14 -04:00
|
|
|
0, // flag
|
|
|
|
0, // mode
|
|
|
|
rxa->dsp_size, // size
|
|
|
|
rxa->midbuff // pointer to input buffer
|
|
|
|
);
|
|
|
|
|
|
|
|
// End notched bandpass section
|
2024-06-16 05:31:13 -04:00
|
|
|
|
|
|
|
// S-meter
|
2024-07-24 09:32:21 -04:00
|
|
|
rxa->smeter = new METER(
|
2024-06-24 04:20:14 -04:00
|
|
|
1, // run
|
|
|
|
0, // optional pointer to another 'run'
|
|
|
|
rxa->dsp_size, // size
|
2024-06-16 05:31:13 -04:00
|
|
|
rxa->midbuff, // pointer to buffer
|
2024-06-24 04:20:14 -04:00
|
|
|
rxa->dsp_rate, // samplerate
|
|
|
|
0.100, // averaging time constant
|
|
|
|
0.100, // peak decay time constant
|
2024-06-16 05:31:13 -04:00
|
|
|
rxa->meter, // result vector
|
2024-06-24 04:20:14 -04:00
|
|
|
RXA_S_AV, // index for average value
|
|
|
|
RXA_S_PK, // index for peak value
|
2024-07-12 21:53:57 -04:00
|
|
|
-1, // index for gain value - disabled
|
2024-06-24 04:20:14 -04:00
|
|
|
0); // pointer for gain computation
|
2024-06-16 05:31:13 -04:00
|
|
|
|
2024-06-24 04:20:14 -04:00
|
|
|
// AM squelch capture (for other modes than FM)
|
2024-07-22 18:39:21 -04:00
|
|
|
rxa->amsq = AMSQ::create_amsq (
|
2024-06-24 04:20:14 -04:00
|
|
|
0, // run
|
|
|
|
rxa->dsp_size, // buffer size
|
2024-06-16 05:31:13 -04:00
|
|
|
rxa->midbuff, // pointer to signal input buffer used by xamsq
|
|
|
|
rxa->midbuff, // pointer to signal output buffer used by xamsq
|
|
|
|
rxa->midbuff, // pointer to trigger buffer that xamsqcap will capture
|
2024-06-24 04:20:14 -04:00
|
|
|
rxa->dsp_rate, // sample rate
|
|
|
|
0.010, // time constant for averaging signal level
|
|
|
|
0.070, // signal up transition time
|
|
|
|
0.070, // signal down transition time
|
|
|
|
0.009, // signal level to initiate tail
|
|
|
|
0.010, // signal level to initiate unmute
|
|
|
|
0.000, // minimum tail length
|
|
|
|
1.500, // maximum tail length
|
|
|
|
0.0); // muted gain
|
|
|
|
|
|
|
|
// AM/SAM demodulator
|
2024-07-22 18:39:21 -04:00
|
|
|
rxa->amd = AMD::create_amd (
|
2024-06-24 04:20:14 -04:00
|
|
|
0, // run - OFF by default
|
|
|
|
rxa->dsp_size, // buffer size
|
2024-06-16 05:31:13 -04:00
|
|
|
rxa->midbuff, // pointer to input buffer
|
|
|
|
rxa->midbuff, // pointer to output buffer
|
2024-06-24 04:20:14 -04:00
|
|
|
0, // mode: 0->AM, 1->SAM
|
|
|
|
1, // levelfade: 0->OFF, 1->ON
|
|
|
|
0, // sideband mode: 0->OFF
|
|
|
|
rxa->dsp_rate, // sample rate
|
|
|
|
-2000.0, // minimum lock frequency
|
|
|
|
+2000.0, // maximum lock frequency
|
|
|
|
1.0, // zeta
|
|
|
|
250.0, // omegaN
|
|
|
|
0.02, // tauR
|
|
|
|
1.4); // tauI
|
|
|
|
|
|
|
|
// FM demodulator
|
2024-07-22 18:39:21 -04:00
|
|
|
rxa->fmd = FMD::create_fmd (
|
2024-06-24 04:20:14 -04:00
|
|
|
0, // run
|
|
|
|
rxa->dsp_size, // buffer size
|
2024-06-16 05:31:13 -04:00
|
|
|
rxa->midbuff, // pointer to input buffer
|
|
|
|
rxa->midbuff, // pointer to output buffer
|
2024-06-24 04:20:14 -04:00
|
|
|
rxa->dsp_rate, // sample rate
|
|
|
|
5000.0, // deviation
|
|
|
|
300.0, // f_low
|
|
|
|
3000.0, // f_high
|
|
|
|
-8000.0, // fmin
|
|
|
|
+8000.0, // fmax
|
|
|
|
1.0, // zeta
|
|
|
|
20000.0, // omegaN
|
|
|
|
0.02, // tau - for dc removal
|
|
|
|
0.5, // audio gain
|
|
|
|
1, // run tone filter
|
|
|
|
254.1, // ctcss frequency
|
|
|
|
std::max(2048, rxa->dsp_size), // # coefs for de-emphasis filter
|
|
|
|
0, // min phase flag for de-emphasis filter
|
|
|
|
std::max(2048, rxa->dsp_size), // # coefs for audio cutoff filter
|
|
|
|
0); // min phase flag for audio cutoff filter
|
|
|
|
|
|
|
|
// FM squelch apply
|
2024-07-22 18:39:21 -04:00
|
|
|
rxa->fmsq = FMSQ::create_fmsq (
|
2024-06-24 04:20:14 -04:00
|
|
|
0, // run
|
|
|
|
rxa->dsp_size, // buffer size
|
2024-06-16 05:31:13 -04:00
|
|
|
rxa->midbuff, // pointer to input signal buffer
|
|
|
|
rxa->midbuff, // pointer to output signal buffer
|
2024-07-22 18:39:21 -04:00
|
|
|
rxa->fmd->audio, // pointer to trigger buffer
|
2024-06-24 04:20:14 -04:00
|
|
|
rxa->dsp_rate, // sample rate
|
|
|
|
5000.0, // cutoff freq for noise filter (Hz)
|
2024-07-22 18:39:21 -04:00
|
|
|
&rxa->fmd->pllpole, // pointer to pole frequency of the fmd pll (Hz)
|
2024-06-24 04:20:14 -04:00
|
|
|
0.100, // delay time after channel flush
|
|
|
|
0.001, // tau for noise averaging
|
|
|
|
0.100, // tau for long noise averaging
|
|
|
|
0.050, // signal up transition time
|
|
|
|
0.010, // signal down transition time
|
|
|
|
0.750, // noise level to initiate tail
|
|
|
|
0.562, // noise level to initiate unmute
|
|
|
|
0.000, // minimum tail time
|
2024-07-06 16:41:33 -04:00
|
|
|
0.100, // maximum tail time
|
2024-06-24 04:20:14 -04:00
|
|
|
std::max(2048, rxa->dsp_size), // number of coefficients for noise filter
|
|
|
|
0); // minimum phase flag
|
|
|
|
|
|
|
|
// Spectral noise blanker (SNB)
|
2024-07-22 18:39:21 -04:00
|
|
|
rxa->snba = SNBA::create_snba (
|
2024-06-24 04:20:14 -04:00
|
|
|
0, // run
|
2024-06-16 05:31:13 -04:00
|
|
|
rxa->midbuff, // input buffer
|
|
|
|
rxa->midbuff, // output buffer
|
2024-06-24 04:20:14 -04:00
|
|
|
rxa->dsp_rate, // input / output sample rate
|
|
|
|
12000, // internal processing sample rate
|
|
|
|
rxa->dsp_size, // buffer size
|
|
|
|
4, // overlap factor to use
|
|
|
|
256, // frame size to use; sized for 12K rate
|
|
|
|
64, // asize
|
|
|
|
2, // npasses
|
|
|
|
8.0, // k1
|
|
|
|
20.0, // k2
|
|
|
|
10, // b
|
|
|
|
2, // pre
|
|
|
|
2, // post
|
|
|
|
0.5, // pmultmin
|
|
|
|
200.0, // output resampler low cutoff
|
|
|
|
5400.0); // output resampler high cutoff
|
|
|
|
|
|
|
|
// Equalizer
|
2024-06-16 05:31:13 -04:00
|
|
|
{
|
2024-06-24 21:50:48 -04:00
|
|
|
float default_F[11] = {0.0, 32.0, 63.0, 125.0, 250.0, 500.0, 1000.0, 2000.0, 4000.0, 8000.0, 16000.0};
|
|
|
|
//float default_G[11] = {0.0, -12.0, -12.0, -12.0, -1.0, +1.0, +4.0, +9.0, +12.0, -10.0, -10.0};
|
|
|
|
float default_G[11] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
|
2024-07-22 18:39:21 -04:00
|
|
|
rxa->eqp = EQP::create_eqp (
|
2024-06-24 04:20:14 -04:00
|
|
|
0, // run - OFF by default
|
|
|
|
rxa->dsp_size, // buffer size
|
|
|
|
std::max(2048, rxa->dsp_size), // number of filter coefficients
|
|
|
|
0, // minimum phase flag
|
|
|
|
rxa->midbuff, // pointer to input buffer
|
|
|
|
rxa->midbuff, // pointer to output buffer
|
|
|
|
10, // number of frequencies
|
|
|
|
default_F, // frequency vector
|
|
|
|
default_G, // gain vector
|
|
|
|
0, // cutoff mode
|
|
|
|
0, // wintype
|
|
|
|
rxa->dsp_rate); // sample rate
|
2024-06-16 05:31:13 -04:00
|
|
|
}
|
|
|
|
|
2024-06-24 04:20:14 -04:00
|
|
|
// Auto notch filter
|
2024-07-22 18:39:21 -04:00
|
|
|
rxa->anf = ANF::create_anf (
|
2024-06-24 04:20:14 -04:00
|
|
|
0, // run - OFF by default
|
|
|
|
0, // position
|
|
|
|
rxa->dsp_size, // buffer size
|
2024-06-16 05:31:13 -04:00
|
|
|
rxa->midbuff, // pointer to input buffer
|
|
|
|
rxa->midbuff, // pointer to output buffer
|
2024-06-24 04:20:14 -04:00
|
|
|
ANF_DLINE_SIZE, // dline_size
|
|
|
|
64, // taps
|
|
|
|
16, // delay
|
|
|
|
0.0001, // two_mu
|
|
|
|
0.1, // gamma
|
|
|
|
1.0, // lidx
|
|
|
|
0.0, // lidx_min
|
|
|
|
200.0, // lidx_max
|
|
|
|
6.25e-12, // ngamma
|
|
|
|
6.25e-10, // den_mult
|
|
|
|
1.0, // lincr
|
|
|
|
3.0); // ldecr
|
|
|
|
|
|
|
|
// LMS noise reduction (ANR or "NR")
|
2024-07-22 18:39:21 -04:00
|
|
|
rxa->anr = ANR::create_anr (
|
2024-06-24 04:20:14 -04:00
|
|
|
0, // run - OFF by default
|
|
|
|
0, // position
|
|
|
|
rxa->dsp_size, // buffer size
|
2024-06-16 05:31:13 -04:00
|
|
|
rxa->midbuff, // pointer to input buffer
|
|
|
|
rxa->midbuff, // pointer to output buffer
|
2024-06-24 04:20:14 -04:00
|
|
|
ANR_DLINE_SIZE, // dline_size
|
|
|
|
64, // taps
|
|
|
|
16, // delay
|
|
|
|
0.0001, // two_mu
|
|
|
|
0.1, // gamma
|
|
|
|
120.0, // lidx
|
|
|
|
120.0, // lidx_min
|
|
|
|
200.0, // lidx_max
|
|
|
|
0.001, // ngamma
|
|
|
|
6.25e-10, // den_mult
|
|
|
|
1.0, // lincr
|
|
|
|
3.0); // ldecr
|
|
|
|
|
|
|
|
// Spectral noise reduyction (EMNR or "NR2")
|
2024-07-22 18:39:21 -04:00
|
|
|
rxa->emnr = EMNR::create_emnr (
|
2024-06-24 04:20:14 -04:00
|
|
|
0, // run
|
|
|
|
0, // position
|
|
|
|
rxa->dsp_size, // buffer size
|
2024-06-16 05:31:13 -04:00
|
|
|
rxa->midbuff, // input buffer
|
|
|
|
rxa->midbuff, // output buffer
|
2024-06-24 04:20:14 -04:00
|
|
|
4096, // FFT size
|
|
|
|
4, // overlap
|
|
|
|
rxa->dsp_rate, // samplerate
|
|
|
|
0, // window type
|
|
|
|
1.0, // gain
|
|
|
|
2, // gain method
|
|
|
|
0, // npe_method
|
|
|
|
1); // ae_run
|
2024-06-16 05:31:13 -04:00
|
|
|
|
|
|
|
// AGC
|
2024-07-22 18:39:21 -04:00
|
|
|
rxa->agc = WCPAGC::create_wcpagc (
|
2024-06-24 04:20:14 -04:00
|
|
|
1, // run
|
|
|
|
3, // mode
|
|
|
|
1, // peakmode = envelope
|
2024-06-16 05:31:13 -04:00
|
|
|
rxa->midbuff, // pointer to input buffer
|
|
|
|
rxa->midbuff, // pointer to output buffer
|
2024-06-24 04:20:14 -04:00
|
|
|
rxa->dsp_size, // buffer size
|
|
|
|
rxa->dsp_rate, // sample rate
|
|
|
|
0.001, // tau_attack
|
|
|
|
0.250, // tau_decay
|
|
|
|
4, // n_tau
|
|
|
|
10000.0, // max_gain
|
|
|
|
1.5, // var_gain
|
|
|
|
1000.0, // fixed_gain
|
|
|
|
1.0, // max_input
|
|
|
|
1.0, // out_target
|
|
|
|
0.250, // tau_fast_backaverage
|
|
|
|
0.005, // tau_fast_decay
|
|
|
|
5.0, // pop_ratio
|
|
|
|
1, // hang_enable
|
|
|
|
0.500, // tau_hang_backmult
|
|
|
|
0.250, // hangtime
|
|
|
|
0.250, // hang_thresh
|
|
|
|
0.100); // tau_hang_decay
|
|
|
|
|
|
|
|
// AGC meter
|
2024-07-24 09:32:21 -04:00
|
|
|
rxa->agcmeter = new METER(
|
2024-06-24 04:20:14 -04:00
|
|
|
0, // run
|
|
|
|
0, // optional pointer to another 'run'
|
|
|
|
rxa->dsp_size, // size
|
2024-06-16 05:31:13 -04:00
|
|
|
rxa->midbuff, // pointer to buffer
|
2024-06-24 04:20:14 -04:00
|
|
|
rxa->dsp_rate, // samplerate
|
|
|
|
0.100, // averaging time constant
|
|
|
|
0.100, // peak decay time constant
|
2024-06-16 05:31:13 -04:00
|
|
|
rxa->meter, // result vector
|
2024-06-24 04:20:14 -04:00
|
|
|
RXA_AGC_AV, // index for average value
|
|
|
|
RXA_AGC_PK, // index for peak value
|
|
|
|
RXA_AGC_GAIN, // index for gain value
|
2024-07-22 18:39:21 -04:00
|
|
|
&rxa->agc->gain); // pointer for gain computation
|
2024-06-16 05:31:13 -04:00
|
|
|
|
2024-06-24 04:20:14 -04:00
|
|
|
// Bandpass filter - After spectral noise reduction in the block diagram
|
2024-07-22 18:39:21 -04:00
|
|
|
rxa->bp1 = BANDPASS::create_bandpass (
|
2024-06-24 04:20:14 -04:00
|
|
|
1, // run - used only with ( AM || ANF || ANR || EMNR)
|
|
|
|
0, // position
|
|
|
|
rxa->dsp_size, // buffer size
|
|
|
|
std::max(2048, rxa->dsp_size), // number of coefficients
|
|
|
|
0, // flag for minimum phase
|
2024-06-16 05:31:13 -04:00
|
|
|
rxa->midbuff, // pointer to input buffer
|
|
|
|
rxa->midbuff, // pointer to output buffer
|
2024-06-24 04:20:14 -04:00
|
|
|
-4150.0, // lower filter frequency
|
|
|
|
-150.0, // upper filter frequency
|
|
|
|
rxa->dsp_rate, // sample rate
|
|
|
|
1, // wintype
|
|
|
|
1.0); // gain
|
2024-06-16 05:31:13 -04:00
|
|
|
|
2024-06-24 04:20:14 -04:00
|
|
|
// Scope/phase display send - pull phase & scope display data
|
2024-07-22 18:39:21 -04:00
|
|
|
rxa->sip1 = SIPHON::create_siphon (
|
2024-06-24 04:20:14 -04:00
|
|
|
0, // run - needed only for phase display
|
|
|
|
0, // position
|
|
|
|
0, // mode
|
|
|
|
0, // disp
|
|
|
|
rxa->dsp_size, // size of input buffer
|
2024-06-16 05:31:13 -04:00
|
|
|
rxa->midbuff, // input buffer
|
2024-06-24 04:20:14 -04:00
|
|
|
4096, // number of samples to store
|
|
|
|
4096, // fft size for spectrum
|
|
|
|
0); // specmode
|
2024-06-16 05:31:13 -04:00
|
|
|
|
2024-06-24 04:20:14 -04:00
|
|
|
// AM carrier block
|
2024-07-22 18:39:21 -04:00
|
|
|
rxa->cbl = CBL::create_cbl (
|
2024-06-24 04:20:14 -04:00
|
|
|
0, // run - needed only if set to ON
|
|
|
|
rxa->dsp_size, // buffer size
|
2024-06-16 05:31:13 -04:00
|
|
|
rxa->midbuff, // pointer to input buffer
|
|
|
|
rxa->midbuff, // pointer to output buffer
|
2024-06-24 04:20:14 -04:00
|
|
|
0, // mode
|
|
|
|
rxa->dsp_rate, // sample rate
|
|
|
|
0.02); // tau
|
2024-06-16 05:31:13 -04:00
|
|
|
|
2024-06-24 04:20:14 -04:00
|
|
|
// CW peaking filter
|
2024-07-22 18:39:21 -04:00
|
|
|
rxa->speak = SPEAK::create_speak (
|
2024-06-24 04:20:14 -04:00
|
|
|
0, // run
|
|
|
|
rxa->dsp_size, // buffer size,
|
2024-06-16 05:31:13 -04:00
|
|
|
rxa->midbuff, // pointer to input buffer
|
|
|
|
rxa->midbuff, // pointer to output buffer
|
2024-06-24 04:20:14 -04:00
|
|
|
rxa->dsp_rate, // sample rate
|
|
|
|
600.0, // center frequency
|
|
|
|
100.0, // bandwidth
|
|
|
|
2.0, // gain
|
|
|
|
4, // number of stages
|
|
|
|
1); // design
|
|
|
|
|
|
|
|
// Dolly filter (multiple peak filter) - default is 2 for RTTY
|
2024-06-16 05:31:13 -04:00
|
|
|
{
|
|
|
|
int def_enable[2] = {1, 1};
|
2024-07-17 20:08:05 -04:00
|
|
|
double def_freq[2] = {2125.0, 2295.0};
|
|
|
|
double def_bw[2] = {75.0, 75.0};
|
|
|
|
double def_gain[2] = {1.0, 1.0};
|
2024-07-22 18:39:21 -04:00
|
|
|
rxa->mpeak = MPEAK::create_mpeak (
|
2024-06-24 04:20:14 -04:00
|
|
|
0, // run
|
|
|
|
rxa->dsp_size, // size
|
2024-06-16 05:31:13 -04:00
|
|
|
rxa->midbuff, // pointer to input buffer
|
|
|
|
rxa->midbuff, // pointer to output buffer
|
2024-06-24 04:20:14 -04:00
|
|
|
rxa->dsp_rate, // sample rate
|
|
|
|
2, // number of peaking filters
|
|
|
|
def_enable, // enable vector
|
|
|
|
def_freq, // frequency vector
|
|
|
|
def_bw, // bandwidth vector
|
|
|
|
def_gain, // gain vector
|
|
|
|
4 ); // number of stages
|
2024-06-16 05:31:13 -04:00
|
|
|
}
|
|
|
|
|
2024-06-24 04:20:14 -04:00
|
|
|
// Syllabic squelch (Voice suelch) - Not in the block diagram
|
2024-07-22 18:39:21 -04:00
|
|
|
rxa->ssql = SSQL::create_ssql(
|
2024-06-24 04:20:14 -04:00
|
|
|
0, // run
|
|
|
|
rxa->dsp_size, // size
|
2024-06-16 05:31:13 -04:00
|
|
|
rxa->midbuff, // pointer to input buffer
|
|
|
|
rxa->midbuff, // pointer to output buffer
|
2024-06-24 04:20:14 -04:00
|
|
|
rxa->dsp_rate, // sample rate
|
|
|
|
0.070, // signal up transition time
|
|
|
|
0.070, // signal down transition time
|
|
|
|
0.0, // muted gain
|
|
|
|
0.1, // mute time-constant
|
|
|
|
0.1, // unmute time-constant
|
|
|
|
0.08, // window threshold
|
|
|
|
0.8197, // trigger threshold
|
|
|
|
2400, // ring size for f_to_v converter
|
|
|
|
2000.0); // max freq for f_to_v converter
|
|
|
|
|
|
|
|
// PatchPanel
|
2024-07-22 18:39:21 -04:00
|
|
|
rxa->panel = PANEL::create_panel (
|
2024-06-24 04:20:14 -04:00
|
|
|
1, // run
|
|
|
|
rxa->dsp_size, // size
|
2024-06-16 05:31:13 -04:00
|
|
|
rxa->midbuff, // pointer to input buffer
|
|
|
|
rxa->midbuff, // pointer to output buffer
|
2024-06-24 04:20:14 -04:00
|
|
|
4.0, // gain1
|
|
|
|
1.0, // gain2I
|
|
|
|
1.0, // gain2Q
|
|
|
|
3, // 3 for I and Q
|
|
|
|
0); // no copy
|
2024-06-16 05:31:13 -04:00
|
|
|
|
2024-06-24 04:20:14 -04:00
|
|
|
// AM squelch apply - absent but in the block diagram
|
|
|
|
|
|
|
|
// Output resampler
|
2024-07-23 22:33:42 -04:00
|
|
|
rxa->rsmpout = new RESAMPLE(
|
2024-06-24 04:20:14 -04:00
|
|
|
0, // run - will be turned ON below if needed
|
|
|
|
rxa->dsp_size, // input buffer size
|
2024-06-16 05:31:13 -04:00
|
|
|
rxa->midbuff, // pointer to input buffer
|
|
|
|
rxa->outbuff, // pointer to output buffer
|
2024-06-24 04:20:14 -04:00
|
|
|
rxa->dsp_rate, // input sample rate
|
|
|
|
rxa->out_rate, // output sample rate
|
|
|
|
0.0, // select cutoff automatically
|
|
|
|
0, // select ncoef automatically
|
|
|
|
1.0); // gain
|
2024-06-16 05:31:13 -04:00
|
|
|
|
|
|
|
// turn OFF / ON resamplers as needed
|
|
|
|
ResCheck (*rxa);
|
|
|
|
return rxa;
|
|
|
|
}
|
|
|
|
|
|
|
|
void RXA::destroy_rxa (RXA *rxa)
|
|
|
|
{
|
2024-07-23 22:33:42 -04:00
|
|
|
delete (rxa->rsmpout);
|
2024-07-22 18:39:21 -04:00
|
|
|
PANEL::destroy_panel (rxa->panel);
|
|
|
|
SSQL::destroy_ssql (rxa->ssql);
|
|
|
|
MPEAK::destroy_mpeak (rxa->mpeak);
|
|
|
|
SPEAK::destroy_speak (rxa->speak);
|
|
|
|
CBL::destroy_cbl (rxa->cbl);
|
|
|
|
SIPHON::destroy_siphon (rxa->sip1);
|
|
|
|
BANDPASS::destroy_bandpass (rxa->bp1);
|
2024-07-24 09:32:21 -04:00
|
|
|
delete (rxa->agcmeter);
|
2024-07-22 18:39:21 -04:00
|
|
|
WCPAGC::destroy_wcpagc (rxa->agc);
|
|
|
|
EMNR::destroy_emnr (rxa->emnr);
|
|
|
|
ANR::destroy_anr (rxa->anr);
|
|
|
|
ANF::destroy_anf (rxa->anf);
|
|
|
|
EQP::destroy_eqp (rxa->eqp);
|
|
|
|
SNBA::destroy_snba (rxa->snba);
|
|
|
|
FMSQ::destroy_fmsq (rxa->fmsq);
|
|
|
|
FMD::destroy_fmd (rxa->fmd);
|
|
|
|
AMD::destroy_amd (rxa->amd);
|
|
|
|
AMSQ::destroy_amsq (rxa->amsq);
|
2024-07-24 09:32:21 -04:00
|
|
|
delete (rxa->smeter);
|
2024-07-24 17:30:41 -04:00
|
|
|
delete (rxa->sender);
|
2024-07-24 17:11:29 -04:00
|
|
|
delete (rxa->bpsnba);
|
2024-07-24 14:29:55 -04:00
|
|
|
delete (rxa->nbp0);
|
|
|
|
delete (rxa->ndb);
|
2024-07-24 09:32:21 -04:00
|
|
|
delete (rxa->adcmeter);
|
2024-07-23 22:33:42 -04:00
|
|
|
delete (rxa->rsmpin);
|
|
|
|
delete (rxa->shift);
|
2024-07-23 02:06:13 -04:00
|
|
|
delete (rxa->nob);
|
|
|
|
delete (rxa->anb);
|
2024-06-16 05:31:13 -04:00
|
|
|
delete[] (rxa->midbuff);
|
|
|
|
delete[] (rxa->outbuff);
|
|
|
|
delete[] (rxa->inbuff);
|
|
|
|
delete rxa;
|
|
|
|
}
|
|
|
|
|
|
|
|
void RXA::flush_rxa (RXA *rxa)
|
|
|
|
{
|
2024-07-16 17:15:13 -04:00
|
|
|
std::fill(rxa->inbuff, rxa->inbuff + 1 * rxa->dsp_insize * 2, 0);
|
|
|
|
std::fill(rxa->outbuff, rxa->outbuff + 1 * rxa->dsp_outsize * 2, 0);
|
|
|
|
std::fill(rxa->midbuff, rxa->midbuff + 2 * rxa->dsp_size * 2, 0);
|
2024-07-23 02:06:13 -04:00
|
|
|
rxa->anb->flush();
|
|
|
|
rxa->nob->flush();
|
2024-07-23 22:33:42 -04:00
|
|
|
rxa->shift->flush();
|
|
|
|
rxa->rsmpin->flush();
|
2024-07-24 09:32:21 -04:00
|
|
|
rxa->adcmeter->flush();
|
2024-07-24 14:29:55 -04:00
|
|
|
rxa->nbp0->flush();
|
2024-07-24 17:11:29 -04:00
|
|
|
rxa->bpsnba->flush();
|
2024-07-24 17:30:41 -04:00
|
|
|
rxa->sender->flush();
|
2024-07-24 09:32:21 -04:00
|
|
|
rxa->smeter->flush();
|
2024-07-22 18:39:21 -04:00
|
|
|
AMSQ::flush_amsq (rxa->amsq);
|
|
|
|
AMD::flush_amd (rxa->amd);
|
|
|
|
FMD::flush_fmd (rxa->fmd);
|
|
|
|
FMSQ::flush_fmsq (rxa->fmsq);
|
|
|
|
SNBA::flush_snba (rxa->snba);
|
|
|
|
EQP::flush_eqp (rxa->eqp);
|
|
|
|
ANF::flush_anf (rxa->anf);
|
|
|
|
ANR::flush_anr (rxa->anr);
|
|
|
|
EMNR::flush_emnr (rxa->emnr);
|
|
|
|
WCPAGC::flush_wcpagc (rxa->agc);
|
2024-07-24 09:32:21 -04:00
|
|
|
rxa->agcmeter->flush();
|
2024-07-22 18:39:21 -04:00
|
|
|
BANDPASS::flush_bandpass (rxa->bp1);
|
|
|
|
SIPHON::flush_siphon (rxa->sip1);
|
|
|
|
CBL::flush_cbl (rxa->cbl);
|
|
|
|
SPEAK::flush_speak (rxa->speak);
|
|
|
|
MPEAK::flush_mpeak (rxa->mpeak);
|
|
|
|
SSQL::flush_ssql (rxa->ssql);
|
|
|
|
PANEL::flush_panel (rxa->panel);
|
2024-07-23 22:33:42 -04:00
|
|
|
rxa->rsmpout->flush();
|
2024-06-16 05:31:13 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void RXA::xrxa (RXA *rxa)
|
|
|
|
{
|
2024-07-23 13:39:09 -04:00
|
|
|
rxa->anb->execute();
|
|
|
|
rxa->nob->execute();
|
2024-07-23 22:33:42 -04:00
|
|
|
rxa->shift->execute();
|
|
|
|
rxa->rsmpin->execute();
|
2024-07-24 09:32:21 -04:00
|
|
|
rxa->adcmeter->execute();
|
2024-07-24 17:11:29 -04:00
|
|
|
rxa->bpsnba->exec_in(0);
|
2024-07-24 14:29:55 -04:00
|
|
|
rxa->nbp0->execute(0);
|
2024-07-24 09:32:21 -04:00
|
|
|
rxa->smeter->execute();
|
2024-07-24 17:30:41 -04:00
|
|
|
rxa->sender->execute();
|
2024-07-22 18:39:21 -04:00
|
|
|
AMSQ::xamsqcap (rxa->amsq);
|
2024-07-24 17:11:29 -04:00
|
|
|
rxa->bpsnba->exec_out(0);
|
2024-07-22 18:39:21 -04:00
|
|
|
AMD::xamd (rxa->amd);
|
|
|
|
FMD::xfmd (rxa->fmd);
|
|
|
|
FMSQ::xfmsq (rxa->fmsq);
|
2024-07-24 17:11:29 -04:00
|
|
|
rxa->bpsnba->exec_in(1);
|
|
|
|
rxa->bpsnba->exec_out(1);
|
2024-07-22 18:39:21 -04:00
|
|
|
SNBA::xsnba (rxa->snba);
|
|
|
|
EQP::xeqp (rxa->eqp);
|
|
|
|
ANF::xanf (rxa->anf, 0);
|
|
|
|
ANR::xanr (rxa->anr, 0);
|
|
|
|
EMNR::xemnr (rxa->emnr, 0);
|
|
|
|
BANDPASS::xbandpass (rxa->bp1, 0);
|
|
|
|
WCPAGC::xwcpagc (rxa->agc);
|
|
|
|
ANF::xanf (rxa->anf, 1);
|
|
|
|
ANR::xanr (rxa->anr, 1);
|
|
|
|
EMNR::xemnr (rxa->emnr, 1);
|
|
|
|
BANDPASS::xbandpass (rxa->bp1, 1);
|
2024-07-24 09:32:21 -04:00
|
|
|
rxa->agcmeter->execute();
|
2024-07-22 18:39:21 -04:00
|
|
|
SIPHON::xsiphon (rxa->sip1, 0);
|
|
|
|
CBL::xcbl (rxa->cbl);
|
|
|
|
SPEAK::xspeak (rxa->speak);
|
|
|
|
MPEAK::xmpeak (rxa->mpeak);
|
|
|
|
SSQL::xssql (rxa->ssql);
|
|
|
|
PANEL::xpanel (rxa->panel);
|
|
|
|
AMSQ::xamsq (rxa->amsq);
|
2024-07-23 22:33:42 -04:00
|
|
|
rxa->rsmpout->execute();
|
2024-06-16 05:31:13 -04:00
|
|
|
}
|
|
|
|
|
2024-06-21 09:33:35 -04:00
|
|
|
void RXA::setInputSamplerate (RXA *rxa, int in_rate)
|
2024-06-16 05:31:13 -04:00
|
|
|
{
|
2024-06-21 09:33:35 -04:00
|
|
|
if (in_rate >= rxa->dsp_rate)
|
|
|
|
rxa->dsp_insize = rxa->dsp_size * (in_rate / rxa->dsp_rate);
|
|
|
|
else
|
|
|
|
rxa->dsp_insize = rxa->dsp_size / (rxa->dsp_rate / in_rate);
|
2024-07-13 17:59:46 -04:00
|
|
|
|
2024-06-16 05:31:13 -04:00
|
|
|
rxa->in_rate = in_rate;
|
|
|
|
// buffers
|
|
|
|
delete[] (rxa->inbuff);
|
2024-06-24 21:50:48 -04:00
|
|
|
rxa->inbuff = new float[1 * rxa->dsp_insize * 2]; // (float *)malloc0(1 * ch.dsp_insize * sizeof(complex));
|
2024-06-29 14:03:13 -04:00
|
|
|
// anb
|
2024-07-23 02:06:13 -04:00
|
|
|
rxa->anb->setBuffers(rxa->inbuff, rxa->inbuff);
|
|
|
|
rxa->anb->setSize(rxa->dsp_insize);
|
|
|
|
rxa->anb->setSamplerate(rxa->in_rate);
|
2024-06-29 14:03:13 -04:00
|
|
|
// nob
|
2024-07-23 02:06:13 -04:00
|
|
|
rxa->nob->setBuffers(rxa->inbuff, rxa->inbuff);
|
|
|
|
rxa->nob->setSize(rxa->dsp_insize);
|
|
|
|
rxa->nob->setSamplerate(rxa->in_rate);
|
2024-06-16 05:31:13 -04:00
|
|
|
// shift
|
2024-07-23 22:33:42 -04:00
|
|
|
rxa->shift->setBuffers(rxa->inbuff, rxa->inbuff);
|
|
|
|
rxa->shift->setSize(rxa->dsp_insize);
|
|
|
|
rxa->shift->setSamplerate(rxa->in_rate);
|
2024-06-16 05:31:13 -04:00
|
|
|
// input resampler
|
2024-07-23 22:33:42 -04:00
|
|
|
rxa->rsmpin->setBuffers(rxa->inbuff, rxa->midbuff);
|
|
|
|
rxa->rsmpin->setSize(rxa->dsp_insize);
|
|
|
|
rxa->rsmpin->setInRate(rxa->in_rate);
|
2024-06-16 05:31:13 -04:00
|
|
|
ResCheck (*rxa);
|
|
|
|
}
|
|
|
|
|
2024-06-21 09:33:35 -04:00
|
|
|
void RXA::setOutputSamplerate (RXA *rxa, int out_rate)
|
2024-06-16 05:31:13 -04:00
|
|
|
{
|
2024-06-21 09:33:35 -04:00
|
|
|
if (out_rate >= rxa->dsp_rate)
|
|
|
|
rxa->dsp_outsize = rxa->dsp_size * (out_rate / rxa->dsp_rate);
|
|
|
|
else
|
|
|
|
rxa->dsp_outsize = rxa->dsp_size / (rxa->dsp_rate / out_rate);
|
2024-07-13 17:59:46 -04:00
|
|
|
|
2024-06-16 05:31:13 -04:00
|
|
|
rxa->out_rate = out_rate;
|
|
|
|
// buffers
|
|
|
|
delete[] (rxa->outbuff);
|
2024-06-24 21:50:48 -04:00
|
|
|
rxa->outbuff = new float[1 * rxa->dsp_outsize * 2]; // (float *)malloc0(1 * ch.dsp_outsize * sizeof(complex));
|
2024-06-16 05:31:13 -04:00
|
|
|
// output resampler
|
2024-07-23 22:33:42 -04:00
|
|
|
rxa->rsmpout->setBuffers(rxa->midbuff, rxa->outbuff);
|
|
|
|
rxa->rsmpout->setOutRate(rxa->out_rate);
|
2024-06-16 05:31:13 -04:00
|
|
|
ResCheck (*rxa);
|
|
|
|
}
|
|
|
|
|
2024-06-21 09:33:35 -04:00
|
|
|
void RXA::setDSPSamplerate (RXA *rxa, int dsp_rate)
|
2024-06-16 05:31:13 -04:00
|
|
|
{
|
2024-06-21 09:33:35 -04:00
|
|
|
if (rxa->in_rate >= dsp_rate)
|
|
|
|
rxa->dsp_insize = rxa->dsp_size * (rxa->in_rate / dsp_rate);
|
|
|
|
else
|
|
|
|
rxa->dsp_insize = rxa->dsp_size / (dsp_rate / rxa->in_rate);
|
2024-07-13 17:59:46 -04:00
|
|
|
|
2024-06-21 09:33:35 -04:00
|
|
|
if (rxa->out_rate >= dsp_rate)
|
|
|
|
rxa->dsp_outsize = rxa->dsp_size * (rxa->out_rate / dsp_rate);
|
|
|
|
else
|
|
|
|
rxa->dsp_outsize = rxa->dsp_size / (dsp_rate / rxa->out_rate);
|
2024-07-13 17:59:46 -04:00
|
|
|
|
2024-06-16 05:31:13 -04:00
|
|
|
rxa->dsp_rate = dsp_rate;
|
|
|
|
// buffers
|
|
|
|
delete[] (rxa->inbuff);
|
2024-06-24 21:50:48 -04:00
|
|
|
rxa->inbuff = new float[1 * rxa->dsp_insize * 2]; // (float *)malloc0(1 * rxa->dsp_insize * sizeof(complex));
|
2024-06-16 05:31:13 -04:00
|
|
|
delete[] (rxa->outbuff);
|
2024-06-24 21:50:48 -04:00
|
|
|
rxa->outbuff = new float[1 * rxa->dsp_outsize * 2]; // (float *)malloc0(1 * rxa->dsp_outsize * sizeof(complex));
|
2024-06-29 14:03:13 -04:00
|
|
|
// anb
|
2024-07-23 02:06:13 -04:00
|
|
|
rxa->anb->setBuffers(rxa->inbuff, rxa->inbuff);
|
|
|
|
rxa->anb->setSize(rxa->dsp_insize);
|
2024-06-29 14:03:13 -04:00
|
|
|
// nob
|
2024-07-23 02:06:13 -04:00
|
|
|
rxa->nob->setBuffers(rxa->inbuff, rxa->inbuff);
|
|
|
|
rxa->nob->setSize(rxa->dsp_insize);
|
2024-06-16 05:31:13 -04:00
|
|
|
// shift
|
2024-07-23 22:33:42 -04:00
|
|
|
rxa->shift->setBuffers(rxa->inbuff, rxa->inbuff);
|
|
|
|
rxa->shift->setSize(rxa->dsp_insize);
|
2024-06-16 05:31:13 -04:00
|
|
|
// input resampler
|
2024-07-23 22:33:42 -04:00
|
|
|
rxa->rsmpin->setBuffers(rxa->inbuff, rxa->midbuff);
|
|
|
|
rxa->rsmpin->setSize(rxa->dsp_insize);
|
|
|
|
rxa->rsmpin->setOutRate(rxa->dsp_rate);
|
2024-06-16 05:31:13 -04:00
|
|
|
// dsp_rate blocks
|
2024-07-24 09:32:21 -04:00
|
|
|
rxa->adcmeter->setSamplerate(rxa->dsp_rate);
|
2024-07-24 14:29:55 -04:00
|
|
|
rxa->nbp0->setSamplerate(rxa->dsp_rate);
|
2024-07-24 17:11:29 -04:00
|
|
|
rxa->bpsnba->setSamplerate(rxa->dsp_rate);
|
2024-07-24 09:32:21 -04:00
|
|
|
rxa->smeter->setSamplerate(rxa->dsp_rate);
|
2024-07-24 17:30:41 -04:00
|
|
|
rxa->sender->setSamplerate(rxa->dsp_rate);
|
2024-07-22 18:39:21 -04:00
|
|
|
AMSQ::setSamplerate_amsq (rxa->amsq, rxa->dsp_rate);
|
|
|
|
AMD::setSamplerate_amd (rxa->amd, rxa->dsp_rate);
|
|
|
|
FMD::setSamplerate_fmd (rxa->fmd, rxa->dsp_rate);
|
|
|
|
FMSQ::setBuffers_fmsq (rxa->fmsq, rxa->midbuff, rxa->midbuff, rxa->fmd->audio);
|
|
|
|
FMSQ::setSamplerate_fmsq (rxa->fmsq, rxa->dsp_rate);
|
|
|
|
SNBA::setSamplerate_snba (rxa->snba, rxa->dsp_rate);
|
|
|
|
EQP::setSamplerate_eqp (rxa->eqp, rxa->dsp_rate);
|
|
|
|
ANF::setSamplerate_anf (rxa->anf, rxa->dsp_rate);
|
|
|
|
ANR::setSamplerate_anr (rxa->anr, rxa->dsp_rate);
|
|
|
|
EMNR::setSamplerate_emnr (rxa->emnr, rxa->dsp_rate);
|
|
|
|
BANDPASS::setSamplerate_bandpass (rxa->bp1, rxa->dsp_rate);
|
|
|
|
WCPAGC::setSamplerate_wcpagc (rxa->agc, rxa->dsp_rate);
|
2024-07-24 09:32:21 -04:00
|
|
|
rxa->agcmeter->setSamplerate(rxa->dsp_rate);
|
2024-07-22 18:39:21 -04:00
|
|
|
SIPHON::setSamplerate_siphon (rxa->sip1, rxa->dsp_rate);
|
|
|
|
CBL::setSamplerate_cbl (rxa->cbl, rxa->dsp_rate);
|
|
|
|
SPEAK::setSamplerate_speak (rxa->speak, rxa->dsp_rate);
|
|
|
|
MPEAK::setSamplerate_mpeak (rxa->mpeak, rxa->dsp_rate);
|
|
|
|
SSQL::setSamplerate_ssql (rxa->ssql, rxa->dsp_rate);
|
|
|
|
PANEL::setSamplerate_panel (rxa->panel, rxa->dsp_rate);
|
2024-06-16 05:31:13 -04:00
|
|
|
// output resampler
|
2024-07-23 22:33:42 -04:00
|
|
|
rxa->rsmpout->setBuffers(rxa->midbuff, rxa->outbuff);
|
|
|
|
rxa->rsmpout->setInRate(rxa->dsp_rate);
|
2024-06-16 05:31:13 -04:00
|
|
|
ResCheck (*rxa);
|
|
|
|
}
|
|
|
|
|
2024-06-21 09:33:35 -04:00
|
|
|
void RXA::setDSPBuffsize (RXA *rxa, int dsp_size)
|
2024-06-16 05:31:13 -04:00
|
|
|
{
|
2024-06-21 09:33:35 -04:00
|
|
|
if (rxa->in_rate >= rxa->dsp_rate)
|
|
|
|
rxa->dsp_insize = dsp_size * (rxa->in_rate / rxa->dsp_rate);
|
|
|
|
else
|
|
|
|
rxa->dsp_insize = dsp_size / (rxa->dsp_rate / rxa->in_rate);
|
2024-07-13 17:59:46 -04:00
|
|
|
|
2024-06-21 09:33:35 -04:00
|
|
|
if (rxa->out_rate >= rxa->dsp_rate)
|
|
|
|
rxa->dsp_outsize = dsp_size * (rxa->out_rate / rxa->dsp_rate);
|
|
|
|
else
|
|
|
|
rxa->dsp_outsize = dsp_size / (rxa->dsp_rate / rxa->out_rate);
|
2024-07-13 17:59:46 -04:00
|
|
|
|
2024-06-16 05:31:13 -04:00
|
|
|
rxa->dsp_size = dsp_size;
|
|
|
|
// buffers
|
|
|
|
delete[](rxa->inbuff);
|
2024-06-24 21:50:48 -04:00
|
|
|
rxa->inbuff = new float[1 * rxa->dsp_insize * 2]; // (float *)malloc0(1 * rxa->dsp_insize * sizeof(complex));
|
2024-06-16 05:31:13 -04:00
|
|
|
delete[] (rxa->midbuff);
|
2024-06-24 21:50:48 -04:00
|
|
|
rxa->midbuff = new float[2 * rxa->dsp_size * 2]; // (float *)malloc0(2 * rxa->dsp_size * sizeof(complex));
|
2024-06-16 05:31:13 -04:00
|
|
|
delete[] (rxa->outbuff);
|
2024-06-24 21:50:48 -04:00
|
|
|
rxa->outbuff = new float[1 * rxa->dsp_outsize * 2]; // (float *)malloc0(1 * rxa->dsp_outsize * sizeof(complex));
|
2024-06-29 14:03:13 -04:00
|
|
|
// anb
|
2024-07-23 02:06:13 -04:00
|
|
|
rxa->anb->setBuffers(rxa->inbuff, rxa->inbuff);
|
|
|
|
rxa->anb->setSize(rxa->dsp_insize);
|
2024-06-29 14:03:13 -04:00
|
|
|
// nob
|
2024-07-23 02:06:13 -04:00
|
|
|
rxa->nob->setBuffers(rxa->inbuff, rxa->inbuff);
|
|
|
|
rxa->nob->setSize(rxa->dsp_insize);
|
2024-06-16 05:31:13 -04:00
|
|
|
// shift
|
2024-07-23 22:33:42 -04:00
|
|
|
rxa->shift->setBuffers(rxa->inbuff, rxa->inbuff);
|
|
|
|
rxa->shift->setSize(rxa->dsp_insize);
|
2024-06-16 05:31:13 -04:00
|
|
|
// input resampler
|
2024-07-23 22:33:42 -04:00
|
|
|
rxa->rsmpin->setBuffers(rxa->inbuff, rxa->midbuff);
|
|
|
|
rxa->rsmpin->setSize(rxa->dsp_insize);
|
2024-06-16 05:31:13 -04:00
|
|
|
// dsp_size blocks
|
2024-07-24 09:32:21 -04:00
|
|
|
rxa->adcmeter->setBuffers(rxa->midbuff);
|
|
|
|
rxa->adcmeter->setSize(rxa->dsp_size);
|
2024-07-24 14:29:55 -04:00
|
|
|
rxa->nbp0->setBuffers(rxa->midbuff, rxa->midbuff);
|
|
|
|
rxa->nbp0->setSize(rxa->dsp_size);
|
2024-07-24 17:11:29 -04:00
|
|
|
rxa->bpsnba->setBuffers(rxa->midbuff, rxa->midbuff);
|
|
|
|
rxa->bpsnba->setSize(rxa->dsp_size);
|
2024-07-24 09:32:21 -04:00
|
|
|
rxa->smeter->setBuffers(rxa->midbuff);
|
2024-07-24 17:30:41 -04:00
|
|
|
rxa->smeter->setSize(rxa->dsp_size);
|
|
|
|
rxa->sender->setBuffers(rxa->midbuff);
|
|
|
|
rxa->sender->setSize(rxa->dsp_size);
|
2024-07-22 18:39:21 -04:00
|
|
|
AMSQ::setBuffers_amsq (rxa->amsq, rxa->midbuff, rxa->midbuff, rxa->midbuff);
|
|
|
|
AMSQ::setSize_amsq (rxa->amsq, rxa->dsp_size);
|
|
|
|
AMD::setBuffers_amd (rxa->amd, rxa->midbuff, rxa->midbuff);
|
|
|
|
AMD::setSize_amd (rxa->amd, rxa->dsp_size);
|
|
|
|
FMD::setBuffers_fmd (rxa->fmd, rxa->midbuff, rxa->midbuff);
|
|
|
|
FMD::setSize_fmd (rxa->fmd, rxa->dsp_size);
|
|
|
|
FMSQ::setBuffers_fmsq (rxa->fmsq, rxa->midbuff, rxa->midbuff, rxa->fmd->audio);
|
|
|
|
FMSQ::setSize_fmsq (rxa->fmsq, rxa->dsp_size);
|
|
|
|
SNBA::setBuffers_snba (rxa->snba, rxa->midbuff, rxa->midbuff);
|
|
|
|
SNBA::setSize_snba (rxa->snba, rxa->dsp_size);
|
|
|
|
EQP::setBuffers_eqp (rxa->eqp, rxa->midbuff, rxa->midbuff);
|
|
|
|
EQP::setSize_eqp (rxa->eqp, rxa->dsp_size);
|
|
|
|
ANF::setBuffers_anf (rxa->anf, rxa->midbuff, rxa->midbuff);
|
|
|
|
ANF::setSize_anf (rxa->anf, rxa->dsp_size);
|
|
|
|
ANR::setBuffers_anr (rxa->anr, rxa->midbuff, rxa->midbuff);
|
|
|
|
ANR::setSize_anr (rxa->anr, rxa->dsp_size);
|
|
|
|
EMNR::setBuffers_emnr (rxa->emnr, rxa->midbuff, rxa->midbuff);
|
|
|
|
EMNR::setSize_emnr (rxa->emnr, rxa->dsp_size);
|
|
|
|
BANDPASS::setBuffers_bandpass (rxa->bp1, rxa->midbuff, rxa->midbuff);
|
|
|
|
BANDPASS::setSize_bandpass (rxa->bp1, rxa->dsp_size);
|
|
|
|
WCPAGC::setBuffers_wcpagc (rxa->agc, rxa->midbuff, rxa->midbuff);
|
|
|
|
WCPAGC::setSize_wcpagc (rxa->agc, rxa->dsp_size);
|
2024-07-24 17:30:41 -04:00
|
|
|
rxa->agcmeter->setBuffers(rxa->midbuff);
|
|
|
|
rxa->agcmeter->setSize(rxa->dsp_size);
|
2024-07-22 18:39:21 -04:00
|
|
|
SIPHON::setBuffers_siphon (rxa->sip1, rxa->midbuff);
|
|
|
|
SIPHON::setSize_siphon (rxa->sip1, rxa->dsp_size);
|
|
|
|
CBL::setBuffers_cbl (rxa->cbl, rxa->midbuff, rxa->midbuff);
|
|
|
|
CBL::setSize_cbl (rxa->cbl, rxa->dsp_size);
|
|
|
|
SPEAK::setBuffers_speak (rxa->speak, rxa->midbuff, rxa->midbuff);
|
|
|
|
SPEAK::setSize_speak (rxa->speak, rxa->dsp_size);
|
|
|
|
MPEAK::setBuffers_mpeak (rxa->mpeak, rxa->midbuff, rxa->midbuff);
|
|
|
|
MPEAK::setSize_mpeak (rxa->mpeak, rxa->dsp_size);
|
|
|
|
SSQL::setBuffers_ssql (rxa->ssql, rxa->midbuff, rxa->midbuff);
|
|
|
|
SSQL::setSize_ssql (rxa->ssql, rxa->dsp_size);
|
|
|
|
PANEL::setBuffers_panel (rxa->panel, rxa->midbuff, rxa->midbuff);
|
|
|
|
PANEL::setSize_panel (rxa->panel, rxa->dsp_size);
|
2024-06-16 05:31:13 -04:00
|
|
|
// output resampler
|
2024-07-23 22:33:42 -04:00
|
|
|
rxa->rsmpout->setBuffers(rxa->midbuff, rxa->outbuff);
|
|
|
|
rxa->rsmpout->setSize(rxa->dsp_size);
|
2024-06-16 05:31:13 -04:00
|
|
|
}
|
|
|
|
|
2024-06-24 04:20:14 -04:00
|
|
|
void RXA::setSpectrumProbe(BufferProbe *spectrumProbe)
|
|
|
|
{
|
2024-07-24 17:30:41 -04:00
|
|
|
sender->SetSpectrum(1, spectrumProbe);
|
2024-07-22 18:39:21 -04:00
|
|
|
sender->run = 1;
|
2024-06-24 04:20:14 -04:00
|
|
|
}
|
|
|
|
|
2024-06-16 05:31:13 -04:00
|
|
|
/********************************************************************************************************
|
|
|
|
* *
|
|
|
|
* RXA Mode & Filter Controls *
|
|
|
|
* *
|
|
|
|
********************************************************************************************************/
|
|
|
|
|
|
|
|
void RXA::SetMode (RXA& rxa, int mode)
|
|
|
|
{
|
|
|
|
if (rxa.mode != mode)
|
|
|
|
{
|
|
|
|
int amd_run = (mode == RXA_AM) || (mode == RXA_SAM);
|
2024-07-22 18:39:21 -04:00
|
|
|
bpsnbaCheck (rxa, mode, rxa.ndb->master_run);
|
2024-06-16 05:31:13 -04:00
|
|
|
bp1Check (
|
|
|
|
rxa,
|
|
|
|
amd_run,
|
2024-07-22 18:39:21 -04:00
|
|
|
rxa.snba->run,
|
|
|
|
rxa.emnr->run,
|
|
|
|
rxa.anf->run,
|
|
|
|
rxa.anr->run
|
2024-06-24 04:20:14 -04:00
|
|
|
);
|
2024-06-16 05:31:13 -04:00
|
|
|
rxa.mode = mode;
|
2024-07-22 18:39:21 -04:00
|
|
|
rxa.amd->run = 0;
|
|
|
|
rxa.fmd->run = 0;
|
2024-07-02 00:14:22 -04:00
|
|
|
|
2024-06-16 05:31:13 -04:00
|
|
|
switch (mode)
|
|
|
|
{
|
|
|
|
case RXA_AM:
|
2024-07-22 18:39:21 -04:00
|
|
|
rxa.amd->run = 1;
|
|
|
|
rxa.amd->mode = 0;
|
2024-06-16 05:31:13 -04:00
|
|
|
break;
|
|
|
|
case RXA_SAM:
|
2024-07-22 18:39:21 -04:00
|
|
|
rxa.amd->run = 1;
|
|
|
|
rxa.amd->mode = 1;
|
2024-06-16 05:31:13 -04:00
|
|
|
break;
|
|
|
|
case RXA_DSB:
|
|
|
|
break;
|
|
|
|
case RXA_FM:
|
2024-07-22 18:39:21 -04:00
|
|
|
rxa.fmd->run = 1;
|
2024-06-16 05:31:13 -04:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
2024-07-02 00:14:22 -04:00
|
|
|
|
2024-06-16 05:31:13 -04:00
|
|
|
bp1Set (rxa);
|
|
|
|
bpsnbaSet (rxa); // update variables
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void RXA::ResCheck (RXA& rxa)
|
|
|
|
{
|
|
|
|
// turn OFF/ON resamplers depending upon whether they're needed
|
2024-07-22 18:39:21 -04:00
|
|
|
RESAMPLE *a = rxa.rsmpin;
|
2024-06-16 05:31:13 -04:00
|
|
|
if (rxa.in_rate != rxa.dsp_rate)
|
|
|
|
a->run = 1;
|
|
|
|
else
|
|
|
|
a->run = 0;
|
2024-07-22 18:39:21 -04:00
|
|
|
a = rxa.rsmpout;
|
2024-06-16 05:31:13 -04:00
|
|
|
if (rxa.dsp_rate != rxa.out_rate)
|
|
|
|
a->run = 1;
|
|
|
|
else
|
|
|
|
a->run = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void RXA::bp1Check (
|
|
|
|
RXA& rxa,
|
|
|
|
int amd_run,
|
|
|
|
int snba_run,
|
|
|
|
int emnr_run,
|
|
|
|
int anf_run,
|
|
|
|
int anr_run
|
|
|
|
)
|
|
|
|
{
|
2024-07-22 18:39:21 -04:00
|
|
|
BANDPASS *a = rxa.bp1;
|
2024-06-24 21:50:48 -04:00
|
|
|
float gain;
|
2024-06-16 05:31:13 -04:00
|
|
|
if (amd_run ||
|
|
|
|
snba_run ||
|
|
|
|
emnr_run ||
|
|
|
|
anf_run ||
|
|
|
|
anr_run
|
|
|
|
)
|
|
|
|
gain = 2.0;
|
|
|
|
else
|
|
|
|
gain = 1.0;
|
|
|
|
if (a->gain != gain)
|
|
|
|
BANDPASS::setGain_bandpass (a, gain, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void RXA::bp1Set (RXA& rxa)
|
|
|
|
{
|
2024-07-22 18:39:21 -04:00
|
|
|
BANDPASS *a = rxa.bp1;
|
2024-06-16 05:31:13 -04:00
|
|
|
int old = a->run;
|
2024-07-22 18:39:21 -04:00
|
|
|
if ((rxa.amd->run == 1) ||
|
|
|
|
(rxa.snba->run == 1) ||
|
|
|
|
(rxa.emnr->run == 1) ||
|
|
|
|
(rxa.anf->run == 1) ||
|
|
|
|
(rxa.anr->run == 1)
|
2024-06-16 05:31:13 -04:00
|
|
|
)
|
|
|
|
a->run = 1;
|
|
|
|
else
|
|
|
|
a->run = 0;
|
|
|
|
if (!old && a->run)
|
|
|
|
BANDPASS::flush_bandpass (a);
|
|
|
|
FIRCORE::setUpdate_fircore (a->p);
|
|
|
|
}
|
|
|
|
|
|
|
|
void RXA::bpsnbaCheck (RXA& rxa, int mode, int notch_run)
|
|
|
|
{
|
|
|
|
// for BPSNBA: set run, position, freqs, run_notches
|
|
|
|
// call this upon change in RXA_mode, snba_run, notch_master_run
|
2024-07-22 18:39:21 -04:00
|
|
|
BPSNBA *a = rxa.bpsnba;
|
2024-06-24 21:50:48 -04:00
|
|
|
float f_low = 0.0, f_high = 0.0;
|
2024-06-16 05:31:13 -04:00
|
|
|
int run_notches = 0;
|
|
|
|
switch (mode)
|
|
|
|
{
|
|
|
|
case RXA_LSB:
|
|
|
|
case RXA_CWL:
|
|
|
|
case RXA_DIGL:
|
|
|
|
f_low = -a->abs_high_freq;
|
|
|
|
f_high = -a->abs_low_freq;
|
|
|
|
run_notches = notch_run;
|
|
|
|
break;
|
|
|
|
case RXA_USB:
|
|
|
|
case RXA_CWU:
|
|
|
|
case RXA_DIGU:
|
|
|
|
f_low = +a->abs_low_freq;
|
|
|
|
f_high = +a->abs_high_freq;
|
|
|
|
run_notches = notch_run;
|
|
|
|
break;
|
|
|
|
case RXA_AM:
|
|
|
|
case RXA_SAM:
|
|
|
|
case RXA_DSB:
|
|
|
|
f_low = +a->abs_low_freq;
|
|
|
|
f_high = +a->abs_high_freq;
|
|
|
|
run_notches = 0;
|
|
|
|
break;
|
|
|
|
case RXA_FM:
|
|
|
|
f_low = +a->abs_low_freq;
|
|
|
|
f_high = +a->abs_high_freq;
|
|
|
|
run_notches = 0;
|
|
|
|
break;
|
|
|
|
case RXA_DRM:
|
|
|
|
case RXA_SPEC:
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
// 'run' and 'position' are examined at run time; no filter changes required.
|
|
|
|
// Recalculate filter if frequencies OR 'run_notches' changed.
|
|
|
|
if ((a->f_low != f_low ) ||
|
|
|
|
(a->f_high != f_high ) ||
|
|
|
|
(a->run_notches != run_notches))
|
|
|
|
{
|
|
|
|
a->f_low = f_low;
|
|
|
|
a->f_high = f_high;
|
|
|
|
a->run_notches = run_notches;
|
|
|
|
// f_low, f_high, run_notches are needed for the filter recalculation
|
2024-07-24 17:11:29 -04:00
|
|
|
rxa.bpsnba->recalc_bpsnba_filter(0);
|
2024-06-16 05:31:13 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void RXA::bpsnbaSet (RXA& rxa)
|
|
|
|
{
|
|
|
|
// for BPSNBA: set run, position, freqs, run_notches
|
|
|
|
// call this upon change in RXA_mode, snba_run, notch_master_run
|
2024-07-22 18:39:21 -04:00
|
|
|
BPSNBA *a = rxa.bpsnba;
|
2024-06-16 05:31:13 -04:00
|
|
|
switch (rxa.mode)
|
|
|
|
{
|
|
|
|
case RXA_LSB:
|
|
|
|
case RXA_CWL:
|
|
|
|
case RXA_DIGL:
|
2024-07-22 18:39:21 -04:00
|
|
|
a->run = rxa.snba->run;
|
2024-06-16 05:31:13 -04:00
|
|
|
a->position = 0;
|
|
|
|
break;
|
|
|
|
case RXA_USB:
|
|
|
|
case RXA_CWU:
|
|
|
|
case RXA_DIGU:
|
2024-07-22 18:39:21 -04:00
|
|
|
a->run = rxa.snba->run;
|
2024-06-16 05:31:13 -04:00
|
|
|
a->position = 0;
|
|
|
|
break;
|
|
|
|
case RXA_AM:
|
|
|
|
case RXA_SAM:
|
|
|
|
case RXA_DSB:
|
2024-07-22 18:39:21 -04:00
|
|
|
a->run = rxa.snba->run;
|
2024-06-16 05:31:13 -04:00
|
|
|
a->position = 1;
|
|
|
|
break;
|
|
|
|
case RXA_FM:
|
2024-07-22 18:39:21 -04:00
|
|
|
a->run = rxa.snba->run;
|
2024-06-16 05:31:13 -04:00
|
|
|
a->position = 1;
|
|
|
|
break;
|
|
|
|
case RXA_DRM:
|
|
|
|
case RXA_SPEC:
|
|
|
|
a->run = 0;
|
|
|
|
break;
|
|
|
|
}
|
2024-07-24 14:29:55 -04:00
|
|
|
FIRCORE::setUpdate_fircore (a->bpsnba->fircore);
|
|
|
|
}
|
|
|
|
|
|
|
|
void RXA::UpdateNBPFiltersLightWeight (RXA& rxa)
|
|
|
|
{ // called when setting tune freq or shift freq
|
|
|
|
rxa.nbp0->calc_lightweight();
|
|
|
|
rxa.bpsnba->bpsnba->calc_lightweight();
|
|
|
|
}
|
|
|
|
|
|
|
|
void RXA::UpdateNBPFilters(RXA& rxa)
|
|
|
|
{
|
|
|
|
NBP *a = rxa.nbp0;
|
|
|
|
BPSNBA *b = rxa.bpsnba;
|
|
|
|
if (a->fnfrun)
|
|
|
|
{
|
|
|
|
a->calc_impulse();
|
|
|
|
FIRCORE::setImpulse_fircore (a->fircore, a->impulse, 1);
|
|
|
|
delete[] (a->impulse);
|
|
|
|
}
|
|
|
|
if (b->bpsnba->fnfrun)
|
|
|
|
{
|
2024-07-24 17:11:29 -04:00
|
|
|
b->recalc_bpsnba_filter(1);
|
2024-07-24 14:29:55 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int RXA::NBPAddNotch (RXA& rxa, int notch, double fcenter, double fwidth, int active)
|
|
|
|
{
|
|
|
|
NOTCHDB *b = rxa.ndb;
|
|
|
|
int rval = b->addNotch(notch, fcenter, fwidth, active);
|
|
|
|
|
|
|
|
if (rval == 0) {
|
|
|
|
RXA::UpdateNBPFilters (rxa);
|
|
|
|
}
|
|
|
|
|
|
|
|
return rval;
|
|
|
|
}
|
|
|
|
|
|
|
|
int RXA::NBPGetNotch (RXA& rxa, int notch, double* fcenter, double* fwidth, int* active)
|
|
|
|
{
|
|
|
|
NOTCHDB *a = rxa.ndb;
|
|
|
|
int rval = a->getNotch(notch, fcenter, fwidth, active);
|
|
|
|
return rval;
|
|
|
|
}
|
|
|
|
|
|
|
|
int RXA::NBPDeleteNotch (RXA& rxa, int notch)
|
|
|
|
{
|
|
|
|
NOTCHDB *a = rxa.ndb;
|
|
|
|
int rval = a->deleteNotch(notch);
|
|
|
|
|
|
|
|
if (rval == 0) {
|
|
|
|
RXA::UpdateNBPFilters (rxa);
|
|
|
|
}
|
|
|
|
|
|
|
|
return rval;
|
|
|
|
}
|
|
|
|
|
|
|
|
int RXA::NBPEditNotch (RXA& rxa, int notch, double fcenter, double fwidth, int active)
|
|
|
|
{
|
|
|
|
NOTCHDB *a = rxa.ndb;
|
|
|
|
int rval = a->editNotch(notch, fcenter, fwidth, active);
|
|
|
|
|
|
|
|
if (rval == 0) {
|
|
|
|
RXA::UpdateNBPFilters (rxa);
|
|
|
|
}
|
|
|
|
|
|
|
|
return rval;
|
|
|
|
}
|
|
|
|
|
|
|
|
void RXA::NBPGetNumNotches (RXA& rxa, int* nnotches)
|
|
|
|
{
|
|
|
|
NOTCHDB *a = rxa.ndb;
|
|
|
|
a->getNumNotches(nnotches);
|
|
|
|
}
|
|
|
|
|
|
|
|
void RXA::NBPSetTuneFrequency (RXA& rxa, double tunefreq)
|
|
|
|
{
|
|
|
|
NOTCHDB *a;
|
|
|
|
a = rxa.ndb;
|
|
|
|
|
|
|
|
if (tunefreq != a->tunefreq)
|
|
|
|
{
|
|
|
|
a->tunefreq = tunefreq;
|
|
|
|
RXA::UpdateNBPFiltersLightWeight (rxa);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void RXA::NBPSetShiftFrequency (RXA& rxa, double shift)
|
|
|
|
{
|
|
|
|
NOTCHDB *a;
|
|
|
|
a = rxa.ndb;
|
|
|
|
if (shift != a->shift)
|
|
|
|
{
|
|
|
|
a->shift = shift;
|
|
|
|
RXA::UpdateNBPFiltersLightWeight (rxa);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void RXA::NBPSetNotchesRun (RXA& rxa, int run)
|
|
|
|
{
|
|
|
|
NOTCHDB *a = rxa.ndb;
|
|
|
|
NBP *b = rxa.nbp0;
|
|
|
|
|
|
|
|
if ( run != a->master_run)
|
|
|
|
{
|
|
|
|
a->master_run = run; // update variables
|
|
|
|
b->fnfrun = a->master_run;
|
|
|
|
RXA::bpsnbaCheck (rxa, rxa.mode, run);
|
|
|
|
b->calc_impulse(); // recalc nbp impulse response
|
|
|
|
FIRCORE::setImpulse_fircore (b->fircore, b->impulse, 0); // calculate new filter masks
|
|
|
|
delete[] (b->impulse);
|
|
|
|
RXA::bpsnbaSet (rxa);
|
|
|
|
FIRCORE::setUpdate_fircore (b->fircore); // apply new filter masks
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void RXA::NBPSetWindow (RXA& rxa, int wintype)
|
|
|
|
{
|
|
|
|
NBP *a;
|
|
|
|
BPSNBA *b;
|
|
|
|
a = rxa.nbp0;
|
|
|
|
b = rxa.bpsnba;
|
|
|
|
|
|
|
|
if ((a->wintype != wintype))
|
|
|
|
{
|
|
|
|
a->wintype = wintype;
|
|
|
|
a->calc_impulse();
|
|
|
|
FIRCORE::setImpulse_fircore (a->fircore, a->impulse, 1);
|
|
|
|
delete[] (a->impulse);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((b->wintype != wintype))
|
|
|
|
{
|
|
|
|
b->wintype = wintype;
|
2024-07-24 17:11:29 -04:00
|
|
|
b->recalc_bpsnba_filter(1);
|
2024-07-24 14:29:55 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void RXA::NBPSetAutoIncrease (RXA& rxa, int autoincr)
|
|
|
|
{
|
|
|
|
NBP *a;
|
|
|
|
BPSNBA *b;
|
|
|
|
a = rxa.nbp0;
|
|
|
|
b = rxa.bpsnba;
|
|
|
|
|
|
|
|
if ((a->autoincr != autoincr))
|
|
|
|
{
|
|
|
|
a->autoincr = autoincr;
|
|
|
|
a->calc_impulse();
|
|
|
|
FIRCORE::setImpulse_fircore (a->fircore, a->impulse, 1);
|
|
|
|
delete[] (a->impulse);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((b->autoincr != autoincr))
|
|
|
|
{
|
|
|
|
b->autoincr = autoincr;
|
2024-07-24 17:11:29 -04:00
|
|
|
b->recalc_bpsnba_filter(1);
|
2024-07-24 14:29:55 -04:00
|
|
|
}
|
2024-06-16 05:31:13 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/********************************************************************************************************
|
|
|
|
* *
|
|
|
|
* Collectives *
|
|
|
|
* *
|
|
|
|
********************************************************************************************************/
|
|
|
|
|
2024-06-24 21:50:48 -04:00
|
|
|
void RXA::SetPassband (RXA& rxa, float f_low, float f_high)
|
2024-06-16 05:31:13 -04:00
|
|
|
{
|
2024-06-24 04:20:14 -04:00
|
|
|
BANDPASS::SetBandpassFreqs (rxa, f_low, f_high); // After spectral noise reduction ( AM || ANF || ANR || EMNR)
|
|
|
|
SNBA::SetSNBAOutputBandwidth (rxa, f_low, f_high); // Spectral noise blanker (SNB)
|
2024-07-24 14:29:55 -04:00
|
|
|
rxa.nbp0->SetFreqs (f_low, f_high); // Notched bandpass
|
2024-06-16 05:31:13 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void RXA::SetNC (RXA& rxa, int nc)
|
|
|
|
{
|
|
|
|
int oldstate = rxa.state;
|
2024-07-24 14:29:55 -04:00
|
|
|
rxa.nbp0->SetNC (nc);
|
2024-07-24 17:11:29 -04:00
|
|
|
rxa.bpsnba->SetNC (nc);
|
2024-06-16 05:31:13 -04:00
|
|
|
BANDPASS::SetBandpassNC (rxa, nc);
|
|
|
|
EQP::SetEQNC (rxa, nc);
|
|
|
|
FMSQ::SetFMSQNC (rxa, nc);
|
|
|
|
FMD::SetFMNCde (rxa, nc);
|
|
|
|
FMD::SetFMNCaud (rxa, nc);
|
|
|
|
rxa.state = oldstate;
|
|
|
|
}
|
|
|
|
|
|
|
|
void RXA::SetMP (RXA& rxa, int mp)
|
|
|
|
{
|
2024-07-24 14:29:55 -04:00
|
|
|
rxa.nbp0->SetMP (mp);
|
2024-07-24 17:11:29 -04:00
|
|
|
rxa.bpsnba->SetMP (mp);
|
2024-06-16 05:31:13 -04:00
|
|
|
BANDPASS::SetBandpassMP (rxa, mp);
|
|
|
|
EQP::SetEQMP (rxa, mp);
|
|
|
|
FMSQ::SetFMSQMP (rxa, mp);
|
|
|
|
FMD::SetFMMPde (rxa, mp);
|
|
|
|
FMD::SetFMMPaud (rxa, mp);
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace WDSP
|