1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-25 01:18:38 -05:00
sdrangel/wdsp/TXA.cpp

1191 lines
46 KiB
C++
Raw Normal View History

2024-06-16 05:31:13 -04:00
/* TXA.c
This file is part of a program that implements a Software-Defined Radio.
Copyright (C) 2013, 2014, 2016, 2017, 2021, 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 "ammod.hpp"
#include "meter.hpp"
#include "resample.hpp"
#include "patchpanel.hpp"
#include "amsq.hpp"
#include "eq.hpp"
#include "cfcomp.hpp"
#include "compress.hpp"
#include "bandpass.hpp"
#include "bps.hpp"
#include "osctrl.hpp"
#include "wcpAGC.hpp"
2024-08-05 14:05:59 -04:00
#include "emphp.hpp"
2024-06-16 05:31:13 -04:00
#include "fmmod.hpp"
#include "siphon.hpp"
#include "gen.hpp"
#include "slew.hpp"
#include "iqc.hpp"
#include "cfir.hpp"
2024-07-29 18:45:32 -04:00
#include "fircore.hpp"
2024-07-30 19:37:17 -04:00
#include "phrot.hpp"
2024-07-29 18:45:32 -04:00
#include "fir.hpp"
2024-06-16 05:31:13 -04:00
#include "TXA.hpp"
namespace WDSP {
2024-08-03 07:54:42 -04:00
TXA::TXA(
int _in_rate, // input samplerate
int _out_rate, // output samplerate
int _dsp_rate, // sample rate for mainstream dsp processing
int _dsp_size // number complex samples processed per buffer in mainstream dsp processing
) : Unit(
_in_rate,
_out_rate,
_dsp_rate,
_dsp_size
2024-06-16 05:31:13 -04:00
)
{
2024-08-03 07:54:42 -04:00
mode = TXA_LSB;
f_low = -5000.0;
f_high = - 100.0;
2024-06-16 05:31:13 -04:00
2024-08-03 07:54:42 -04:00
rsmpin = new RESAMPLE(
2024-06-16 05:31:13 -04:00
0, // run - will be turned on below if needed
2024-08-03 07:54:42 -04:00
dsp_insize, // input buffer size
inbuff, // pointer to input buffer
midbuff, // pointer to output buffer
in_rate, // input sample rate
dsp_rate, // output sample rate
2024-06-16 05:31:13 -04:00
0.0, // select cutoff automatically
0, // select ncoef automatically
1.0); // gain
2024-08-03 07:54:42 -04:00
gen0 = new GEN(
2024-06-16 05:31:13 -04:00
0, // run
2024-08-03 07:54:42 -04:00
dsp_size, // buffer size
midbuff, // input buffer
midbuff, // output buffer
dsp_rate, // sample rate
2024-06-16 05:31:13 -04:00
2); // mode
2024-08-03 07:54:42 -04:00
panel = new PANEL(
2024-06-16 05:31:13 -04:00
1, // run
2024-08-03 07:54:42 -04:00
dsp_size, // size
midbuff, // pointer to input buffer
midbuff, // pointer to output buffer
2024-06-16 05:31:13 -04:00
1.0, // gain1
1.0, // gain2I
1.0, // gain2Q
2, // 1 to use Q, 2 to use I for input
0); // 0, no copy
2024-08-03 07:54:42 -04:00
phrot = new PHROT(
2024-06-16 05:31:13 -04:00
0, // run
2024-08-03 07:54:42 -04:00
dsp_size, // size
midbuff, // input buffer
midbuff, // output buffer
dsp_rate, // samplerate
2024-06-16 05:31:13 -04:00
338.0, // 1/2 of phase frequency
8); // number of stages
2024-08-03 07:54:42 -04:00
micmeter = new METER(
2024-06-16 05:31:13 -04:00
1, // run
2024-08-03 07:54:42 -04:00
nullptr, // optional pointer to another 'run'
dsp_size, // size
midbuff, // pointer to buffer
dsp_rate, // samplerate
2024-06-16 05:31:13 -04:00
0.100, // averaging time constant
0.100, // peak decay time constant
2024-08-03 07:54:42 -04:00
meter, // result vector
2024-06-16 05:31:13 -04:00
TXA_MIC_AV, // index for average value
TXA_MIC_PK, // index for peak value
-1, // index for gain value
2024-08-03 07:54:42 -04:00
nullptr); // pointer for gain computation
2024-06-16 05:31:13 -04:00
2024-08-03 07:54:42 -04:00
amsq = new AMSQ(
2024-06-16 05:31:13 -04:00
0, // run
2024-08-03 07:54:42 -04:00
dsp_size, // size
midbuff, // input buffer
midbuff, // output buffer
midbuff, // trigger buffer
dsp_rate, // sample rate
2024-06-16 05:31:13 -04:00
0.010, // time constant for averaging signal
0.004, // up-slew time
0.004, // down-slew time
0.180, // signal level to initiate tail
0.200, // signal level to initiate unmute
0.000, // minimum tail length
0.025, // maximum tail length
0.200); // muted gain
{
2024-08-03 07:54:42 -04:00
std::array<float, 11> default_F = {0.0, 32.0, 63.0, 125.0, 250.0, 500.0, 1000.0, 2000.0, 4000.0, 8000.0, 16000.0};
std::array<float, 11> default_G = {0.0, -12.0, -12.0, -12.0, -1.0, +1.0, +4.0, +9.0, +12.0, -10.0, -10.0};
2024-06-24 21:50:48 -04:00
//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-08-03 07:54:42 -04:00
eqp = new EQP (
2024-06-16 05:31:13 -04:00
0, // run - OFF by default
2024-08-03 07:54:42 -04:00
dsp_size, // size
std::max(2048, dsp_size), // number of filter coefficients
2024-06-16 05:31:13 -04:00
0, // minimum phase flag
2024-08-03 07:54:42 -04:00
midbuff, // pointer to input buffer
midbuff, // pointer to output buffer
2024-06-16 05:31:13 -04:00
10, // nfreqs
2024-08-03 07:54:42 -04:00
default_F.data(), // vector of frequencies
default_G.data(), // vector of gain values
2024-06-16 05:31:13 -04:00
0, // cutoff mode
0, // wintype
2024-08-03 07:54:42 -04:00
dsp_rate); // samplerate
2024-06-16 05:31:13 -04:00
}
2024-08-03 07:54:42 -04:00
eqmeter = new METER(
2024-06-16 05:31:13 -04:00
1, // run
2024-08-03 07:54:42 -04:00
&(eqp->run), // pointer to eqp 'run'
dsp_size, // size
midbuff, // pointer to buffer
dsp_rate, // samplerate
2024-06-16 05:31:13 -04:00
0.100, // averaging time constant
0.100, // peak decay time constant
2024-08-03 07:54:42 -04:00
meter, // result vector
2024-06-16 05:31:13 -04:00
TXA_EQ_AV, // index for average value
TXA_EQ_PK, // index for peak value
-1, // index for gain value
2024-08-03 07:54:42 -04:00
nullptr); // pointer for gain computation
2024-06-16 05:31:13 -04:00
2024-08-05 14:05:59 -04:00
preemph = new EMPHP(
2024-06-16 05:31:13 -04:00
0, // run
1, // position
2024-08-03 07:54:42 -04:00
dsp_size, // size
std::max(2048, dsp_size), // number of filter coefficients
2024-06-16 05:31:13 -04:00
0, // minimum phase flag
2024-08-03 07:54:42 -04:00
midbuff, // input buffer
midbuff, // output buffer,
dsp_rate, // sample rate
2024-06-16 05:31:13 -04:00
0, // pre-emphasis type
300.0, // f_low
3000.0); // f_high
2024-08-03 07:54:42 -04:00
leveler = new WCPAGC(
2024-06-16 05:31:13 -04:00
0, // run - OFF by default
5, // mode
0, // 0 for max(I,Q), 1 for envelope
2024-08-03 07:54:42 -04:00
midbuff, // input buff pointer
midbuff, // output buff pointer
dsp_size, // io_buffsize
dsp_rate, // sample rate
2024-06-16 05:31:13 -04:00
0.001, // tau_attack
0.500, // tau_decay
6, // n_tau
1.778, // max_gain
1.0, // var_gain
1.0, // fixed_gain
1.0, // max_input
1.05, // out_targ
0.250, // tau_fast_backaverage
0.005, // tau_fast_decay
5.0, // pop_ratio
0, // hang_enable
0.500, // tau_hang_backmult
0.500, // hangtime
2.000, // hang_thresh
0.100); // tau_hang_decay
2024-08-03 07:54:42 -04:00
lvlrmeter = new METER(
2024-06-16 05:31:13 -04:00
1, // run
2024-08-03 07:54:42 -04:00
&(leveler->run), // pointer to leveler 'run'
dsp_size, // size
midbuff, // pointer to buffer
dsp_rate, // samplerate
2024-06-16 05:31:13 -04:00
0.100, // averaging time constant
0.100, // peak decay time constant
2024-08-03 07:54:42 -04:00
meter, // result vector
2024-06-16 05:31:13 -04:00
TXA_LVLR_AV, // index for average value
TXA_LVLR_PK, // index for peak value
TXA_LVLR_GAIN, // index for gain value
2024-08-03 07:54:42 -04:00
&leveler->gain); // pointer for gain computation
2024-06-16 05:31:13 -04:00
{
2024-08-05 14:05:59 -04:00
std::array<double, 5> default_F = {200.0, 1000.0, 2000.0, 3000.0, 4000.0};
std::array<double, 5> default_G = { 0.0, 5.0, 10.0, 10.0, 5.0};
std::array<double, 5> default_E = { 7.0, 7.0, 7.0, 7.0, 7.0};
cfcomp = new CFCOMP(
2024-06-16 05:31:13 -04:00
0, // run
0, // position
0, // post-equalizer run
2024-08-03 07:54:42 -04:00
dsp_size, // size
midbuff, // input buffer
midbuff, // output buffer
2024-06-16 05:31:13 -04:00
2048, // fft size
4, // overlap
2024-08-03 07:54:42 -04:00
dsp_rate, // samplerate
2024-06-16 05:31:13 -04:00
1, // window type
0, // compression method
5, // nfreqs
0.0, // pre-compression
0.0, // pre-postequalization
2024-08-03 07:54:42 -04:00
default_F.data(), // frequency array
default_G.data(), // compression array
default_E.data(), // eq array
2024-06-16 05:31:13 -04:00
0.25, // metering time constant
0.50); // display time constant
}
2024-08-03 07:54:42 -04:00
cfcmeter = new METER(
2024-06-16 05:31:13 -04:00
1, // run
2024-08-03 07:54:42 -04:00
&(cfcomp->run), // pointer to eqp 'run'
dsp_size, // size
midbuff, // pointer to buffer
dsp_rate, // samplerate
2024-06-16 05:31:13 -04:00
0.100, // averaging time constant
0.100, // peak decay time constant
2024-08-03 07:54:42 -04:00
meter, // result vector
2024-06-16 05:31:13 -04:00
TXA_CFC_AV, // index for average value
TXA_CFC_PK, // index for peak value
TXA_CFC_GAIN, // index for gain value
2024-08-03 07:54:42 -04:00
(double*) &cfcomp->gain); // pointer for gain computation
2024-06-16 05:31:13 -04:00
2024-08-03 07:54:42 -04:00
bp0 = new BANDPASS(
2024-06-16 05:31:13 -04:00
1, // always runs
0, // position
2024-08-03 07:54:42 -04:00
dsp_size, // size
std::max(2048, dsp_size), // number of coefficients
2024-06-16 05:31:13 -04:00
0, // flag for minimum phase
2024-08-03 07:54:42 -04:00
midbuff, // pointer to input buffer
midbuff, // pointer to output buffer
f_low, // low freq cutoff
f_high, // high freq cutoff
dsp_rate, // samplerate
2024-06-16 05:31:13 -04:00
1, // wintype
2.0); // gain
2024-08-07 15:14:09 -04:00
compressor = new COMPRESSOR(
2024-06-16 05:31:13 -04:00
0, // run - OFF by default
2024-08-03 07:54:42 -04:00
dsp_size, // size
midbuff, // pointer to input buffer
midbuff, // pointer to output buffer
2024-06-16 05:31:13 -04:00
3.0); // gain
2024-08-03 07:54:42 -04:00
bp1 = new BANDPASS(
2024-06-16 05:31:13 -04:00
0, // ONLY RUNS WHEN COMPRESSOR IS USED
0, // position
2024-08-03 07:54:42 -04:00
dsp_size, // size
std::max(2048, dsp_size), // number of coefficients
2024-06-16 05:31:13 -04:00
0, // flag for minimum phase
2024-08-03 07:54:42 -04:00
midbuff, // pointer to input buffer
midbuff, // pointer to output buffer
f_low, // low freq cutoff
f_high, // high freq cutoff
dsp_rate, // samplerate
2024-06-16 05:31:13 -04:00
1, // wintype
2.0); // gain
2024-08-07 15:14:09 -04:00
osctrl = new OSCTRL(
2024-06-16 05:31:13 -04:00
0, // run
2024-08-03 07:54:42 -04:00
dsp_size, // size
midbuff, // input buffer
midbuff, // output buffer
dsp_rate, // sample rate
1.95f); // gain for clippings
2024-06-16 05:31:13 -04:00
2024-08-03 07:54:42 -04:00
bp2 = new BANDPASS(
2024-06-16 05:31:13 -04:00
0, // ONLY RUNS WHEN COMPRESSOR IS USED
0, // position
2024-08-03 07:54:42 -04:00
dsp_size, // size
std::max(2048, dsp_size), // number of coefficients
2024-06-16 05:31:13 -04:00
0, // flag for minimum phase
2024-08-03 07:54:42 -04:00
midbuff, // pointer to input buffer
midbuff, // pointer to output buffer
f_low, // low freq cutoff
f_high, // high freq cutoff
dsp_rate, // samplerate
2024-06-16 05:31:13 -04:00
1, // wintype
1.0); // gain
2024-08-03 07:54:42 -04:00
compmeter = new METER(
2024-06-16 05:31:13 -04:00
1, // run
2024-08-03 07:54:42 -04:00
&(compressor->run), // pointer to compressor 'run'
dsp_size, // size
midbuff, // pointer to buffer
dsp_rate, // samplerate
2024-06-16 05:31:13 -04:00
0.100, // averaging time constant
0.100, // peak decay time constant
2024-08-03 07:54:42 -04:00
meter, // result vector
2024-06-16 05:31:13 -04:00
TXA_COMP_AV, // index for average value
TXA_COMP_PK, // index for peak value
-1, // index for gain value
2024-08-03 07:54:42 -04:00
nullptr); // pointer for gain computation
2024-06-16 05:31:13 -04:00
2024-08-03 07:54:42 -04:00
alc = new WCPAGC(
2024-06-16 05:31:13 -04:00
1, // run - always ON
5, // mode
1, // 0 for max(I,Q), 1 for envelope
2024-08-03 07:54:42 -04:00
midbuff, // input buff pointer
midbuff, // output buff pointer
dsp_size, // io_buffsize
dsp_rate, // sample rate
2024-06-16 05:31:13 -04:00
0.001, // tau_attack
0.010, // tau_decay
6, // n_tau
1.0, // max_gain
1.0, // var_gain
1.0, // fixed_gain
1.0, // max_input
1.0, // out_targ
0.250, // tau_fast_backaverage
0.005, // tau_fast_decay
5.0, // pop_ratio
0, // hang_enable
0.500, // tau_hang_backmult
0.500, // hangtime
2.000, // hang_thresh
0.100); // tau_hang_decay
2024-08-05 14:05:59 -04:00
ammod = new AMMOD(
2024-06-16 05:31:13 -04:00
0, // run - OFF by default
0, // mode: 0=>AM, 1=>DSB
2024-08-03 07:54:42 -04:00
dsp_size, // size
midbuff, // pointer to input buffer
midbuff, // pointer to output buffer
2024-06-16 05:31:13 -04:00
0.5); // carrier level
2024-08-07 15:14:09 -04:00
fmmod = new FMMOD(
2024-06-16 05:31:13 -04:00
0, // run - OFF by default
2024-08-03 07:54:42 -04:00
dsp_size, // size
midbuff, // pointer to input buffer
midbuff, // pointer to input buffer
dsp_rate, // samplerate
2024-06-16 05:31:13 -04:00
5000.0, // deviation
300.0, // low cutoff frequency
3000.0, // high cutoff frequency
1, // ctcss run control
2024-08-03 07:54:42 -04:00
0.10f, // ctcss level
2024-06-16 05:31:13 -04:00
100.0, // ctcss frequency
1, // run bandpass filter
2024-08-03 07:54:42 -04:00
std::max(2048, dsp_size), // number coefficients for bandpass filter
2024-06-16 05:31:13 -04:00
0); // minimum phase flag
2024-08-03 07:54:42 -04:00
gen1 = new GEN(
2024-06-16 05:31:13 -04:00
0, // run
2024-08-03 07:54:42 -04:00
dsp_size, // buffer size
midbuff, // input buffer
midbuff, // output buffer
dsp_rate, // sample rate
2024-06-16 05:31:13 -04:00
0); // mode
2024-08-07 15:14:09 -04:00
uslew = new USLEW(
2024-08-03 07:54:42 -04:00
&upslew, // pointer to channel upslew flag
dsp_size, // buffer size
midbuff, // input buffer
midbuff, // output buffer
2024-08-07 15:14:09 -04:00
(double) dsp_rate, // sample rate
2024-06-16 05:31:13 -04:00
0.000, // delay time
2024-08-07 15:14:09 -04:00
0.005); // upslew time
2024-06-16 05:31:13 -04:00
2024-08-03 07:54:42 -04:00
alcmeter = new METER(
2024-06-16 05:31:13 -04:00
1, // run
2024-08-03 07:54:42 -04:00
nullptr, // optional pointer to a 'run'
dsp_size, // size
midbuff, // pointer to buffer
dsp_rate, // samplerate
2024-06-16 05:31:13 -04:00
0.100, // averaging time constant
0.100, // peak decay time constant
2024-08-03 07:54:42 -04:00
meter, // result vector
2024-06-16 05:31:13 -04:00
TXA_ALC_AV, // index for average value
TXA_ALC_PK, // index for peak value
TXA_ALC_GAIN, // index for gain value
2024-08-03 07:54:42 -04:00
&alc->gain); // pointer for gain computation
2024-06-16 05:31:13 -04:00
2024-08-03 07:54:42 -04:00
sip1 = new SIPHON(
2024-06-16 05:31:13 -04:00
1, // run
0, // position
0, // mode
0, // disp
2024-08-03 07:54:42 -04:00
dsp_size, // input buffer size
midbuff, // input buffer
2024-06-16 05:31:13 -04:00
16384, // number of samples to buffer
16384, // fft size for spectrum
1); // specmode
// txa->calcc = create_calcc (
2024-06-16 05:31:13 -04:00
// channel, // channel number
// 1, // run calibration
// 1024, // input buffer size
2024-08-03 07:54:42 -04:00
// in_rate, // samplerate
2024-06-16 05:31:13 -04:00
// 16, // ints
// 256, // spi
// (1.0 / 0.4072), // hw_scale
// 0.1, // mox delay
// 0.0, // loop delay
// 0.8, // ptol
// 0, // mox
// 0, // solidmox
// 1, // pin mode
// 1, // map mode
// 0, // stbl mode
// 256, // pin samples
// 0.9); // alpha
2024-08-07 15:14:09 -04:00
iqc.p0 = iqc.p1 = new IQC(
2024-06-16 05:31:13 -04:00
0, // run
2024-08-03 07:54:42 -04:00
dsp_size, // size
midbuff, // input buffer
midbuff, // output buffer
2024-08-07 15:14:09 -04:00
(double) dsp_rate, // sample rate
2024-06-16 05:31:13 -04:00
16, // ints
2024-08-07 15:14:09 -04:00
0.005, // changeover time
2024-06-16 05:31:13 -04:00
256); // spi
2024-08-07 15:14:09 -04:00
cfir = new CFIR(
2024-06-16 05:31:13 -04:00
0, // run
2024-08-03 07:54:42 -04:00
dsp_size, // size
std::max(2048, dsp_size), // number of filter coefficients
2024-06-16 05:31:13 -04:00
0, // minimum phase flag
2024-08-03 07:54:42 -04:00
midbuff, // input buffer
midbuff, // output buffer
dsp_rate, // input sample rate
out_rate, // CIC input sample rate
2024-06-16 05:31:13 -04:00
1, // CIC differential delay
640, // CIC interpolation factor
5, // CIC integrator-comb pairs
20000.0, // cutoff frequency
2, // brick-wall windowed rolloff
0.0, // raised-cosine transition width
0); // window type
2024-08-03 07:54:42 -04:00
rsmpout = new RESAMPLE(
2024-06-16 05:31:13 -04:00
0, // run - will be turned ON below if needed
2024-08-03 07:54:42 -04:00
dsp_size, // input size
midbuff, // pointer to input buffer
outbuff, // pointer to output buffer
dsp_rate, // input sample rate
out_rate, // output sample rate
2024-06-16 05:31:13 -04:00
0.0, // select cutoff automatically
0, // select ncoef automatically
0.980); // gain
2024-08-03 07:54:42 -04:00
outmeter = new METER(
2024-06-16 05:31:13 -04:00
1, // run
2024-08-03 07:54:42 -04:00
nullptr, // optional pointer to another 'run'
dsp_outsize, // size
outbuff, // pointer to buffer
out_rate, // samplerate
2024-06-16 05:31:13 -04:00
0.100, // averaging time constant
0.100, // peak decay time constant
2024-08-03 07:54:42 -04:00
meter, // result vector
2024-06-16 05:31:13 -04:00
TXA_OUT_AV, // index for average value
TXA_OUT_PK, // index for peak value
-1, // index for gain value
2024-08-03 07:54:42 -04:00
nullptr); // pointer for gain computation
2024-06-16 05:31:13 -04:00
// turn OFF / ON resamplers as needed
2024-08-03 07:54:42 -04:00
resCheck();
2024-06-16 05:31:13 -04:00
}
2024-08-03 07:54:42 -04:00
TXA::~TXA()
2024-06-16 05:31:13 -04:00
{
// in reverse order, free each item we created
2024-08-03 07:54:42 -04:00
delete outmeter;
delete rsmpout;
2024-08-07 15:14:09 -04:00
delete cfir;
delete iqc.p0;
2024-08-03 07:54:42 -04:00
delete sip1;
delete alcmeter;
2024-08-07 15:14:09 -04:00
delete uslew;
2024-08-03 07:54:42 -04:00
delete gen1;
2024-08-07 15:14:09 -04:00
delete fmmod;
2024-08-05 14:05:59 -04:00
delete ammod;
2024-08-03 07:54:42 -04:00
delete alc;
delete compmeter;
delete bp2;
2024-08-07 15:14:09 -04:00
delete osctrl;
2024-08-03 07:54:42 -04:00
delete bp1;
2024-08-07 15:14:09 -04:00
delete compressor;
2024-08-03 07:54:42 -04:00
delete bp0;
delete cfcmeter;
2024-08-05 14:05:59 -04:00
delete cfcomp;
2024-08-03 07:54:42 -04:00
delete lvlrmeter;
delete leveler;
2024-08-05 14:05:59 -04:00
delete preemph;
2024-08-03 07:54:42 -04:00
delete eqmeter;
delete eqp;
delete amsq;
delete micmeter;
delete phrot;
delete panel;
delete gen0;
delete rsmpin;
2024-06-16 05:31:13 -04:00
}
2024-08-03 07:54:42 -04:00
void TXA::flush()
2024-06-16 05:31:13 -04:00
{
2024-08-03 07:54:42 -04:00
Unit::flushBuffers();
rsmpin->flush();
gen0->flush();
panel->flush ();
phrot->flush();
micmeter->flush ();
amsq->flush ();
eqp->flush();
eqmeter->flush ();
2024-08-05 14:05:59 -04:00
preemph->flush();
2024-08-03 07:54:42 -04:00
leveler->flush();
lvlrmeter->flush ();
2024-08-05 14:05:59 -04:00
cfcomp->flush();
2024-08-03 07:54:42 -04:00
cfcmeter->flush ();
bp0->flush ();
2024-08-07 15:14:09 -04:00
compressor->flush();
2024-08-03 07:54:42 -04:00
bp1->flush ();
2024-08-07 15:14:09 -04:00
osctrl->flush();
2024-08-03 07:54:42 -04:00
bp2->flush ();
compmeter->flush ();
alc->flush ();
2024-08-05 14:05:59 -04:00
ammod->flush();
2024-08-07 15:14:09 -04:00
fmmod->flush();
2024-08-03 07:54:42 -04:00
gen1->flush();
2024-08-07 15:14:09 -04:00
uslew->flush();
2024-08-03 07:54:42 -04:00
alcmeter->flush ();
sip1->flush();
2024-08-07 15:14:09 -04:00
iqc.p0->flush();
cfir->flush();
2024-08-03 07:54:42 -04:00
rsmpout->flush();
outmeter->flush ();
2024-06-16 05:31:13 -04:00
}
2024-08-03 07:54:42 -04:00
void TXA::execute()
2024-06-16 05:31:13 -04:00
{
2024-08-03 07:54:42 -04:00
rsmpin->execute(); // input resampler
gen0->execute(); // input signal generator
panel->execute(); // includes MIC gain
phrot->execute(); // phase rotator
micmeter->execute (); // MIC meter
amsq->xcap (); // downward expander capture
amsq->execute (); // downward expander action
eqp->execute (); // pre-EQ
eqmeter->execute (); // EQ meter
2024-08-05 14:05:59 -04:00
preemph->execute(0); // FM pre-emphasis (first option)
2024-08-03 07:54:42 -04:00
leveler->execute (); // Leveler
lvlrmeter->execute (); // Leveler Meter
2024-08-05 14:05:59 -04:00
cfcomp->execute(0); // Continuous Frequency Compressor with post-EQ
2024-08-03 07:54:42 -04:00
cfcmeter->execute (); // CFC+PostEQ Meter
bp0->execute (0); // primary bandpass filter
2024-08-07 15:14:09 -04:00
compressor->execute(); // COMP compressor
2024-08-03 07:54:42 -04:00
bp1->execute (0); // aux bandpass (runs if COMP)
2024-08-07 15:14:09 -04:00
osctrl->execute(); // CESSB Overshoot Control
2024-08-03 07:54:42 -04:00
bp2->execute (0); // aux bandpass (runs if CESSB)
compmeter->execute (); // COMP meter
alc->execute (); // ALC
2024-08-05 14:05:59 -04:00
ammod->execute(); // AM Modulator
preemph->execute(1); // FM pre-emphasis (second option)
2024-08-07 15:14:09 -04:00
fmmod->execute(); // FM Modulator
2024-08-03 07:54:42 -04:00
gen1->execute(); // output signal generator (TUN and Two-tone)
2024-08-07 15:14:09 -04:00
uslew->execute(uslewCheck()); // up-slew for AM, FM, and gens
2024-08-03 07:54:42 -04:00
alcmeter->execute (); // ALC Meter
sip1->execute(0); // siphon data for display
2024-08-07 15:14:09 -04:00
iqc.p0->execute(); // PureSignal correction
cfir->execute(); // compensating FIR filter (used Protocol_2 only)
2024-08-03 07:54:42 -04:00
rsmpout->execute(); // output resampler
outmeter->execute (); // output meter
2024-06-16 05:31:13 -04:00
}
2024-08-03 07:54:42 -04:00
void TXA::setInputSamplerate(int in_rate)
2024-06-16 05:31:13 -04:00
{
2024-08-03 07:54:42 -04:00
Unit::setBuffersInputSamplerate(in_rate);
2024-06-16 05:31:13 -04:00
// input resampler
2024-08-03 07:54:42 -04:00
rsmpin->setBuffers(inbuff, midbuff);
rsmpin->setSize(dsp_insize);
rsmpin->setInRate(in_rate);
resCheck();
2024-06-16 05:31:13 -04:00
}
2024-08-03 07:54:42 -04:00
void TXA::setOutputSamplerate(int out_rate)
2024-06-16 05:31:13 -04:00
{
2024-08-03 07:54:42 -04:00
Unit::setBuffersOutputSamplerate(out_rate);
2024-06-16 05:31:13 -04:00
// cfir - needs to know input rate of firmware CIC
2024-08-07 15:14:09 -04:00
cfir->setOutRate(out_rate);
2024-06-16 05:31:13 -04:00
// output resampler
2024-08-03 07:54:42 -04:00
rsmpout->setBuffers(midbuff, outbuff);
rsmpout->setOutRate(out_rate);
resCheck();
2024-06-16 05:31:13 -04:00
// output meter
2024-08-03 07:54:42 -04:00
outmeter->setBuffers(outbuff);
outmeter->setSize(dsp_outsize);
outmeter->setSamplerate (out_rate);
2024-06-16 05:31:13 -04:00
}
2024-08-03 07:54:42 -04:00
void TXA::setDSPSamplerate(int dsp_rate)
2024-06-16 05:31:13 -04:00
{
2024-08-03 07:54:42 -04:00
Unit::setBuffersDSPSamplerate(dsp_rate);
2024-06-16 05:31:13 -04:00
// input resampler
2024-08-03 07:54:42 -04:00
rsmpin->setBuffers(inbuff, midbuff);
rsmpin->setSize(dsp_insize);
rsmpin->setOutRate(dsp_rate);
2024-06-16 05:31:13 -04:00
// dsp_rate blocks
2024-08-03 07:54:42 -04:00
gen0->setSamplerate(dsp_rate);
panel->setSamplerate(dsp_rate);
phrot->setSamplerate(dsp_rate);
micmeter->setSamplerate (dsp_rate);
amsq->setSamplerate (dsp_rate);
eqp->setSamplerate (dsp_rate);
eqmeter->setSamplerate (dsp_rate);
2024-08-05 14:05:59 -04:00
preemph->setSamplerate(dsp_rate);
2024-08-03 07:54:42 -04:00
leveler->setSamplerate (dsp_rate);
lvlrmeter->setSamplerate (dsp_rate);
2024-08-05 14:05:59 -04:00
cfcomp->setSamplerate(dsp_rate);
2024-08-03 07:54:42 -04:00
cfcmeter->setSamplerate (dsp_rate);
bp0->setSamplerate (dsp_rate);
2024-08-07 15:14:09 -04:00
compressor->setSamplerate(dsp_rate);
2024-08-03 07:54:42 -04:00
bp1->setSamplerate (dsp_rate);
2024-08-07 15:14:09 -04:00
osctrl->setSamplerate(dsp_rate);
2024-08-03 07:54:42 -04:00
bp2->setSamplerate (dsp_rate);
compmeter->setSamplerate (dsp_rate);
alc->setSamplerate (dsp_rate);
2024-08-05 14:05:59 -04:00
ammod->setSamplerate(dsp_rate);
2024-08-07 15:14:09 -04:00
fmmod->setSamplerate(dsp_rate);
2024-08-03 07:54:42 -04:00
gen1->setSamplerate(dsp_rate);
2024-08-07 15:14:09 -04:00
uslew->setSamplerate(dsp_rate);
2024-08-03 07:54:42 -04:00
alcmeter->setSamplerate (dsp_rate);
sip1->setSamplerate (dsp_rate);
2024-08-07 15:14:09 -04:00
iqc.p0->setSamplerate(dsp_rate);
cfir->setSamplerate(dsp_rate);
2024-06-16 05:31:13 -04:00
// output resampler
2024-08-03 07:54:42 -04:00
rsmpout->setBuffers(midbuff, outbuff);
rsmpout->setInRate(dsp_rate);
resCheck();
2024-06-16 05:31:13 -04:00
// output meter
2024-08-03 07:54:42 -04:00
outmeter->setBuffers(outbuff);
outmeter->setSize (dsp_outsize);
2024-06-16 05:31:13 -04:00
}
2024-08-03 07:54:42 -04:00
void TXA::setDSPBuffsize(int dsp_size)
2024-06-16 05:31:13 -04:00
{
2024-08-03 07:54:42 -04:00
Unit::setBuffersDSPBuffsize(dsp_size);
2024-06-16 05:31:13 -04:00
// input resampler
2024-08-03 07:54:42 -04:00
rsmpin->setBuffers(inbuff, midbuff);
rsmpin->setSize(dsp_insize);
2024-06-16 05:31:13 -04:00
// dsp_size blocks
2024-08-03 07:54:42 -04:00
gen0->setBuffers(midbuff, midbuff);
gen0->setSize(dsp_size);
panel->setBuffers(midbuff, midbuff);
panel->setSize(dsp_size);
phrot->setBuffers(midbuff, midbuff);
phrot->setSize(dsp_size);
micmeter->setBuffers (midbuff);
micmeter->setSize (dsp_size);
amsq->setBuffers (midbuff, midbuff, midbuff);
amsq->setSize (dsp_size);
eqp->setBuffers (midbuff, midbuff);
eqp->setSize (dsp_size);
eqmeter->setBuffers (midbuff);
eqmeter->setSize (dsp_size);
2024-08-05 14:05:59 -04:00
preemph->setBuffers(midbuff, midbuff);
preemph->setSize(dsp_size);
2024-08-03 07:54:42 -04:00
leveler->setBuffers(midbuff, midbuff);
leveler->setSize(dsp_size);
lvlrmeter->setBuffers(midbuff);
lvlrmeter->setSize(dsp_size);
2024-08-05 14:05:59 -04:00
cfcomp->setBuffers(midbuff, midbuff);
cfcomp->setSize(dsp_size);
2024-08-03 07:54:42 -04:00
cfcmeter->setBuffers(midbuff);
cfcmeter->setSize(dsp_size);
bp0->setBuffers (midbuff, midbuff);
bp0->setSize (dsp_size);
2024-08-07 15:14:09 -04:00
compressor->setBuffers(midbuff, midbuff);
compressor->setSize(dsp_size);
2024-08-03 07:54:42 -04:00
bp1->setBuffers (midbuff, midbuff);
bp1->setSize (dsp_size);
2024-08-07 15:14:09 -04:00
osctrl->setBuffers(midbuff, midbuff);
osctrl->setSize(dsp_size);
2024-08-03 07:54:42 -04:00
bp2->setBuffers (midbuff, midbuff);
bp2->setSize (dsp_size);
compmeter->setBuffers(midbuff);
compmeter->setSize(dsp_size);
alc->setBuffers(midbuff, midbuff);
alc->setSize( dsp_size);
2024-08-05 14:05:59 -04:00
ammod->setBuffers(midbuff, midbuff);
ammod->setSize(dsp_size);
2024-08-07 15:14:09 -04:00
fmmod->setBuffers(midbuff, midbuff);
fmmod->setSize(dsp_size);
2024-08-03 07:54:42 -04:00
gen1->setBuffers(midbuff, midbuff);
gen1->setSize(dsp_size);
2024-08-07 15:14:09 -04:00
uslew->setBuffers(midbuff, midbuff);
uslew->setSize(dsp_size);
2024-08-03 07:54:42 -04:00
alcmeter->setBuffers (midbuff);
alcmeter->setSize(dsp_size);
sip1->setBuffers (midbuff);
sip1->setSize (dsp_size);
2024-08-07 15:14:09 -04:00
iqc.p0->IQC::setBuffers(midbuff, midbuff);
iqc.p0->IQC::setSize(dsp_size);
cfir->setBuffers(midbuff, midbuff);
cfir->setSize(dsp_size);
2024-06-16 05:31:13 -04:00
// output resampler
2024-08-03 07:54:42 -04:00
rsmpout->setBuffers(midbuff, outbuff);
rsmpout->setSize(dsp_size);
2024-06-16 05:31:13 -04:00
// output meter
2024-08-03 07:54:42 -04:00
outmeter->setBuffers(outbuff);
outmeter->setSize(dsp_outsize);
2024-06-16 05:31:13 -04:00
}
/********************************************************************************************************
* *
* TXA Properties *
* *
********************************************************************************************************/
2024-08-03 07:54:42 -04:00
void TXA::setMode(int _mode)
2024-06-16 05:31:13 -04:00
{
2024-08-03 07:54:42 -04:00
if (mode != _mode)
2024-06-16 05:31:13 -04:00
{
2024-08-03 07:54:42 -04:00
mode = _mode;
ammod->run = 0;
fmmod->run = 0;
preemph->run = 0;
2024-07-13 17:59:46 -04:00
2024-08-03 07:54:42 -04:00
switch (_mode)
2024-06-16 05:31:13 -04:00
{
case TXA_AM:
case TXA_SAM:
2024-08-03 07:54:42 -04:00
ammod->run = 1;
ammod->mode = 0;
2024-06-16 05:31:13 -04:00
break;
case TXA_DSB:
2024-08-03 07:54:42 -04:00
ammod->run = 1;
ammod->mode = 1;
2024-06-16 05:31:13 -04:00
break;
case TXA_AM_LSB:
case TXA_AM_USB:
2024-08-03 07:54:42 -04:00
ammod->run = 1;
ammod->mode = 2;
2024-06-16 05:31:13 -04:00
break;
case TXA_FM:
2024-08-03 07:54:42 -04:00
fmmod->run = 1;
preemph->run = 1;
2024-06-16 05:31:13 -04:00
break;
default:
break;
}
2024-07-13 17:59:46 -04:00
2024-08-03 07:54:42 -04:00
setupBPFilters();
2024-06-16 05:31:13 -04:00
}
}
2024-08-03 07:54:42 -04:00
void TXA::setBandpassFreqs(float _f_low, float _f_high)
2024-06-16 05:31:13 -04:00
{
2024-08-03 07:54:42 -04:00
if ((f_low != _f_low) || (f_high != _f_high))
2024-06-16 05:31:13 -04:00
{
2024-08-03 07:54:42 -04:00
f_low = _f_low;
f_high = _f_high;
setupBPFilters();
2024-06-16 05:31:13 -04:00
}
}
/********************************************************************************************************
* *
* TXA Internal Functions *
* *
********************************************************************************************************/
2024-08-03 07:54:42 -04:00
void TXA::resCheck()
2024-06-16 05:31:13 -04:00
{
2024-08-03 07:54:42 -04:00
RESAMPLE *a = rsmpin;
if (in_rate != dsp_rate)
2024-06-16 05:31:13 -04:00
a->run = 1;
else
a->run = 0;
2024-08-03 07:54:42 -04:00
a = rsmpout;
if (dsp_rate != out_rate)
2024-06-16 05:31:13 -04:00
a->run = 1;
else
a->run = 0;
}
2024-08-03 07:54:42 -04:00
int TXA::uslewCheck()
2024-06-16 05:31:13 -04:00
{
2024-08-03 07:54:42 -04:00
return (ammod->run == 1) ||
(fmmod->run == 1) ||
(gen0->run == 1) ||
(gen1->run == 1);
2024-06-16 05:31:13 -04:00
}
2024-08-03 07:54:42 -04:00
void TXA::setupBPFilters()
2024-06-16 05:31:13 -04:00
{
2024-08-03 07:54:42 -04:00
bp0->run = 1;
bp1->run = 0;
bp2->run = 0;
switch (mode)
2024-06-16 05:31:13 -04:00
{
case TXA_LSB:
case TXA_USB:
case TXA_CWL:
case TXA_CWU:
case TXA_DIGL:
case TXA_DIGU:
case TXA_SPEC:
case TXA_DRM:
2024-08-03 07:54:42 -04:00
bp0->calcBandpassFilter (f_low, f_high, 2.0);
if (compressor->run)
2024-06-16 05:31:13 -04:00
{
2024-08-03 07:54:42 -04:00
bp1->calcBandpassFilter (f_low, f_high, 2.0);
bp1->run = 1;
if (osctrl->run)
2024-06-16 05:31:13 -04:00
{
2024-08-03 07:54:42 -04:00
bp2->calcBandpassFilter (f_low, f_high, 1.0);
bp2->run = 1;
2024-06-16 05:31:13 -04:00
}
}
break;
case TXA_DSB:
case TXA_AM:
case TXA_SAM:
case TXA_FM:
2024-08-03 07:54:42 -04:00
if (compressor->run)
2024-06-16 05:31:13 -04:00
{
2024-08-03 07:54:42 -04:00
bp0->calcBandpassFilter (0.0, f_high, 2.0);
bp1->calcBandpassFilter (0.0, f_high, 2.0);
bp1->run = 1;
if (osctrl->run)
2024-06-16 05:31:13 -04:00
{
2024-08-03 07:54:42 -04:00
bp2->calcBandpassFilter (0.0, f_high, 1.0);
bp2->run = 1;
2024-06-16 05:31:13 -04:00
}
}
else
{
2024-08-03 07:54:42 -04:00
bp0->calcBandpassFilter (f_low, f_high, 1.0);
2024-06-16 05:31:13 -04:00
}
break;
case TXA_AM_LSB:
2024-08-03 07:54:42 -04:00
bp0->calcBandpassFilter (-f_high, 0.0, 2.0);
if (compressor->run)
2024-06-16 05:31:13 -04:00
{
2024-08-03 07:54:42 -04:00
bp1->calcBandpassFilter (-f_high, 0.0, 2.0);
bp1->run = 1;
if (osctrl->run)
2024-06-16 05:31:13 -04:00
{
2024-08-03 07:54:42 -04:00
bp2->calcBandpassFilter (-f_high, 0.0, 1.0);
bp2->run = 1;
2024-06-16 05:31:13 -04:00
}
}
break;
case TXA_AM_USB:
2024-08-03 07:54:42 -04:00
bp0->calcBandpassFilter (0.0, f_high, 2.0);
if (compressor->run)
2024-06-16 05:31:13 -04:00
{
2024-08-03 07:54:42 -04:00
bp1->calcBandpassFilter (0.0, f_high, 2.0);
bp1->run = 1;
if (osctrl->run)
2024-06-16 05:31:13 -04:00
{
2024-08-03 07:54:42 -04:00
bp2->calcBandpassFilter(0.0, f_high, 1.0);
bp2->run = 1;
2024-06-16 05:31:13 -04:00
}
}
break;
2024-08-03 07:54:42 -04:00
default:
break;
2024-06-16 05:31:13 -04:00
}
}
2024-08-03 07:54:42 -04:00
void TXA::setBandpassNC(int _nc)
2024-07-29 18:45:32 -04:00
{
// NOTE: 'nc' must be >= 'size'
BANDPASS *a;
2024-08-03 07:54:42 -04:00
a = bp0;
2024-07-29 18:45:32 -04:00
2024-08-03 07:54:42 -04:00
if (a->nc != _nc)
2024-07-29 18:45:32 -04:00
{
2024-08-03 07:54:42 -04:00
a->nc = _nc;
std::vector<float> impulse;
FIR::fir_bandpass (
impulse,
2024-07-29 18:45:32 -04:00
a->nc,
a->f_low,
a->f_high,
a->samplerate,
a->wintype,
1,
a->gain / (double)(2 * a->size)
);
a->fircore->setNc(impulse);
2024-07-29 18:45:32 -04:00
}
2024-08-03 07:54:42 -04:00
a = bp1;
2024-07-29 18:45:32 -04:00
2024-08-03 07:54:42 -04:00
if (a->nc != _nc)
2024-07-29 18:45:32 -04:00
{
2024-08-03 07:54:42 -04:00
a->nc = _nc;
std::vector<float> impulse;
FIR::fir_bandpass (
impulse,
2024-07-29 18:45:32 -04:00
a->nc,
a->f_low,
a->f_high,
a->samplerate,
a->wintype,
1,
a->gain / (double)(2 * a->size)
);
a->fircore->setNc(impulse);
2024-07-29 18:45:32 -04:00
}
2024-08-03 07:54:42 -04:00
a = bp2;
2024-07-29 18:45:32 -04:00
2024-08-03 07:54:42 -04:00
if (a->nc != _nc)
2024-07-29 18:45:32 -04:00
{
2024-08-03 07:54:42 -04:00
a->nc = _nc;
std::vector<float> impulse;
FIR::fir_bandpass (
impulse,
2024-07-29 18:45:32 -04:00
a->nc,
a->f_low,
a->f_high,
a->samplerate,
a->wintype,
1,
a->gain / (double)(2 * a->size)
);
a->fircore->setNc(impulse);
2024-07-29 18:45:32 -04:00
}
}
2024-08-03 07:54:42 -04:00
void TXA::setBandpassMP(int _mp)
2024-07-29 18:45:32 -04:00
{
BANDPASS *a;
2024-08-03 07:54:42 -04:00
a = bp0;
2024-07-29 18:45:32 -04:00
2024-08-03 07:54:42 -04:00
if (_mp != a->mp)
2024-07-29 18:45:32 -04:00
{
2024-08-03 07:54:42 -04:00
a->mp = _mp;
2024-08-06 00:26:53 -04:00
a->fircore->setMp(a->mp);
2024-07-29 18:45:32 -04:00
}
2024-08-03 07:54:42 -04:00
a = bp1;
2024-07-29 18:45:32 -04:00
2024-08-03 07:54:42 -04:00
if (_mp != a->mp)
2024-07-29 18:45:32 -04:00
{
2024-08-03 07:54:42 -04:00
a->mp = _mp;
2024-08-06 00:26:53 -04:00
a->fircore->setMp(a->mp);
2024-07-29 18:45:32 -04:00
}
2024-08-03 07:54:42 -04:00
a = bp2;
2024-07-29 18:45:32 -04:00
2024-08-03 07:54:42 -04:00
if (_mp != a->mp)
2024-07-29 18:45:32 -04:00
{
2024-08-03 07:54:42 -04:00
a->mp = _mp;
2024-08-06 00:26:53 -04:00
a->fircore->setMp(a->mp);
2024-07-29 18:45:32 -04:00
}
}
2024-06-16 05:31:13 -04:00
/********************************************************************************************************
* *
* Collectives *
* *
********************************************************************************************************/
2024-08-03 07:54:42 -04:00
void TXA::setNC(int _nc)
2024-06-16 05:31:13 -04:00
{
2024-08-03 07:54:42 -04:00
int oldstate = state;
setBandpassNC (_nc);
2024-08-05 14:05:59 -04:00
preemph->setNC (_nc);
2024-08-03 07:54:42 -04:00
eqp->setNC (_nc);
2024-08-07 15:14:09 -04:00
fmmod->setNC (_nc);
cfir->setNC (_nc);
2024-08-03 07:54:42 -04:00
state = oldstate;
2024-06-16 05:31:13 -04:00
}
2024-08-03 07:54:42 -04:00
void TXA::setMP(int _mp)
2024-06-16 05:31:13 -04:00
{
2024-08-03 07:54:42 -04:00
setBandpassMP (_mp);
2024-08-05 14:05:59 -04:00
preemph->setMP (_mp);
2024-08-03 07:54:42 -04:00
eqp->setMP (_mp);
2024-08-07 15:14:09 -04:00
fmmod->setMP (_mp);
2024-06-16 05:31:13 -04:00
}
2024-08-03 07:54:42 -04:00
void TXA::setFMAFFilter(float _low, float _high)
2024-06-16 05:31:13 -04:00
{
2024-08-05 14:05:59 -04:00
preemph->setFreqs (_low, _high);
2024-08-07 15:14:09 -04:00
fmmod->setAFFreqs (_low, _high);
2024-06-16 05:31:13 -04:00
}
2024-08-05 14:05:59 -04:00
void TXA::SetBPSRun (TXA& txa, int _run)
{
txa.bp1->run = _run;
}
void TXA::SetBPSFreqs (TXA& txa, double _f_low, double _f_high)
{
std::vector<float> impulse;
2024-08-05 14:05:59 -04:00
BPS *a;
a = txa.bps0;
if ((_f_low != a->f_low) || (_f_high != a->f_high))
{
a->f_low = _f_low;
a->f_high = _f_high;
FIR::fir_bandpass(impulse, a->size + 1, _f_low, _f_high, a->samplerate, a->wintype, 1, 1.0 / (float)(2 * a->size));
FIR::fftcv_mults (a->mults, 2 * a->size, impulse.data());
2024-08-05 14:05:59 -04:00
}
a = txa.bps1;
if ((_f_low != a->f_low) || (_f_high != a->f_high))
{
a->f_low = _f_low;
a->f_high = _f_high;
FIR::fir_bandpass(impulse, a->size + 1, _f_low, _f_high, a->samplerate, a->wintype, 1, 1.0 / (float)(2 * a->size));
FIR::fftcv_mults (a->mults, 2 * a->size, impulse.data());
2024-08-05 14:05:59 -04:00
}
a = txa.bps2;
if ((_f_low != a->f_low) || (_f_high != a->f_high))
{
a->f_low = _f_low;
a->f_high = _f_high;
FIR::fir_bandpass(impulse, a->size + 1, _f_low, _f_high, a->samplerate, a->wintype, 1, 1.0 / (float)(2 * a->size));
FIR::fftcv_mults (a->mults, 2 * a->size, impulse.data());
2024-08-05 14:05:59 -04:00
}
}
void TXA::SetBPSWindow (TXA& txa, int _wintype)
{
std::vector<float> impulse;
2024-08-05 14:05:59 -04:00
BPS *a;
a = txa.bps0;
if (a->wintype != _wintype)
{
a->wintype = _wintype;
FIR::fir_bandpass(impulse, a->size + 1, a->f_low, a->f_high, a->samplerate, a->wintype, 1, 1.0 / (float)(2 * a->size));
FIR::fftcv_mults (a->mults, 2 * a->size, impulse.data());
2024-08-05 14:05:59 -04:00
}
a = txa.bps1;
if (a->wintype != _wintype)
{
a->wintype = _wintype;
FIR::fir_bandpass(impulse, a->size + 1, a->f_low, a->f_high, a->samplerate, a->wintype, 1, 1.0 / (float)(2 * a->size));
FIR::fftcv_mults (a->mults, 2 * a->size, impulse.data());
2024-08-05 14:05:59 -04:00
}
a = txa.bps2;
if (a->wintype != _wintype)
{
a->wintype = _wintype;
FIR::fir_bandpass (impulse, a->size + 1, a->f_low, a->f_high, a->samplerate, a->wintype, 1, 1.0 / (float)(2 * a->size));
FIR::fftcv_mults (a->mults, 2 * a->size, impulse.data());
2024-08-07 15:14:09 -04:00
}
}
void TXA::SetCompressorRun (TXA& txa, int _run)
{
if (txa.compressor->run != _run)
{
txa.compressor->run = _run;
txa.setupBPFilters();
2024-08-05 14:05:59 -04:00
}
}
2024-08-07 15:14:09 -04:00
void TXA::SetosctrlRun (TXA& txa, int run)
{
if (txa.osctrl->run != run)
{
txa.osctrl->run = run;
txa.setupBPFilters();
}
}
void TXA::GetiqcValues (TXA& txa, std::vector<double>& cm, std::vector<double>& cc, std::vector<double>& cs)
{
IQC *a;
a = txa.iqc.p0;
cm.resize(a->ints * 4);
cc.resize(a->ints * 4);
cs.resize(a->ints * 4);
std::copy(a->cm[a->cset].begin(), a->cm[a->cset].begin() + a->ints * 4, cm.begin());
std::copy(a->cc[a->cset].begin(), a->cc[a->cset].begin() + a->ints * 4, cc.begin());
std::copy(a->cs[a->cset].begin(), a->cs[a->cset].begin() + a->ints * 4, cs.begin());
}
void TXA::SetiqcValues (TXA& txa, const std::vector<double>& cm, const std::vector<double>& cc, const std::vector<double>& cs)
{
IQC *a;
a = txa.iqc.p0;
a->cset = 1 - a->cset;
std::copy(cm.begin(), cm.begin() + a->ints * 4, a->cm[a->cset].begin());
std::copy(cc.begin(), cc.begin() + a->ints * 4, a->cc[a->cset].begin());
std::copy(cs.begin(), cs.begin() + a->ints * 4, a->cs[a->cset].begin());
a->state = IQC::IQCSTATE::RUN;
}
void TXA::SetiqcSwap (TXA& txa, const std::vector<double>& cm, const std::vector<double>& cc, const std::vector<double>& cs)
{
IQC *a = txa.iqc.p1;
a->cset = 1 - a->cset;
std::copy(cm.begin(), cm.begin() + a->ints * 4, a->cm[a->cset].begin());
std::copy(cc.begin(), cc.begin() + a->ints * 4, a->cc[a->cset].begin());
std::copy(cs.begin(), cs.begin() + a->ints * 4, a->cs[a->cset].begin());
a->busy = 1;
a->state = IQC::IQCSTATE::SWAP;
a->count = 0;
}
void TXA::SetiqcStart (TXA& txa, const std::vector<double>& cm, const std::vector<double>& cc, const std::vector<double>& cs)
{
IQC *a = txa.iqc.p1;
a->cset = 0;
std::copy(cm.begin(), cm.begin() + a->ints * 4, a->cm[a->cset].begin());
std::copy(cc.begin(), cc.begin() + a->ints * 4, a->cc[a->cset].begin());
std::copy(cs.begin(), cs.begin() + a->ints * 4, a->cs[a->cset].begin());
a->busy = 1;
a->state = IQC::IQCSTATE::BEGIN;
a->count = 0;
txa.iqc.p1->run = 1;
}
void TXA::SetiqcEnd (TXA& txa)
{
IQC *a = txa.iqc.p1;
a->busy = 1;
a->state = IQC::IQCSTATE::END;
a->count = 0;
txa.iqc.p1->run = 0;
}
void TXA::GetiqcDogCount (TXA& txa, int* count)
{
IQC *a = txa.iqc.p1;
*count = a->dog.count;
}
void TXA::SetiqcDogCount (TXA& txa, int count)
{
IQC *a = txa.iqc.p1;
a->dog.count = count;
}
2024-08-05 14:05:59 -04:00
2024-06-16 05:31:13 -04:00
} // namespace WDSP