mirror of
https://github.com/f4exb/sdrangel.git
synced 2025-06-29 23:45:22 -04:00
Compare commits
3 Commits
59f97f3912
...
3c2192603b
Author | SHA1 | Date | |
---|---|---|---|
|
3c2192603b | ||
|
86f27fc4d6 | ||
|
8a267240df |
@ -486,18 +486,18 @@ void WDSPRxSink::applySettings(const WDSPRxSettings& settings, bool force)
|
||||
if ((m_settings.m_dnr != settings.m_dnr)
|
||||
|| (m_settings.m_nrScheme != settings.m_nrScheme) || force)
|
||||
{
|
||||
WDSP::ANR::SetANRRun(*m_rxa, 0);
|
||||
WDSP::EMNR::SetEMNRRun(*m_rxa, 0);
|
||||
WDSP::RXA::SetANRRun(*m_rxa, 0);
|
||||
WDSP::RXA::SetEMNRRun(*m_rxa, 0);
|
||||
|
||||
if (settings.m_dnr)
|
||||
{
|
||||
switch (settings.m_nrScheme)
|
||||
{
|
||||
case WDSPRxProfile::NRSchemeNR:
|
||||
WDSP::ANR::SetANRRun(*m_rxa, 1);
|
||||
WDSP::RXA::SetANRRun(*m_rxa, 1);
|
||||
break;
|
||||
case WDSPRxProfile::NRSchemeNR2:
|
||||
WDSP::EMNR::SetEMNRRun(*m_rxa, 1);
|
||||
WDSP::RXA::SetEMNRRun(*m_rxa, 1);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@ -560,7 +560,7 @@ void WDSPRxSink::applySettings(const WDSPRxSettings& settings, bool force)
|
||||
}
|
||||
|
||||
if ((m_settings.m_anf != settings.m_anf) || force) {
|
||||
WDSP::ANF::SetANFRun(*m_rxa, settings.m_anf ? 1 : 0);
|
||||
WDSP::RXA::SetANFRun(*m_rxa, settings.m_anf ? 1 : 0);
|
||||
}
|
||||
|
||||
// Caution: Causes corruption
|
||||
|
75
wdsp/RXA.cpp
75
wdsp/RXA.cpp
@ -289,7 +289,7 @@ RXA* RXA::create_rxa (
|
||||
rxa->dsp_size, // buffer size
|
||||
rxa->midbuff, // pointer to input signal buffer
|
||||
rxa->midbuff, // pointer to output signal buffer
|
||||
rxa->fmd->audio, // pointer to trigger buffer
|
||||
rxa->fmd->audio.data(), // pointer to trigger buffer
|
||||
rxa->dsp_rate, // sample rate
|
||||
5000.0, // cutoff freq for noise filter (Hz)
|
||||
&rxa->fmd->pllpole, // pointer to pole frequency of the fmd pll (Hz)
|
||||
@ -760,9 +760,9 @@ void RXA::setDSPSamplerate (RXA *rxa, int dsp_rate)
|
||||
rxa->amsq->setSamplerate(rxa->dsp_rate);
|
||||
rxa->amd->setSamplerate(rxa->dsp_rate);
|
||||
rxa->fmd->setSamplerate(rxa->dsp_rate);
|
||||
rxa->fmsq->setBuffers(rxa->midbuff, rxa->midbuff, rxa->fmd->audio);
|
||||
rxa->fmsq->setBuffers(rxa->midbuff, rxa->midbuff, rxa->fmd->audio.data());
|
||||
rxa->fmsq->setSamplerate(rxa->dsp_rate);
|
||||
rxa->snba->setSamplerate(rxa->dsp_rate);
|
||||
// rxa->snba->setSamplerate(rxa->dsp_rate); SMBA removed
|
||||
rxa->eqp->setSamplerate(rxa->dsp_rate);
|
||||
ANF::setSamplerate_anf (rxa->anf, rxa->dsp_rate);
|
||||
ANR::setSamplerate_anr (rxa->anr, rxa->dsp_rate);
|
||||
@ -831,7 +831,7 @@ void RXA::setDSPBuffsize (RXA *rxa, int dsp_size)
|
||||
rxa->amd->setSize(rxa->dsp_size);
|
||||
rxa->fmd->setBuffers(rxa->midbuff, rxa->midbuff);
|
||||
rxa->fmd->setSize(rxa->dsp_size);
|
||||
rxa->fmsq->setBuffers(rxa->midbuff, rxa->midbuff, rxa->fmd->audio);
|
||||
rxa->fmsq->setBuffers(rxa->midbuff, rxa->midbuff, rxa->fmd->audio.data());
|
||||
rxa->fmsq->setSize(rxa->dsp_size);
|
||||
rxa->snba->setBuffers(rxa->midbuff, rxa->midbuff);
|
||||
rxa->snba->setSize(rxa->dsp_size);
|
||||
@ -1225,20 +1225,20 @@ void RXA::NBPSetAutoIncrease (RXA& rxa, int autoincr)
|
||||
}
|
||||
}
|
||||
|
||||
void RXA::SetAMDRun(RXA& rxa, int _run)
|
||||
void RXA::SetAMDRun(RXA& rxa, int run)
|
||||
{
|
||||
if (rxa.amd->run != _run)
|
||||
if (rxa.amd->run != run)
|
||||
{
|
||||
RXA::bp1Check (
|
||||
rxa,
|
||||
_run,
|
||||
run,
|
||||
rxa.snba->run,
|
||||
rxa.emnr->run,
|
||||
rxa.anf->run,
|
||||
rxa.anr->run
|
||||
);
|
||||
|
||||
rxa.amd->run = _run;
|
||||
rxa.amd->run = run;
|
||||
RXA::bp1Set (rxa);
|
||||
}
|
||||
}
|
||||
@ -1264,6 +1264,65 @@ void RXA::SetSNBARun (RXA& rxa, int run)
|
||||
}
|
||||
}
|
||||
|
||||
void RXA::SetANFRun (RXA& rxa, int run)
|
||||
{
|
||||
ANF *a = rxa.anf;
|
||||
|
||||
if (a->run != run)
|
||||
{
|
||||
RXA::bp1Check (
|
||||
rxa,
|
||||
rxa.amd->run,
|
||||
rxa.snba->run,
|
||||
rxa.emnr->run,
|
||||
run,
|
||||
rxa.anr->run
|
||||
);
|
||||
a->run = run;
|
||||
RXA::bp1Set (rxa);
|
||||
ANF::flush_anf (a);
|
||||
}
|
||||
}
|
||||
|
||||
void RXA::SetANRRun (RXA& rxa, int run)
|
||||
{
|
||||
ANR *a = rxa.anr;
|
||||
|
||||
if (a->run != run)
|
||||
{
|
||||
RXA::bp1Check (
|
||||
rxa,
|
||||
rxa.amd->run,
|
||||
rxa.snba->run,
|
||||
rxa.emnr->run,
|
||||
rxa.anf->run,
|
||||
run
|
||||
);
|
||||
a->run = run;
|
||||
RXA::bp1Set (rxa);
|
||||
ANR::flush_anr (a);
|
||||
}
|
||||
}
|
||||
|
||||
void RXA::SetEMNRRun (RXA& rxa, int run)
|
||||
{
|
||||
EMNR *a = rxa.emnr;
|
||||
|
||||
if (a->run != run)
|
||||
{
|
||||
RXA::bp1Check (
|
||||
rxa,
|
||||
rxa.amd->run,
|
||||
rxa.snba->run,
|
||||
run,
|
||||
rxa.anf->run,
|
||||
rxa.anr->run
|
||||
);
|
||||
a->run = run;
|
||||
RXA::bp1Set (rxa);
|
||||
}
|
||||
}
|
||||
|
||||
/********************************************************************************************************
|
||||
* *
|
||||
* Collectives *
|
||||
|
@ -171,6 +171,12 @@ public:
|
||||
static void SetAMDRun(RXA& rxa, int run);
|
||||
// SNBA
|
||||
static void SetSNBARun (RXA& rxa, int run);
|
||||
// ANF
|
||||
static void SetANFRun (RXA& rxa, int run);
|
||||
// ANR
|
||||
static void SetANRRun (RXA& rxa, int run);
|
||||
// EMNR
|
||||
static void SetEMNRRun (RXA& rxa, int run);
|
||||
|
||||
// Collectives
|
||||
static void SetPassband (RXA& rxa, float f_low, float f_high);
|
||||
|
15
wdsp/amd.hpp
15
wdsp/amd.hpp
@ -37,6 +37,8 @@ warren@wpratt.com
|
||||
#define OUT_IDX (3 * STAGES)
|
||||
#endif
|
||||
|
||||
#include <array>
|
||||
|
||||
#include "export.h"
|
||||
|
||||
namespace WDSP {
|
||||
@ -68,12 +70,12 @@ public:
|
||||
double onem_mtauR; // 1.0 - carrier_removal_multiplier
|
||||
double mtauI; // carrier insertion multiplier
|
||||
double onem_mtauI; // 1.0 - carrier_insertion_multiplier
|
||||
double a[3 * STAGES + 3]; // Filter a variables
|
||||
double b[3 * STAGES + 3]; // Filter b variables
|
||||
double c[3 * STAGES + 3]; // Filter c variables
|
||||
double d[3 * STAGES + 3]; // Filter d variables
|
||||
double c0[STAGES]; // Filter coefficients - path 0
|
||||
double c1[STAGES]; // Filter coefficients - path 1
|
||||
std::array<double, 3*STAGES + 3> a; // Filter a variables
|
||||
std::array<double, 3*STAGES + 3> b; // Filter b variables
|
||||
std::array<double, 3*STAGES + 3> c; // Filter c variables
|
||||
std::array<double, 3*STAGES + 3> d; // Filter d variables
|
||||
std::array<double, STAGES> c0; // Filter coefficients - path 0
|
||||
std::array<double, STAGES> c1; // Filter coefficients - path 1
|
||||
double dsI; // delayed sample, I path
|
||||
double dsQ; // delayed sample, Q path
|
||||
double dc_insert; // dc component to insert in output
|
||||
@ -97,6 +99,7 @@ public:
|
||||
double tauR,
|
||||
double tauI
|
||||
);
|
||||
AMD(const AMD&) = delete;
|
||||
~AMD() = default;
|
||||
|
||||
void init();
|
||||
|
@ -58,27 +58,20 @@ void AMSQ::compute_slews()
|
||||
void AMSQ::calc()
|
||||
{
|
||||
// signal averaging
|
||||
trigsig = new float[size * 2];
|
||||
trigsig.resize(size * 2);
|
||||
avm = exp(-1.0 / (rate * avtau));
|
||||
onem_avm = 1.0 - avm;
|
||||
avsig = 0.0;
|
||||
// level change
|
||||
ntup = (int)(tup * rate);
|
||||
ntdown = (int)(tdown * rate);
|
||||
cup = new double[(ntup + 1) * 2]; // (float *)malloc0((ntup + 1) * sizeof(float));
|
||||
cdown = new double[(ntdown + 1) * 2]; // (float *)malloc0((ntdown + 1) * sizeof(float));
|
||||
cup.resize((ntup + 1) * 2); // (float *)malloc0((ntup + 1) * sizeof(float));
|
||||
cdown.resize((ntdown + 1) * 2); // (float *)malloc0((ntdown + 1) * sizeof(float));
|
||||
compute_slews();
|
||||
// control
|
||||
state = 0;
|
||||
}
|
||||
|
||||
void AMSQ::decalc()
|
||||
{
|
||||
delete[] cdown;
|
||||
delete[] cup;
|
||||
delete[] trigsig;
|
||||
}
|
||||
|
||||
AMSQ::AMSQ (
|
||||
int _run,
|
||||
int _size,
|
||||
@ -113,14 +106,9 @@ AMSQ::AMSQ (
|
||||
calc();
|
||||
}
|
||||
|
||||
AMSQ::~AMSQ()
|
||||
{
|
||||
decalc();
|
||||
}
|
||||
|
||||
void AMSQ::flush()
|
||||
{
|
||||
std::fill(trigsig, trigsig + size * 2, 0);
|
||||
std::fill(trigsig.begin(), trigsig.end(), 0);
|
||||
avsig = 0.0;
|
||||
state = 0;
|
||||
}
|
||||
@ -222,7 +210,7 @@ void AMSQ::execute()
|
||||
|
||||
void AMSQ::xcap()
|
||||
{
|
||||
std::copy(trigger, trigger + size * 2, trigsig);
|
||||
std::copy(trigger, trigger + size * 2, trigsig.begin());
|
||||
}
|
||||
|
||||
void AMSQ::setBuffers(float* _in, float* _out, float* _trigger)
|
||||
@ -234,14 +222,12 @@ void AMSQ::setBuffers(float* _in, float* _out, float* _trigger)
|
||||
|
||||
void AMSQ::setSamplerate(int _rate)
|
||||
{
|
||||
decalc();
|
||||
rate = _rate;
|
||||
calc();
|
||||
}
|
||||
|
||||
void AMSQ::setSize(int _size)
|
||||
{
|
||||
decalc();
|
||||
size = _size;
|
||||
calc();
|
||||
}
|
||||
|
@ -27,6 +27,8 @@ warren@wpratt.com
|
||||
#ifndef _amsq_h
|
||||
#define _amsq_h
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "export.h"
|
||||
|
||||
namespace WDSP {
|
||||
@ -37,25 +39,25 @@ class TXA;
|
||||
class WDSP_API AMSQ
|
||||
{
|
||||
public:
|
||||
int run; // 0 if squelch system is OFF; 1 if it's ON
|
||||
int size; // size of input/output buffers
|
||||
int run; // 0 if squelch system is OFF; 1 if it's ON
|
||||
int size; // size of input/output buffers
|
||||
float* in; // squelch input signal buffer
|
||||
float* out; // squelch output signal buffer
|
||||
float* trigger; // pointer to trigger data source
|
||||
float* trigsig; // buffer containing trigger signal
|
||||
double rate; // sample rate
|
||||
double avtau; // time constant for averaging noise
|
||||
std::vector<float> trigsig; // buffer containing trigger signal
|
||||
double rate; // sample rate
|
||||
double avtau; // time constant for averaging noise
|
||||
double avm;
|
||||
double onem_avm;
|
||||
double avsig;
|
||||
int state; // state machine control
|
||||
int state; // state machine control
|
||||
int count;
|
||||
double tup;
|
||||
double tdown;
|
||||
int ntup;
|
||||
int ntdown;
|
||||
double* cup;
|
||||
double* cdown;
|
||||
std::vector<double> cup;
|
||||
std::vector<double> cdown;
|
||||
double tail_thresh;
|
||||
double unmute_thresh;
|
||||
double min_tail;
|
||||
@ -78,7 +80,8 @@ public:
|
||||
double _max_tail,
|
||||
double _muted_gain
|
||||
);
|
||||
~AMSQ();
|
||||
AMSQ(const AMSQ&) = delete;
|
||||
~AMSQ() = default;
|
||||
|
||||
void flush();
|
||||
void execute();
|
||||
@ -95,7 +98,6 @@ public:
|
||||
private:
|
||||
void compute_slews();
|
||||
void calc();
|
||||
void decalc();
|
||||
};
|
||||
|
||||
} // namespace WDSP
|
||||
|
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();
|
||||
|
21
wdsp/anf.cpp
21
wdsp/anf.cpp
@ -182,27 +182,6 @@ void ANF::setSize_anf (ANF *a, int size)
|
||||
* *
|
||||
********************************************************************************************************/
|
||||
|
||||
void ANF::SetANFRun (RXA& rxa, int run)
|
||||
{
|
||||
ANF *a = rxa.anf;
|
||||
|
||||
if (a->run != run)
|
||||
{
|
||||
RXA::bp1Check (
|
||||
rxa,
|
||||
rxa.amd->run,
|
||||
rxa.snba->run,
|
||||
rxa.emnr->run,
|
||||
run,
|
||||
rxa.anr->run
|
||||
);
|
||||
a->run = run;
|
||||
RXA::bp1Set (rxa);
|
||||
flush_anf (a);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ANF::SetANFVals (RXA& rxa, int taps, int delay, double gain, double leakage)
|
||||
{
|
||||
rxa.anf->n_taps = taps;
|
||||
|
@ -87,7 +87,6 @@ public:
|
||||
static void setSamplerate_anf (ANF *a, int rate);
|
||||
static void setSize_anf (ANF *a, int size);
|
||||
// RXA Properties
|
||||
static void SetANFRun (RXA& rxa, int setit);
|
||||
static void SetANFVals (RXA& rxa, int taps, int delay, double gain, double leakage);
|
||||
static void SetANFTaps (RXA& rxa, int taps);
|
||||
static void SetANFDelay (RXA& rxa, int delay);
|
||||
|
20
wdsp/anr.cpp
20
wdsp/anr.cpp
@ -182,26 +182,6 @@ void ANR::setSize_anr (ANR *a, int size)
|
||||
* *
|
||||
********************************************************************************************************/
|
||||
|
||||
void ANR::SetANRRun (RXA& rxa, int run)
|
||||
{
|
||||
ANR *a = rxa.anr;
|
||||
|
||||
if (a->run != run)
|
||||
{
|
||||
RXA::bp1Check (
|
||||
rxa,
|
||||
rxa.amd->run,
|
||||
rxa.snba->run,
|
||||
rxa.emnr->run,
|
||||
rxa.anf->run,
|
||||
run
|
||||
);
|
||||
a->run = run;
|
||||
RXA::bp1Set (rxa);
|
||||
flush_anr (a);
|
||||
}
|
||||
}
|
||||
|
||||
void ANR::SetANRVals (RXA& rxa, int taps, int delay, double gain, double leakage)
|
||||
{
|
||||
rxa.anr->n_taps = taps;
|
||||
|
@ -89,7 +89,6 @@ public:
|
||||
static void setSamplerate_anr (ANR *a, int rate);
|
||||
static void setSize_anr (ANR *a, int size);
|
||||
// RXA Properties
|
||||
static void SetANRRun (RXA& rxa, int setit);
|
||||
static void SetANRVals (RXA& rxa, int taps, int delay, double gain, double leakage);
|
||||
static void SetANRTaps (RXA& rxa, int taps);
|
||||
static void SetANRDelay (RXA& rxa, int delay);
|
||||
|
@ -79,6 +79,7 @@ public:
|
||||
int maxpb,
|
||||
NOTCHDB* notchdb
|
||||
);
|
||||
BPSNBA(const BPSNBA&) = delete;
|
||||
~BPSNBA();
|
||||
|
||||
void flush();
|
||||
|
@ -1071,25 +1071,6 @@ void EMNR::setSize_emnr (EMNR *a, int size)
|
||||
* *
|
||||
********************************************************************************************************/
|
||||
|
||||
void EMNR::SetEMNRRun (RXA& rxa, int run)
|
||||
{
|
||||
EMNR *a = rxa.emnr;
|
||||
|
||||
if (a->run != run)
|
||||
{
|
||||
RXA::bp1Check (
|
||||
rxa,
|
||||
rxa.amd->run,
|
||||
rxa.snba->run,
|
||||
run,
|
||||
rxa.anf->run,
|
||||
rxa.anr->run
|
||||
);
|
||||
a->run = run;
|
||||
RXA::bp1Set (rxa);
|
||||
}
|
||||
}
|
||||
|
||||
void EMNR::SetEMNRgainMethod (RXA& rxa, int method)
|
||||
{
|
||||
rxa.emnr->g.gain_method = method;
|
||||
|
@ -185,7 +185,6 @@ public:
|
||||
static void setSamplerate_emnr (EMNR *a, int rate);
|
||||
static void setSize_emnr (EMNR *a, int size);
|
||||
// RXA Properties
|
||||
static void SetEMNRRun (RXA& rxa, int run);
|
||||
static void SetEMNRgainMethod (RXA& rxa, int method);
|
||||
static void SetEMNRnpeMethod (RXA& rxa, int method);
|
||||
static void SetEMNRaeRun (RXA& rxa, int run);
|
||||
|
49
wdsp/eqp.cpp
49
wdsp/eqp.cpp
@ -222,14 +222,14 @@ EQP::EQP(
|
||||
in = _in;
|
||||
out = _out;
|
||||
nfreqs = _nfreqs;
|
||||
F = new float[nfreqs + 1]; // (float *) malloc0 ((nfreqs + 1) * sizeof (float));
|
||||
G = new float[nfreqs + 1]; // (float *) malloc0 ((nfreqs + 1) * sizeof (float));
|
||||
memcpy (F, _F, (_nfreqs + 1) * sizeof (float));
|
||||
memcpy (G, _G, (_nfreqs + 1) * sizeof (float));
|
||||
F.resize(nfreqs + 1); // (float *) malloc0 ((nfreqs + 1) * sizeof (float));
|
||||
G.resize(nfreqs + 1); // (float *) malloc0 ((nfreqs + 1) * sizeof (float));
|
||||
std::copy(_F, _F + (_nfreqs + 1), F.begin());
|
||||
std::copy(_G, _G + (_nfreqs + 1), G.begin());
|
||||
ctfmode = _ctfmode;
|
||||
wintype = _wintype;
|
||||
samplerate = (double) _samplerate;
|
||||
impulse = eq_impulse (nc, nfreqs, F, G, samplerate, 1.0 / (2.0 * size), ctfmode, wintype);
|
||||
impulse = eq_impulse (nc, nfreqs, F.data(), G.data(), samplerate, 1.0 / (2.0 * size), ctfmode, wintype);
|
||||
fircore = FIRCORE::create_fircore (size, in, out, nc, mp, impulse);
|
||||
delete[] (impulse);
|
||||
}
|
||||
@ -263,7 +263,7 @@ void EQP::setSamplerate(int rate)
|
||||
{
|
||||
float* impulse;
|
||||
samplerate = rate;
|
||||
impulse = eq_impulse (nc, nfreqs, F, G, samplerate, 1.0 / (2.0 * size), ctfmode, wintype);
|
||||
impulse = eq_impulse (nc, nfreqs, F.data(), G.data(), samplerate, 1.0 / (2.0 * size), ctfmode, wintype);
|
||||
FIRCORE::setImpulse_fircore (fircore, impulse, 1);
|
||||
delete[] (impulse);
|
||||
}
|
||||
@ -273,7 +273,7 @@ void EQP::setSize(int _size)
|
||||
float* impulse;
|
||||
size = _size;
|
||||
FIRCORE::setSize_fircore (fircore, size);
|
||||
impulse = eq_impulse (nc, nfreqs, F, G, samplerate, 1.0 / (2.0 * size), ctfmode, wintype);
|
||||
impulse = eq_impulse (nc, nfreqs, F.data(), G.data(), samplerate, 1.0 / (2.0 * size), ctfmode, wintype);
|
||||
FIRCORE::setImpulse_fircore (fircore, impulse, 1);
|
||||
delete[] (impulse);
|
||||
}
|
||||
@ -296,7 +296,7 @@ void EQP::setNC(int _nc)
|
||||
if (nc != _nc)
|
||||
{
|
||||
nc = _nc;
|
||||
impulse = eq_impulse (nc, nfreqs, F, G, samplerate, 1.0 / (2.0 * size), ctfmode, wintype);
|
||||
impulse = eq_impulse (nc, nfreqs, F.data(), G.data(), samplerate, 1.0 / (2.0 * size), ctfmode, wintype);
|
||||
FIRCORE::setNc_fircore (fircore, nc, impulse);
|
||||
delete[] (impulse);
|
||||
}
|
||||
@ -314,15 +314,12 @@ void EQP::setMP(int _mp)
|
||||
void EQP::setProfile(int _nfreqs, const float* _F, const float* _G)
|
||||
{
|
||||
float* impulse;
|
||||
delete[] (G);
|
||||
delete[] (F);
|
||||
nfreqs = _nfreqs;
|
||||
F = new float[nfreqs + 1]; // (float *) malloc0 ((nfreqs + 1) * sizeof (float));
|
||||
G = new float[nfreqs + 1]; // (float *) malloc0 ((nfreqs + 1) * sizeof (float));
|
||||
memcpy (F, _F, (_nfreqs + 1) * sizeof (float));
|
||||
memcpy (G, _G, (_nfreqs + 1) * sizeof (float));
|
||||
impulse = eq_impulse (nc, nfreqs, F, G,
|
||||
samplerate, 1.0 / (2.0 * size), ctfmode, wintype);
|
||||
F.resize(nfreqs + 1); // (float *) malloc0 ((nfreqs + 1) * sizeof (float));
|
||||
G.resize(nfreqs + 1); // (float *) malloc0 ((nfreqs + 1) * sizeof (float));
|
||||
std::copy(_F, _F + (_nfreqs + 1), F.begin());
|
||||
std::copy(_G, _G + (_nfreqs + 1), G.begin());
|
||||
impulse = eq_impulse (nc, nfreqs, F.data(), G.data(), samplerate, 1.0 / (2.0 * size), ctfmode, wintype);
|
||||
FIRCORE::setImpulse_fircore (fircore, impulse, 1);
|
||||
delete[] (impulse);
|
||||
}
|
||||
@ -331,7 +328,7 @@ void EQP::setCtfmode(int _mode)
|
||||
{
|
||||
float* impulse;
|
||||
ctfmode = _mode;
|
||||
impulse = eq_impulse (nc, nfreqs, F, G, samplerate, 1.0 / (2.0 * size), ctfmode, wintype);
|
||||
impulse = eq_impulse (nc, nfreqs, F.data(), G.data(), samplerate, 1.0 / (2.0 * size), ctfmode, wintype);
|
||||
FIRCORE::setImpulse_fircore (fircore, impulse, 1);
|
||||
delete[] (impulse);
|
||||
}
|
||||
@ -340,7 +337,7 @@ void EQP::setWintype(int _wintype)
|
||||
{
|
||||
float* impulse;
|
||||
wintype = _wintype;
|
||||
impulse = eq_impulse (nc, nfreqs, F, G, samplerate, 1.0 / (2.0 * size), ctfmode, wintype);
|
||||
impulse = eq_impulse (nc, nfreqs, F.data(), G.data(), samplerate, 1.0 / (2.0 * size), ctfmode, wintype);
|
||||
FIRCORE::setImpulse_fircore (fircore, impulse, 1);
|
||||
delete[] (impulse);
|
||||
}
|
||||
@ -348,11 +345,9 @@ void EQP::setWintype(int _wintype)
|
||||
void EQP::setGrphEQ(int *rxeq)
|
||||
{ // three band equalizer (legacy compatibility)
|
||||
float* impulse;
|
||||
delete[] (G);
|
||||
delete[] (F);
|
||||
nfreqs = 4;
|
||||
F = new float[nfreqs + 1]; // (float *) malloc0 ((nfreqs + 1) * sizeof (float));
|
||||
G = new float[nfreqs + 1]; // (float *) malloc0 ((nfreqs + 1) * sizeof (float));
|
||||
F.resize(nfreqs + 1); // (float *) malloc0 ((nfreqs + 1) * sizeof (float));
|
||||
G.resize(nfreqs + 1); // (float *) malloc0 ((nfreqs + 1) * sizeof (float));
|
||||
F[1] = 150.0;
|
||||
F[2] = 400.0;
|
||||
F[3] = 1500.0;
|
||||
@ -363,7 +358,7 @@ void EQP::setGrphEQ(int *rxeq)
|
||||
G[3] = (float)rxeq[2];
|
||||
G[4] = (float)rxeq[3];
|
||||
ctfmode = 0;
|
||||
impulse = eq_impulse (nc, nfreqs, F, G, samplerate, 1.0 / (2.0 * size), ctfmode, wintype);
|
||||
impulse = eq_impulse (nc, nfreqs, F.data(), G.data(), samplerate, 1.0 / (2.0 * size), ctfmode, wintype);
|
||||
FIRCORE::setImpulse_fircore (fircore, impulse, 1);
|
||||
delete[] (impulse);
|
||||
}
|
||||
@ -372,11 +367,9 @@ void EQP::setGrphEQ10(int *rxeq)
|
||||
{ // ten band equalizer (legacy compatibility)
|
||||
float* impulse;
|
||||
int i;
|
||||
delete[] (G);
|
||||
delete[] (F);
|
||||
nfreqs = 10;
|
||||
F = new float[nfreqs + 1]; // (float *) malloc0 ((nfreqs + 1) * sizeof (float));
|
||||
G = new float[nfreqs + 1]; // (float *) malloc0 ((nfreqs + 1) * sizeof (float));
|
||||
F.resize(nfreqs + 1); // (float *) malloc0 ((nfreqs + 1) * sizeof (float));
|
||||
G.resize(nfreqs + 1); // (float *) malloc0 ((nfreqs + 1) * sizeof (float));
|
||||
F[1] = 32.0;
|
||||
F[2] = 63.0;
|
||||
F[3] = 125.0;
|
||||
@ -390,7 +383,7 @@ void EQP::setGrphEQ10(int *rxeq)
|
||||
for (i = 0; i <= nfreqs; i++)
|
||||
G[i] = (float)rxeq[i];
|
||||
ctfmode = 0;
|
||||
impulse = eq_impulse (nc, nfreqs, F, G, samplerate, 1.0 / (2.0 * size), ctfmode, wintype);
|
||||
impulse = eq_impulse (nc, nfreqs, F.data(), G.data(), samplerate, 1.0 / (2.0 * size), ctfmode, wintype);
|
||||
// print_impulse ("rxeq.txt", nc, impulse, 1, 0);
|
||||
FIRCORE::setImpulse_fircore (fircore, impulse, 1);
|
||||
delete[] (impulse);
|
||||
|
@ -34,6 +34,8 @@ warren@wpratt.com
|
||||
#ifndef wdsp_eqp_h
|
||||
#define wdsp_eqp_h
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "export.h"
|
||||
|
||||
namespace WDSP {
|
||||
@ -52,8 +54,8 @@ public:
|
||||
float* in;
|
||||
float* out;
|
||||
int nfreqs;
|
||||
float* F;
|
||||
float* G;
|
||||
std::vector<float> F;
|
||||
std::vector<float> G;
|
||||
int ctfmode;
|
||||
int wintype;
|
||||
double samplerate;
|
||||
@ -73,6 +75,7 @@ public:
|
||||
int wintype,
|
||||
int samplerate
|
||||
);
|
||||
EQP(const EQP&) = delete;
|
||||
~EQP();
|
||||
|
||||
void flush();
|
||||
|
14
wdsp/fmd.cpp
14
wdsp/fmd.cpp
@ -136,9 +136,9 @@ FMD::FMD(
|
||||
float* impulse;
|
||||
calc();
|
||||
// de-emphasis filter
|
||||
audio = new float[size * 2]; // (float *) malloc0 (size * sizeof (complex));
|
||||
audio.resize(size * 2); // (float *) malloc0 (size * sizeof (complex));
|
||||
impulse = FCurve::fc_impulse (nc_de, f_low, f_high, +20.0 * log10(f_high / f_low), 0.0, 1, rate, 1.0 / (2.0 * size), 0, 0);
|
||||
pde = FIRCORE::create_fircore (size, audio, out, nc_de, mp_de, impulse);
|
||||
pde = FIRCORE::create_fircore (size, audio.data(), out, nc_de, mp_de, impulse);
|
||||
delete[] (impulse);
|
||||
// audio filter
|
||||
impulse = FIR::fir_bandpass(nc_aud, 0.8 * f_low, 1.1 * f_high, rate, 0, 1, afgain / (2.0 * size));
|
||||
@ -150,13 +150,12 @@ FMD::~FMD()
|
||||
{
|
||||
FIRCORE::destroy_fircore (paud);
|
||||
FIRCORE::destroy_fircore (pde);
|
||||
delete[] (audio);
|
||||
decalc();
|
||||
}
|
||||
|
||||
void FMD::flush()
|
||||
{
|
||||
std::fill(audio, audio + size * 2, 0);
|
||||
std::fill(audio.begin(), audio.end(), 0);
|
||||
FIRCORE::flush_fircore (pde);
|
||||
FIRCORE::flush_fircore (paud);
|
||||
phs = 0.0;
|
||||
@ -219,7 +218,7 @@ void FMD::setBuffers(float* _in, float* _out)
|
||||
in = _in;
|
||||
out = _out;
|
||||
calc();
|
||||
FIRCORE::setBuffers_fircore (pde, audio, out);
|
||||
FIRCORE::setBuffers_fircore (pde, audio.data(), out);
|
||||
FIRCORE::setBuffers_fircore (paud, out, out);
|
||||
WCPAGC::setBuffers_wcpagc (plim, out, out);
|
||||
}
|
||||
@ -245,14 +244,13 @@ void FMD::setSize(int _size)
|
||||
{
|
||||
float* impulse;
|
||||
decalc();
|
||||
delete[] (audio);
|
||||
size = _size;
|
||||
calc();
|
||||
audio = new float[size * 2]; // (float *) malloc0 (size * sizeof (complex));
|
||||
audio.resize(size * 2); // (float *) malloc0 (size * sizeof (complex));
|
||||
// de-emphasis filter
|
||||
FIRCORE::destroy_fircore (pde);
|
||||
impulse = FCurve::fc_impulse (nc_de, f_low, f_high, +20.0 * log10(f_high / f_low), 0.0, 1, rate, 1.0 / (2.0 * size), 0, 0);
|
||||
pde = FIRCORE::create_fircore (size, audio, out, nc_de, mp_de, impulse);
|
||||
pde = FIRCORE::create_fircore (size, audio.data(), out, nc_de, mp_de, impulse);
|
||||
delete[] (impulse);
|
||||
// audio filter
|
||||
FIRCORE::destroy_fircore (paud);
|
||||
|
@ -28,6 +28,8 @@ warren@wpratt.com
|
||||
#ifndef wdsp_fmd_h
|
||||
#define wdsp_fmd_h
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "export.h"
|
||||
|
||||
namespace WDSP {
|
||||
@ -67,7 +69,7 @@ public:
|
||||
double deviation;
|
||||
double again;
|
||||
// for de-emphasis filter
|
||||
float* audio;
|
||||
std::vector<float> audio;
|
||||
FIRCORE *pde;
|
||||
int nc_de;
|
||||
int mp_de;
|
||||
@ -108,6 +110,7 @@ public:
|
||||
int nc_aud,
|
||||
int mp_aud
|
||||
);
|
||||
FMD(const FMD&) = delete;
|
||||
~FMD();
|
||||
|
||||
void flush();
|
||||
|
@ -38,7 +38,7 @@ void FMSQ::calc()
|
||||
float* impulse;
|
||||
int i;
|
||||
// noise filter
|
||||
noise = new float[2 * size * 2]; // (float *)malloc0(2 * size * sizeof(complex));
|
||||
noise.resize(2 * size * 2); // (float *)malloc0(2 * size * sizeof(complex));
|
||||
F[0] = 0.0;
|
||||
F[1] = fc;
|
||||
F[2] = *pllpole;
|
||||
@ -47,8 +47,8 @@ void FMSQ::calc()
|
||||
G[1] = 0.0;
|
||||
G[2] = 3.0;
|
||||
G[3] = +20.0 * log10(20000.0 / *pllpole);
|
||||
impulse = EQP::eq_impulse (nc, 3, F, G, rate, 1.0 / (2.0 * size), 0, 0);
|
||||
p = FIRCORE::create_fircore (size, trigger, noise, nc, mp, impulse);
|
||||
impulse = EQP::eq_impulse (nc, 3, F.data(), G.data(), rate, 1.0 / (2.0 * size), 0, 0);
|
||||
p = FIRCORE::create_fircore (size, trigger, noise.data(), nc, mp, impulse);
|
||||
delete[] (impulse);
|
||||
// noise averaging
|
||||
avm = exp(-1.0 / (rate * avtau));
|
||||
@ -60,8 +60,8 @@ void FMSQ::calc()
|
||||
// level change
|
||||
ntup = (int)(tup * rate);
|
||||
ntdown = (int)(tdown * rate);
|
||||
cup = new double[ntup + 1]; // (float *)malloc0 ((ntup + 1) * sizeof(float));
|
||||
cdown = new double[ntdown + 1]; //(float *)malloc0 ((ntdown + 1) * sizeof(float));
|
||||
cup.resize(ntup + 1); // (float *)malloc0 ((ntup + 1) * sizeof(float));
|
||||
cdown.resize(ntdown + 1); //(float *)malloc0 ((ntdown + 1) * sizeof(float));
|
||||
delta = PI / (double) ntup;
|
||||
theta = 0.0;
|
||||
|
||||
@ -88,10 +88,7 @@ void FMSQ::calc()
|
||||
|
||||
void FMSQ::decalc()
|
||||
{
|
||||
delete[] (cdown);
|
||||
delete[] (cup);
|
||||
FIRCORE::destroy_fircore (p);
|
||||
delete[] (noise);
|
||||
}
|
||||
|
||||
FMSQ::FMSQ(
|
||||
@ -261,7 +258,7 @@ void FMSQ::setBuffers(float* in, float* out, float* trig)
|
||||
insig = in;
|
||||
outsig = out;
|
||||
trigger = trig;
|
||||
FIRCORE::setBuffers_fircore (p, trigger, noise);
|
||||
FIRCORE::setBuffers_fircore (p, trigger, noise.data());
|
||||
}
|
||||
|
||||
void FMSQ::setSamplerate(int _rate)
|
||||
@ -302,7 +299,7 @@ void FMSQ::setNC(int _nc)
|
||||
if (nc != _nc)
|
||||
{
|
||||
nc = _nc;
|
||||
impulse = EQP::eq_impulse (nc, 3, F, G, rate, 1.0 / (2.0 * size), 0, 0);
|
||||
impulse = EQP::eq_impulse (nc, 3, F.data(), G.data(), rate, 1.0 / (2.0 * size), 0, 0);
|
||||
FIRCORE::setNc_fircore (p, nc, impulse);
|
||||
delete[] (impulse);
|
||||
}
|
||||
|
@ -28,6 +28,9 @@ warren@wpratt.com
|
||||
#ifndef wdsp_fmsq_h
|
||||
#define wdsp_fmsq_h
|
||||
|
||||
#include <array>
|
||||
#include <vector>
|
||||
|
||||
#include "export.h"
|
||||
|
||||
namespace WDSP {
|
||||
@ -43,11 +46,11 @@ public:
|
||||
float* outsig; // squelch output signal buffer
|
||||
float* trigger; // buffer used to trigger mute/unmute (may be same as input; matches timing of input buffer)
|
||||
double rate; // sample rate
|
||||
float* noise;
|
||||
std::vector<float> noise;
|
||||
double fc; // corner frequency for sig / noise detection
|
||||
double* pllpole; // pointer to pole frequency of the fm demodulator pll
|
||||
float F[4];
|
||||
float G[4];
|
||||
std::array<float, 4> F;
|
||||
std::array<float, 4> G;
|
||||
double avtau; // time constant for averaging noise
|
||||
double avm;
|
||||
double onem_avm;
|
||||
@ -62,8 +65,8 @@ public:
|
||||
double tdown;
|
||||
int ntup;
|
||||
int ntdown;
|
||||
double* cup;
|
||||
double* cdown;
|
||||
std::vector<double> cup;
|
||||
std::vector<double> cdown;
|
||||
double tail_thresh;
|
||||
double unmute_thresh;
|
||||
double min_tail;
|
||||
@ -97,6 +100,7 @@ public:
|
||||
int _nc,
|
||||
int _mp
|
||||
);
|
||||
FMSQ(const FMSQ&) = delete;
|
||||
~FMSQ();
|
||||
|
||||
void flush();
|
||||
|
@ -109,11 +109,11 @@ void METER::execute()
|
||||
if (np > peak)
|
||||
peak = np;
|
||||
|
||||
result[enum_av] = 10.0 * MemLog::mlog10 (avg + 1.0e-40);
|
||||
result[enum_pk] = 10.0 * MemLog::mlog10 (peak + 1.0e-40);
|
||||
result[enum_av] = 10.0 * MemLog::mlog10 (avg <= 0 ? 1.0e-20 : avg);
|
||||
result[enum_pk] = 10.0 * MemLog::mlog10 (peak <= 0 ? 1.0e-20 : peak);
|
||||
|
||||
if ((pgain != 0) && (enum_gain >= 0))
|
||||
result[enum_gain] = 20.0 * MemLog::mlog10 (*pgain + 1.0e-40);
|
||||
result[enum_gain] = 20.0 * MemLog::mlog10 (*pgain <= 0 ? 1.0e-20 : *pgain);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -129,6 +129,7 @@ void METER::execute()
|
||||
void METER::setBuffers(float* in)
|
||||
{
|
||||
buff = in;
|
||||
flush();
|
||||
}
|
||||
|
||||
void METER::setSamplerate(int _rate)
|
||||
|
54
wdsp/nbp.cpp
54
wdsp/nbp.cpp
@ -44,20 +44,11 @@ NOTCHDB::NOTCHDB(int _master_run, int _maxnotches)
|
||||
master_run = _master_run;
|
||||
maxnotches = _maxnotches;
|
||||
nn = 0;
|
||||
fcenter = new double[maxnotches]; // (float *) malloc0 (maxnotches * sizeof (float));
|
||||
fwidth = new double[maxnotches]; // (float *) malloc0 (maxnotches * sizeof (float));
|
||||
nlow = new double[maxnotches]; // (float *) malloc0 (maxnotches * sizeof (float));
|
||||
nhigh = new double[maxnotches]; // (float *) malloc0 (maxnotches * sizeof (float));
|
||||
active = new int[maxnotches]; // (int *) malloc0 (maxnotches * sizeof (int ));
|
||||
}
|
||||
|
||||
NOTCHDB::~NOTCHDB()
|
||||
{
|
||||
delete[] (active);
|
||||
delete[] (nhigh);
|
||||
delete[] (nlow);
|
||||
delete[] (fwidth);
|
||||
delete[] (fcenter);
|
||||
fcenter.resize(maxnotches); // (float *) malloc0 (maxnotches * sizeof (float));
|
||||
fwidth.resize(maxnotches); // (float *) malloc0 (maxnotches * sizeof (float));
|
||||
nlow.resize(maxnotches); // (float *) malloc0 (maxnotches * sizeof (float));
|
||||
nhigh.resize(maxnotches); // (float *) malloc0 (maxnotches * sizeof (float));
|
||||
active.resize(maxnotches); // (int *) malloc0 (maxnotches * sizeof (int ));
|
||||
}
|
||||
|
||||
int NOTCHDB::addNotch(int notch, double _fcenter, double _fwidth, int _active)
|
||||
@ -198,17 +189,17 @@ double NBP::min_notch_width()
|
||||
|
||||
int NBP::make_nbp (
|
||||
int nn,
|
||||
int* active,
|
||||
double* center,
|
||||
double* width,
|
||||
double* nlow,
|
||||
double* nhigh,
|
||||
std::vector<int>& active,
|
||||
std::vector<double>& center,
|
||||
std::vector<double>& width,
|
||||
std::vector<double>& nlow,
|
||||
std::vector<double>& nhigh,
|
||||
double minwidth,
|
||||
int autoincr,
|
||||
double flow,
|
||||
double fhigh,
|
||||
double* bplow,
|
||||
double* bphigh,
|
||||
std::vector<double>& bplow,
|
||||
std::vector<double>& bphigh,
|
||||
int* havnotch
|
||||
)
|
||||
{
|
||||
@ -328,8 +319,15 @@ void NBP::calc_lightweight()
|
||||
bplow[i] -= offset;
|
||||
bphigh[i] -= offset;
|
||||
}
|
||||
impulse = fir_mbandpass (nc, numpb, bplow, bphigh,
|
||||
rate, gain / (float)(2 * size), wintype);
|
||||
impulse = fir_mbandpass (
|
||||
nc,
|
||||
numpb,
|
||||
bplow.data(),
|
||||
bphigh.data(),
|
||||
rate,
|
||||
gain / (float)(2 * size),
|
||||
wintype
|
||||
);
|
||||
FIRCORE::setImpulse_fircore (fircore, impulse, 1);
|
||||
// print_impulse ("nbp.txt", size + 1, impulse, 1, 0);
|
||||
delete[](impulse);
|
||||
@ -375,8 +373,8 @@ void NBP::calc_impulse ()
|
||||
impulse = fir_mbandpass (
|
||||
nc,
|
||||
numpb,
|
||||
bplow,
|
||||
bphigh,
|
||||
bplow.data(),
|
||||
bphigh.data(),
|
||||
rate,
|
||||
gain / (float)(2 * size),
|
||||
wintype
|
||||
@ -431,8 +429,8 @@ NBP::NBP(
|
||||
maxpb(_maxpb),
|
||||
notchdb(_notchdb)
|
||||
{
|
||||
bplow = new double[maxpb]; // (float *) malloc0 (maxpb * sizeof (float));
|
||||
bphigh = new double[maxpb]; // (float *) malloc0 (maxpb * sizeof (float));
|
||||
bplow.resize(maxpb); // (float *) malloc0 (maxpb * sizeof (float));
|
||||
bphigh.resize(maxpb); // (float *) malloc0 (maxpb * sizeof (float));
|
||||
calc_impulse ();
|
||||
fircore = FIRCORE::create_fircore (size, in, out, nc, mp, impulse);
|
||||
// print_impulse ("nbp.txt", size + 1, impulse, 1, 0);
|
||||
@ -442,8 +440,6 @@ NBP::NBP(
|
||||
NBP::~NBP()
|
||||
{
|
||||
FIRCORE::destroy_fircore (fircore);
|
||||
delete[] (bphigh);
|
||||
delete[] (bplow);
|
||||
}
|
||||
|
||||
void NBP::flush()
|
||||
|
34
wdsp/nbp.hpp
34
wdsp/nbp.hpp
@ -28,6 +28,8 @@ warren@wpratt.com
|
||||
#ifndef wdsp_nbp_h
|
||||
#define wdsp_nbp_h
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "export.h"
|
||||
|
||||
namespace WDSP {
|
||||
@ -41,15 +43,16 @@ public:
|
||||
double tunefreq;
|
||||
double shift;
|
||||
int nn;
|
||||
int* active;
|
||||
double* fcenter;
|
||||
double* fwidth;
|
||||
double* nlow;
|
||||
double* nhigh;
|
||||
std::vector<int> active;
|
||||
std::vector<double> fcenter;
|
||||
std::vector<double> fwidth;
|
||||
std::vector<double> nlow;
|
||||
std::vector<double> nhigh;
|
||||
int maxnotches;
|
||||
|
||||
NOTCHDB(int master_run, int maxnotches);
|
||||
~NOTCHDB();
|
||||
NOTCHDB(const NOTCHDB&) = delete;
|
||||
~NOTCHDB() = default;
|
||||
|
||||
int addNotch (int notch, double fcenter, double fwidth, int active);
|
||||
int getNotch (int notch, double* fcenter, double* fwidth, int* active);
|
||||
@ -79,8 +82,8 @@ public:
|
||||
float* impulse; // filter impulse response
|
||||
int maxpb; // maximum number of passbands
|
||||
NOTCHDB* notchdb; // ptr to addr of notch-database data structure
|
||||
double* bplow; // array of passband lows
|
||||
double* bphigh; // array of passband highs
|
||||
std::vector<double> bplow; // array of passband lows
|
||||
std::vector<double> bphigh; // array of passband highs
|
||||
int numpb; // number of passbands
|
||||
FIRCORE *fircore;
|
||||
int havnotch;
|
||||
@ -104,6 +107,7 @@ public:
|
||||
int maxpb,
|
||||
NOTCHDB* notchdb
|
||||
);
|
||||
NBP(const NBP&) = delete;
|
||||
~NBP();
|
||||
|
||||
void flush();
|
||||
@ -127,17 +131,17 @@ private:
|
||||
double min_notch_width ();
|
||||
static int make_nbp (
|
||||
int nn,
|
||||
int* active,
|
||||
double* center,
|
||||
double* width,
|
||||
double* nlow,
|
||||
double* nhigh,
|
||||
std::vector<int>& active,
|
||||
std::vector<double>& center,
|
||||
std::vector<double>& width,
|
||||
std::vector<double>& nlow,
|
||||
std::vector<double>& nhigh,
|
||||
double minwidth,
|
||||
int autoincr,
|
||||
double flow,
|
||||
double fhigh,
|
||||
double* bplow,
|
||||
double* bphigh,
|
||||
std::vector<double>& bplow,
|
||||
std::vector<double>& bphigh,
|
||||
int* havnotch
|
||||
);
|
||||
};
|
||||
|
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();
|
||||
|
@ -84,7 +84,7 @@ void RESAMPLE::calc()
|
||||
|
||||
ncoef = (ncoef / L + 1) * L;
|
||||
cpp = ncoef / L;
|
||||
h = new double[ncoef]; // (float *)malloc0(ncoef * sizeof(float));
|
||||
h.resize(ncoef); // (float *)malloc0(ncoef * sizeof(float));
|
||||
impulse = FIR::fir_bandpass(ncoef, fc_norm_low, fc_norm_high, 1.0, 1, 0, gain * (double)L);
|
||||
i = 0;
|
||||
|
||||
@ -95,19 +95,13 @@ void RESAMPLE::calc()
|
||||
}
|
||||
|
||||
ringsize = cpp;
|
||||
ring = new double[ringsize]; // (float *)malloc0(ringsize * sizeof(complex));
|
||||
ring.resize(ringsize); // (float *)malloc0(ringsize * sizeof(complex));
|
||||
idx_in = ringsize - 1;
|
||||
phnum = 0;
|
||||
|
||||
delete[] (impulse);
|
||||
}
|
||||
|
||||
void RESAMPLE::decalc()
|
||||
{
|
||||
delete[] ring;
|
||||
delete[] h;
|
||||
}
|
||||
|
||||
RESAMPLE::RESAMPLE (
|
||||
int _run,
|
||||
int _size,
|
||||
@ -133,15 +127,10 @@ RESAMPLE::RESAMPLE (
|
||||
calc();
|
||||
}
|
||||
|
||||
RESAMPLE::~RESAMPLE()
|
||||
{
|
||||
decalc();
|
||||
}
|
||||
|
||||
|
||||
void RESAMPLE::flush()
|
||||
{
|
||||
std::fill(ring, ring + 2 * ringsize, 0);
|
||||
std::fill(ring.begin(), ring.end(), 0);
|
||||
idx_in = ringsize - 1;
|
||||
phnum = 0;
|
||||
}
|
||||
@ -210,14 +199,12 @@ void RESAMPLE::setSize(int _size)
|
||||
|
||||
void RESAMPLE::setInRate(int _rate)
|
||||
{
|
||||
decalc();
|
||||
in_rate = _rate;
|
||||
calc();
|
||||
}
|
||||
|
||||
void RESAMPLE::setOutRate(int _rate)
|
||||
{
|
||||
decalc();
|
||||
out_rate = _rate;
|
||||
calc();
|
||||
}
|
||||
@ -226,7 +213,6 @@ void RESAMPLE::setFCLow(double _fc_low)
|
||||
{
|
||||
if (fc_low != _fc_low)
|
||||
{
|
||||
decalc();
|
||||
fc_low = _fc_low;
|
||||
calc();
|
||||
}
|
||||
@ -236,7 +222,6 @@ void RESAMPLE::setBandwidth(double _fc_low, double _fc_high)
|
||||
{
|
||||
if (fc_low != _fc_low || _fc_high != fcin)
|
||||
{
|
||||
decalc();
|
||||
fc_low = _fc_low;
|
||||
fcin = _fc_high;
|
||||
calc();
|
||||
|
@ -34,6 +34,8 @@ warren@wpratt.com
|
||||
#ifndef wdsp_resample_h
|
||||
#define wdsp_resample_h
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "export.h"
|
||||
|
||||
namespace WDSP {
|
||||
@ -56,9 +58,9 @@ public:
|
||||
int ncoef; // number of coefficients
|
||||
int L; // interpolation factor
|
||||
int M; // decimation factor
|
||||
double* h; // coefficients
|
||||
std::vector<double> h; // coefficients
|
||||
int ringsize; // number of complex pairs the ring buffer holds
|
||||
double* ring; // ring buffer
|
||||
std::vector<double> ring; // ring buffer
|
||||
int cpp; // coefficients of the phase
|
||||
int phnum; // phase number
|
||||
|
||||
@ -73,7 +75,8 @@ public:
|
||||
int ncoef,
|
||||
double gain
|
||||
);
|
||||
~RESAMPLE();
|
||||
RESAMPLE(const RESAMPLE&) = delete;
|
||||
~RESAMPLE() = default;
|
||||
|
||||
void flush();
|
||||
int execute();
|
||||
@ -90,7 +93,6 @@ public:
|
||||
|
||||
private:
|
||||
void calc();
|
||||
void decalc();
|
||||
};
|
||||
|
||||
} // namespace WDSP
|
||||
|
Loading…
x
Reference in New Issue
Block a user