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