1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-22 16:08:39 -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 _advtime,
double _backtau, double _backtau,
double _threshold 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)]; wave = new double[((int)(MAX_SAMPLERATE * MAX_TAU) + 1)];
dline_size = (int)((MAX_TAU + MAX_ADVTIME) * MAX_SAMPLERATE) + 1; dline_size = (int)((MAX_TAU + MAX_ADVTIME) * MAX_SAMPLERATE) + 1;
dline = new float[dline_size * 2]; dline = new float[dline_size * 2];

View File

@ -39,7 +39,7 @@ warren@wpratt.com
namespace WDSP { namespace WDSP {
void NOB::init_nob() void NOB::init()
{ {
int i; int i;
double coef; double coef;
@ -85,21 +85,21 @@ NOB::NOB (
double _max_imp_seq_time, double _max_imp_seq_time,
double _backtau, double _backtau,
double _threshold 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 * ( dline_size = (int)(MAX_SAMPLERATE * (
MAX_ADV_SLEW_TIME + MAX_ADV_SLEW_TIME +
MAX_ADV_TIME + MAX_ADV_TIME +
@ -126,7 +126,7 @@ NOB::NOB (
fcoefs[8] = 0.017797128; fcoefs[8] = 0.017797128;
fcoefs[9] = 0.012457989; fcoefs[9] = 0.012457989;
init_nob(); init();
} }
NOB::~NOB() NOB::~NOB()
@ -621,32 +621,32 @@ void NOB::setBuffsize(int size)
void NOB::setSamplerate(int rate) void NOB::setSamplerate(int rate)
{ {
samplerate = (double) rate; samplerate = (double) rate;
init_nob(); init();
} }
void NOB::setTau(double tau) void NOB::setTau(double tau)
{ {
advslewtime = tau; advslewtime = tau;
hangslewtime = tau; hangslewtime = tau;
init_nob(); init();
} }
void NOB::setHangtime(double _time) void NOB::setHangtime(double _time)
{ {
hangtime = _time; hangtime = _time;
init_nob(); init();
} }
void NOB::setAdvtime(double _time) void NOB::setAdvtime(double _time)
{ {
advtime = _time; advtime = _time;
init_nob(); init();
} }
void NOB::setBacktau(double tau) void NOB::setBacktau(double tau)
{ {
backtau = tau; backtau = tau;
init_nob(); init();
} }
void NOB::setThreshold(double thresh) void NOB::setThreshold(double thresh)

View File

@ -41,11 +41,11 @@ public:
int buffsize; // size of input/output buffer int buffsize; // size of input/output buffer
float* in; // input buffer float* in; // input buffer
float* out; // output buffer float* out; // output buffer
int mode;
int dline_size; // length of delay line which is 'double dline[length][2]' int dline_size; // length of delay line which is 'double dline[length][2]'
double *dline; // pointer to delay line double *dline; // pointer to delay line
int *imp; int *imp;
double samplerate; // samplerate, used to convert times into sample counts double samplerate; // samplerate, used to convert times into sample counts
int mode;
double advslewtime; // transition time, signal<->zero double advslewtime; // transition time, signal<->zero
double advtime; // deadtime (zero output) in advance of detected noise double advtime; // deadtime (zero output) in advance of detected noise
double hangslewtime; double hangslewtime;
@ -116,7 +116,7 @@ public:
void setThreshold (double thresh); void setThreshold (double thresh);
private: 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 x, y, z;
int i, j, k; int i, j, k;
@ -102,7 +102,7 @@ void RESAMPLE::calc_resample()
delete[] (impulse); delete[] (impulse);
} }
void RESAMPLE::decalc_resample() void RESAMPLE::decalc()
{ {
delete[] ring; delete[] ring;
delete[] h; delete[] h;
@ -118,24 +118,24 @@ RESAMPLE::RESAMPLE (
double _fc, double _fc,
int _ncoef, int _ncoef,
double _gain 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; calc();
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();
} }
RESAMPLE::~RESAMPLE() RESAMPLE::~RESAMPLE()
{ {
decalc_resample(); decalc();
} }
@ -210,25 +210,25 @@ void RESAMPLE::setSize(int _size)
void RESAMPLE::setInRate(int _rate) void RESAMPLE::setInRate(int _rate)
{ {
decalc_resample(); decalc();
in_rate = _rate; in_rate = _rate;
calc_resample(); calc();
} }
void RESAMPLE::setOutRate(int _rate) void RESAMPLE::setOutRate(int _rate)
{ {
decalc_resample(); decalc();
out_rate = _rate; out_rate = _rate;
calc_resample(); calc();
} }
void RESAMPLE::setFCLow(double _fc_low) void RESAMPLE::setFCLow(double _fc_low)
{ {
if (fc_low != _fc_low) if (fc_low != _fc_low)
{ {
decalc_resample(); decalc();
fc_low = _fc_low; 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) if (fc_low != _fc_low || _fc_high != fcin)
{ {
decalc_resample(); decalc();
fc_low = _fc_low; fc_low = _fc_low;
fcin = _fc_high; fcin = _fc_high;
calc_resample(); calc();
} }
} }

View File

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

View File

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

View File

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