1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-10 18:43:28 -05:00

WDSP: BPSNBA: replaced static methods

This commit is contained in:
f4exb 2024-07-24 23:11:29 +02:00
parent cc8c6d8004
commit 0bd4bbe0d4
3 changed files with 139 additions and 145 deletions

View File

@ -180,7 +180,7 @@ RXA* RXA::create_rxa (
rxa->ndb); // addr of database pointer
// bandpass for snba
rxa->bpsnba = BPSNBA::create_bpsnba (
rxa->bpsnba = new BPSNBA (
0, // bpsnba run flag
0, // run the notches
0, // position
@ -584,7 +584,7 @@ void RXA::destroy_rxa (RXA *rxa)
AMSQ::destroy_amsq (rxa->amsq);
delete (rxa->smeter);
SENDER::destroy_sender (rxa->sender);
BPSNBA::destroy_bpsnba (rxa->bpsnba);
delete (rxa->bpsnba);
delete (rxa->nbp0);
delete (rxa->ndb);
delete (rxa->adcmeter);
@ -609,7 +609,7 @@ void RXA::flush_rxa (RXA *rxa)
rxa->rsmpin->flush();
rxa->adcmeter->flush();
rxa->nbp0->flush();
BPSNBA::flush_bpsnba (rxa->bpsnba);
rxa->bpsnba->flush();
SENDER::flush_sender (rxa->sender);
rxa->smeter->flush();
AMSQ::flush_amsq (rxa->amsq);
@ -640,17 +640,17 @@ void RXA::xrxa (RXA *rxa)
rxa->shift->execute();
rxa->rsmpin->execute();
rxa->adcmeter->execute();
BPSNBA::xbpsnbain (rxa->bpsnba, 0);
rxa->bpsnba->exec_in(0);
rxa->nbp0->execute(0);
rxa->smeter->execute();
SENDER::xsender (rxa->sender);
AMSQ::xamsqcap (rxa->amsq);
BPSNBA::xbpsnbaout (rxa->bpsnba, 0);
rxa->bpsnba->exec_out(0);
AMD::xamd (rxa->amd);
FMD::xfmd (rxa->fmd);
FMSQ::xfmsq (rxa->fmsq);
BPSNBA::xbpsnbain (rxa->bpsnba, 1);
BPSNBA::xbpsnbaout (rxa->bpsnba, 1);
rxa->bpsnba->exec_in(1);
rxa->bpsnba->exec_out(1);
SNBA::xsnba (rxa->snba);
EQP::xeqp (rxa->eqp);
ANF::xanf (rxa->anf, 0);
@ -754,7 +754,7 @@ void RXA::setDSPSamplerate (RXA *rxa, int dsp_rate)
// dsp_rate blocks
rxa->adcmeter->setSamplerate(rxa->dsp_rate);
rxa->nbp0->setSamplerate(rxa->dsp_rate);
BPSNBA::setSamplerate_bpsnba (rxa->bpsnba, rxa->dsp_rate);
rxa->bpsnba->setSamplerate(rxa->dsp_rate);
rxa->smeter->setSamplerate(rxa->dsp_rate);
SENDER::setSamplerate_sender (rxa->sender, rxa->dsp_rate);
AMSQ::setSamplerate_amsq (rxa->amsq, rxa->dsp_rate);
@ -819,8 +819,8 @@ void RXA::setDSPBuffsize (RXA *rxa, int dsp_size)
rxa->adcmeter->setSize(rxa->dsp_size);
rxa->nbp0->setBuffers(rxa->midbuff, rxa->midbuff);
rxa->nbp0->setSize(rxa->dsp_size);
BPSNBA::setBuffers_bpsnba (rxa->bpsnba, rxa->midbuff, rxa->midbuff);
BPSNBA::setSize_bpsnba (rxa->bpsnba, rxa->dsp_size);
rxa->bpsnba->setBuffers(rxa->midbuff, rxa->midbuff);
rxa->bpsnba->setSize(rxa->dsp_size);
rxa->smeter->setBuffers(rxa->midbuff);
rxa->smeter->METER::setSize(rxa->dsp_size);
SENDER::setBuffers_sender (rxa->sender, rxa->midbuff);
@ -1028,7 +1028,7 @@ void RXA::bpsnbaCheck (RXA& rxa, int mode, int notch_run)
a->f_high = f_high;
a->run_notches = run_notches;
// f_low, f_high, run_notches are needed for the filter recalculation
BPSNBA::recalc_bpsnba_filter (a, 0);
rxa.bpsnba->recalc_bpsnba_filter(0);
}
}
@ -1087,7 +1087,7 @@ void RXA::UpdateNBPFilters(RXA& rxa)
}
if (b->bpsnba->fnfrun)
{
BPSNBA::recalc_bpsnba_filter (b, 1);
b->recalc_bpsnba_filter(1);
}
}
@ -1199,7 +1199,7 @@ void RXA::NBPSetWindow (RXA& rxa, int wintype)
if ((b->wintype != wintype))
{
b->wintype = wintype;
BPSNBA::recalc_bpsnba_filter (b, 1);
b->recalc_bpsnba_filter(1);
}
}
@ -1221,7 +1221,7 @@ void RXA::NBPSetAutoIncrease (RXA& rxa, int autoincr)
if ((b->autoincr != autoincr))
{
b->autoincr = autoincr;
BPSNBA::recalc_bpsnba_filter (b, 1);
b->recalc_bpsnba_filter(1);
}
}
@ -1242,7 +1242,7 @@ void RXA::SetNC (RXA& rxa, int nc)
{
int oldstate = rxa.state;
rxa.nbp0->SetNC (nc);
BPSNBA::BPSNBASetNC (rxa, nc);
rxa.bpsnba->SetNC (nc);
BANDPASS::SetBandpassNC (rxa, nc);
EQP::SetEQNC (rxa, nc);
FMSQ::SetFMSQNC (rxa, nc);
@ -1254,7 +1254,7 @@ void RXA::SetNC (RXA& rxa, int nc)
void RXA::SetMP (RXA& rxa, int mp)
{
rxa.nbp0->SetMP (mp);
BPSNBA::BPSNBASetMP (rxa, mp);
rxa.bpsnba->SetMP (mp);
BANDPASS::SetBandpassMP (rxa, mp);
EQP::SetEQMP (rxa, mp);
FMSQ::SetFMSQMP (rxa, mp);

View File

@ -51,135 +51,132 @@ namespace WDSP {
// for its input and output to happen at different points in the processing pipeline. This means it must
// include a buffer, 'buff'. Its input and output are done via functions xbpshbain() and xbpshbaout().
void BPSNBA::calc_bpsnba (BPSNBA *a)
void BPSNBA::calc()
{
a->buff = new float[a->size * 2]; // (double *) malloc0 (a->size * sizeof (complex));
a->bpsnba = new NBP (
buff = new float[size * 2]; // (double *) malloc0 (size * sizeof (complex));
bpsnba = new NBP (
1, // run, always runs (use bpsnba 'run')
a->run_notches, // run the notches
run_notches, // run the notches
0, // position variable for nbp (not for bpsnba), always 0
a->size, // buffer size
a->nc, // number of filter coefficients
a->mp, // minimum phase flag
a->buff, // pointer to input buffer
a->out, // pointer to output buffer
a->f_low, // lower filter frequency
a->f_high, // upper filter frequency
a->rate, // sample rate
a->wintype, // wintype
a->gain, // gain
a->autoincr, // auto-increase notch width if below min
a->maxpb, // max number of passbands
a->ptraddr); // addr of database pointer
size, // buffer size
nc, // number of filter coefficients
mp, // minimum phase flag
buff, // pointer to input buffer
out, // pointer to output buffer
f_low, // lower filter frequency
f_high, // upper filter frequency
rate, // sample rate
wintype, // wintype
gain, // gain
autoincr, // auto-increase notch width if below min
maxpb, // max number of passbands
notchdb); // addr of database pointer
}
BPSNBA* BPSNBA::create_bpsnba (
int run,
int run_notches,
int position,
int size,
int nc,
int mp,
float* in,
float* out,
int rate,
double abs_low_freq,
double abs_high_freq,
double f_low,
double f_high,
int wintype,
double gain,
int autoincr,
int maxpb,
NOTCHDB* ptraddr
)
BPSNBA::BPSNBA(
int _run,
int _run_notches,
int _position,
int _size,
int _nc,
int _mp,
float* _in,
float* _out,
int _rate,
double _abs_low_freq,
double _abs_high_freq,
double _f_low,
double _f_high,
int _wintype,
double _gain,
int _autoincr,
int _maxpb,
NOTCHDB* _notchdb
) :
run(_run),
run_notches(_run_notches),
position(_position),
size(_size),
nc(_nc),
mp(_mp),
in(_in),
out(_out),
rate(_rate),
abs_low_freq(_abs_low_freq),
abs_high_freq(_abs_high_freq),
f_low(_f_low),
f_high(_f_high),
wintype(_wintype),
gain(_gain),
autoincr(_autoincr),
maxpb(_maxpb),
notchdb(_notchdb)
{
BPSNBA *a = new BPSNBA;
a->run = run;
a->run_notches = run_notches;
a->position = position;
a->size = size;
a->nc = nc;
a->mp = mp;
a->in = in;
a->out = out;
a->rate = rate;
a->abs_low_freq = abs_low_freq;
a->abs_high_freq = abs_high_freq;
a->f_low = f_low;
a->f_high = f_high;
a->wintype = wintype;
a->gain = gain;
a->autoincr = autoincr;
a->maxpb = maxpb;
a->ptraddr = ptraddr;
calc_bpsnba (a);
return a;
calc();
}
void BPSNBA::decalc_bpsnba (BPSNBA *a)
void BPSNBA::decalc()
{
delete (a->bpsnba);
delete[] (a->buff);
delete (bpsnba);
delete[] (buff);
}
void BPSNBA::destroy_bpsnba (BPSNBA *a)
BPSNBA::~BPSNBA()
{
decalc_bpsnba (a);
delete[] (a);
decalc();
}
void BPSNBA::flush_bpsnba (BPSNBA *a)
void BPSNBA::flush()
{
std::fill(a->buff, a->buff + a->size * 2, 0);
a->bpsnba->flush();
std::fill(buff, buff + size * 2, 0);
bpsnba->flush();
}
void BPSNBA::setBuffers_bpsnba (BPSNBA *a, float* in, float* out)
void BPSNBA::setBuffers(float* _in, float* _out)
{
decalc_bpsnba (a);
a->in = in;
a->out = out;
calc_bpsnba (a);
decalc();
in = _in;
out = _out;
calc();
}
void BPSNBA::setSamplerate_bpsnba (BPSNBA *a, int rate)
void BPSNBA::setSamplerate(int _rate)
{
decalc_bpsnba (a);
a->rate = rate;
calc_bpsnba (a);
decalc();
rate = _rate;
calc();
}
void BPSNBA::setSize_bpsnba (BPSNBA *a, int size)
void BPSNBA::setSize(int _size)
{
decalc_bpsnba (a);
a->size = size;
calc_bpsnba (a);
decalc();
size = _size;
calc();
}
void BPSNBA::xbpsnbain (BPSNBA *a, int position)
void BPSNBA::exec_in(int _position)
{
if (a->run && a->position == position)
std::copy(a->in, a->in + a->size * 2, a->buff);
if (run && position == _position)
std::copy(in, in + size * 2, buff);
}
void BPSNBA::xbpsnbaout (BPSNBA *a, int position)
void BPSNBA::exec_out(int _position)
{
if (a->run && a->position == position)
a->bpsnba->execute(0);
if (run && position == _position)
bpsnba->execute(0);
}
void BPSNBA::recalc_bpsnba_filter (BPSNBA *a, int update)
void BPSNBA::recalc_bpsnba_filter(int update)
{
// Call anytime one of the parameters listed below has been changed in
// the BPSNBA struct.
NBP *b = a->bpsnba;
b->fnfrun = a->run_notches;
b->flow = a->f_low;
b->fhigh = a->f_high;
b->wintype = a->wintype;
b->gain = a->gain;
b->autoincr = a->autoincr;
NBP *b = bpsnba;
b->fnfrun = run_notches;
b->flow = f_low;
b->fhigh = f_high;
b->wintype = wintype;
b->gain = gain;
b->autoincr = autoincr;
b->calc_impulse();
FIRCORE::setImpulse_fircore (b->fircore, b->impulse, update);
delete[] (b->impulse);
@ -187,31 +184,27 @@ void BPSNBA::recalc_bpsnba_filter (BPSNBA *a, int update)
/********************************************************************************************************
* *
* RXA Properties *
* Properties *
* *
********************************************************************************************************/
void BPSNBA::BPSNBASetNC (RXA& rxa, int nc)
void BPSNBA::SetNC(int _nc)
{
BPSNBA *a = rxa.bpsnba;
if (a->nc != nc)
if (nc != _nc)
{
a->nc = nc;
a->bpsnba->nc = a->nc;
a->bpsnba->setNc();
nc = _nc;
bpsnba->nc = nc;
bpsnba->setNc();
}
}
void BPSNBA::BPSNBASetMP (RXA& rxa, int mp)
void BPSNBA::SetMP(int _mp)
{
BPSNBA *a = rxa.bpsnba;
if (a->mp != mp)
if (mp != _mp)
{
a->mp = mp;
a->bpsnba->mp = a->mp;
a->bpsnba->setMp();
mp = _mp;
bpsnba->mp = mp;
bpsnba->setMp();
}
}

View File

@ -47,19 +47,19 @@ public:
float* in; // input buffer
float* out; // output buffer
int rate; // sample rate
float* buff; // internal buffer
NBP *bpsnba; // pointer to the notched bandpass filter, nbp
double f_low; // low cutoff frequency
double f_high; // high cutoff frequency
double abs_low_freq; // lowest positive freq supported by SNB
double abs_high_freq; // highest positive freq supported by SNG
double f_low; // low cutoff frequency
double f_high; // high cutoff frequency
float* buff; // internal buffer
int wintype; // filter window type
double gain; // filter gain
int autoincr; // use auto increment for notch width
int maxpb; // maximum passband segments supported
NOTCHDB* ptraddr; // pointer to address of NOTCH DATABASE
NOTCHDB* notchdb; // pointer to address of NOTCH DATABASE
NBP *bpsnba; // pointer to the notched bandpass filter, nbp
static BPSNBA* create_bpsnba (
BPSNBA(
int run,
int run_notches,
int position,
@ -77,23 +77,24 @@ public:
double gain,
int autoincr,
int maxpb,
NOTCHDB* ptraddr
NOTCHDB* notchdb
);
static void destroy_bpsnba (BPSNBA *a);
static void flush_bpsnba (BPSNBA *a);
static void setBuffers_bpsnba (BPSNBA *a, float* in, float* out);
static void setSamplerate_bpsnba (BPSNBA *a, int rate);
static void setSize_bpsnba (BPSNBA *a, int size);
static void xbpsnbain (BPSNBA *a, int position);
static void xbpsnbaout (BPSNBA *a, int position);
static void recalc_bpsnba_filter (BPSNBA *a, int update);
// RXA Propertoes
static void BPSNBASetNC (RXA& rxa, int nc);
static void BPSNBASetMP (RXA& rxa, int mp);
~BPSNBA();
void flush();
void setBuffers(float* in, float* out);
void setSamplerate(int rate);
void setSize(int size);
void exec_in(int position);
void exec_out(int position);
void recalc_bpsnba_filter(int update);
// Propertoes
void SetNC(int nc);
void SetMP(int mp);
private:
static void calc_bpsnba (BPSNBA *a);
static void decalc_bpsnba (BPSNBA *a);
void calc();
void decalc();
};