1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-09-21 04:16:34 -04:00

WDSP: BANDPASS rework

This commit is contained in:
f4exb 2024-07-30 00:45:32 +02:00
parent bc06095a56
commit 575fa755f8
5 changed files with 291 additions and 297 deletions

View File

@ -444,7 +444,7 @@ RXA* RXA::create_rxa (
&rxa->agc->gain); // pointer for gain computation
// Bandpass filter - After spectral noise reduction in the block diagram
rxa->bp1 = BANDPASS::create_bandpass (
rxa->bp1 = new BANDPASS (
1, // run - used only with ( AM || ANF || ANR || EMNR)
0, // position
rxa->dsp_size, // buffer size
@ -570,7 +570,7 @@ void RXA::destroy_rxa (RXA *rxa)
SPEAK::destroy_speak (rxa->speak);
CBL::destroy_cbl (rxa->cbl);
SIPHON::destroy_siphon (rxa->sip1);
BANDPASS::destroy_bandpass (rxa->bp1);
delete (rxa->bp1);
delete (rxa->agcmeter);
delete (rxa->agc);
delete (rxa->emnr);
@ -623,7 +623,7 @@ void RXA::flush_rxa (RXA *rxa)
rxa->emnr->flush();
rxa->agc->flush();
rxa->agcmeter->flush();
BANDPASS::flush_bandpass (rxa->bp1);
rxa->bp1->flush();
SIPHON::flush_siphon (rxa->sip1);
CBL::flush_cbl (rxa->cbl);
SPEAK::flush_speak (rxa->speak);
@ -656,12 +656,12 @@ void RXA::xrxa (RXA *rxa)
rxa->anf->execute(0);
rxa->anr->ANR::execute(0);
rxa->emnr->execute(0);
BANDPASS::xbandpass (rxa->bp1, 0);
rxa->bp1->BANDPASS::execute(0);
rxa->agc->execute();
rxa->anf->execute(1);
rxa->anr->execute(1);
rxa->emnr->execute(1);
BANDPASS::xbandpass (rxa->bp1, 1);
rxa->bp1->execute(1);
rxa->agcmeter->execute();
SIPHON::xsiphon (rxa->sip1, 0);
CBL::xcbl (rxa->cbl);
@ -767,7 +767,7 @@ void RXA::setDSPSamplerate (RXA *rxa, int dsp_rate)
rxa->anf->setSamplerate(rxa->dsp_rate);
rxa->anr->setSamplerate(rxa->dsp_rate);
rxa->emnr->setSamplerate(rxa->dsp_rate);
BANDPASS::setSamplerate_bandpass (rxa->bp1, rxa->dsp_rate);
rxa->bp1->setSamplerate(rxa->dsp_rate);
rxa->agc->setSamplerate(rxa->dsp_rate);
rxa->agcmeter->setSamplerate(rxa->dsp_rate);
SIPHON::setSamplerate_siphon (rxa->sip1, rxa->dsp_rate);
@ -843,8 +843,8 @@ void RXA::setDSPBuffsize (RXA *rxa, int dsp_size)
rxa->anr->setSize(rxa->dsp_size);
rxa->emnr->setBuffers(rxa->midbuff, rxa->midbuff);
rxa->emnr->setSize(rxa->dsp_size);
BANDPASS::setBuffers_bandpass (rxa->bp1, rxa->midbuff, rxa->midbuff);
BANDPASS::setSize_bandpass (rxa->bp1, rxa->dsp_size);
rxa->bp1->setBuffers(rxa->midbuff, rxa->midbuff);
rxa->bp1->setSize(rxa->dsp_size);
rxa->agc->setBuffers(rxa->midbuff, rxa->midbuff);
rxa->agc->setSize(rxa->dsp_size);
rxa->agcmeter->setBuffers(rxa->midbuff);
@ -957,7 +957,7 @@ void RXA::bp1Check (
else
gain = 1.0;
if (a->gain != gain)
BANDPASS::setGain_bandpass (a, gain, 0);
a->setGain(gain, 0);
}
void RXA::bp1Set (RXA& rxa)
@ -974,8 +974,8 @@ void RXA::bp1Set (RXA& rxa)
else
a->run = 0;
if (!old && a->run)
BANDPASS::flush_bandpass (a);
FIRCORE::setUpdate_fircore (a->p);
a->flush();
FIRCORE::setUpdate_fircore (a->fircore);
}
void RXA::bpsnbaCheck (RXA& rxa, int mode, int notch_run)
@ -1368,7 +1368,7 @@ void RXA::SetAGCThresh(RXA& rxa, double thresh, double size, double rate)
void RXA::SetPassband (RXA& rxa, float f_low, float f_high)
{
BANDPASS::SetBandpassFreqs (rxa, f_low, f_high); // After spectral noise reduction ( AM || ANF || ANR || EMNR)
rxa.bp1->setBandpassFreqs (f_low, f_high); // After spectral noise reduction ( AM || ANF || ANR || EMNR)
rxa.snba->setOutputBandwidth (f_low, f_high); // Spectral noise blanker (SNB)
rxa.nbp0->SetFreqs (f_low, f_high); // Notched bandpass
}
@ -1378,7 +1378,7 @@ void RXA::SetNC (RXA& rxa, int nc)
int oldstate = rxa.state;
rxa.nbp0->SetNC (nc);
rxa.bpsnba->SetNC (nc);
BANDPASS::SetBandpassNC (rxa, nc);
rxa.bp1->SetBandpassNC (nc);
rxa.eqp->setNC (nc);
rxa.fmsq->setNC (nc);
rxa.fmd->setNCde (nc);
@ -1390,7 +1390,7 @@ void RXA::SetMP (RXA& rxa, int mp)
{
rxa.nbp0->SetMP (mp);
rxa.bpsnba->SetMP (mp);
BANDPASS::SetBandpassMP (rxa, mp);
rxa.bp1->SetBandpassMP (mp);
rxa.eqp->setMP (mp);
rxa.fmsq->setMP (mp);
rxa.fmd->setMPde (mp);

View File

@ -47,6 +47,8 @@ warren@wpratt.com
#include "slew.hpp"
#include "iqc.hpp"
#include "cfir.hpp"
#include "fircore.hpp"
#include "fir.hpp"
#include "TXA.hpp"
namespace WDSP {
@ -276,7 +278,7 @@ TXA* TXA::create_txa (
TXA_CFC_GAIN, // index for gain value
(double*) &txa->cfcomp->gain); // pointer for gain computation
txa->bp0 = BANDPASS::create_bandpass (
txa->bp0 = new BANDPASS(
1, // always runs
0, // position
txa->dsp_size, // size
@ -297,7 +299,7 @@ TXA* TXA::create_txa (
txa->midbuff, // pointer to output buffer
3.0); // gain
txa->bp1 = BANDPASS::create_bandpass (
txa->bp1 = new BANDPASS(
0, // ONLY RUNS WHEN COMPRESSOR IS USED
0, // position
txa->dsp_size, // size
@ -319,7 +321,7 @@ TXA* TXA::create_txa (
txa->dsp_rate, // sample rate
1.95); // gain for clippings
txa->bp2 = BANDPASS::create_bandpass (
txa->bp2 = new BANDPASS(
0, // ONLY RUNS WHEN COMPRESSOR IS USED
0, // position
txa->dsp_size, // size
@ -532,11 +534,11 @@ void TXA::destroy_txa (TXA *txa)
AMMOD::destroy_ammod (txa->ammod);
delete (txa->alc);
delete (txa->compmeter);
BANDPASS::destroy_bandpass (txa->bp2);
delete (txa->bp2);
OSCTRL::destroy_osctrl (txa->osctrl);
BANDPASS::destroy_bandpass (txa->bp1);
delete (txa->bp1);
COMPRESSOR::destroy_compressor (txa->compressor);
BANDPASS::destroy_bandpass (txa->bp0);
delete (txa->bp0);
delete (txa->cfcmeter);
CFCOMP::destroy_cfcomp (txa->cfcomp);
delete (txa->lvlrmeter);
@ -574,11 +576,11 @@ void TXA::flush_txa (TXA* txa)
txa->lvlrmeter->flush ();
CFCOMP::flush_cfcomp (txa->cfcomp);
txa->cfcmeter->flush ();
BANDPASS::flush_bandpass (txa->bp0);
txa->bp0->flush ();
COMPRESSOR::flush_compressor (txa->compressor);
BANDPASS::flush_bandpass (txa->bp1);
txa->bp1->flush ();
OSCTRL::flush_osctrl (txa->osctrl);
BANDPASS::flush_bandpass (txa->bp2);
txa->bp2->flush ();
txa->compmeter->flush ();
txa->alc->flush ();
AMMOD::flush_ammod (txa->ammod);
@ -609,11 +611,11 @@ void xtxa (TXA* txa)
txa->lvlrmeter->execute (); // Leveler Meter
CFCOMP::xcfcomp (txa->cfcomp, 0); // Continuous Frequency Compressor with post-EQ
txa->cfcmeter->execute (); // CFC+PostEQ Meter
BANDPASS::xbandpass (txa->bp0, 0); // primary bandpass filter
txa->bp0->execute (0); // primary bandpass filter
COMPRESSOR::xcompressor (txa->compressor); // COMP compressor
BANDPASS::xbandpass (txa->bp1, 0); // aux bandpass (runs if COMP)
txa->bp1->execute (0); // aux bandpass (runs if COMP)
OSCTRL::xosctrl (txa->osctrl); // CESSB Overshoot Control
BANDPASS::xbandpass (txa->bp2, 0); // aux bandpass (runs if CESSB)
txa->bp2->execute (0); // aux bandpass (runs if CESSB)
txa->compmeter->execute (); // COMP meter
txa->alc->execute (); // ALC
AMMOD::xammod (txa->ammod); // AM Modulator
@ -706,11 +708,11 @@ void TXA::setDSPSamplerate (TXA *txa, int dsp_rate)
txa->lvlrmeter->setSamplerate (txa->dsp_rate);
CFCOMP::setSamplerate_cfcomp (txa->cfcomp, txa->dsp_rate);
txa->cfcmeter->setSamplerate (txa->dsp_rate);
BANDPASS::setSamplerate_bandpass (txa->bp0, txa->dsp_rate);
txa->bp0->setSamplerate (txa->dsp_rate);
COMPRESSOR::setSamplerate_compressor (txa->compressor, txa->dsp_rate);
BANDPASS::setSamplerate_bandpass (txa->bp1, txa->dsp_rate);
txa->bp1->setSamplerate (txa->dsp_rate);
OSCTRL::setSamplerate_osctrl (txa->osctrl, txa->dsp_rate);
BANDPASS::setSamplerate_bandpass (txa->bp2, txa->dsp_rate);
txa->bp2->setSamplerate (txa->dsp_rate);
txa->compmeter->setSamplerate (txa->dsp_rate);
txa->alc->setSamplerate (txa->dsp_rate);
AMMOD::setSamplerate_ammod (txa->ammod, txa->dsp_rate);
@ -778,16 +780,16 @@ void TXA::setDSPBuffsize (TXA *txa, int dsp_size)
CFCOMP::setSize_cfcomp (txa->cfcomp, txa->dsp_size);
txa->cfcmeter->setBuffers(txa->midbuff);
txa->cfcmeter->setSize(txa->dsp_size);
BANDPASS::setBuffers_bandpass (txa->bp0, txa->midbuff, txa->midbuff);
BANDPASS::setSize_bandpass (txa->bp0, txa->dsp_size);
txa->bp0->setBuffers (txa->midbuff, txa->midbuff);
txa->bp0->setSize (txa->dsp_size);
COMPRESSOR::setBuffers_compressor (txa->compressor, txa->midbuff, txa->midbuff);
COMPRESSOR::setSize_compressor (txa->compressor, txa->dsp_size);
BANDPASS::setBuffers_bandpass (txa->bp1, txa->midbuff, txa->midbuff);
BANDPASS::setSize_bandpass (txa->bp1, txa->dsp_size);
txa->bp1->setBuffers (txa->midbuff, txa->midbuff);
txa->bp1->setSize (txa->dsp_size);
OSCTRL::setBuffers_osctrl (txa->osctrl, txa->midbuff, txa->midbuff);
OSCTRL::setSize_osctrl (txa->osctrl, txa->dsp_size);
BANDPASS::setBuffers_bandpass (txa->bp2, txa->midbuff, txa->midbuff);
BANDPASS::setSize_bandpass (txa->bp2, txa->dsp_size);
txa->bp2->setBuffers (txa->midbuff, txa->midbuff);
txa->bp2->setSize (txa->dsp_size);
txa->compmeter->setBuffers(txa->midbuff);
txa->compmeter->setSize(txa->dsp_size);
txa->alc->setBuffers(txa->midbuff, txa->midbuff);
@ -914,14 +916,14 @@ void TXA::SetupBPFilters (TXA& txa)
case TXA_DIGU:
case TXA_SPEC:
case TXA_DRM:
BANDPASS::CalcBandpassFilter (txa.bp0, txa.f_low, txa.f_high, 2.0);
txa.bp0->calcBandpassFilter (txa.f_low, txa.f_high, 2.0);
if (txa.compressor->run)
{
BANDPASS::CalcBandpassFilter (txa.bp1, txa.f_low, txa.f_high, 2.0);
txa.bp1->calcBandpassFilter (txa.f_low, txa.f_high, 2.0);
txa.bp1->run = 1;
if (txa.osctrl->run)
{
BANDPASS::CalcBandpassFilter (txa.bp2, txa.f_low, txa.f_high, 1.0);
txa.bp2->calcBandpassFilter (txa.f_low, txa.f_high, 1.0);
txa.bp2->run = 1;
}
}
@ -932,42 +934,42 @@ void TXA::SetupBPFilters (TXA& txa)
case TXA_FM:
if (txa.compressor->run)
{
BANDPASS::CalcBandpassFilter (txa.bp0, 0.0, txa.f_high, 2.0);
BANDPASS::CalcBandpassFilter (txa.bp1, 0.0, txa.f_high, 2.0);
txa.bp0->calcBandpassFilter (0.0, txa.f_high, 2.0);
txa.bp1->calcBandpassFilter (0.0, txa.f_high, 2.0);
txa.bp1->run = 1;
if (txa.osctrl->run)
{
BANDPASS::CalcBandpassFilter (txa.bp2, 0.0, txa.f_high, 1.0);
txa.bp2->calcBandpassFilter (0.0, txa.f_high, 1.0);
txa.bp2->run = 1;
}
}
else
{
BANDPASS::CalcBandpassFilter (txa.bp0, txa.f_low, txa.f_high, 1.0);
txa.bp0->calcBandpassFilter (txa.f_low, txa.f_high, 1.0);
}
break;
case TXA_AM_LSB:
BANDPASS::CalcBandpassFilter (txa.bp0, -txa.f_high, 0.0, 2.0);
txa.bp0->calcBandpassFilter (-txa.f_high, 0.0, 2.0);
if (txa.compressor->run)
{
BANDPASS::CalcBandpassFilter (txa.bp1, -txa.f_high, 0.0, 2.0);
txa.bp1->calcBandpassFilter (-txa.f_high, 0.0, 2.0);
txa.bp1->run = 1;
if (txa.osctrl->run)
{
BANDPASS::CalcBandpassFilter (txa.bp2, -txa.f_high, 0.0, 1.0);
txa.bp2->calcBandpassFilter (-txa.f_high, 0.0, 1.0);
txa.bp2->run = 1;
}
}
break;
case TXA_AM_USB:
BANDPASS::CalcBandpassFilter (txa.bp0, 0.0, txa.f_high, 2.0);
txa.bp0->calcBandpassFilter (0.0, txa.f_high, 2.0);
if (txa.compressor->run)
{
BANDPASS::CalcBandpassFilter (txa.bp1, 0.0, txa.f_high, 2.0);
txa.bp1->calcBandpassFilter (0.0, txa.f_high, 2.0);
txa.bp1->run = 1;
if (txa.osctrl->run)
{
BANDPASS::CalcBandpassFilter (txa.bp2, 0.0, txa.f_high, 1.0);
txa.bp2->calcBandpassFilter(0.0, txa.f_high, 1.0);
txa.bp2->run = 1;
}
}
@ -975,6 +977,93 @@ void TXA::SetupBPFilters (TXA& txa)
}
}
void TXA::SetBandpassNC (TXA& txa, int nc)
{
// NOTE: 'nc' must be >= 'size'
BANDPASS *a;
a = txa.bp0;
if (a->nc != nc)
{
a->nc = nc;
float* impulse = FIR::fir_bandpass (
a->nc,
a->f_low,
a->f_high,
a->samplerate,
a->wintype,
1,
a->gain / (double)(2 * a->size)
);
FIRCORE::setNc_fircore (a->fircore, a->nc, impulse);
delete[] (impulse);
}
a = txa.bp1;
if (a->nc != nc)
{
a->nc = nc;
float* impulse = FIR::fir_bandpass (
a->nc,
a->f_low,
a->f_high,
a->samplerate,
a->wintype,
1,
a->gain / (double)(2 * a->size)
);
FIRCORE::setNc_fircore (a->fircore, a->nc, impulse);
delete[] (impulse);
}
a = txa.bp2;
if (a->nc != nc)
{
a->nc = nc;
float* impulse = FIR::fir_bandpass (
a->nc,
a->f_low,
a->f_high,
a->samplerate,
a->wintype,
1,
a->gain / (double)(2 * a->size)
);
FIRCORE::setNc_fircore (a->fircore, a->nc, impulse);
delete[] (impulse);
}
}
void TXA::SetBandpassMP (TXA& txa, int mp)
{
BANDPASS *a;
a = txa.bp0;
if (mp != a->mp)
{
a->mp = mp;
FIRCORE::setMp_fircore (a->fircore, a->mp);
}
a = txa.bp1;
if (mp != a->mp)
{
a->mp = mp;
FIRCORE::setMp_fircore (a->fircore, a->mp);
}
a = txa.bp2;
if (mp != a->mp)
{
a->mp = mp;
FIRCORE::setMp_fircore (a->fircore, a->mp);
}
}
/********************************************************************************************************
* *
* Collectives *
@ -984,7 +1073,8 @@ void TXA::SetupBPFilters (TXA& txa)
void TXA::SetNC (TXA& txa, int nc)
{
int oldstate = txa.state;
BANDPASS::SetBandpassNC (txa, nc);
SetBandpassNC (txa, nc);
EMPHP::SetFMEmphNC (txa, nc);
txa.eqp->setNC (nc);
FMMOD::SetFMNC (txa, nc);
@ -994,7 +1084,7 @@ void TXA::SetNC (TXA& txa, int nc)
void TXA::SetMP (TXA& txa, int mp)
{
BANDPASS::SetBandpassMP (txa, mp);
SetBandpassMP (txa, mp);
EMPHP::SetFMEmphMP (txa, mp);
txa.eqp->setMP (mp);
FMMOD::SetFMMP (txa, mp);

View File

@ -191,6 +191,8 @@ public:
// TXA Properties
static void SetMode (TXA& txa, int mode);
static void SetBandpassFreqs (TXA& txa, float f_low, float f_high);
static void SetBandpassNC (TXA& txa, int nc);
static void SetBandpassMP (TXA& txa, int mp);
// Collectives
static void SetNC (TXA& txa, int nc);

View File

@ -40,143 +40,140 @@ namespace WDSP {
* *
********************************************************************************************************/
BANDPASS* BANDPASS::create_bandpass (
int run,
int position,
int size,
int nc,
int mp,
float* in,
float* out,
double f_low,
double f_high,
int samplerate,
int wintype,
double gain
BANDPASS::BANDPASS(
int _run,
int _position,
int _size,
int _nc,
int _mp,
float* _in,
float* _out,
double _f_low,
double _f_high,
int _samplerate,
int _wintype,
double _gain
)
{
// NOTE: 'nc' must be >= 'size'
BANDPASS *a = new BANDPASS;
a->run = run;
a->position = position;
a->size = size;
a->nc = nc;
a->mp = mp;
a->in = in;
a->out = out;
a->f_low = f_low;
a->f_high = f_high;
a->samplerate = samplerate;
a->wintype = wintype;
a->gain = gain;
run = _run;
position = _position;
size = _size;
nc = _nc;
mp = _mp;
in = _in;
out = _out;
f_low = _f_low;
f_high = _f_high;
samplerate = _samplerate;
wintype = _wintype;
gain = _gain;
float* impulse = FIR::fir_bandpass (
a->nc,
a->f_low,
a->f_high,
a->samplerate,
a->wintype,
nc,
f_low,
f_high,
samplerate,
wintype,
1,
a->gain / (double)(2 * a->size)
gain / (double)(2 * size)
);
a->p = FIRCORE::create_fircore (a->size, a->in, a->out, a->nc, a->mp, impulse);
delete[] impulse;
return a;
}
void BANDPASS::destroy_bandpass (BANDPASS *a)
{
FIRCORE::destroy_fircore (a->p);
delete a;
}
void BANDPASS::flush_bandpass (BANDPASS *a)
{
FIRCORE::flush_fircore (a->p);
}
void BANDPASS::xbandpass (BANDPASS *a, int pos)
{
if (a->run && a->position == pos)
FIRCORE::xfircore (a->p);
else if (a->out != a->in)
std::copy( a->in, a->in + a->size * 2, a->out);
}
void BANDPASS::setBuffers_bandpass (BANDPASS *a, float* in, float* out)
{
a->in = in;
a->out = out;
FIRCORE::setBuffers_fircore (a->p, a->in, a->out);
}
void BANDPASS::setSamplerate_bandpass (BANDPASS *a, int rate)
{
a->samplerate = rate;
float* impulse = FIR::fir_bandpass (
a->nc,
a->f_low,
a->f_high,
a->samplerate,
a->wintype,
1,
a->gain / (float)(2 * a->size)
);
FIRCORE::setImpulse_fircore (a->p, impulse, 1);
fircore = FIRCORE::create_fircore (size, in, out, nc, mp, impulse);
delete[] impulse;
}
void BANDPASS::setSize_bandpass (BANDPASS *a, int size)
BANDPASS::~BANDPASS()
{
FIRCORE::destroy_fircore (fircore);
}
void BANDPASS::flush()
{
FIRCORE::flush_fircore(fircore);
}
void BANDPASS::execute(int pos)
{
if (run && position == pos)
FIRCORE::xfircore(fircore);
else if (out != in)
std::copy(in, in + size * 2, out);
}
void BANDPASS::setBuffers(float* _in, float* _out)
{
in = _in;
out = _out;
FIRCORE::setBuffers_fircore(fircore, in, out);
}
void BANDPASS::setSamplerate(int _rate)
{
samplerate = _rate;
float* impulse = FIR::fir_bandpass (
nc,
f_low,
f_high,
samplerate,
wintype,
1,
gain / (double) (2 * size)
);
FIRCORE::setImpulse_fircore (fircore, impulse, 1);
delete[] impulse;
}
void BANDPASS::setSize(int _size)
{
// NOTE: 'size' must be <= 'nc'
a->size = size;
FIRCORE::setSize_fircore (a->p, a->size);
size = _size;
FIRCORE::setSize_fircore (fircore, size);
// recalc impulse because scale factor is a function of size
float* impulse = FIR::fir_bandpass (
a->nc,
a->f_low,
a->f_high,
a->samplerate,
a->wintype,
nc,
f_low,
f_high,
samplerate,
wintype,
1,
a->gain / (float)(2 * a->size)
gain / (double) (2 * size)
);
FIRCORE::setImpulse_fircore (a->p, impulse, 1);
FIRCORE::setImpulse_fircore (fircore, impulse, 1);
delete[] (impulse);
}
void BANDPASS::setGain_bandpass (BANDPASS *a, double gain, int update)
void BANDPASS::setGain(double _gain, int _update)
{
a->gain = gain;
gain = _gain;
float* impulse = FIR::fir_bandpass (
a->nc,
a->f_low,
a->f_high,
a->samplerate,
a->wintype,
nc,
f_low,
f_high,
samplerate,
wintype,
1,
a->gain / (double)(2 * a->size)
gain / (double) (2 * size)
);
FIRCORE::setImpulse_fircore (a->p, impulse, update);
FIRCORE::setImpulse_fircore (fircore, impulse, _update);
delete[] (impulse);
}
void BANDPASS::CalcBandpassFilter (BANDPASS *a, double f_low, double f_high, double gain)
void BANDPASS::calcBandpassFilter(double _f_low, double _f_high, double _gain)
{
if ((a->f_low != f_low) || (a->f_high != f_high) || (a->gain != gain))
if ((f_low != _f_low) || (f_high != _f_high) || (gain != _gain))
{
a->f_low = f_low;
a->f_high = f_high;
a->gain = gain;
f_low = _f_low;
f_high = _f_high;
gain = _gain;
float* impulse = FIR::fir_bandpass (
a->nc,
a->f_low,
a->f_high,
a->samplerate,
a->wintype,
nc,
f_low,
f_high,
samplerate,
wintype,
1,
a->gain / (double)(2 * a->size)
gain / (double)(2 * size)
);
FIRCORE::setImpulse_fircore (a->p, impulse, 1);
FIRCORE::setImpulse_fircore (fircore, impulse, 1);
delete[] (impulse);
}
}
@ -187,62 +184,54 @@ void BANDPASS::CalcBandpassFilter (BANDPASS *a, double f_low, double f_high, dou
* *
********************************************************************************************************/
void BANDPASS::SetBandpassFreqs (RXA& rxa, double f_low, double f_high)
void BANDPASS::setBandpassFreqs(double _f_low, double _f_high)
{
BANDPASS *a = rxa.bp1;
if ((f_low != a->f_low) || (f_high != a->f_high))
if ((_f_low != f_low) || (_f_high != f_high))
{
float* impulse = FIR::fir_bandpass (
a->nc,
f_low,
f_high,
a->samplerate,
a->wintype,
nc,
_f_low,
_f_high,
samplerate,
wintype,
1,
a->gain / (double)(2 * a->size)
gain / (double)(2 * size)
);
FIRCORE::setImpulse_fircore (a->p, impulse, 0);
FIRCORE::setImpulse_fircore (fircore, impulse, 0);
delete[] (impulse);
a->f_low = f_low;
a->f_high = f_high;
FIRCORE::setUpdate_fircore (a->p);
f_low = _f_low;
f_high = _f_high;
FIRCORE::setUpdate_fircore (fircore);
}
}
void BANDPASS::SetBandpassNC (RXA& rxa, int nc)
void BANDPASS::SetBandpassNC(int _nc)
{
// NOTE: 'nc' must be >= 'size'
BANDPASS *a;
a = rxa.bp1;
if (nc != a->nc)
if (_nc != nc)
{
a->nc = nc;
nc = _nc;
float* impulse = FIR::fir_bandpass (
a->nc,
a->f_low,
a->f_high,
a->samplerate,
a->wintype,
nc,
f_low,
f_high,
samplerate,
wintype,
1,
a->gain / (double)(2 * a->size)
gain / (double)( 2 * size)
);
FIRCORE::setNc_fircore (a->p, a->nc, impulse);
FIRCORE::setNc_fircore (fircore, nc, impulse);
delete[] (impulse);
}
}
void BANDPASS::SetBandpassMP (RXA& rxa, int mp)
void BANDPASS::SetBandpassMP(int _mp)
{
BANDPASS *a;
a = rxa.bp1;
if (mp != a->mp)
if (_mp != mp)
{
a->mp = mp;
FIRCORE::setMp_fircore (a->p, a->mp);
mp = _mp;
FIRCORE::setMp_fircore (fircore, mp);
}
}
@ -263,7 +252,7 @@ void BANDPASS::SetBandpassMP (RXA& rxa, int mp)
// a->f_low = f_low;
// a->f_high = f_high;
// impulse = fir_bandpass (a->nc, a->f_low, a->f_high, a->samplerate, a->wintype, 1, a->gain / (float)(2 * a->size));
// setImpulse_fircore (a->p, impulse, 1);
// setImpulse_fircore (a->fircore, impulse, 1);
// delete[] (impulse);
// }
// a = txa.bp1;
@ -272,7 +261,7 @@ void BANDPASS::SetBandpassMP (RXA& rxa, int mp)
// a->f_low = f_low;
// a->f_high = f_high;
// impulse = fir_bandpass (a->nc, a->f_low, a->f_high, a->samplerate, a->wintype, 1, a->gain / (float)(2 * a->size));
// setImpulse_fircore (a->p, impulse, 1);
// setImpulse_fircore (a->fircore, impulse, 1);
// delete[] (impulse);
// }
// a = txa.bp2;
@ -281,96 +270,9 @@ void BANDPASS::SetBandpassMP (RXA& rxa, int mp)
// a->f_low = f_low;
// a->f_high = f_high;
// impulse = fir_bandpass (a->nc, a->f_low, a->f_high, a->samplerate, a->wintype, 1, a->gain / (float)(2 * a->size));
// setImpulse_fircore (a->p, impulse, 1);
// setImpulse_fircore (a->fircore, impulse, 1);
// delete[] (impulse);
// }
//}
void BANDPASS::SetBandpassNC (TXA& txa, int nc)
{
// NOTE: 'nc' must be >= 'size'
BANDPASS *a;
a = txa.bp0;
if (a->nc != nc)
{
a->nc = nc;
float* impulse = FIR::fir_bandpass (
a->nc,
a->f_low,
a->f_high,
a->samplerate,
a->wintype,
1,
a->gain / (double)(2 * a->size)
);
FIRCORE::setNc_fircore (a->p, a->nc, impulse);
delete[] (impulse);
}
a = txa.bp1;
if (a->nc != nc)
{
a->nc = nc;
float* impulse = FIR::fir_bandpass (
a->nc,
a->f_low,
a->f_high,
a->samplerate,
a->wintype,
1,
a->gain / (double)(2 * a->size)
);
FIRCORE::setNc_fircore (a->p, a->nc, impulse);
delete[] (impulse);
}
a = txa.bp2;
if (a->nc != nc)
{
a->nc = nc;
float* impulse = FIR::fir_bandpass (
a->nc,
a->f_low,
a->f_high,
a->samplerate,
a->wintype,
1,
a->gain / (double)(2 * a->size)
);
FIRCORE::setNc_fircore (a->p, a->nc, impulse);
delete[] (impulse);
}
}
void BANDPASS::SetBandpassMP (TXA& txa, int mp)
{
BANDPASS *a;
a = txa.bp0;
if (mp != a->mp)
{
a->mp = mp;
FIRCORE::setMp_fircore (a->p, a->mp);
}
a = txa.bp1;
if (mp != a->mp)
{
a->mp = mp;
FIRCORE::setMp_fircore (a->p, a->mp);
}
a = txa.bp2;
if (mp != a->mp)
{
a->mp = mp;
FIRCORE::setMp_fircore (a->p, a->mp);
}
}
} // namespace WDSP

View File

@ -64,9 +64,9 @@ public:
double samplerate;
int wintype;
double gain;
FIRCORE *p;
FIRCORE *fircore;
static BANDPASS *create_bandpass (
BANDPASS(
int run,
int position,
int size,
@ -80,21 +80,21 @@ public:
int wintype,
double gain
);
static void destroy_bandpass (BANDPASS *a);
static void flush_bandpass (BANDPASS *a);
static void xbandpass (BANDPASS *a, int pos);
static void setBuffers_bandpass (BANDPASS *a, float* in, float* out);
static void setSamplerate_bandpass (BANDPASS *a, int rate);
static void setSize_bandpass (BANDPASS *a, int size);
static void setGain_bandpass (BANDPASS *a, double gain, int update);
static void CalcBandpassFilter (BANDPASS *a, double f_low, double f_high, double gain);
BANDPASS(const BANDPASS&) = delete;
BANDPASS& operator=(const BANDPASS& other) = delete;
~BANDPASS();
void flush();
void execute(int pos);
void setBuffers(float* in, float* out);
void setSamplerate(int rate);
void setSize(int size);
void setGain(double gain, int update);
void calcBandpassFilter(double f_low, double f_high, double gain);
// RXA Prototypes
static void SetBandpassFreqs (RXA& rxa, double f_low, double f_high);
static void SetBandpassNC (RXA& rxa, int nc);
static void SetBandpassMP (RXA& rxa, int mp);
// TXA Prototypes
static void SetBandpassNC (TXA& txa, int nc);
static void SetBandpassMP (TXA& txa, int mp);
void setBandpassFreqs(double f_low, double f_high);
void SetBandpassNC(int nc);
void SetBandpassMP(int mp);
};
} // namespace WDSP