1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-12-23 01:55:48 -05:00

WDSP: minor adjustments

This commit is contained in:
f4exb 2024-07-24 04:52:00 +02:00
parent e81c9cc5b0
commit 49dc91cb6b
7 changed files with 81 additions and 74 deletions

View File

@ -72,18 +72,18 @@ ANB::ANB (
double _advtime,
double _backtau,
double _threshold
)
) :
run(_run),
buffsize(_buffsize),
in(_in),
out(_out),
samplerate(_samplerate),
tau(_tau),
hangtime(_hangtime),
advtime(_advtime),
backtau(_backtau),
threshold(_threshold)
{
run = _run;
buffsize = _buffsize;
in = _in;
out = _out;
samplerate = _samplerate;
tau = _tau;
hangtime = _hangtime;
advtime = _advtime;
backtau = _backtau;
threshold = _threshold;
wave = new double[((int)(MAX_SAMPLERATE * MAX_TAU) + 1)];
dline_size = (int)((MAX_TAU + MAX_ADVTIME) * MAX_SAMPLERATE) + 1;
dline = new float[dline_size * 2];

View File

@ -39,7 +39,7 @@ warren@wpratt.com
namespace WDSP {
void NOB::init_nob()
void NOB::init()
{
int i;
double coef;
@ -85,21 +85,21 @@ NOB::NOB (
double _max_imp_seq_time,
double _backtau,
double _threshold
)
) :
run(_run),
buffsize(_buffsize),
in(_in),
out(_out),
samplerate(_samplerate),
mode(_mode),
advslewtime(_advslewtime),
advtime(_advtime),
hangslewtime(_hangslewtime),
hangtime(_hangtime),
max_imp_seq_time(_max_imp_seq_time),
backtau(_backtau),
threshold(_threshold)
{
run = _run;
buffsize = _buffsize;
in = _in;
out = _out;
samplerate = _samplerate;
mode = _mode;
advslewtime = _advslewtime;
advtime = _advtime;
hangslewtime = _hangslewtime;
hangtime = _hangtime;
max_imp_seq_time = _max_imp_seq_time;
backtau = _backtau;
threshold = _threshold;
dline_size = (int)(MAX_SAMPLERATE * (
MAX_ADV_SLEW_TIME +
MAX_ADV_TIME +
@ -126,7 +126,7 @@ NOB::NOB (
fcoefs[8] = 0.017797128;
fcoefs[9] = 0.012457989;
init_nob();
init();
}
NOB::~NOB()
@ -621,32 +621,32 @@ void NOB::setBuffsize(int size)
void NOB::setSamplerate(int rate)
{
samplerate = (double) rate;
init_nob();
init();
}
void NOB::setTau(double tau)
{
advslewtime = tau;
hangslewtime = tau;
init_nob();
init();
}
void NOB::setHangtime(double _time)
{
hangtime = _time;
init_nob();
init();
}
void NOB::setAdvtime(double _time)
{
advtime = _time;
init_nob();
init();
}
void NOB::setBacktau(double tau)
{
backtau = tau;
init_nob();
init();
}
void NOB::setThreshold(double thresh)

View File

@ -41,11 +41,11 @@ public:
int buffsize; // size of input/output buffer
float* in; // input buffer
float* out; // output buffer
int mode;
int dline_size; // length of delay line which is 'double dline[length][2]'
double *dline; // pointer to delay line
int *imp;
double samplerate; // samplerate, used to convert times into sample counts
int mode;
double advslewtime; // transition time, signal<->zero
double advtime; // deadtime (zero output) in advance of detected noise
double hangslewtime;
@ -116,7 +116,7 @@ public:
void setThreshold (double thresh);
private:
void init_nob();
void init();
};

View File

@ -37,7 +37,7 @@ namespace WDSP {
* *
************************************************************************************************/
void RESAMPLE::calc_resample()
void RESAMPLE::calc()
{
int x, y, z;
int i, j, k;
@ -102,7 +102,7 @@ void RESAMPLE::calc_resample()
delete[] (impulse);
}
void RESAMPLE::decalc_resample()
void RESAMPLE::decalc()
{
delete[] ring;
delete[] h;
@ -118,24 +118,24 @@ RESAMPLE::RESAMPLE (
double _fc,
int _ncoef,
double _gain
)
) :
run(_run),
size(_size),
in(_in),
out(_out),
in_rate(_in_rate),
out_rate(_out_rate),
fcin(_fc),
fc_low(-1.0), // could add to create_resample() parameters
ncoefin(_ncoef),
gain(_gain)
{
run = _run;
size = _size;
in = _in;
out = _out;
in_rate = _in_rate;
out_rate = _out_rate;
fcin = _fc;
fc_low = -1.0; // could add to create_resample() parameters
ncoefin = _ncoef;
gain = _gain;
calc_resample();
calc();
}
RESAMPLE::~RESAMPLE()
{
decalc_resample();
decalc();
}
@ -210,25 +210,25 @@ void RESAMPLE::setSize(int _size)
void RESAMPLE::setInRate(int _rate)
{
decalc_resample();
decalc();
in_rate = _rate;
calc_resample();
calc();
}
void RESAMPLE::setOutRate(int _rate)
{
decalc_resample();
decalc();
out_rate = _rate;
calc_resample();
calc();
}
void RESAMPLE::setFCLow(double _fc_low)
{
if (fc_low != _fc_low)
{
decalc_resample();
decalc();
fc_low = _fc_low;
calc_resample();
calc();
}
}
@ -236,10 +236,10 @@ void RESAMPLE::setBandwidth(double _fc_low, double _fc_high)
{
if (fc_low != _fc_low || _fc_high != fcin)
{
decalc_resample();
decalc();
fc_low = _fc_low;
fcin = _fc_high;
calc_resample();
calc();
}
}

View File

@ -50,9 +50,9 @@ public:
double fcin;
double fc;
double fc_low;
double gain;
int idx_in; // index for input into ring
int ncoefin;
double gain;
int ncoef; // number of coefficients
int L; // interpolation factor
int M; // decimation factor
@ -89,8 +89,8 @@ public:
static void destroyV (void* ptr);
private:
void calc_resample();
void decalc_resample();
void calc();
void decalc();
};
} // namespace WDSP

View File

@ -31,23 +31,30 @@ warren@wpratt.com
namespace WDSP {
void SHIFT::calc_shift()
void SHIFT::calc()
{
delta = TWOPI * shift / rate;
cos_delta = cos (delta);
sin_delta = sin (delta);
}
SHIFT::SHIFT (int _run, int _size, float* _in, float* _out, int _rate, double _fshift)
SHIFT::SHIFT (
int _run,
int _size,
float* _in,
float* _out,
int _rate,
double _fshift
) :
run(_run),
size(_size),
in(_in),
out(_out),
rate((double) _rate),
shift(_fshift)
{
run = _run;
size = _size;
in = _in;
out = _out;
rate = (double) _rate;
shift = _fshift;
phase = 0.0;
calc_shift();
calc();
}
void SHIFT::flush()
@ -99,7 +106,7 @@ void SHIFT::setSamplerate(int _rate)
{
rate = _rate;
phase = 0.0;
calc_shift();
calc();
}
void SHIFT::setSize(int _size)
@ -119,10 +126,10 @@ void SHIFT::SetRun (int _run)
run = _run;
}
void SHIFT::SetFreq(double fshift)
void SHIFT::SetFreq(double _fshift)
{
shift = fshift;
calc_shift();
shift = _fshift;
calc();
}
} // namespace WDSP

View File

@ -61,7 +61,7 @@ public:
void SetFreq (double fshift);
private:
void calc_shift ();
void calc();
};
} // namespace WDSP