mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-12-23 01:55:48 -05:00
WDSP: CBL rework
This commit is contained in:
parent
350117b9a9
commit
913d5bf7b0
14
wdsp/RXA.cpp
14
wdsp/RXA.cpp
@ -471,7 +471,7 @@ RXA* RXA::create_rxa (
|
|||||||
0); // specmode
|
0); // specmode
|
||||||
|
|
||||||
// AM carrier block
|
// AM carrier block
|
||||||
rxa->cbl = CBL::create_cbl (
|
rxa->cbl = new CBL(
|
||||||
0, // run - needed only if set to ON
|
0, // run - needed only if set to ON
|
||||||
rxa->dsp_size, // buffer size
|
rxa->dsp_size, // buffer size
|
||||||
rxa->midbuff, // pointer to input buffer
|
rxa->midbuff, // pointer to input buffer
|
||||||
@ -568,7 +568,7 @@ void RXA::destroy_rxa (RXA *rxa)
|
|||||||
SSQL::destroy_ssql (rxa->ssql);
|
SSQL::destroy_ssql (rxa->ssql);
|
||||||
MPEAK::destroy_mpeak (rxa->mpeak);
|
MPEAK::destroy_mpeak (rxa->mpeak);
|
||||||
SPEAK::destroy_speak (rxa->speak);
|
SPEAK::destroy_speak (rxa->speak);
|
||||||
CBL::destroy_cbl (rxa->cbl);
|
delete (rxa->cbl);
|
||||||
delete (rxa->sip1);
|
delete (rxa->sip1);
|
||||||
delete (rxa->bp1);
|
delete (rxa->bp1);
|
||||||
delete (rxa->agcmeter);
|
delete (rxa->agcmeter);
|
||||||
@ -625,7 +625,7 @@ void RXA::flush_rxa (RXA *rxa)
|
|||||||
rxa->agcmeter->flush();
|
rxa->agcmeter->flush();
|
||||||
rxa->bp1->flush();
|
rxa->bp1->flush();
|
||||||
rxa->sip1->flush();
|
rxa->sip1->flush();
|
||||||
CBL::flush_cbl (rxa->cbl);
|
rxa->cbl->flush();
|
||||||
SPEAK::flush_speak (rxa->speak);
|
SPEAK::flush_speak (rxa->speak);
|
||||||
MPEAK::flush_mpeak (rxa->mpeak);
|
MPEAK::flush_mpeak (rxa->mpeak);
|
||||||
SSQL::flush_ssql (rxa->ssql);
|
SSQL::flush_ssql (rxa->ssql);
|
||||||
@ -664,7 +664,7 @@ void RXA::xrxa (RXA *rxa)
|
|||||||
rxa->bp1->execute(1);
|
rxa->bp1->execute(1);
|
||||||
rxa->agcmeter->execute();
|
rxa->agcmeter->execute();
|
||||||
rxa->sip1->execute(0);
|
rxa->sip1->execute(0);
|
||||||
CBL::xcbl (rxa->cbl);
|
rxa->cbl->execute();
|
||||||
SPEAK::xspeak (rxa->speak);
|
SPEAK::xspeak (rxa->speak);
|
||||||
MPEAK::xmpeak (rxa->mpeak);
|
MPEAK::xmpeak (rxa->mpeak);
|
||||||
SSQL::xssql (rxa->ssql);
|
SSQL::xssql (rxa->ssql);
|
||||||
@ -771,7 +771,7 @@ void RXA::setDSPSamplerate (RXA *rxa, int dsp_rate)
|
|||||||
rxa->agc->setSamplerate(rxa->dsp_rate);
|
rxa->agc->setSamplerate(rxa->dsp_rate);
|
||||||
rxa->agcmeter->setSamplerate(rxa->dsp_rate);
|
rxa->agcmeter->setSamplerate(rxa->dsp_rate);
|
||||||
rxa->sip1->setSamplerate(rxa->dsp_rate);
|
rxa->sip1->setSamplerate(rxa->dsp_rate);
|
||||||
CBL::setSamplerate_cbl (rxa->cbl, rxa->dsp_rate);
|
rxa->cbl->setSamplerate(rxa->dsp_rate);
|
||||||
SPEAK::setSamplerate_speak (rxa->speak, rxa->dsp_rate);
|
SPEAK::setSamplerate_speak (rxa->speak, rxa->dsp_rate);
|
||||||
MPEAK::setSamplerate_mpeak (rxa->mpeak, rxa->dsp_rate);
|
MPEAK::setSamplerate_mpeak (rxa->mpeak, rxa->dsp_rate);
|
||||||
SSQL::setSamplerate_ssql (rxa->ssql, rxa->dsp_rate);
|
SSQL::setSamplerate_ssql (rxa->ssql, rxa->dsp_rate);
|
||||||
@ -851,8 +851,8 @@ void RXA::setDSPBuffsize (RXA *rxa, int dsp_size)
|
|||||||
rxa->agcmeter->setSize(rxa->dsp_size);
|
rxa->agcmeter->setSize(rxa->dsp_size);
|
||||||
rxa->sip1->setBuffers(rxa->midbuff);
|
rxa->sip1->setBuffers(rxa->midbuff);
|
||||||
rxa->sip1->setSize(rxa->dsp_size);
|
rxa->sip1->setSize(rxa->dsp_size);
|
||||||
CBL::setBuffers_cbl (rxa->cbl, rxa->midbuff, rxa->midbuff);
|
rxa->cbl->setBuffers(rxa->midbuff, rxa->midbuff);
|
||||||
CBL::setSize_cbl (rxa->cbl, rxa->dsp_size);
|
rxa->cbl->setSize(rxa->dsp_size);
|
||||||
SPEAK::setBuffers_speak (rxa->speak, rxa->midbuff, rxa->midbuff);
|
SPEAK::setBuffers_speak (rxa->speak, rxa->midbuff, rxa->midbuff);
|
||||||
SPEAK::setSize_speak (rxa->speak, rxa->dsp_size);
|
SPEAK::setSize_speak (rxa->speak, rxa->dsp_size);
|
||||||
MPEAK::setBuffers_mpeak (rxa->mpeak, rxa->midbuff, rxa->midbuff);
|
MPEAK::setBuffers_mpeak (rxa->mpeak, rxa->midbuff, rxa->midbuff);
|
||||||
|
113
wdsp/cblock.cpp
113
wdsp/cblock.cpp
@ -31,95 +31,88 @@ warren@wpratt.com
|
|||||||
|
|
||||||
namespace WDSP {
|
namespace WDSP {
|
||||||
|
|
||||||
void CBL::calc_cbl (CBL *a)
|
void CBL::calc()
|
||||||
{
|
{
|
||||||
a->prevIin = 0.0;
|
prevIin = 0.0;
|
||||||
a->prevQin = 0.0;
|
prevQin = 0.0;
|
||||||
a->prevIout = 0.0;
|
prevIout = 0.0;
|
||||||
a->prevQout = 0.0;
|
prevQout = 0.0;
|
||||||
a->mtau = exp(-1.0 / (a->sample_rate * a->tau));
|
mtau = exp(-1.0 / (sample_rate * tau));
|
||||||
}
|
}
|
||||||
|
|
||||||
CBL* CBL::create_cbl(
|
CBL::CBL(
|
||||||
int run,
|
int _run,
|
||||||
int buff_size,
|
int _buff_size,
|
||||||
float *in_buff,
|
float *_in_buff,
|
||||||
float *out_buff,
|
float *_out_buff,
|
||||||
int mode,
|
int _mode,
|
||||||
int sample_rate,
|
int _sample_rate,
|
||||||
double tau
|
double _tau
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
CBL *a = new CBL;
|
run = _run;
|
||||||
a->run = run;
|
buff_size = _buff_size;
|
||||||
a->buff_size = buff_size;
|
in_buff = _in_buff;
|
||||||
a->in_buff = in_buff;
|
out_buff = _out_buff;
|
||||||
a->out_buff = out_buff;
|
mode = _mode;
|
||||||
a->mode = mode;
|
sample_rate = (double) _sample_rate;
|
||||||
a->sample_rate = (double) sample_rate;
|
tau = _tau;
|
||||||
a->tau = tau;
|
calc();
|
||||||
calc_cbl (a);
|
|
||||||
return a;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CBL::destroy_cbl(CBL *a)
|
void CBL::flush()
|
||||||
{
|
{
|
||||||
delete a;
|
prevIin = 0.0;
|
||||||
|
prevQin = 0.0;
|
||||||
|
prevIout = 0.0;
|
||||||
|
prevQout = 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CBL::flush_cbl (CBL *a)
|
void CBL::execute()
|
||||||
{
|
{
|
||||||
a->prevIin = 0.0;
|
if (run)
|
||||||
a->prevQin = 0.0;
|
|
||||||
a->prevIout = 0.0;
|
|
||||||
a->prevQout = 0.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CBL::xcbl (CBL *a)
|
|
||||||
{
|
|
||||||
if (a->run)
|
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
double tempI, tempQ;
|
double tempI, tempQ;
|
||||||
|
|
||||||
for (i = 0; i < a->buff_size; i++)
|
for (i = 0; i < buff_size; i++)
|
||||||
{
|
{
|
||||||
tempI = a->in_buff[2 * i + 0];
|
tempI = in_buff[2 * i + 0];
|
||||||
tempQ = a->in_buff[2 * i + 1];
|
tempQ = in_buff[2 * i + 1];
|
||||||
a->out_buff[2 * i + 0] = a->in_buff[2 * i + 0] - a->prevIin + a->mtau * a->prevIout;
|
out_buff[2 * i + 0] = in_buff[2 * i + 0] - prevIin + mtau * prevIout;
|
||||||
a->out_buff[2 * i + 1] = a->in_buff[2 * i + 1] - a->prevQin + a->mtau * a->prevQout;
|
out_buff[2 * i + 1] = in_buff[2 * i + 1] - prevQin + mtau * prevQout;
|
||||||
a->prevIin = tempI;
|
prevIin = tempI;
|
||||||
a->prevQin = tempQ;
|
prevQin = tempQ;
|
||||||
|
|
||||||
if (fabs(a->prevIout = a->out_buff[2 * i + 0]) < 1.0e-20)
|
if (fabs(prevIout = out_buff[2 * i + 0]) < 1.0e-20)
|
||||||
a->prevIout = 0.0;
|
prevIout = 0.0;
|
||||||
|
|
||||||
if (fabs(a->prevQout = a->out_buff[2 * i + 1]) < 1.0e-20)
|
if (fabs(prevQout = out_buff[2 * i + 1]) < 1.0e-20)
|
||||||
a->prevQout = 0.0;
|
prevQout = 0.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (a->in_buff != a->out_buff)
|
else if (in_buff != out_buff)
|
||||||
{
|
{
|
||||||
std::copy(a->in_buff, a->in_buff + a->buff_size * 2, a->out_buff);
|
std::copy(in_buff, in_buff + buff_size * 2, out_buff);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CBL::setBuffers_cbl (CBL *a, float* in, float* out)
|
void CBL::setBuffers(float* _in, float* _out)
|
||||||
{
|
{
|
||||||
a->in_buff = in;
|
in_buff = _in;
|
||||||
a->out_buff = out;
|
out_buff = _out;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CBL::setSamplerate_cbl (CBL *a, int rate)
|
void CBL::setSamplerate(int _rate)
|
||||||
{
|
{
|
||||||
a->sample_rate = rate;
|
sample_rate = _rate;
|
||||||
calc_cbl (a);
|
calc();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CBL::setSize_cbl (CBL *a, int size)
|
void CBL::setSize(int _size)
|
||||||
{
|
{
|
||||||
a->buff_size = size;
|
buff_size = _size;
|
||||||
flush_cbl (a);
|
flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
/********************************************************************************************************
|
/********************************************************************************************************
|
||||||
@ -128,9 +121,9 @@ void CBL::setSize_cbl (CBL *a, int size)
|
|||||||
* *
|
* *
|
||||||
********************************************************************************************************/
|
********************************************************************************************************/
|
||||||
|
|
||||||
void CBL::SetCBLRun(RXA& rxa, int setit)
|
void CBL::setRun(int setit)
|
||||||
{
|
{
|
||||||
rxa.cbl->run = setit;
|
run = setit;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace WDSP
|
} // namespace WDSP
|
||||||
|
@ -50,7 +50,7 @@ public:
|
|||||||
double tau; //carrier removal time constant
|
double tau; //carrier removal time constant
|
||||||
double mtau; //carrier removal multiplier
|
double mtau; //carrier removal multiplier
|
||||||
|
|
||||||
static CBL* create_cbl(
|
CBL(
|
||||||
int run,
|
int run,
|
||||||
int buff_size,
|
int buff_size,
|
||||||
float *in_buff,
|
float *in_buff,
|
||||||
@ -59,17 +59,20 @@ public:
|
|||||||
int sample_rate,
|
int sample_rate,
|
||||||
double tau
|
double tau
|
||||||
);
|
);
|
||||||
static void destroy_cbl (CBL *a);
|
CBL(const CBL&) = delete;
|
||||||
static void flush_cbl (CBL *a);
|
CBL& operator=(CBL& other) = delete;
|
||||||
static void xcbl (CBL *a);
|
~CBL() = default;
|
||||||
static void setBuffers_cbl (CBL *a, float* in, float* out);
|
|
||||||
static void setSamplerate_cbl (CBL *a, int rate);
|
void flush();
|
||||||
static void setSize_cbl (CBL *a, int size);
|
void execute();
|
||||||
// RXA Properties
|
void setBuffers(float* in, float* out);
|
||||||
static void SetCBLRun(RXA& rxa, int setit);
|
void setSamplerate(int rate);
|
||||||
|
void setSize(int size);
|
||||||
|
// Public Properties
|
||||||
|
void setRun(int setit);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static void calc_cbl (CBL *a);
|
void calc();
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace WDSP
|
} // namespace WDSP
|
||||||
|
@ -140,7 +140,7 @@ void SSQL::compute_ssql_slews(SSQL *a)
|
|||||||
void SSQL::calc_ssql (SSQL *a)
|
void SSQL::calc_ssql (SSQL *a)
|
||||||
{
|
{
|
||||||
a->b1 = new float[a->size * 2]; // (float*) malloc0 (a->size * sizeof (complex));
|
a->b1 = new float[a->size * 2]; // (float*) malloc0 (a->size * sizeof (complex));
|
||||||
a->dcbl = CBL::create_cbl (1, a->size, a->in, a->b1, 0, a->rate, 0.02);
|
a->dcbl = new CBL(1, a->size, a->in, a->b1, 0, a->rate, 0.02);
|
||||||
a->ibuff = new float[a->size]; // (float*) malloc0 (a->size * sizeof (float));
|
a->ibuff = new float[a->size]; // (float*) malloc0 (a->size * sizeof (float));
|
||||||
a->ftovbuff = new float[a->size]; // (float*) malloc0(a->size * sizeof (float));
|
a->ftovbuff = new float[a->size]; // (float*) malloc0(a->size * sizeof (float));
|
||||||
a->cvtr = FTOV::create_ftov (1, a->size, a->rate, a->ftov_rsize, a->ftov_fmax, a->ibuff, a->ftovbuff);
|
a->cvtr = FTOV::create_ftov (1, a->size, a->rate, a->ftov_rsize, a->ftov_fmax, a->ibuff, a->ftovbuff);
|
||||||
@ -175,7 +175,7 @@ void SSQL::decalc_ssql (SSQL *a)
|
|||||||
FTOV::destroy_ftov (a->cvtr);
|
FTOV::destroy_ftov (a->cvtr);
|
||||||
delete[] (a->ftovbuff);
|
delete[] (a->ftovbuff);
|
||||||
delete[] (a->ibuff);
|
delete[] (a->ibuff);
|
||||||
CBL::destroy_cbl (a->dcbl);
|
delete (a->dcbl);
|
||||||
delete[] (a->b1);
|
delete[] (a->b1);
|
||||||
delete[] (a->cdown);
|
delete[] (a->cdown);
|
||||||
delete[] (a->cup);
|
delete[] (a->cup);
|
||||||
@ -230,7 +230,7 @@ void SSQL::flush_ssql (SSQL *a)
|
|||||||
{
|
{
|
||||||
|
|
||||||
std::fill(a->b1, a->b1 + a->size * 2, 0);
|
std::fill(a->b1, a->b1 + a->size * 2, 0);
|
||||||
CBL::flush_cbl (a->dcbl);
|
a->dcbl->flush();
|
||||||
memset (a->ibuff, 0, a->size * sizeof (float));
|
memset (a->ibuff, 0, a->size * sizeof (float));
|
||||||
memset (a->ftovbuff, 0, a->size * sizeof (float));
|
memset (a->ftovbuff, 0, a->size * sizeof (float));
|
||||||
FTOV::flush_ftov (a->cvtr);
|
FTOV::flush_ftov (a->cvtr);
|
||||||
@ -252,7 +252,7 @@ void SSQL::xssql (SSQL *a)
|
|||||||
{
|
{
|
||||||
if (a->run)
|
if (a->run)
|
||||||
{
|
{
|
||||||
CBL::xcbl (a->dcbl); // dc block the input signal
|
a->dcbl->execute(); // dc block the input signal
|
||||||
for (int i = 0; i < a->size; i++) // extract 'I' component
|
for (int i = 0; i < a->size; i++) // extract 'I' component
|
||||||
a->ibuff[i] = a->b1[2 * i];
|
a->ibuff[i] = a->b1[2 * i];
|
||||||
FTOV::xftov (a->cvtr); // convert frequency to voltage, ignoring amplitude
|
FTOV::xftov (a->cvtr); // convert frequency to voltage, ignoring amplitude
|
||||||
|
Loading…
Reference in New Issue
Block a user