mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-12-23 01:55:48 -05:00
WDSP: ANB, NOB, ANSQ: use vectors instead of C arrays and disable copy constructor
This commit is contained in:
parent
59f97f3912
commit
8a267240df
@ -78,6 +78,7 @@ public:
|
||||
double _max_tail,
|
||||
double _muted_gain
|
||||
);
|
||||
AMSQ(const AMSQ&) = delete;
|
||||
~AMSQ();
|
||||
|
||||
void flush();
|
||||
|
24
wdsp/anb.cpp
24
wdsp/anb.cpp
@ -57,7 +57,7 @@ void ANB::initBlanker()
|
||||
for (i = 0; i <= trans_count; i++)
|
||||
wave[i] = 0.5 * cos(i * coef);
|
||||
|
||||
std::fill(dline, dline + dline_size * 2, 0);
|
||||
std::fill(dline.begin(), dline.end(), 0);
|
||||
}
|
||||
|
||||
ANB::ANB (
|
||||
@ -81,20 +81,20 @@ ANB::ANB (
|
||||
hangtime(_hangtime),
|
||||
advtime(_advtime),
|
||||
backtau(_backtau),
|
||||
threshold(_threshold)
|
||||
threshold(_threshold),
|
||||
dtime(0),
|
||||
htime(0),
|
||||
itime(0),
|
||||
atime(0)
|
||||
{
|
||||
wave = new double[((int)(MAX_SAMPLERATE * MAX_TAU) + 1)];
|
||||
tau = tau < 0.0 ? 0.0 : (tau > MAX_TAU ? MAX_TAU : tau);
|
||||
hangtime = hangtime < 0.0 ? 0.0 : (hangtime > MAX_ADVTIME ? MAX_ADVTIME : hangtime);
|
||||
advtime = advtime < 0.0 ? 0.0 : (advtime > MAX_ADVTIME ? MAX_ADVTIME : advtime);
|
||||
samplerate = samplerate < 0.0 ? 0.0 : (samplerate > MAX_SAMPLERATE ? MAX_SAMPLERATE : samplerate);
|
||||
wave.resize((int)(MAX_SAMPLERATE * MAX_TAU) + 1);
|
||||
dline_size = (int)((MAX_TAU + MAX_ADVTIME) * MAX_SAMPLERATE) + 1;
|
||||
dline = new float[dline_size * 2];
|
||||
dline.resize(dline_size * 2);
|
||||
initBlanker();
|
||||
legacy = new float[2048 * 2]; /////////////// legacy interface - remove
|
||||
}
|
||||
|
||||
ANB::~ANB()
|
||||
{
|
||||
delete[] legacy; /////////////// legacy interface - remove
|
||||
delete[] dline;
|
||||
delete[] wave;
|
||||
}
|
||||
|
||||
void ANB::flush()
|
||||
|
14
wdsp/anb.hpp
14
wdsp/anb.hpp
@ -28,6 +28,8 @@ warren@wpratt.com
|
||||
#ifndef wdsp_anb_h
|
||||
#define wdsp_anb_h
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "export.h"
|
||||
|
||||
namespace WDSP {
|
||||
@ -37,17 +39,17 @@ class WDSP_API ANB
|
||||
public:
|
||||
int run;
|
||||
int buffsize; // size of input/output buffer
|
||||
float* in; // input buffer
|
||||
float* out; // output buffer
|
||||
float* in; // input buffer
|
||||
float* out; // output buffer
|
||||
int dline_size; // length of delay line which is 'double dline[length][2]'
|
||||
float *dline; // pointer to delay line
|
||||
std::vector<float> dline; // delay line
|
||||
double samplerate; // samplerate, used to convert times into sample counts
|
||||
double tau; // transition time, signal<->zero
|
||||
double hangtime; // time to stay at zero after noise is no longer detected
|
||||
double advtime; // deadtime (zero output) in advance of detected noise
|
||||
double backtau; // time constant used in averaging the magnitude of the input signal
|
||||
double threshold; // triggers if (noise > threshold * average_signal_magnitude)
|
||||
double *wave; // pointer to array holding transition waveform
|
||||
std::vector<double> wave; // array holding transition waveform
|
||||
int state; // state of the state machine
|
||||
double avg; // average value of the signal magnitude
|
||||
int dtime; // count when decreasing the signal magnitude
|
||||
@ -64,7 +66,6 @@ public:
|
||||
int count; // set each time a noise sample is detected, counts down
|
||||
double backmult; // multiplier for waveform averaging
|
||||
double ombackmult; // multiplier for waveform averaging
|
||||
float *legacy;
|
||||
|
||||
ANB(
|
||||
int run,
|
||||
@ -78,7 +79,8 @@ public:
|
||||
double backtau,
|
||||
double threshold
|
||||
);
|
||||
~ANB();
|
||||
ANB(const ANB&) = delete;
|
||||
~ANB() = default;
|
||||
|
||||
void flush();
|
||||
void execute();
|
||||
|
33
wdsp/nob.cpp
33
wdsp/nob.cpp
@ -105,15 +105,15 @@ NOB::NOB (
|
||||
MAX_HANG_SLEW_TIME +
|
||||
MAX_HANG_TIME +
|
||||
MAX_SEQ_TIME ) + 2);
|
||||
dline = new double[dline_size * 2];
|
||||
imp = new int[dline_size];
|
||||
awave = new double[(int)(MAX_ADV_SLEW_TIME * MAX_SAMPLERATE + 1)];
|
||||
hwave = new double[(int)(MAX_HANG_SLEW_TIME * MAX_SAMPLERATE + 1)];
|
||||
dline.resize(dline_size * 2);
|
||||
imp.resize(dline_size);
|
||||
awave.resize((int)(MAX_ADV_SLEW_TIME * MAX_SAMPLERATE + 1));
|
||||
hwave.resize((int)(MAX_HANG_SLEW_TIME * MAX_SAMPLERATE + 1));
|
||||
|
||||
filterlen = 10;
|
||||
bfbuff = new double[filterlen * 2];
|
||||
ffbuff = new double[filterlen * 2];
|
||||
fcoefs = new double[filterlen];
|
||||
bfbuff.resize(filterlen * 2);
|
||||
ffbuff.resize(filterlen * 2);
|
||||
fcoefs.resize(filterlen);
|
||||
fcoefs[0] = 0.308720593;
|
||||
fcoefs[1] = 0.216104415;
|
||||
fcoefs[2] = 0.151273090;
|
||||
@ -128,17 +128,6 @@ NOB::NOB (
|
||||
init();
|
||||
}
|
||||
|
||||
NOB::~NOB()
|
||||
{
|
||||
delete[] fcoefs;
|
||||
delete[] ffbuff;
|
||||
delete[] bfbuff;
|
||||
delete[] hwave;
|
||||
delete[] awave;
|
||||
delete[] imp;
|
||||
delete[] dline;
|
||||
}
|
||||
|
||||
void NOB::flush()
|
||||
{
|
||||
out_idx = 0;
|
||||
@ -149,10 +138,10 @@ void NOB::flush()
|
||||
avg = 1.0;
|
||||
bfb_in_idx = filterlen - 1;
|
||||
ffb_in_idx = filterlen - 1;
|
||||
std::fill(dline, dline + dline_size * 2, 0);
|
||||
std::fill(imp, imp + dline_size, 0);
|
||||
std::fill(bfbuff, bfbuff + filterlen * 2, 0);
|
||||
std::fill(ffbuff, ffbuff + filterlen * 2, 0);
|
||||
std::fill(dline.begin(), dline.end(), 0);
|
||||
std::fill(imp.begin(), imp.end(), 0);
|
||||
std::fill(bfbuff.begin(), bfbuff.end(), 0);
|
||||
std::fill(ffbuff.begin(), ffbuff.end(), 0);
|
||||
}
|
||||
|
||||
void NOB::execute()
|
||||
|
23
wdsp/nob.hpp
23
wdsp/nob.hpp
@ -28,6 +28,8 @@ warren@wpratt.com
|
||||
#ifndef wdsp_nob_h
|
||||
#define wdsp_nob_h
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "export.h"
|
||||
|
||||
namespace WDSP {
|
||||
@ -37,11 +39,11 @@ class WDSP_API NOB
|
||||
public:
|
||||
int run;
|
||||
int buffsize; // size of input/output buffer
|
||||
float* in; // input buffer
|
||||
float* out; // output buffer
|
||||
float* in; // input buffer
|
||||
float* out; // output buffer
|
||||
int dline_size; // length of delay line which is 'double dline[length][2]'
|
||||
double *dline; // pointer to delay line
|
||||
int *imp;
|
||||
std::vector<double> dline; // delay line
|
||||
std::vector<int> imp;
|
||||
double samplerate; // samplerate, used to convert times into sample counts
|
||||
int mode;
|
||||
double advslewtime; // transition time, signal<->zero
|
||||
@ -50,15 +52,15 @@ public:
|
||||
double hangtime; // time to stay at zero after noise is no longer detected
|
||||
double max_imp_seq_time;
|
||||
int filterlen;
|
||||
double *fcoefs;
|
||||
double *bfbuff;
|
||||
std::vector<double> fcoefs;
|
||||
std::vector<double> bfbuff;
|
||||
int bfb_in_idx;
|
||||
double *ffbuff;
|
||||
std::vector<double> ffbuff;
|
||||
int ffb_in_idx;
|
||||
double backtau; // time constant used in averaging the magnitude of the input signal
|
||||
double threshold; // triggers if (noise > threshold * average_signal_magnitude)
|
||||
double *awave; // pointer to array holding transition waveform
|
||||
double *hwave;
|
||||
std::vector<double> awave; // array holding transition waveform
|
||||
std::vector<double> hwave;
|
||||
int state; // state of the state machine
|
||||
double avg; // average value of the signal magnitude
|
||||
int time; // count when decreasing the signal magnitude
|
||||
@ -96,7 +98,8 @@ public:
|
||||
double backtau,
|
||||
double threshold
|
||||
);
|
||||
~NOB();
|
||||
NOB(const NOB&) = delete;
|
||||
~NOB() = default;
|
||||
//////////// legacy interface - remove
|
||||
void flush();
|
||||
void execute();
|
||||
|
Loading…
Reference in New Issue
Block a user