mirror of
https://github.com/f4exb/sdrangel.git
synced 2026-07-25 19:44:12 -04:00
WDSP: BPSNBA: replaced static methods
This commit is contained in:
+102
-109
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user