mirror of
https://github.com/f4exb/sdrangel.git
synced 2025-06-13 20:12:29 -04:00
WDSP: nigrate to float mostly
This commit is contained in:
parent
8d9dc3b5ed
commit
bc34a759c7
39
wdsp/RXA.cpp
39
wdsp/RXA.cpp
@ -80,9 +80,10 @@ RXA* RXA::create_rxa (
|
||||
rxa->dsp_outsize = dsp_size / (dsp_rate / out_rate);
|
||||
|
||||
rxa->mode = RXA_LSB;
|
||||
rxa->inbuff = new double[1 * rxa->dsp_insize * 2]; // (double *) malloc0 (1 * ch.dsp_insize * sizeof (complex));
|
||||
rxa->outbuff = new double[1 * rxa->dsp_outsize * 2]; // (double *) malloc0 (1 * ch.dsp_outsize * sizeof (complex));
|
||||
rxa->midbuff = new double[2 * rxa->dsp_size * 2]; // (double *) malloc0 (2 * ch.dsp_size * sizeof (complex));
|
||||
rxa->inbuff = new float[1 * rxa->dsp_insize * 2]; // (float *) malloc0 (1 * ch.dsp_insize * sizeof (complex));
|
||||
rxa->outbuff = new float[1 * rxa->dsp_outsize * 2]; // (float *) malloc0 (1 * ch.dsp_outsize * sizeof (complex));
|
||||
rxa->midbuff = new float[2 * rxa->dsp_size * 2]; // (float *) malloc0 (2 * ch.dsp_size * sizeof (complex));
|
||||
memset(rxa->meter, 0, sizeof(float)*RXA_METERTYPE_LAST);
|
||||
|
||||
// Ftequency shifter - shift to select a slice of spectrum
|
||||
rxa->shift.p = SHIFT::create_shift (
|
||||
@ -306,9 +307,9 @@ RXA* RXA::create_rxa (
|
||||
|
||||
// Equalizer
|
||||
{
|
||||
double default_F[11] = {0.0, 32.0, 63.0, 125.0, 250.0, 500.0, 1000.0, 2000.0, 4000.0, 8000.0, 16000.0};
|
||||
//double default_G[11] = {0.0, -12.0, -12.0, -12.0, -1.0, +1.0, +4.0, +9.0, +12.0, -10.0, -10.0};
|
||||
double default_G[11] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
|
||||
float default_F[11] = {0.0, 32.0, 63.0, 125.0, 250.0, 500.0, 1000.0, 2000.0, 4000.0, 8000.0, 16000.0};
|
||||
//float default_G[11] = {0.0, -12.0, -12.0, -12.0, -1.0, +1.0, +4.0, +9.0, +12.0, -10.0, -10.0};
|
||||
float default_G[11] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
|
||||
rxa->eqp.p = EQP::create_eqp (
|
||||
0, // run - OFF by default
|
||||
rxa->dsp_size, // buffer size
|
||||
@ -475,9 +476,9 @@ RXA* RXA::create_rxa (
|
||||
// Dolly filter (multiple peak filter) - default is 2 for RTTY
|
||||
{
|
||||
int def_enable[2] = {1, 1};
|
||||
double def_freq[2] = {2125.0, 2295.0};
|
||||
double def_bw[2] = {75.0, 75.0};
|
||||
double def_gain[2] = {1.0, 1.0};
|
||||
float def_freq[2] = {2125.0, 2295.0};
|
||||
float def_bw[2] = {75.0, 75.0};
|
||||
float def_gain[2] = {1.0, 1.0};
|
||||
rxa->mpeak.p = MPEAK::create_mpeak (
|
||||
0, // run
|
||||
rxa->dsp_size, // size
|
||||
@ -659,7 +660,7 @@ void RXA::setInputSamplerate (RXA *rxa, int in_rate)
|
||||
rxa->in_rate = in_rate;
|
||||
// buffers
|
||||
delete[] (rxa->inbuff);
|
||||
rxa->inbuff = new double[1 * rxa->dsp_insize * 2]; // (double *)malloc0(1 * ch.dsp_insize * sizeof(complex));
|
||||
rxa->inbuff = new float[1 * rxa->dsp_insize * 2]; // (float *)malloc0(1 * ch.dsp_insize * sizeof(complex));
|
||||
// shift
|
||||
SHIFT::setBuffers_shift (rxa->shift.p, rxa->inbuff, rxa->inbuff);
|
||||
SHIFT::setSize_shift (rxa->shift.p, rxa->dsp_insize);
|
||||
@ -682,7 +683,7 @@ void RXA::setOutputSamplerate (RXA *rxa, int out_rate)
|
||||
rxa->out_rate = out_rate;
|
||||
// buffers
|
||||
delete[] (rxa->outbuff);
|
||||
rxa->outbuff = new double[1 * rxa->dsp_outsize * 2]; // (double *)malloc0(1 * ch.dsp_outsize * sizeof(complex));
|
||||
rxa->outbuff = new float[1 * rxa->dsp_outsize * 2]; // (float *)malloc0(1 * ch.dsp_outsize * sizeof(complex));
|
||||
// output resampler
|
||||
RESAMPLE::setBuffers_resample (rxa->rsmpout.p, rxa->midbuff, rxa->outbuff);
|
||||
RESAMPLE::setOutRate_resample (rxa->rsmpout.p, rxa->out_rate);
|
||||
@ -704,9 +705,9 @@ void RXA::setDSPSamplerate (RXA *rxa, int dsp_rate)
|
||||
rxa->dsp_rate = dsp_rate;
|
||||
// buffers
|
||||
delete[] (rxa->inbuff);
|
||||
rxa->inbuff = new double[1 * rxa->dsp_insize * 2]; // (double *)malloc0(1 * rxa->dsp_insize * sizeof(complex));
|
||||
rxa->inbuff = new float[1 * rxa->dsp_insize * 2]; // (float *)malloc0(1 * rxa->dsp_insize * sizeof(complex));
|
||||
delete[] (rxa->outbuff);
|
||||
rxa->outbuff = new double[1 * rxa->dsp_outsize * 2]; // (double *)malloc0(1 * rxa->dsp_outsize * sizeof(complex));
|
||||
rxa->outbuff = new float[1 * rxa->dsp_outsize * 2]; // (float *)malloc0(1 * rxa->dsp_outsize * sizeof(complex));
|
||||
// shift
|
||||
SHIFT::setBuffers_shift (rxa->shift.p, rxa->inbuff, rxa->inbuff);
|
||||
SHIFT::setSize_shift (rxa->shift.p, rxa->dsp_insize);
|
||||
@ -761,11 +762,11 @@ void RXA::setDSPBuffsize (RXA *rxa, int dsp_size)
|
||||
rxa->dsp_size = dsp_size;
|
||||
// buffers
|
||||
delete[](rxa->inbuff);
|
||||
rxa->inbuff = new double[1 * rxa->dsp_insize * 2]; // (double *)malloc0(1 * rxa->dsp_insize * sizeof(complex));
|
||||
rxa->inbuff = new float[1 * rxa->dsp_insize * 2]; // (float *)malloc0(1 * rxa->dsp_insize * sizeof(complex));
|
||||
delete[] (rxa->midbuff);
|
||||
rxa->midbuff = new double[2 * rxa->dsp_size * 2]; // (double *)malloc0(2 * rxa->dsp_size * sizeof(complex));
|
||||
rxa->midbuff = new float[2 * rxa->dsp_size * 2]; // (float *)malloc0(2 * rxa->dsp_size * sizeof(complex));
|
||||
delete[] (rxa->outbuff);
|
||||
rxa->outbuff = new double[1 * rxa->dsp_outsize * 2]; // (double *)malloc0(1 * rxa->dsp_outsize * sizeof(complex));
|
||||
rxa->outbuff = new float[1 * rxa->dsp_outsize * 2]; // (float *)malloc0(1 * rxa->dsp_outsize * sizeof(complex));
|
||||
// shift
|
||||
SHIFT::setBuffers_shift (rxa->shift.p, rxa->inbuff, rxa->inbuff);
|
||||
SHIFT::setSize_shift (rxa->shift.p, rxa->dsp_insize);
|
||||
@ -909,7 +910,7 @@ void RXA::bp1Check (
|
||||
)
|
||||
{
|
||||
BANDPASS *a = rxa.bp1.p;
|
||||
double gain;
|
||||
float gain;
|
||||
if (amd_run ||
|
||||
snba_run ||
|
||||
emnr_run ||
|
||||
@ -946,7 +947,7 @@ void RXA::bpsnbaCheck (RXA& rxa, int mode, int notch_run)
|
||||
// for BPSNBA: set run, position, freqs, run_notches
|
||||
// call this upon change in RXA_mode, snba_run, notch_master_run
|
||||
BPSNBA *a = rxa.bpsnba.p;
|
||||
double f_low = 0.0, f_high = 0.0;
|
||||
float f_low = 0.0, f_high = 0.0;
|
||||
int run_notches = 0;
|
||||
switch (mode)
|
||||
{
|
||||
@ -1038,7 +1039,7 @@ void RXA::bpsnbaSet (RXA& rxa)
|
||||
* *
|
||||
********************************************************************************************************/
|
||||
|
||||
void RXA::SetPassband (RXA& rxa, double f_low, double f_high)
|
||||
void RXA::SetPassband (RXA& rxa, float f_low, float f_high)
|
||||
{
|
||||
BANDPASS::SetBandpassFreqs (rxa, f_low, f_high); // After spectral noise reduction ( AM || ANF || ANR || EMNR)
|
||||
SNBA::SetSNBAOutputBandwidth (rxa, f_low, f_high); // Spectral noise blanker (SNB)
|
||||
|
14
wdsp/RXA.hpp
14
wdsp/RXA.hpp
@ -97,7 +97,7 @@ public:
|
||||
};
|
||||
|
||||
int mode;
|
||||
double meter[RXA_METERTYPE_LAST];
|
||||
float meter[RXA_METERTYPE_LAST];
|
||||
QRecursiveMutex *pmtupdate[RXA_METERTYPE_LAST];
|
||||
struct
|
||||
{
|
||||
@ -215,8 +215,8 @@ public:
|
||||
static void xrxa (RXA *rxa);
|
||||
int get_insize() const { return dsp_insize; }
|
||||
int get_outsize() const { return dsp_outsize; }
|
||||
double *get_inbuff() { return inbuff; }
|
||||
double *get_outbuff() { return outbuff; }
|
||||
float *get_inbuff() { return inbuff; }
|
||||
float *get_outbuff() { return outbuff; }
|
||||
void setSpectrumProbe(BufferProbe *_spectrumProbe);
|
||||
static void setInputSamplerate (RXA *rxa, int in_rate);
|
||||
static void setOutputSamplerate (RXA *rxa, int out_rate);
|
||||
@ -232,14 +232,14 @@ public:
|
||||
static void bpsnbaSet (RXA& rxa);
|
||||
|
||||
// Collectives
|
||||
static void SetPassband (RXA& rxa, double f_low, double f_high);
|
||||
static void SetPassband (RXA& rxa, float f_low, float f_high);
|
||||
static void SetNC (RXA& rxa, int nc);
|
||||
static void SetMP (RXA& rxa, int mp);
|
||||
|
||||
private:
|
||||
double* inbuff;
|
||||
double* midbuff;
|
||||
double* outbuff;
|
||||
float* inbuff;
|
||||
float* midbuff;
|
||||
float* outbuff;
|
||||
};
|
||||
|
||||
} // namespace WDSP
|
||||
|
40
wdsp/TXA.cpp
40
wdsp/TXA.cpp
@ -78,9 +78,9 @@ TXA* TXA::create_txa (
|
||||
txa->mode = TXA_LSB;
|
||||
txa->f_low = -5000.0;
|
||||
txa->f_high = - 100.0;
|
||||
txa->inbuff = new double[1 * txa->dsp_insize * 2]; // (double *) malloc0 (1 * txa->dsp_insize * sizeof (complex));
|
||||
txa->outbuff = new double[1 * txa->dsp_outsize * 2]; // (double *) malloc0 (1 * txa->dsp_outsize * sizeof (complex));
|
||||
txa->midbuff = new double[3 * txa->dsp_size * 2]; //(double *) malloc0 (2 * txa->dsp_size * sizeof (complex));
|
||||
txa->inbuff = new float[1 * txa->dsp_insize * 2]; // (float *) malloc0 (1 * txa->dsp_insize * sizeof (complex));
|
||||
txa->outbuff = new float[1 * txa->dsp_outsize * 2]; // (float *) malloc0 (1 * txa->dsp_outsize * sizeof (complex));
|
||||
txa->midbuff = new float[3 * txa->dsp_size * 2]; //(float *) malloc0 (2 * txa->dsp_size * sizeof (complex));
|
||||
|
||||
txa->rsmpin.p = RESAMPLE::create_resample (
|
||||
0, // run - will be turned on below if needed
|
||||
@ -153,9 +153,9 @@ TXA* TXA::create_txa (
|
||||
0.200); // muted gain
|
||||
|
||||
{
|
||||
double default_F[11] = {0.0, 32.0, 63.0, 125.0, 250.0, 500.0, 1000.0, 2000.0, 4000.0, 8000.0, 16000.0};
|
||||
double default_G[11] = {0.0, -12.0, -12.0, -12.0, -1.0, +1.0, +4.0, +9.0, +12.0, -10.0, -10.0};
|
||||
//double default_G[11] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
|
||||
float default_F[11] = {0.0, 32.0, 63.0, 125.0, 250.0, 500.0, 1000.0, 2000.0, 4000.0, 8000.0, 16000.0};
|
||||
float default_G[11] = {0.0, -12.0, -12.0, -12.0, -1.0, +1.0, +4.0, +9.0, +12.0, -10.0, -10.0};
|
||||
//float default_G[11] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
|
||||
txa->eqp.p = EQP::create_eqp (
|
||||
0, // run - OFF by default
|
||||
txa->dsp_size, // size
|
||||
@ -240,9 +240,9 @@ TXA* TXA::create_txa (
|
||||
&txa->leveler.p->gain); // pointer for gain computation
|
||||
|
||||
{
|
||||
double default_F[5] = {200.0, 1000.0, 2000.0, 3000.0, 4000.0};
|
||||
double default_G[5] = {0.0, 5.0, 10.0, 10.0, 5.0};
|
||||
double default_E[5] = {7.0, 7.0, 7.0, 7.0, 7.0};
|
||||
float default_F[5] = {200.0, 1000.0, 2000.0, 3000.0, 4000.0};
|
||||
float default_G[5] = {0.0, 5.0, 10.0, 10.0, 5.0};
|
||||
float default_E[5] = {7.0, 7.0, 7.0, 7.0, 7.0};
|
||||
txa->cfcomp.p = CFCOMP::create_cfcomp(
|
||||
0, // run
|
||||
0, // position
|
||||
@ -278,7 +278,7 @@ TXA* TXA::create_txa (
|
||||
TXA_CFC_AV, // index for average value
|
||||
TXA_CFC_PK, // index for peak value
|
||||
TXA_CFC_GAIN, // index for gain value
|
||||
&txa->cfcomp.p->gain); // pointer for gain computation
|
||||
(double*) &txa->cfcomp.p->gain); // pointer for gain computation
|
||||
|
||||
txa->bp0.p = BANDPASS::create_bandpass (
|
||||
1, // always runs
|
||||
@ -470,7 +470,7 @@ TXA* TXA::create_txa (
|
||||
txa->dsp_size, // size
|
||||
txa->midbuff, // input buffer
|
||||
txa->midbuff, // output buffer
|
||||
(double)txa->dsp_rate, // sample rate
|
||||
(float)txa->dsp_rate, // sample rate
|
||||
16, // ints
|
||||
0.005, // changeover time
|
||||
256); // spi
|
||||
@ -649,7 +649,7 @@ void TXA::setInputSamplerate (TXA *txa, int in_rate)
|
||||
txa->in_rate = in_rate;
|
||||
// buffers
|
||||
delete[] (txa->inbuff);
|
||||
txa->inbuff = new double[1 * txa->dsp_insize * 2]; //(double *)malloc0(1 * txa->dsp_insize * sizeof(complex));
|
||||
txa->inbuff = new float[1 * txa->dsp_insize * 2]; //(float *)malloc0(1 * txa->dsp_insize * sizeof(complex));
|
||||
// input resampler
|
||||
RESAMPLE::setBuffers_resample (txa->rsmpin.p, txa->inbuff, txa->midbuff);
|
||||
RESAMPLE::setSize_resample (txa->rsmpin.p, txa->dsp_insize);
|
||||
@ -670,7 +670,7 @@ void TXA::setOutputSamplerate (TXA* txa, int out_rate)
|
||||
txa->out_rate = out_rate;
|
||||
// buffers
|
||||
delete[] (txa->outbuff);
|
||||
txa->outbuff = new double[1 * txa->dsp_outsize * 2]; // (double *)malloc0(1 * txa->dsp_outsize * sizeof(complex));
|
||||
txa->outbuff = new float[1 * txa->dsp_outsize * 2]; // (float *)malloc0(1 * txa->dsp_outsize * sizeof(complex));
|
||||
// cfir - needs to know input rate of firmware CIC
|
||||
CFIR::setOutRate_cfir (txa->cfir.p, txa->out_rate);
|
||||
// output resampler
|
||||
@ -701,9 +701,9 @@ void TXA::setDSPSamplerate (TXA *txa, int dsp_rate)
|
||||
txa->dsp_rate = dsp_rate;
|
||||
// buffers
|
||||
delete[] (txa->inbuff);
|
||||
txa->inbuff = new double[1 * txa->dsp_insize * 2]; // (double *)malloc0(1 * txa->dsp_insize * sizeof(complex));
|
||||
txa->inbuff = new float[1 * txa->dsp_insize * 2]; // (float *)malloc0(1 * txa->dsp_insize * sizeof(complex));
|
||||
delete[] (txa->outbuff);
|
||||
txa->outbuff = new double[1 * txa->dsp_outsize * 2]; // (double *)malloc0(1 * txa->dsp_outsize * sizeof(complex));
|
||||
txa->outbuff = new float[1 * txa->dsp_outsize * 2]; // (float *)malloc0(1 * txa->dsp_outsize * sizeof(complex));
|
||||
// input resampler
|
||||
RESAMPLE::setBuffers_resample (txa->rsmpin.p, txa->inbuff, txa->midbuff);
|
||||
RESAMPLE::setSize_resample (txa->rsmpin.p, txa->dsp_insize);
|
||||
@ -763,11 +763,11 @@ void TXA::setDSPBuffsize (TXA *txa, int dsp_size)
|
||||
txa->dsp_size = dsp_size;
|
||||
// buffers
|
||||
delete[] (txa->inbuff);
|
||||
txa->inbuff = new double[1 * txa->dsp_insize * 2]; // (double *)malloc0(1 * txa->dsp_insize * sizeof(complex));
|
||||
txa->inbuff = new float[1 * txa->dsp_insize * 2]; // (float *)malloc0(1 * txa->dsp_insize * sizeof(complex));
|
||||
delete[] (txa->midbuff);
|
||||
txa->midbuff = new double[2 * txa->dsp_size * 2]; // (double *)malloc0(2 * txa->dsp_size * sizeof(complex));
|
||||
txa->midbuff = new float[2 * txa->dsp_size * 2]; // (float *)malloc0(2 * txa->dsp_size * sizeof(complex));
|
||||
delete[] (txa->outbuff);
|
||||
txa->outbuff = new double[1 * txa->dsp_outsize * 2]; // (double *)malloc0(1 * txa->dsp_outsize * sizeof(complex));
|
||||
txa->outbuff = new float[1 * txa->dsp_outsize * 2]; // (float *)malloc0(1 * txa->dsp_outsize * sizeof(complex));
|
||||
// input resampler
|
||||
RESAMPLE::setBuffers_resample (txa->rsmpin.p, txa->inbuff, txa->midbuff);
|
||||
RESAMPLE::setSize_resample (txa->rsmpin.p, txa->dsp_insize);
|
||||
@ -879,7 +879,7 @@ void TXA::SetMode (TXA& txa, int mode)
|
||||
}
|
||||
}
|
||||
|
||||
void TXA::SetBandpassFreqs (TXA& txa, double f_low, double f_high)
|
||||
void TXA::SetBandpassFreqs (TXA& txa, float f_low, float f_high)
|
||||
{
|
||||
if ((txa.f_low != f_low) || (txa.f_high != f_high))
|
||||
{
|
||||
@ -1019,7 +1019,7 @@ void TXA::SetMP (TXA& txa, int mp)
|
||||
FMMOD::SetFMMP (txa, mp);
|
||||
}
|
||||
|
||||
void TXA::SetFMAFFilter (TXA& txa, double low, double high)
|
||||
void TXA::SetFMAFFilter (TXA& txa, float low, float high)
|
||||
{
|
||||
EMPHP::SetFMPreEmphFreqs (txa, low, high);
|
||||
FMMOD::SetFMAFFreqs (txa, low, high);
|
||||
|
20
wdsp/TXA.hpp
20
wdsp/TXA.hpp
@ -125,9 +125,9 @@ public:
|
||||
};
|
||||
|
||||
int mode;
|
||||
double f_low;
|
||||
double f_high;
|
||||
double meter[TXA_METERTYPE_LAST];
|
||||
float f_low;
|
||||
float f_high;
|
||||
float meter[TXA_METERTYPE_LAST];
|
||||
QRecursiveMutex *pmtupdate[TXA_METERTYPE_LAST];
|
||||
std::atomic<long> upslew;
|
||||
struct
|
||||
@ -228,8 +228,8 @@ public:
|
||||
static void xtxa (TXA *txa);
|
||||
int get_insize() const { return dsp_insize; }
|
||||
int get_outsize() const { return dsp_outsize; }
|
||||
double *get_inbuff() { return inbuff; }
|
||||
double *get_outbuff() { return outbuff; }
|
||||
float *get_inbuff() { return inbuff; }
|
||||
float *get_outbuff() { return outbuff; }
|
||||
static void setInputSamplerate (TXA *txa, int in_rate);
|
||||
static void setOutputSamplerate (TXA *txa, int out_rate);
|
||||
static void setDSPSamplerate (TXA *txa, int dsp_rate);
|
||||
@ -237,20 +237,20 @@ public:
|
||||
|
||||
// TXA Properties
|
||||
static void SetMode (TXA& txa, int mode);
|
||||
static void SetBandpassFreqs (TXA& txa, double f_low, double f_high);
|
||||
static void SetBandpassFreqs (TXA& txa, float f_low, float f_high);
|
||||
|
||||
// Collectives
|
||||
static void SetNC (TXA& txa, int nc);
|
||||
static void SetMP (TXA& txa, int mp);
|
||||
static void SetFMAFFilter (TXA& txa, double low, double high);
|
||||
static void SetFMAFFilter (TXA& txa, float low, float high);
|
||||
static void SetupBPFilters (TXA& txa);
|
||||
static int UslewCheck (TXA& txa);
|
||||
|
||||
private:
|
||||
static void ResCheck (TXA& txa);
|
||||
double* inbuff;
|
||||
double* midbuff;
|
||||
double* outbuff;
|
||||
float* inbuff;
|
||||
float* midbuff;
|
||||
float* outbuff;
|
||||
};
|
||||
|
||||
} // namespace WDSP
|
||||
|
34
wdsp/amd.cpp
34
wdsp/amd.cpp
@ -41,18 +41,18 @@ AMD* AMD::create_amd
|
||||
(
|
||||
int run,
|
||||
int buff_size,
|
||||
double *in_buff,
|
||||
double *out_buff,
|
||||
float *in_buff,
|
||||
float *out_buff,
|
||||
int mode,
|
||||
int levelfade,
|
||||
int sbmode,
|
||||
int sample_rate,
|
||||
double fmin,
|
||||
double fmax,
|
||||
double zeta,
|
||||
double omegaN,
|
||||
double tauR,
|
||||
double tauI
|
||||
float fmin,
|
||||
float fmax,
|
||||
float zeta,
|
||||
float omegaN,
|
||||
float tauR,
|
||||
float tauI
|
||||
)
|
||||
{
|
||||
AMD *a = new AMD();
|
||||
@ -63,7 +63,7 @@ AMD* AMD::create_amd
|
||||
a->mode = mode;
|
||||
a->levelfade = levelfade;
|
||||
a->sbmode = sbmode;
|
||||
a->sample_rate = (double)sample_rate;
|
||||
a->sample_rate = (float)sample_rate;
|
||||
a->fmin = fmin;
|
||||
a->fmax = fmax;
|
||||
a->zeta = zeta;
|
||||
@ -126,13 +126,13 @@ void AMD::flush_amd (AMD *a)
|
||||
void AMD::xamd (AMD *a)
|
||||
{
|
||||
int i;
|
||||
double audio;
|
||||
double vco[2];
|
||||
double corr[2];
|
||||
double det;
|
||||
double del_out;
|
||||
double ai, bi, aq, bq;
|
||||
double ai_ps, bi_ps, aq_ps, bq_ps;
|
||||
float audio;
|
||||
float vco[2];
|
||||
float corr[2];
|
||||
float det;
|
||||
float del_out;
|
||||
float ai, bi, aq, bq;
|
||||
float ai_ps, bi_ps, aq_ps, bq_ps;
|
||||
int j, k;
|
||||
if (a->run)
|
||||
{
|
||||
@ -251,7 +251,7 @@ void AMD::xamd (AMD *a)
|
||||
}
|
||||
}
|
||||
|
||||
void AMD::setBuffers_amd (AMD *a, double* in, double* out)
|
||||
void AMD::setBuffers_amd (AMD *a, float* in, float* out)
|
||||
{
|
||||
a->in_buff = in;
|
||||
a->out_buff = out;
|
||||
|
76
wdsp/amd.hpp
76
wdsp/amd.hpp
@ -47,36 +47,36 @@ class WDSP_API AMD {
|
||||
public:
|
||||
int run;
|
||||
int buff_size; // buffer size
|
||||
double *in_buff; // pointer to input buffer
|
||||
double *out_buff; // pointer to output buffer
|
||||
float *in_buff; // pointer to input buffer
|
||||
float *out_buff; // pointer to output buffer
|
||||
int mode; // demodulation mode
|
||||
double sample_rate; // sample rate
|
||||
double dc; // dc component in demodulated output
|
||||
double fmin; // pll - minimum carrier freq to lock
|
||||
double fmax; // pll - maximum carrier freq to lock
|
||||
double omega_min; // pll - minimum lock check parameter
|
||||
double omega_max; // pll - maximum lock check parameter
|
||||
double zeta; // pll - damping factor; as coded, must be <=1.0
|
||||
double omegaN; // pll - natural frequency
|
||||
double phs; // pll - phase accumulator
|
||||
double omega; // pll - locked pll frequency
|
||||
double fil_out; // pll - filter output
|
||||
double g1, g2; // pll - filter gain parameters
|
||||
double tauR; // carrier removal time constant
|
||||
double tauI; // carrier insertion time constant
|
||||
double mtauR; // carrier removal multiplier
|
||||
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
|
||||
double dsI; // delayed sample, I path
|
||||
double dsQ; // delayed sample, Q path
|
||||
double dc_insert; // dc component to insert in output
|
||||
float sample_rate; // sample rate
|
||||
float dc; // dc component in demodulated output
|
||||
float fmin; // pll - minimum carrier freq to lock
|
||||
float fmax; // pll - maximum carrier freq to lock
|
||||
float omega_min; // pll - minimum lock check parameter
|
||||
float omega_max; // pll - maximum lock check parameter
|
||||
float zeta; // pll - damping factor; as coded, must be <=1.0
|
||||
float omegaN; // pll - natural frequency
|
||||
float phs; // pll - phase accumulator
|
||||
float omega; // pll - locked pll frequency
|
||||
float fil_out; // pll - filter output
|
||||
float g1, g2; // pll - filter gain parameters
|
||||
float tauR; // carrier removal time constant
|
||||
float tauI; // carrier insertion time constant
|
||||
float mtauR; // carrier removal multiplier
|
||||
float onem_mtauR; // 1.0 - carrier_removal_multiplier
|
||||
float mtauI; // carrier insertion multiplier
|
||||
float onem_mtauI; // 1.0 - carrier_insertion_multiplier
|
||||
float a[3 * STAGES + 3]; // Filter a variables
|
||||
float b[3 * STAGES + 3]; // Filter b variables
|
||||
float c[3 * STAGES + 3]; // Filter c variables
|
||||
float d[3 * STAGES + 3]; // Filter d variables
|
||||
float c0[STAGES]; // Filter coefficients - path 0
|
||||
float c1[STAGES]; // Filter coefficients - path 1
|
||||
float dsI; // delayed sample, I path
|
||||
float dsQ; // delayed sample, Q path
|
||||
float dc_insert; // dc component to insert in output
|
||||
int sbmode; // sideband mode
|
||||
int levelfade; // Fade Leveler switch
|
||||
|
||||
@ -84,25 +84,25 @@ public:
|
||||
(
|
||||
int run,
|
||||
int buff_size,
|
||||
double *in_buff,
|
||||
double *out_buff,
|
||||
float *in_buff,
|
||||
float *out_buff,
|
||||
int mode,
|
||||
int levelfade,
|
||||
int sbmode,
|
||||
int sample_rate,
|
||||
double fmin,
|
||||
double fmax,
|
||||
double zeta,
|
||||
double omegaN,
|
||||
double tauR,
|
||||
double tauI
|
||||
float fmin,
|
||||
float fmax,
|
||||
float zeta,
|
||||
float omegaN,
|
||||
float tauR,
|
||||
float tauI
|
||||
);
|
||||
|
||||
static void init_amd (AMD *a);
|
||||
static void destroy_amd (AMD *a);
|
||||
static void flush_amd (AMD *a);
|
||||
static void xamd (AMD *a);
|
||||
static void setBuffers_amd (AMD *a, double* in, double* out);
|
||||
static void setBuffers_amd (AMD *a, float* in, float* out);
|
||||
static void setSamplerate_amd (AMD *a, int rate);
|
||||
static void setSize_amd (AMD *a, int size);
|
||||
// RXA Properties
|
||||
|
@ -34,7 +34,7 @@ warren@wpratt.com
|
||||
|
||||
namespace WDSP {
|
||||
|
||||
AMMOD* AMMOD::create_ammod (int run, int mode, int size, double* in, double* out, double c_level)
|
||||
AMMOD* AMMOD::create_ammod (int run, int mode, int size, float* in, float* out, float c_level)
|
||||
{
|
||||
AMMOD *a = new AMMOD;
|
||||
a->run = run;
|
||||
@ -86,7 +86,7 @@ void AMMOD::xammod(AMMOD *a)
|
||||
memcpy (a->out, a->in, a->size * sizeof (wcomplex));
|
||||
}
|
||||
|
||||
void AMMOD::setBuffers_ammod(AMMOD *a, double* in, double* out)
|
||||
void AMMOD::setBuffers_ammod(AMMOD *a, float* in, float* out)
|
||||
{
|
||||
a->in = in;
|
||||
a->out = out;
|
||||
@ -108,7 +108,7 @@ void AMMOD::setSize_ammod(AMMOD *a, int size)
|
||||
* *
|
||||
********************************************************************************************************/
|
||||
|
||||
void AMMOD::SetAMCarrierLevel (TXA& txa, double c_level)
|
||||
void AMMOD::SetAMCarrierLevel (TXA& txa, float c_level)
|
||||
{
|
||||
txa.csDSP.lock();
|
||||
txa.ammod.p->c_level = c_level;
|
||||
|
@ -40,21 +40,21 @@ public:
|
||||
int run;
|
||||
int mode;
|
||||
int size;
|
||||
double* in;
|
||||
double* out;
|
||||
double c_level;
|
||||
double a_level;
|
||||
double mult;
|
||||
float* in;
|
||||
float* out;
|
||||
float c_level;
|
||||
float a_level;
|
||||
float mult;
|
||||
|
||||
static AMMOD* create_ammod(int run, int mode, int size, double* in, double* out, double c_level);
|
||||
static AMMOD* create_ammod(int run, int mode, int size, float* in, float* out, float c_level);
|
||||
static void destroy_ammod (AMMOD *a);
|
||||
static void flush_ammod (AMMOD *a);
|
||||
static void xammod (AMMOD *a);
|
||||
static void setBuffers_ammod (AMMOD *a, double* in, double* out);
|
||||
static void setBuffers_ammod (AMMOD *a, float* in, float* out);
|
||||
static void setSamplerate_ammod (AMMOD *a, int rate);
|
||||
static void setSize_ammod (AMMOD *a, int size);
|
||||
// TXA Properties
|
||||
static void SetAMCarrierLevel (TXA& txa, double c_level);
|
||||
static void SetAMCarrierLevel (TXA& txa, float c_level);
|
||||
};
|
||||
|
||||
} // namespace WDSP
|
||||
|
@ -37,15 +37,15 @@ namespace WDSP {
|
||||
void AMSQ::compute_slews(AMSQ *a)
|
||||
{
|
||||
int i;
|
||||
double delta, theta;
|
||||
delta = PI / (double)a->ntup;
|
||||
float delta, theta;
|
||||
delta = PI / (float)a->ntup;
|
||||
theta = 0.0;
|
||||
for (i = 0; i <= a->ntup; i++)
|
||||
{
|
||||
a->cup[i] = a->muted_gain + (1.0 - a->muted_gain) * 0.5 * (1.0 - cos (theta));
|
||||
theta += delta;
|
||||
}
|
||||
delta = PI / (double)a->ntdown;
|
||||
delta = PI / (float)a->ntdown;
|
||||
theta = 0.0;
|
||||
for (i = 0; i <= a->ntdown; i++)
|
||||
{
|
||||
@ -57,15 +57,15 @@ void AMSQ::compute_slews(AMSQ *a)
|
||||
void AMSQ::calc_amsq(AMSQ *a)
|
||||
{
|
||||
// signal averaging
|
||||
a->trigsig = new double[a->size * 2]; // (double *)malloc0(a->size * sizeof(wcomplex));
|
||||
a->trigsig = new float[a->size * 2]; // (float *)malloc0(a->size * sizeof(wcomplex));
|
||||
a->avm = exp(-1.0 / (a->rate * a->avtau));
|
||||
a->onem_avm = 1.0 - a->avm;
|
||||
a->avsig = 0.0;
|
||||
// level change
|
||||
a->ntup = (int)(a->tup * a->rate);
|
||||
a->ntdown = (int)(a->tdown * a->rate);
|
||||
a->cup = new double[(a->ntup + 1) * 2]; // (double *)malloc0((a->ntup + 1) * sizeof(double));
|
||||
a->cdown = new double[(a->ntdown + 1) * 2]; // (double *)malloc0((a->ntdown + 1) * sizeof(double));
|
||||
a->cup = new float[(a->ntup + 1) * 2]; // (float *)malloc0((a->ntup + 1) * sizeof(float));
|
||||
a->cdown = new float[(a->ntdown + 1) * 2]; // (float *)malloc0((a->ntdown + 1) * sizeof(float));
|
||||
compute_slews(a);
|
||||
// control
|
||||
a->state = 0;
|
||||
@ -78,15 +78,15 @@ void AMSQ::decalc_amsq (AMSQ *a)
|
||||
delete[] a->trigsig;
|
||||
}
|
||||
|
||||
AMSQ* AMSQ::create_amsq (int run, int size, double* in, double* out, double* trigger, int rate, double avtau,
|
||||
double tup, double tdown, double tail_thresh, double unmute_thresh, double min_tail, double max_tail, double muted_gain)
|
||||
AMSQ* AMSQ::create_amsq (int run, int size, float* in, float* out, float* trigger, int rate, float avtau,
|
||||
float tup, float tdown, float tail_thresh, float unmute_thresh, float min_tail, float max_tail, float muted_gain)
|
||||
{
|
||||
AMSQ *a = new AMSQ;
|
||||
a->run = run;
|
||||
a->size = size;
|
||||
a->in = in;
|
||||
a->out = out;
|
||||
a->rate = (double)rate;
|
||||
a->rate = (float)rate;
|
||||
a->muted_gain = muted_gain;
|
||||
a->trigger = trigger;
|
||||
a->avtau = avtau;
|
||||
@ -127,7 +127,7 @@ void AMSQ::xamsq (AMSQ *a)
|
||||
if (a->run)
|
||||
{
|
||||
int i;
|
||||
double sig, siglimit;
|
||||
float sig, siglimit;
|
||||
for (i = 0; i < a->size; i++)
|
||||
{
|
||||
sig = sqrt (a->trigsig[2 * i + 0] * a->trigsig[2 * i + 0] + a->trigsig[2 * i + 1] * a->trigsig[2 * i + 1]);
|
||||
@ -188,7 +188,7 @@ void AMSQ::xamsqcap (AMSQ *a)
|
||||
memcpy (a->trigsig, a->trigger, a->size * sizeof (wcomplex));
|
||||
}
|
||||
|
||||
void AMSQ::setBuffers_amsq (AMSQ *a, double* in, double* out, double* trigger)
|
||||
void AMSQ::setBuffers_amsq (AMSQ *a, float* in, float* out, float* trigger)
|
||||
{
|
||||
a->in = in;
|
||||
a->out = out;
|
||||
@ -222,16 +222,16 @@ void AMSQ::SetAMSQRun (RXA& rxa, int run)
|
||||
rxa.csDSP.unlock();
|
||||
}
|
||||
|
||||
void AMSQ::SetAMSQThreshold (RXA& rxa, double threshold)
|
||||
void AMSQ::SetAMSQThreshold (RXA& rxa, float threshold)
|
||||
{
|
||||
double thresh = pow (10.0, threshold / 20.0);
|
||||
float thresh = pow (10.0, threshold / 20.0);
|
||||
rxa.csDSP.lock();
|
||||
rxa.amsq.p->tail_thresh = 0.9 * thresh;
|
||||
rxa.amsq.p->unmute_thresh = thresh;
|
||||
rxa.csDSP.unlock();
|
||||
}
|
||||
|
||||
void AMSQ::SetAMSQMaxTail (RXA& rxa, double tail)
|
||||
void AMSQ::SetAMSQMaxTail (RXA& rxa, float tail)
|
||||
{
|
||||
AMSQ *a;
|
||||
rxa.csDSP.lock();
|
||||
@ -254,7 +254,7 @@ void AMSQ::SetAMSQRun (TXA& txa, int run)
|
||||
txa.csDSP.unlock();
|
||||
}
|
||||
|
||||
void AMSQ::SetAMSQMutedGain (TXA& txa, double dBlevel)
|
||||
void AMSQ::SetAMSQMutedGain (TXA& txa, float dBlevel)
|
||||
{ // dBlevel is negative
|
||||
AMSQ *a;
|
||||
txa.csDSP.lock();
|
||||
@ -264,9 +264,9 @@ void AMSQ::SetAMSQMutedGain (TXA& txa, double dBlevel)
|
||||
txa.csDSP.unlock();
|
||||
}
|
||||
|
||||
void AMSQ::SetAMSQThreshold (TXA& txa, double threshold)
|
||||
void AMSQ::SetAMSQThreshold (TXA& txa, float threshold)
|
||||
{
|
||||
double thresh = pow (10.0, threshold / 20.0);
|
||||
float thresh = pow (10.0, threshold / 20.0);
|
||||
txa.csDSP.lock();
|
||||
txa.amsq.p->tail_thresh = 0.9 * thresh;
|
||||
txa.amsq.p->unmute_thresh = thresh;
|
||||
|
@ -39,45 +39,45 @@ 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
|
||||
double* in; // squelch input signal buffer
|
||||
double* out; // squelch output signal buffer
|
||||
double* trigger; // pointer to trigger data source
|
||||
double* trigsig; // buffer containing trigger signal
|
||||
double rate; // sample rate
|
||||
double avtau; // time constant for averaging noise
|
||||
double avm;
|
||||
double onem_avm;
|
||||
double avsig;
|
||||
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
|
||||
float rate; // sample rate
|
||||
float avtau; // time constant for averaging noise
|
||||
float avm;
|
||||
float onem_avm;
|
||||
float avsig;
|
||||
int state; // state machine control
|
||||
int count;
|
||||
double tup;
|
||||
double tdown;
|
||||
float tup;
|
||||
float tdown;
|
||||
int ntup;
|
||||
int ntdown;
|
||||
double* cup;
|
||||
double* cdown;
|
||||
double tail_thresh;
|
||||
double unmute_thresh;
|
||||
double min_tail;
|
||||
double max_tail;
|
||||
double muted_gain;
|
||||
float* cup;
|
||||
float* cdown;
|
||||
float tail_thresh;
|
||||
float unmute_thresh;
|
||||
float min_tail;
|
||||
float max_tail;
|
||||
float muted_gain;
|
||||
|
||||
static AMSQ* create_amsq (int run, int size, double* in, double* out, double* trigger, int rate, double avtau, double tup, double tdown, double tail_thresh, double unmute_thresh, double min_tail, double max_tail, double muted_gain);
|
||||
static AMSQ* create_amsq (int run, int size, float* in, float* out, float* trigger, int rate, float avtau, float tup, float tdown, float tail_thresh, float unmute_thresh, float min_tail, float max_tail, float muted_gain);
|
||||
static void destroy_amsq (AMSQ *a);
|
||||
static void flush_amsq (AMSQ *a);
|
||||
static void xamsq (AMSQ *a);
|
||||
static void xamsqcap (AMSQ *a);
|
||||
static void setBuffers_amsq (AMSQ *a, double* in, double* out, double* trigger);
|
||||
static void setBuffers_amsq (AMSQ *a, float* in, float* out, float* trigger);
|
||||
static void setSamplerate_amsq (AMSQ *a, int rate);
|
||||
static void setSize_amsq (AMSQ *a, int size);
|
||||
// RXA Properties
|
||||
static void SetAMSQRun (RXA& rxa, int run);
|
||||
static void SetAMSQThreshold (RXA& rxa, double threshold);
|
||||
static void SetAMSQMaxTail (RXA& rxa, double tail);
|
||||
static void SetAMSQThreshold (RXA& rxa, float threshold);
|
||||
static void SetAMSQMaxTail (RXA& rxa, float tail);
|
||||
// TXA Properties
|
||||
static void SetAMSQRun (TXA& txa, int run);
|
||||
static void SetAMSQMutedGain (TXA& txa, double dBlevel);
|
||||
static void SetAMSQThreshold (TXA& txa, double threshold);
|
||||
static void SetAMSQMutedGain (TXA& txa, float dBlevel);
|
||||
static void SetAMSQThreshold (TXA& txa, float threshold);
|
||||
|
||||
private:
|
||||
static void compute_slews(AMSQ *a);
|
||||
|
44
wdsp/anf.cpp
44
wdsp/anf.cpp
@ -40,20 +40,20 @@ ANF* ANF::create_anf(
|
||||
int run,
|
||||
int position,
|
||||
int buff_size,
|
||||
double *in_buff,
|
||||
double *out_buff,
|
||||
float *in_buff,
|
||||
float *out_buff,
|
||||
int dline_size,
|
||||
int n_taps,
|
||||
int delay,
|
||||
double two_mu,
|
||||
double gamma,
|
||||
double lidx,
|
||||
double lidx_min,
|
||||
double lidx_max,
|
||||
double ngamma,
|
||||
double den_mult,
|
||||
double lincr,
|
||||
double ldecr
|
||||
float two_mu,
|
||||
float gamma,
|
||||
float lidx,
|
||||
float lidx_min,
|
||||
float lidx_max,
|
||||
float ngamma,
|
||||
float den_mult,
|
||||
float lincr,
|
||||
float ldecr
|
||||
)
|
||||
{
|
||||
ANF *a = new ANF;
|
||||
@ -77,8 +77,8 @@ ANF* ANF::create_anf(
|
||||
a->lincr = lincr;
|
||||
a->ldecr = ldecr;
|
||||
|
||||
memset (a->d, 0, sizeof(double) * ANF_DLINE_SIZE);
|
||||
memset (a->w, 0, sizeof(double) * ANF_DLINE_SIZE);
|
||||
memset (a->d, 0, sizeof(float) * ANF_DLINE_SIZE);
|
||||
memset (a->w, 0, sizeof(float) * ANF_DLINE_SIZE);
|
||||
|
||||
return a;
|
||||
}
|
||||
@ -91,9 +91,9 @@ void ANF::destroy_anf (ANF *a)
|
||||
void ANF::xanf(ANF *a, int position)
|
||||
{
|
||||
int i, j, idx;
|
||||
double c0, c1;
|
||||
double y, error, sigma, inv_sigp;
|
||||
double nel, nev;
|
||||
float c0, c1;
|
||||
float y, error, sigma, inv_sigp;
|
||||
float nel, nev;
|
||||
if (a->run && (a->position == position))
|
||||
{
|
||||
for (i = 0; i < a->buff_size; i++)
|
||||
@ -144,12 +144,12 @@ void ANF::xanf(ANF *a, int position)
|
||||
|
||||
void ANF::flush_anf (ANF *a)
|
||||
{
|
||||
memset (a->d, 0, sizeof(double) * ANF_DLINE_SIZE);
|
||||
memset (a->w, 0, sizeof(double) * ANF_DLINE_SIZE);
|
||||
memset (a->d, 0, sizeof(float) * ANF_DLINE_SIZE);
|
||||
memset (a->w, 0, sizeof(float) * ANF_DLINE_SIZE);
|
||||
a->in_idx = 0;
|
||||
}
|
||||
|
||||
void ANF::setBuffers_anf (ANF *a, double* in, double* out)
|
||||
void ANF::setBuffers_anf (ANF *a, float* in, float* out)
|
||||
{
|
||||
a->in_buff = in;
|
||||
a->out_buff = out;
|
||||
@ -188,7 +188,7 @@ void ANF::SetANFRun (RXA& rxa, int run)
|
||||
}
|
||||
|
||||
|
||||
void ANF::SetANFVals (RXA& rxa, int taps, int delay, double gain, double leakage)
|
||||
void ANF::SetANFVals (RXA& rxa, int taps, int delay, float gain, float leakage)
|
||||
{
|
||||
rxa.csDSP.lock();
|
||||
rxa.anf.p->n_taps = taps;
|
||||
@ -215,7 +215,7 @@ void ANF::SetANFDelay (RXA& rxa, int delay)
|
||||
rxa.csDSP.unlock();
|
||||
}
|
||||
|
||||
void ANF::SetANFGain (RXA& rxa, double gain)
|
||||
void ANF::SetANFGain (RXA& rxa, float gain)
|
||||
{
|
||||
rxa.csDSP.lock();
|
||||
rxa.anf.p->two_mu = gain;
|
||||
@ -223,7 +223,7 @@ void ANF::SetANFGain (RXA& rxa, double gain)
|
||||
rxa.csDSP.unlock();
|
||||
}
|
||||
|
||||
void ANF::SetANFLeakage (RXA& rxa, double leakage)
|
||||
void ANF::SetANFLeakage (RXA& rxa, float leakage)
|
||||
{
|
||||
rxa.csDSP.lock();
|
||||
rxa.anf.p->gamma = leakage;
|
||||
|
56
wdsp/anf.hpp
56
wdsp/anf.hpp
@ -42,57 +42,57 @@ public:
|
||||
int run;
|
||||
int position;
|
||||
int buff_size;
|
||||
double *in_buff;
|
||||
double *out_buff;
|
||||
float *in_buff;
|
||||
float *out_buff;
|
||||
int dline_size;
|
||||
int mask;
|
||||
int n_taps;
|
||||
int delay;
|
||||
double two_mu;
|
||||
double gamma;
|
||||
double d [ANF_DLINE_SIZE];
|
||||
double w [ANF_DLINE_SIZE];
|
||||
float two_mu;
|
||||
float gamma;
|
||||
float d [ANF_DLINE_SIZE];
|
||||
float w [ANF_DLINE_SIZE];
|
||||
int in_idx;
|
||||
double lidx;
|
||||
double lidx_min;
|
||||
double lidx_max;
|
||||
double ngamma;
|
||||
double den_mult;
|
||||
double lincr;
|
||||
double ldecr;
|
||||
float lidx;
|
||||
float lidx_min;
|
||||
float lidx_max;
|
||||
float ngamma;
|
||||
float den_mult;
|
||||
float lincr;
|
||||
float ldecr;
|
||||
|
||||
static ANF* create_anf(
|
||||
int run,
|
||||
int position,
|
||||
int buff_size,
|
||||
double *in_buff,
|
||||
double *out_buff,
|
||||
float *in_buff,
|
||||
float *out_buff,
|
||||
int dline_size,
|
||||
int n_taps,
|
||||
int delay,
|
||||
double two_mu,
|
||||
double gamma,
|
||||
double lidx,
|
||||
double lidx_min,
|
||||
double lidx_max,
|
||||
double ngamma,
|
||||
double den_mult,
|
||||
double lincr,
|
||||
double ldecr
|
||||
float two_mu,
|
||||
float gamma,
|
||||
float lidx,
|
||||
float lidx_min,
|
||||
float lidx_max,
|
||||
float ngamma,
|
||||
float den_mult,
|
||||
float lincr,
|
||||
float ldecr
|
||||
);
|
||||
static void destroy_anf (ANF *a);
|
||||
static void flush_anf (ANF *a);
|
||||
static void xanf (ANF *a, int position);
|
||||
static void setBuffers_anf (ANF *a, double* in, double* out);
|
||||
static void setBuffers_anf (ANF *a, float* in, float* out);
|
||||
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 SetANFVals (RXA& rxa, int taps, int delay, float gain, float leakage);
|
||||
static void SetANFTaps (RXA& rxa, int taps);
|
||||
static void SetANFDelay (RXA& rxa, int delay);
|
||||
static void SetANFGain (RXA& rxa, double gain);
|
||||
static void SetANFLeakage (RXA& rxa, double leakage);
|
||||
static void SetANFGain (RXA& rxa, float gain);
|
||||
static void SetANFLeakage (RXA& rxa, float leakage);
|
||||
static void SetANFPosition (RXA& rxa, int position);
|
||||
};
|
||||
|
||||
|
44
wdsp/anr.cpp
44
wdsp/anr.cpp
@ -42,21 +42,21 @@ ANR* ANR::create_anr (
|
||||
int run,
|
||||
int position,
|
||||
int buff_size,
|
||||
double *in_buff,
|
||||
double *out_buff,
|
||||
float *in_buff,
|
||||
float *out_buff,
|
||||
int dline_size,
|
||||
int n_taps,
|
||||
int delay,
|
||||
double two_mu,
|
||||
double gamma,
|
||||
float two_mu,
|
||||
float gamma,
|
||||
|
||||
double lidx,
|
||||
double lidx_min,
|
||||
double lidx_max,
|
||||
double ngamma,
|
||||
double den_mult,
|
||||
double lincr,
|
||||
double ldecr
|
||||
float lidx,
|
||||
float lidx_min,
|
||||
float lidx_max,
|
||||
float ngamma,
|
||||
float den_mult,
|
||||
float lincr,
|
||||
float ldecr
|
||||
)
|
||||
{
|
||||
ANR *a = new ANR;
|
||||
@ -80,8 +80,8 @@ ANR* ANR::create_anr (
|
||||
a->lincr = lincr;
|
||||
a->ldecr = ldecr;
|
||||
|
||||
memset (a->d, 0, sizeof(double) * ANR_DLINE_SIZE);
|
||||
memset (a->w, 0, sizeof(double) * ANR_DLINE_SIZE);
|
||||
memset (a->d, 0, sizeof(float) * ANR_DLINE_SIZE);
|
||||
memset (a->w, 0, sizeof(float) * ANR_DLINE_SIZE);
|
||||
|
||||
return a;
|
||||
}
|
||||
@ -94,9 +94,9 @@ void ANR::destroy_anr (ANR *a)
|
||||
void ANR::xanr (ANR *a, int position)
|
||||
{
|
||||
int i, j, idx;
|
||||
double c0, c1;
|
||||
double y, error, sigma, inv_sigp;
|
||||
double nel, nev;
|
||||
float c0, c1;
|
||||
float y, error, sigma, inv_sigp;
|
||||
float nel, nev;
|
||||
if (a->run && (a->position == position))
|
||||
{
|
||||
for (i = 0; i < a->buff_size; i++)
|
||||
@ -147,12 +147,12 @@ void ANR::xanr (ANR *a, int position)
|
||||
|
||||
void ANR::flush_anr (ANR *a)
|
||||
{
|
||||
memset (a->d, 0, sizeof(double) * ANR_DLINE_SIZE);
|
||||
memset (a->w, 0, sizeof(double) * ANR_DLINE_SIZE);
|
||||
memset (a->d, 0, sizeof(float) * ANR_DLINE_SIZE);
|
||||
memset (a->w, 0, sizeof(float) * ANR_DLINE_SIZE);
|
||||
a->in_idx = 0;
|
||||
}
|
||||
|
||||
void ANR::setBuffers_anr (ANR *a, double* in, double* out)
|
||||
void ANR::setBuffers_anr (ANR *a, float* in, float* out)
|
||||
{
|
||||
a->in_buff = in;
|
||||
a->out_buff = out;
|
||||
@ -190,7 +190,7 @@ void ANR::SetANRRun (RXA& rxa, int run)
|
||||
}
|
||||
}
|
||||
|
||||
void ANR::SetANRVals (RXA& rxa, int taps, int delay, double gain, double leakage)
|
||||
void ANR::SetANRVals (RXA& rxa, int taps, int delay, float gain, float leakage)
|
||||
{
|
||||
rxa.csDSP.lock();
|
||||
rxa.anr.p->n_taps = taps;
|
||||
@ -217,7 +217,7 @@ void ANR::SetANRDelay (RXA& rxa, int delay)
|
||||
rxa.csDSP.unlock();
|
||||
}
|
||||
|
||||
void ANR::SetANRGain (RXA& rxa, double gain)
|
||||
void ANR::SetANRGain (RXA& rxa, float gain)
|
||||
{
|
||||
rxa.csDSP.lock();
|
||||
rxa.anr.p->two_mu = gain;
|
||||
@ -225,7 +225,7 @@ void ANR::SetANRGain (RXA& rxa, double gain)
|
||||
rxa.csDSP.unlock();
|
||||
}
|
||||
|
||||
void ANR::SetANRLeakage (RXA& rxa, double leakage)
|
||||
void ANR::SetANRLeakage (RXA& rxa, float leakage)
|
||||
{
|
||||
rxa.csDSP.lock();
|
||||
rxa.anr.p->gamma = leakage;
|
||||
|
56
wdsp/anr.hpp
56
wdsp/anr.hpp
@ -42,60 +42,60 @@ public:
|
||||
int run;
|
||||
int position;
|
||||
int buff_size;
|
||||
double *in_buff;
|
||||
double *out_buff;
|
||||
float *in_buff;
|
||||
float *out_buff;
|
||||
int dline_size;
|
||||
int mask;
|
||||
int n_taps;
|
||||
int delay;
|
||||
double two_mu;
|
||||
double gamma;
|
||||
double d [ANR_DLINE_SIZE];
|
||||
double w [ANR_DLINE_SIZE];
|
||||
float two_mu;
|
||||
float gamma;
|
||||
float d [ANR_DLINE_SIZE];
|
||||
float w [ANR_DLINE_SIZE];
|
||||
int in_idx;
|
||||
|
||||
double lidx;
|
||||
double lidx_min;
|
||||
double lidx_max;
|
||||
double ngamma;
|
||||
double den_mult;
|
||||
double lincr;
|
||||
double ldecr;
|
||||
float lidx;
|
||||
float lidx_min;
|
||||
float lidx_max;
|
||||
float ngamma;
|
||||
float den_mult;
|
||||
float lincr;
|
||||
float ldecr;
|
||||
|
||||
static ANR* create_anr (
|
||||
int run,
|
||||
int position,
|
||||
int buff_size,
|
||||
double *in_buff,
|
||||
double *out_buff,
|
||||
float *in_buff,
|
||||
float *out_buff,
|
||||
int dline_size,
|
||||
int n_taps,
|
||||
int delay,
|
||||
double two_mu,
|
||||
double gamma,
|
||||
float two_mu,
|
||||
float gamma,
|
||||
|
||||
double lidx,
|
||||
double lidx_min,
|
||||
double lidx_max,
|
||||
double ngamma,
|
||||
double den_mult,
|
||||
double lincr,
|
||||
double ldecr
|
||||
float lidx,
|
||||
float lidx_min,
|
||||
float lidx_max,
|
||||
float ngamma,
|
||||
float den_mult,
|
||||
float lincr,
|
||||
float ldecr
|
||||
);
|
||||
|
||||
static void destroy_anr (ANR *a);
|
||||
static void flush_anr (ANR *a);
|
||||
static void xanr (ANR *a, int position);
|
||||
static void setBuffers_anr (ANR *a, double* in, double* out);
|
||||
static void setBuffers_anr (ANR *a, float* in, float* out);
|
||||
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 SetANRVals (RXA& rxa, int taps, int delay, float gain, float leakage);
|
||||
static void SetANRTaps (RXA& rxa, int taps);
|
||||
static void SetANRDelay (RXA& rxa, int delay);
|
||||
static void SetANRGain (RXA& rxa, double gain);
|
||||
static void SetANRLeakage (RXA& rxa, double leakage);
|
||||
static void SetANRGain (RXA& rxa, float gain);
|
||||
static void SetANRLeakage (RXA& rxa, float leakage);
|
||||
static void SetANRPosition (RXA& rxa, int position);
|
||||
};
|
||||
|
||||
|
@ -40,12 +40,12 @@ namespace WDSP {
|
||||
* *
|
||||
********************************************************************************************************/
|
||||
|
||||
BANDPASS* BANDPASS::create_bandpass (int run, int position, int size, int nc, int mp, double* in, double* out,
|
||||
double f_low, double f_high, int samplerate, int wintype, double gain)
|
||||
BANDPASS* BANDPASS::create_bandpass (int run, int position, int size, int nc, int mp, float* in, float* out,
|
||||
float f_low, float f_high, int samplerate, int wintype, float gain)
|
||||
{
|
||||
// NOTE: 'nc' must be >= 'size'
|
||||
BANDPASS *a = new BANDPASS;
|
||||
double* impulse;
|
||||
float* impulse;
|
||||
a->run = run;
|
||||
a->position = position;
|
||||
a->size = size;
|
||||
@ -58,7 +58,7 @@ BANDPASS* BANDPASS::create_bandpass (int run, int position, int size, int nc, in
|
||||
a->samplerate = samplerate;
|
||||
a->wintype = wintype;
|
||||
a->gain = gain;
|
||||
impulse = FIR::fir_bandpass (a->nc, a->f_low, a->f_high, a->samplerate, a->wintype, 1, a->gain / (double)(2 * a->size));
|
||||
impulse = FIR::fir_bandpass (a->nc, a->f_low, a->f_high, a->samplerate, a->wintype, 1, a->gain / (float)(2 * a->size));
|
||||
a->p = FIRCORE::create_fircore (a->size, a->in, a->out, a->nc, a->mp, impulse);
|
||||
delete[] impulse;
|
||||
return a;
|
||||
@ -83,7 +83,7 @@ void BANDPASS::xbandpass (BANDPASS *a, int pos)
|
||||
memcpy (a->out, a->in, a->size * sizeof (wcomplex));
|
||||
}
|
||||
|
||||
void BANDPASS::setBuffers_bandpass (BANDPASS *a, double* in, double* out)
|
||||
void BANDPASS::setBuffers_bandpass (BANDPASS *a, float* in, float* out)
|
||||
{
|
||||
a->in = in;
|
||||
a->out = out;
|
||||
@ -92,9 +92,9 @@ void BANDPASS::setBuffers_bandpass (BANDPASS *a, double* in, double* out)
|
||||
|
||||
void BANDPASS::setSamplerate_bandpass (BANDPASS *a, int rate)
|
||||
{
|
||||
double* impulse;
|
||||
float* impulse;
|
||||
a->samplerate = rate;
|
||||
impulse = FIR::fir_bandpass (a->nc, a->f_low, a->f_high, a->samplerate, a->wintype, 1, a->gain / (double)(2 * a->size));
|
||||
impulse = FIR::fir_bandpass (a->nc, a->f_low, a->f_high, a->samplerate, a->wintype, 1, a->gain / (float)(2 * a->size));
|
||||
FIRCORE::setImpulse_fircore (a->p, impulse, 1);
|
||||
delete[] impulse;
|
||||
}
|
||||
@ -102,33 +102,33 @@ void BANDPASS::setSamplerate_bandpass (BANDPASS *a, int rate)
|
||||
void BANDPASS::setSize_bandpass (BANDPASS *a, int size)
|
||||
{
|
||||
// NOTE: 'size' must be <= 'nc'
|
||||
double* impulse;
|
||||
float* impulse;
|
||||
a->size = size;
|
||||
FIRCORE::setSize_fircore (a->p, a->size);
|
||||
// recalc impulse because scale factor is a function of size
|
||||
impulse = FIR::fir_bandpass (a->nc, a->f_low, a->f_high, a->samplerate, a->wintype, 1, a->gain / (double)(2 * a->size));
|
||||
impulse = FIR::fir_bandpass (a->nc, a->f_low, a->f_high, a->samplerate, a->wintype, 1, a->gain / (float)(2 * a->size));
|
||||
FIRCORE::setImpulse_fircore (a->p, impulse, 1);
|
||||
delete[] (impulse);
|
||||
}
|
||||
|
||||
void BANDPASS::setGain_bandpass (BANDPASS *a, double gain, int update)
|
||||
void BANDPASS::setGain_bandpass (BANDPASS *a, float gain, int update)
|
||||
{
|
||||
double* impulse;
|
||||
float* impulse;
|
||||
a->gain = gain;
|
||||
impulse = FIR::fir_bandpass (a->nc, a->f_low, a->f_high, a->samplerate, a->wintype, 1, a->gain / (double)(2 * a->size));
|
||||
impulse = FIR::fir_bandpass (a->nc, a->f_low, a->f_high, a->samplerate, a->wintype, 1, a->gain / (float)(2 * a->size));
|
||||
FIRCORE::setImpulse_fircore (a->p, impulse, update);
|
||||
delete[] (impulse);
|
||||
}
|
||||
|
||||
void BANDPASS::CalcBandpassFilter (BANDPASS *a, double f_low, double f_high, double gain)
|
||||
void BANDPASS::CalcBandpassFilter (BANDPASS *a, float f_low, float f_high, float gain)
|
||||
{
|
||||
double* impulse;
|
||||
float* impulse;
|
||||
if ((a->f_low != f_low) || (a->f_high != f_high) || (a->gain != gain))
|
||||
{
|
||||
a->f_low = f_low;
|
||||
a->f_high = f_high;
|
||||
a->gain = gain;
|
||||
impulse = FIR::fir_bandpass (a->nc, a->f_low, a->f_high, a->samplerate, a->wintype, 1, a->gain / (double)(2 * a->size));
|
||||
impulse = FIR::fir_bandpass (a->nc, a->f_low, a->f_high, a->samplerate, a->wintype, 1, a->gain / (float)(2 * a->size));
|
||||
FIRCORE::setImpulse_fircore (a->p, impulse, 1);
|
||||
delete[] (impulse);
|
||||
}
|
||||
@ -140,14 +140,14 @@ void BANDPASS::CalcBandpassFilter (BANDPASS *a, double f_low, double f_high, dou
|
||||
* *
|
||||
********************************************************************************************************/
|
||||
|
||||
void BANDPASS::SetBandpassFreqs (RXA& rxa, double f_low, double f_high)
|
||||
void BANDPASS::SetBandpassFreqs (RXA& rxa, float f_low, float f_high)
|
||||
{
|
||||
double* impulse;
|
||||
float* impulse;
|
||||
BANDPASS *a = rxa.bp1.p;
|
||||
if ((f_low != a->f_low) || (f_high != a->f_high))
|
||||
{
|
||||
impulse = FIR::fir_bandpass (a->nc, f_low, f_high, a->samplerate,
|
||||
a->wintype, 1, a->gain / (double)(2 * a->size));
|
||||
a->wintype, 1, a->gain / (float)(2 * a->size));
|
||||
FIRCORE::setImpulse_fircore (a->p, impulse, 0);
|
||||
delete[] (impulse);
|
||||
rxa.csDSP.lock();
|
||||
@ -161,14 +161,14 @@ void BANDPASS::SetBandpassFreqs (RXA& rxa, double f_low, double f_high)
|
||||
void BANDPASS::SetBandpassNC (RXA& rxa, int nc)
|
||||
{
|
||||
// NOTE: 'nc' must be >= 'size'
|
||||
double* impulse;
|
||||
float* impulse;
|
||||
BANDPASS *a;
|
||||
rxa.csDSP.lock();
|
||||
a = rxa.bp1.p;
|
||||
if (nc != a->nc)
|
||||
{
|
||||
a->nc = nc;
|
||||
impulse = FIR::fir_bandpass (a->nc, a->f_low, a->f_high, a->samplerate, a->wintype, 1, a->gain / (double)(2 * a->size));
|
||||
impulse = FIR::fir_bandpass (a->nc, a->f_low, a->f_high, a->samplerate, a->wintype, 1, a->gain / (float)(2 * a->size));
|
||||
FIRCORE::setNc_fircore (a->p, a->nc, impulse);
|
||||
delete[] (impulse);
|
||||
}
|
||||
@ -193,16 +193,16 @@ void BANDPASS::SetBandpassMP (RXA& rxa, int mp)
|
||||
********************************************************************************************************/
|
||||
|
||||
//PORT
|
||||
//void SetTXABandpassFreqs (int channel, double f_low, double f_high)
|
||||
//void SetTXABandpassFreqs (int channel, float f_low, float f_high)
|
||||
//{
|
||||
// double* impulse;
|
||||
// float* impulse;
|
||||
// BANDPASS a;
|
||||
// a = txa.bp0.p;
|
||||
// if ((f_low != a->f_low) || (f_high != a->f_high))
|
||||
// {
|
||||
// a->f_low = f_low;
|
||||
// a->f_high = f_high;
|
||||
// impulse = fir_bandpass (a->nc, a->f_low, a->f_high, a->samplerate, a->wintype, 1, a->gain / (double)(2 * a->size));
|
||||
// impulse = fir_bandpass (a->nc, a->f_low, a->f_high, a->samplerate, a->wintype, 1, a->gain / (float)(2 * a->size));
|
||||
// setImpulse_fircore (a->p, impulse, 1);
|
||||
// delete[] (impulse);
|
||||
// }
|
||||
@ -211,7 +211,7 @@ void BANDPASS::SetBandpassMP (RXA& rxa, int mp)
|
||||
// {
|
||||
// a->f_low = f_low;
|
||||
// a->f_high = f_high;
|
||||
// impulse = fir_bandpass (a->nc, a->f_low, a->f_high, a->samplerate, a->wintype, 1, a->gain / (double)(2 * a->size));
|
||||
// impulse = fir_bandpass (a->nc, a->f_low, a->f_high, a->samplerate, a->wintype, 1, a->gain / (float)(2 * a->size));
|
||||
// setImpulse_fircore (a->p, impulse, 1);
|
||||
// delete[] (impulse);
|
||||
// }
|
||||
@ -220,7 +220,7 @@ void BANDPASS::SetBandpassMP (RXA& rxa, int mp)
|
||||
// {
|
||||
// a->f_low = f_low;
|
||||
// a->f_high = f_high;
|
||||
// impulse = fir_bandpass (a->nc, a->f_low, a->f_high, a->samplerate, a->wintype, 1, a->gain / (double)(2 * a->size));
|
||||
// impulse = fir_bandpass (a->nc, a->f_low, a->f_high, a->samplerate, a->wintype, 1, a->gain / (float)(2 * a->size));
|
||||
// setImpulse_fircore (a->p, impulse, 1);
|
||||
// delete[] (impulse);
|
||||
// }
|
||||
@ -229,14 +229,14 @@ void BANDPASS::SetBandpassMP (RXA& rxa, int mp)
|
||||
void BANDPASS::SetBandpassNC (TXA& txa, int nc)
|
||||
{
|
||||
// NOTE: 'nc' must be >= 'size'
|
||||
double* impulse;
|
||||
float* impulse;
|
||||
BANDPASS *a;
|
||||
txa.csDSP.lock();
|
||||
a = txa.bp0.p;
|
||||
if (a->nc != nc)
|
||||
{
|
||||
a->nc = nc;
|
||||
impulse = FIR::fir_bandpass (a->nc, a->f_low, a->f_high, a->samplerate, a->wintype, 1, a->gain / (double)(2 * a->size));
|
||||
impulse = FIR::fir_bandpass (a->nc, a->f_low, a->f_high, a->samplerate, a->wintype, 1, a->gain / (float)(2 * a->size));
|
||||
FIRCORE::setNc_fircore (a->p, a->nc, impulse);
|
||||
delete[] (impulse);
|
||||
}
|
||||
@ -244,7 +244,7 @@ void BANDPASS::SetBandpassNC (TXA& txa, int nc)
|
||||
if (a->nc != nc)
|
||||
{
|
||||
a->nc = nc;
|
||||
impulse = FIR::fir_bandpass (a->nc, a->f_low, a->f_high, a->samplerate, a->wintype, 1, a->gain / (double)(2 * a->size));
|
||||
impulse = FIR::fir_bandpass (a->nc, a->f_low, a->f_high, a->samplerate, a->wintype, 1, a->gain / (float)(2 * a->size));
|
||||
FIRCORE::setNc_fircore (a->p, a->nc, impulse);
|
||||
delete[] (impulse);
|
||||
}
|
||||
@ -252,7 +252,7 @@ void BANDPASS::SetBandpassNC (TXA& txa, int nc)
|
||||
if (a->nc != nc)
|
||||
{
|
||||
a->nc = nc;
|
||||
impulse = FIR::fir_bandpass (a->nc, a->f_low, a->f_high, a->samplerate, a->wintype, 1, a->gain / (double)(2 * a->size));
|
||||
impulse = FIR::fir_bandpass (a->nc, a->f_low, a->f_high, a->samplerate, a->wintype, 1, a->gain / (float)(2 * a->size));
|
||||
FIRCORE::setNc_fircore (a->p, a->nc, impulse);
|
||||
delete[] (impulse);
|
||||
}
|
||||
|
@ -57,27 +57,27 @@ public:
|
||||
int size;
|
||||
int nc;
|
||||
int mp;
|
||||
double* in;
|
||||
double* out;
|
||||
double f_low;
|
||||
double f_high;
|
||||
double samplerate;
|
||||
float* in;
|
||||
float* out;
|
||||
float f_low;
|
||||
float f_high;
|
||||
float samplerate;
|
||||
int wintype;
|
||||
double gain;
|
||||
float gain;
|
||||
FIRCORE *p;
|
||||
|
||||
static BANDPASS *create_bandpass (int run, int position, int size, int nc, int mp, double* in, double* out,
|
||||
double f_low, double f_high, int samplerate, int wintype, double gain);
|
||||
static BANDPASS *create_bandpass (int run, int position, int size, int nc, int mp, float* in, float* out,
|
||||
float f_low, float f_high, int samplerate, int wintype, float gain);
|
||||
static void destroy_bandpass (BANDPASS *a);
|
||||
static void flush_bandpass (BANDPASS *a);
|
||||
static void xbandpass (BANDPASS *a, int pos);
|
||||
static void setBuffers_bandpass (BANDPASS *a, double* in, double* out);
|
||||
static void setBuffers_bandpass (BANDPASS *a, float* in, float* out);
|
||||
static void setSamplerate_bandpass (BANDPASS *a, int rate);
|
||||
static void setSize_bandpass (BANDPASS *a, int size);
|
||||
static void setGain_bandpass (BANDPASS *a, double gain, int update);
|
||||
static void CalcBandpassFilter (BANDPASS *a, double f_low, double f_high, double gain);
|
||||
static void setGain_bandpass (BANDPASS *a, float gain, int update);
|
||||
static void CalcBandpassFilter (BANDPASS *a, float f_low, float f_high, float gain);
|
||||
// RXA Prototypes
|
||||
static void SetBandpassFreqs (RXA& rxa, double f_low, double f_high);
|
||||
static void SetBandpassFreqs (RXA& rxa, float f_low, float f_high);
|
||||
static void SetBandpassNC (RXA& rxa, int nc);
|
||||
static void SetBandpassMP (RXA& rxa, int mp);
|
||||
// TXA Prototypes
|
||||
|
128
wdsp/bldr.cpp
128
wdsp/bldr.cpp
@ -34,38 +34,38 @@ BLDR* BLDR::create_builder(int points, int ints)
|
||||
{
|
||||
// for the create function, 'points' and 'ints' are the MAXIMUM values that will be encountered
|
||||
BLDR *a = new BLDR;
|
||||
a->catxy = new double[2 * points]; // (double*)malloc0(2 * points * sizeof(double));
|
||||
a->sx = new double[points]; // (double*)malloc0( points * sizeof(double));
|
||||
a->sy = new double[points]; // (double*)malloc0( points * sizeof(double));
|
||||
a->h = new double[ints]; // (double*)malloc0( ints * sizeof(double));
|
||||
a->catxy = new float[2 * points]; // (float*)malloc0(2 * points * sizeof(float));
|
||||
a->sx = new float[points]; // (float*)malloc0( points * sizeof(float));
|
||||
a->sy = new float[points]; // (float*)malloc0( points * sizeof(float));
|
||||
a->h = new float[ints]; // (float*)malloc0( ints * sizeof(float));
|
||||
a->p = new int[ints]; // (int*) malloc0( ints * sizeof(int));
|
||||
a->np = new int[ints]; // (int*) malloc0( ints * sizeof(int));
|
||||
a->taa = new double[ints]; // (double*)malloc0( ints * sizeof(double));
|
||||
a->tab = new double[ints]; // (double*)malloc0( ints * sizeof(double));
|
||||
a->tag = new double[ints]; // (double*)malloc0( ints * sizeof(double));
|
||||
a->tad = new double[ints]; // (double*)malloc0( ints * sizeof(double));
|
||||
a->tbb = new double[ints]; // (double*)malloc0( ints * sizeof(double));
|
||||
a->tbg = new double[ints]; // (double*)malloc0( ints * sizeof(double));
|
||||
a->tbd = new double[ints]; // (double*)malloc0( ints * sizeof(double));
|
||||
a->tgg = new double[ints]; // (double*)malloc0( ints * sizeof(double));
|
||||
a->tgd = new double[ints]; // (double*)malloc0( ints * sizeof(double));
|
||||
a->tdd = new double[ints]; // (double*)malloc0( ints * sizeof(double));
|
||||
a->taa = new float[ints]; // (float*)malloc0( ints * sizeof(float));
|
||||
a->tab = new float[ints]; // (float*)malloc0( ints * sizeof(float));
|
||||
a->tag = new float[ints]; // (float*)malloc0( ints * sizeof(float));
|
||||
a->tad = new float[ints]; // (float*)malloc0( ints * sizeof(float));
|
||||
a->tbb = new float[ints]; // (float*)malloc0( ints * sizeof(float));
|
||||
a->tbg = new float[ints]; // (float*)malloc0( ints * sizeof(float));
|
||||
a->tbd = new float[ints]; // (float*)malloc0( ints * sizeof(float));
|
||||
a->tgg = new float[ints]; // (float*)malloc0( ints * sizeof(float));
|
||||
a->tgd = new float[ints]; // (float*)malloc0( ints * sizeof(float));
|
||||
a->tdd = new float[ints]; // (float*)malloc0( ints * sizeof(float));
|
||||
int nsize = 3 * ints + 1;
|
||||
int intp1 = ints + 1;
|
||||
int intm1 = ints - 1;
|
||||
a->A = new double[intp1 * intp1]; // (double*)malloc0(intp1 * intp1 * sizeof(double));
|
||||
a->B = new double[intp1 * intp1]; // (double*)malloc0(intp1 * intp1 * sizeof(double));
|
||||
a->C = new double[intp1 * intp1]; // (double*)malloc0(intm1 * intp1 * sizeof(double));
|
||||
a->D = new double[intp1]; // (double*)malloc0(intp1 * sizeof(double));
|
||||
a->E = new double[intp1 * intp1]; // (double*)malloc0(intp1 * intp1 * sizeof(double));
|
||||
a->F = new double[intm1 * intp1]; // (double*)malloc0(intm1 * intp1 * sizeof(double));
|
||||
a->G = new double[intp1]; // (double*)malloc0(intp1 * sizeof(double));
|
||||
a->MAT = new double[nsize * nsize]; // (double*)malloc0(nsize * nsize * sizeof(double));
|
||||
a->RHS = new double[nsize]; // (double*)malloc0(nsize * sizeof(double));
|
||||
a->SLN = new double[nsize]; // (double*)malloc0(nsize * sizeof(double));
|
||||
a->z = new double[intp1]; // (double*)malloc0(intp1 * sizeof(double));
|
||||
a->zp = new double[intp1]; // (double*)malloc0(intp1 * sizeof(double));
|
||||
a->wrk = new double[nsize]; // (double*)malloc0(nsize * sizeof(double));
|
||||
a->A = new float[intp1 * intp1]; // (float*)malloc0(intp1 * intp1 * sizeof(float));
|
||||
a->B = new float[intp1 * intp1]; // (float*)malloc0(intp1 * intp1 * sizeof(float));
|
||||
a->C = new float[intp1 * intp1]; // (float*)malloc0(intm1 * intp1 * sizeof(float));
|
||||
a->D = new float[intp1]; // (float*)malloc0(intp1 * sizeof(float));
|
||||
a->E = new float[intp1 * intp1]; // (float*)malloc0(intp1 * intp1 * sizeof(float));
|
||||
a->F = new float[intm1 * intp1]; // (float*)malloc0(intm1 * intp1 * sizeof(float));
|
||||
a->G = new float[intp1]; // (float*)malloc0(intp1 * sizeof(float));
|
||||
a->MAT = new float[nsize * nsize]; // (float*)malloc0(nsize * nsize * sizeof(float));
|
||||
a->RHS = new float[nsize]; // (float*)malloc0(nsize * sizeof(float));
|
||||
a->SLN = new float[nsize]; // (float*)malloc0(nsize * sizeof(float));
|
||||
a->z = new float[intp1]; // (float*)malloc0(intp1 * sizeof(float));
|
||||
a->zp = new float[intp1]; // (float*)malloc0(intp1 * sizeof(float));
|
||||
a->wrk = new float[nsize]; // (float*)malloc0(nsize * sizeof(float));
|
||||
a->ipiv = new int[nsize]; // (int*) malloc0(nsize * sizeof(int));
|
||||
return a;
|
||||
}
|
||||
@ -112,56 +112,56 @@ void BLDR::destroy_builder(BLDR *a)
|
||||
|
||||
void BLDRflush_builder(BLDR *a, int points, int ints)
|
||||
{
|
||||
memset(a->catxy, 0, 2 * points * sizeof(double));
|
||||
memset(a->sx, 0, points * sizeof(double));
|
||||
memset(a->sy, 0, points * sizeof(double));
|
||||
memset(a->h, 0, ints * sizeof(double));
|
||||
memset(a->catxy, 0, 2 * points * sizeof(float));
|
||||
memset(a->sx, 0, points * sizeof(float));
|
||||
memset(a->sy, 0, points * sizeof(float));
|
||||
memset(a->h, 0, ints * sizeof(float));
|
||||
memset(a->p, 0, ints * sizeof(int));
|
||||
memset(a->np, 0, ints * sizeof(int));
|
||||
memset(a->taa, 0, ints * sizeof(double));
|
||||
memset(a->tab, 0, ints * sizeof(double));
|
||||
memset(a->tag, 0, ints * sizeof(double));
|
||||
memset(a->tad, 0, ints * sizeof(double));
|
||||
memset(a->tbb, 0, ints * sizeof(double));
|
||||
memset(a->tbg, 0, ints * sizeof(double));
|
||||
memset(a->tbd, 0, ints * sizeof(double));
|
||||
memset(a->tgg, 0, ints * sizeof(double));
|
||||
memset(a->tgd, 0, ints * sizeof(double));
|
||||
memset(a->tdd, 0, ints * sizeof(double));
|
||||
memset(a->taa, 0, ints * sizeof(float));
|
||||
memset(a->tab, 0, ints * sizeof(float));
|
||||
memset(a->tag, 0, ints * sizeof(float));
|
||||
memset(a->tad, 0, ints * sizeof(float));
|
||||
memset(a->tbb, 0, ints * sizeof(float));
|
||||
memset(a->tbg, 0, ints * sizeof(float));
|
||||
memset(a->tbd, 0, ints * sizeof(float));
|
||||
memset(a->tgg, 0, ints * sizeof(float));
|
||||
memset(a->tgd, 0, ints * sizeof(float));
|
||||
memset(a->tdd, 0, ints * sizeof(float));
|
||||
int nsize = 3 * ints + 1;
|
||||
int intp1 = ints + 1;
|
||||
int intm1 = ints - 1;
|
||||
memset(a->A, 0, intp1 * intp1 * sizeof(double));
|
||||
memset(a->B, 0, intp1 * intp1 * sizeof(double));
|
||||
memset(a->C, 0, intm1 * intp1 * sizeof(double));
|
||||
memset(a->D, 0, intp1 * sizeof(double));
|
||||
memset(a->E, 0, intp1 * intp1 * sizeof(double));
|
||||
memset(a->F, 0, intm1 * intp1 * sizeof(double));
|
||||
memset(a->G, 0, intp1 * sizeof(double));
|
||||
memset(a->MAT, 0, nsize * nsize * sizeof(double));
|
||||
memset(a->RHS, 0, nsize * sizeof(double));
|
||||
memset(a->SLN, 0, nsize * sizeof(double));
|
||||
memset(a->z, 0, intp1 * sizeof(double));
|
||||
memset(a->zp, 0, intp1 * sizeof(double));
|
||||
memset(a->wrk, 0, nsize * sizeof(double));
|
||||
memset(a->A, 0, intp1 * intp1 * sizeof(float));
|
||||
memset(a->B, 0, intp1 * intp1 * sizeof(float));
|
||||
memset(a->C, 0, intm1 * intp1 * sizeof(float));
|
||||
memset(a->D, 0, intp1 * sizeof(float));
|
||||
memset(a->E, 0, intp1 * intp1 * sizeof(float));
|
||||
memset(a->F, 0, intm1 * intp1 * sizeof(float));
|
||||
memset(a->G, 0, intp1 * sizeof(float));
|
||||
memset(a->MAT, 0, nsize * nsize * sizeof(float));
|
||||
memset(a->RHS, 0, nsize * sizeof(float));
|
||||
memset(a->SLN, 0, nsize * sizeof(float));
|
||||
memset(a->z, 0, intp1 * sizeof(float));
|
||||
memset(a->zp, 0, intp1 * sizeof(float));
|
||||
memset(a->wrk, 0, nsize * sizeof(float));
|
||||
memset(a->ipiv, 0, nsize * sizeof(int));
|
||||
}
|
||||
|
||||
int BLDR::fcompare(const void* a, const void* b)
|
||||
{
|
||||
if (*(double*)a < *(double*)b)
|
||||
if (*(float*)a < *(float*)b)
|
||||
return -1;
|
||||
else if (*(double*)a == *(double*)b)
|
||||
else if (*(float*)a == *(float*)b)
|
||||
return 0;
|
||||
else
|
||||
return 1;
|
||||
}
|
||||
|
||||
void BLDR::decomp(int n, double* a, int* piv, int* info, double* wrk)
|
||||
void BLDR::decomp(int n, float* a, int* piv, int* info, float* wrk)
|
||||
{
|
||||
int i, j, k;
|
||||
int t_piv;
|
||||
double m_row, mt_row, m_col, mt_col;
|
||||
float m_row, mt_row, m_col, mt_col;
|
||||
*info = 0;
|
||||
for (i = 0; i < n; i++)
|
||||
{
|
||||
@ -216,10 +216,10 @@ cleanup:
|
||||
return;
|
||||
}
|
||||
|
||||
void BLDR::dsolve(int n, double* a, int* piv, double* b, double* x)
|
||||
void BLDR::dsolve(int n, float* a, int* piv, float* b, float* x)
|
||||
{
|
||||
int j, k;
|
||||
double sum;
|
||||
float sum;
|
||||
|
||||
for (k = 0; k < n; k++)
|
||||
{
|
||||
@ -238,7 +238,7 @@ void BLDR::dsolve(int n, double* a, int* piv, double* b, double* x)
|
||||
}
|
||||
}
|
||||
|
||||
void BLDR::cull(int* n, int ints, double* x, double* t, double ptol)
|
||||
void BLDR::cull(int* n, int ints, float* x, float* t, float ptol)
|
||||
{
|
||||
int k = 0;
|
||||
int i = *n;
|
||||
@ -255,9 +255,9 @@ void BLDR::cull(int* n, int ints, double* x, double* t, double ptol)
|
||||
*n -= k;
|
||||
}
|
||||
|
||||
void BLDR::xbuilder(BLDR *a, int points, double* x, double* y, int ints, double* t, int* info, double* c, double ptol)
|
||||
void BLDR::xbuilder(BLDR *a, int points, float* x, float* y, int ints, float* t, int* info, float* c, float ptol)
|
||||
{
|
||||
double u, v, alpha, beta, gamma, delta;
|
||||
float u, v, alpha, beta, gamma, delta;
|
||||
int nsize = 3 * ints + 1;
|
||||
int intp1 = ints + 1;
|
||||
int intm1 = ints - 1;
|
||||
@ -269,7 +269,7 @@ void BLDR::xbuilder(BLDR *a, int points, double* x, double* y, int ints, double*
|
||||
a->catxy[2 * i + 0] = x[i];
|
||||
a->catxy[2 * i + 1] = y[i];
|
||||
}
|
||||
qsort(a->catxy, points, 2 * sizeof(double), fcompare);
|
||||
qsort(a->catxy, points, 2 * sizeof(float), fcompare);
|
||||
for (i = 0; i < points; i++)
|
||||
{
|
||||
a->sx[i] = a->catxy[2 * i + 0];
|
||||
|
@ -35,47 +35,47 @@ namespace WDSP {
|
||||
class WDSP_API BLDR
|
||||
{
|
||||
public:
|
||||
double* catxy;
|
||||
double* sx;
|
||||
double* sy;
|
||||
double* h;
|
||||
float* catxy;
|
||||
float* sx;
|
||||
float* sy;
|
||||
float* h;
|
||||
int* p;
|
||||
int* np;
|
||||
double* taa;
|
||||
double* tab;
|
||||
double* tag;
|
||||
double* tad;
|
||||
double* tbb;
|
||||
double* tbg;
|
||||
double* tbd;
|
||||
double* tgg;
|
||||
double* tgd;
|
||||
double* tdd;
|
||||
double* A;
|
||||
double* B;
|
||||
double* C;
|
||||
double* D;
|
||||
double* E;
|
||||
double* F;
|
||||
double* G;
|
||||
double* MAT;
|
||||
double* RHS;
|
||||
double* SLN;
|
||||
double* z;
|
||||
double* zp;
|
||||
double* wrk;
|
||||
float* taa;
|
||||
float* tab;
|
||||
float* tag;
|
||||
float* tad;
|
||||
float* tbb;
|
||||
float* tbg;
|
||||
float* tbd;
|
||||
float* tgg;
|
||||
float* tgd;
|
||||
float* tdd;
|
||||
float* A;
|
||||
float* B;
|
||||
float* C;
|
||||
float* D;
|
||||
float* E;
|
||||
float* F;
|
||||
float* G;
|
||||
float* MAT;
|
||||
float* RHS;
|
||||
float* SLN;
|
||||
float* z;
|
||||
float* zp;
|
||||
float* wrk;
|
||||
int* ipiv;
|
||||
|
||||
static BLDR* create_builder(int points, int ints);
|
||||
static void destroy_builder(BLDR *a);
|
||||
static void flush_builder(BLDR *a, int points, int ints);
|
||||
static void xbuilder(BLDR *a, int points, double* x, double* y, int ints, double* t, int* info, double* c, double ptol);
|
||||
static void xbuilder(BLDR *a, int points, float* x, float* y, int ints, float* t, int* info, float* c, float ptol);
|
||||
|
||||
private:
|
||||
static int fcompare(const void* a, const void* b);
|
||||
static void decomp(int n, double* a, int* piv, int* info, double* wrk);
|
||||
static void dsolve(int n, double* a, int* piv, double* b, double* x);
|
||||
static void cull(int* n, int ints, double* x, double* t, double ptol);
|
||||
static void decomp(int n, float* a, int* piv, int* info, float* wrk);
|
||||
static void dsolve(int n, float* a, int* piv, float* b, float* x);
|
||||
static void cull(int* n, int ints, float* x, float* t, float ptol);
|
||||
};
|
||||
|
||||
} // namespace WDSP
|
||||
|
60
wdsp/bps.cpp
60
wdsp/bps.cpp
@ -44,33 +44,33 @@ namespace WDSP {
|
||||
|
||||
void BPS::calc_bps (BPS *a)
|
||||
{
|
||||
double* impulse;
|
||||
a->infilt = new double[2 * a->size * 2]; // (double *)malloc0(2 * a->size * sizeof(wcomplex));
|
||||
a->product = new double[2 * a->size * 2]; // (double *)malloc0(2 * a->size * sizeof(wcomplex));
|
||||
impulse = FIR::fir_bandpass(a->size + 1, a->f_low, a->f_high, a->samplerate, a->wintype, 1, 1.0 / (double)(2 * a->size));
|
||||
float* impulse;
|
||||
a->infilt = new float[2 * a->size * 2]; // (float *)malloc0(2 * a->size * sizeof(wcomplex));
|
||||
a->product = new float[2 * a->size * 2]; // (float *)malloc0(2 * a->size * sizeof(wcomplex));
|
||||
impulse = FIR::fir_bandpass(a->size + 1, a->f_low, a->f_high, a->samplerate, a->wintype, 1, 1.0 / (float)(2 * a->size));
|
||||
a->mults = FIR::fftcv_mults(2 * a->size, impulse);
|
||||
a->CFor = fftw_plan_dft_1d(2 * a->size, (fftw_complex *)a->infilt, (fftw_complex *)a->product, FFTW_FORWARD, FFTW_PATIENT);
|
||||
a->CRev = fftw_plan_dft_1d(2 * a->size, (fftw_complex *)a->product, (fftw_complex *)a->out, FFTW_BACKWARD, FFTW_PATIENT);
|
||||
a->CFor = fftwf_plan_dft_1d(2 * a->size, (fftwf_complex *)a->infilt, (fftwf_complex *)a->product, FFTW_FORWARD, FFTW_PATIENT);
|
||||
a->CRev = fftwf_plan_dft_1d(2 * a->size, (fftwf_complex *)a->product, (fftwf_complex *)a->out, FFTW_BACKWARD, FFTW_PATIENT);
|
||||
delete[](impulse);
|
||||
}
|
||||
|
||||
void BPS::decalc_bps (BPS *a)
|
||||
{
|
||||
fftw_destroy_plan(a->CRev);
|
||||
fftw_destroy_plan(a->CFor);
|
||||
fftwf_destroy_plan(a->CRev);
|
||||
fftwf_destroy_plan(a->CFor);
|
||||
delete[] (a->mults);
|
||||
delete[] (a->product);
|
||||
delete[] (a->infilt);
|
||||
}
|
||||
|
||||
BPS* BPS::create_bps (int run, int position, int size, double* in, double* out,
|
||||
double f_low, double f_high, int samplerate, int wintype, double gain)
|
||||
BPS* BPS::create_bps (int run, int position, int size, float* in, float* out,
|
||||
float f_low, float f_high, int samplerate, int wintype, float gain)
|
||||
{
|
||||
BPS *a = new BPS;
|
||||
a->run = run;
|
||||
a->position = position;
|
||||
a->size = size;
|
||||
a->samplerate = (double)samplerate;
|
||||
a->samplerate = (float)samplerate;
|
||||
a->wintype = wintype;
|
||||
a->gain = gain;
|
||||
a->in = in;
|
||||
@ -95,11 +95,11 @@ void BPS::flush_bps (BPS *a)
|
||||
void BPS::xbps (BPS *a, int pos)
|
||||
{
|
||||
int i;
|
||||
double I, Q;
|
||||
float I, Q;
|
||||
if (a->run && pos == a->position)
|
||||
{
|
||||
memcpy (&(a->infilt[2 * a->size]), a->in, a->size * sizeof (wcomplex));
|
||||
fftw_execute (a->CFor);
|
||||
fftwf_execute (a->CFor);
|
||||
for (i = 0; i < 2 * a->size; i++)
|
||||
{
|
||||
I = a->gain * a->product[2 * i + 0];
|
||||
@ -107,14 +107,14 @@ void BPS::xbps (BPS *a, int pos)
|
||||
a->product[2 * i + 0] = I * a->mults[2 * i + 0] - Q * a->mults[2 * i + 1];
|
||||
a->product[2 * i + 1] = I * a->mults[2 * i + 1] + Q * a->mults[2 * i + 0];
|
||||
}
|
||||
fftw_execute (a->CRev);
|
||||
fftwf_execute (a->CRev);
|
||||
memcpy (a->infilt, &(a->infilt[2 * a->size]), a->size * sizeof(wcomplex));
|
||||
}
|
||||
else if (a->in != a->out)
|
||||
memcpy (a->out, a->in, a->size * sizeof (wcomplex));
|
||||
}
|
||||
|
||||
void BPS::setBuffers_bps (BPS *a, double* in, double* out)
|
||||
void BPS::setBuffers_bps (BPS *a, float* in, float* out)
|
||||
{
|
||||
decalc_bps (a);
|
||||
a->in = in;
|
||||
@ -136,7 +136,7 @@ void BPS::setSize_bps (BPS *a, int size)
|
||||
calc_bps (a);
|
||||
}
|
||||
|
||||
void BPS::setFreqs_bps (BPS *a, double f_low, double f_high)
|
||||
void BPS::setFreqs_bps (BPS *a, float f_low, float f_high)
|
||||
{
|
||||
decalc_bps (a);
|
||||
a->f_low = f_low;
|
||||
@ -157,9 +157,9 @@ void BPS::SetBPSRun (RXA& rxa, int run)
|
||||
rxa.csDSP.unlock();
|
||||
}
|
||||
|
||||
void BPS::SetBPSFreqs (RXA& rxa, double f_low, double f_high)
|
||||
void BPS::SetBPSFreqs (RXA& rxa, float f_low, float f_high)
|
||||
{
|
||||
double* impulse;
|
||||
float* impulse;
|
||||
BPS *a1;
|
||||
rxa.csDSP.lock();
|
||||
a1 = rxa.bps1.p;
|
||||
@ -168,7 +168,7 @@ void BPS::SetBPSFreqs (RXA& rxa, double f_low, double f_high)
|
||||
a1->f_low = f_low;
|
||||
a1->f_high = f_high;
|
||||
delete[] (a1->mults);
|
||||
impulse = FIR::fir_bandpass(a1->size + 1, f_low, f_high, a1->samplerate, a1->wintype, 1, 1.0 / (double)(2 * a1->size));
|
||||
impulse = FIR::fir_bandpass(a1->size + 1, f_low, f_high, a1->samplerate, a1->wintype, 1, 1.0 / (float)(2 * a1->size));
|
||||
a1->mults = FIR::fftcv_mults (2 * a1->size, impulse);
|
||||
delete[] (impulse);
|
||||
}
|
||||
@ -177,7 +177,7 @@ void BPS::SetBPSFreqs (RXA& rxa, double f_low, double f_high)
|
||||
|
||||
void BPS::SetBPSWindow (RXA& rxa, int wintype)
|
||||
{
|
||||
double* impulse;
|
||||
float* impulse;
|
||||
BPS *a1;
|
||||
rxa.csDSP.lock();
|
||||
a1 = rxa.bps1.p;
|
||||
@ -185,7 +185,7 @@ void BPS::SetBPSWindow (RXA& rxa, int wintype)
|
||||
{
|
||||
a1->wintype = wintype;
|
||||
delete[] (a1->mults);
|
||||
impulse = FIR::fir_bandpass(a1->size + 1, a1->f_low, a1->f_high, a1->samplerate, a1->wintype, 1, 1.0 / (double)(2 * a1->size));
|
||||
impulse = FIR::fir_bandpass(a1->size + 1, a1->f_low, a1->f_high, a1->samplerate, a1->wintype, 1, 1.0 / (float)(2 * a1->size));
|
||||
a1->mults = FIR::fftcv_mults (2 * a1->size, impulse);
|
||||
delete[] (impulse);
|
||||
}
|
||||
@ -205,9 +205,9 @@ void BPS::SetBPSRun (TXA& txa, int run)
|
||||
txa.csDSP.unlock();
|
||||
}
|
||||
|
||||
void BPS::SetBPSFreqs (TXA& txa, double f_low, double f_high)
|
||||
void BPS::SetBPSFreqs (TXA& txa, float f_low, float f_high)
|
||||
{
|
||||
double* impulse;
|
||||
float* impulse;
|
||||
BPS *a;
|
||||
txa.csDSP.lock();
|
||||
a = txa.bps0.p;
|
||||
@ -216,7 +216,7 @@ void BPS::SetBPSFreqs (TXA& txa, double f_low, double f_high)
|
||||
a->f_low = f_low;
|
||||
a->f_high = f_high;
|
||||
delete[] (a->mults);
|
||||
impulse = FIR::fir_bandpass(a->size + 1, f_low, f_high, a->samplerate, a->wintype, 1, 1.0 / (double)(2 * a->size));
|
||||
impulse = FIR::fir_bandpass(a->size + 1, f_low, f_high, a->samplerate, a->wintype, 1, 1.0 / (float)(2 * a->size));
|
||||
a->mults = FIR::fftcv_mults (2 * a->size, impulse);
|
||||
delete[] (impulse);
|
||||
}
|
||||
@ -226,7 +226,7 @@ void BPS::SetBPSFreqs (TXA& txa, double f_low, double f_high)
|
||||
a->f_low = f_low;
|
||||
a->f_high = f_high;
|
||||
delete[] (a->mults);
|
||||
impulse = FIR::fir_bandpass(a->size + 1, f_low, f_high, a->samplerate, a->wintype, 1, 1.0 / (double)(2 * a->size));
|
||||
impulse = FIR::fir_bandpass(a->size + 1, f_low, f_high, a->samplerate, a->wintype, 1, 1.0 / (float)(2 * a->size));
|
||||
a->mults = FIR::fftcv_mults (2 * a->size, impulse);
|
||||
delete[] (impulse);
|
||||
}
|
||||
@ -236,7 +236,7 @@ void BPS::SetBPSFreqs (TXA& txa, double f_low, double f_high)
|
||||
a->f_low = f_low;
|
||||
a->f_high = f_high;
|
||||
delete[] (a->mults);
|
||||
impulse = FIR::fir_bandpass(a->size + 1, f_low, f_high, a->samplerate, a->wintype, 1, 1.0 / (double)(2 * a->size));
|
||||
impulse = FIR::fir_bandpass(a->size + 1, f_low, f_high, a->samplerate, a->wintype, 1, 1.0 / (float)(2 * a->size));
|
||||
a->mults = FIR::fftcv_mults (2 * a->size, impulse);
|
||||
delete[] (impulse);
|
||||
}
|
||||
@ -245,7 +245,7 @@ void BPS::SetBPSFreqs (TXA& txa, double f_low, double f_high)
|
||||
|
||||
void BPS::SetBPSWindow (TXA& txa, int wintype)
|
||||
{
|
||||
double* impulse;
|
||||
float* impulse;
|
||||
BPS *a;
|
||||
txa.csDSP.lock();
|
||||
a = txa.bps0.p;
|
||||
@ -253,7 +253,7 @@ void BPS::SetBPSWindow (TXA& txa, int wintype)
|
||||
{
|
||||
a->wintype = wintype;
|
||||
delete[] (a->mults);
|
||||
impulse = FIR::fir_bandpass(a->size + 1, a->f_low, a->f_high, a->samplerate, a->wintype, 1, 1.0 / (double)(2 * a->size));
|
||||
impulse = FIR::fir_bandpass(a->size + 1, a->f_low, a->f_high, a->samplerate, a->wintype, 1, 1.0 / (float)(2 * a->size));
|
||||
a->mults = FIR::fftcv_mults (2 * a->size, impulse);
|
||||
delete[] (impulse);
|
||||
}
|
||||
@ -262,7 +262,7 @@ void BPS::SetBPSWindow (TXA& txa, int wintype)
|
||||
{
|
||||
a->wintype = wintype;
|
||||
delete[] (a->mults);
|
||||
impulse = FIR::fir_bandpass(a->size + 1, a->f_low, a->f_high, a->samplerate, a->wintype, 1, 1.0 / (double)(2 * a->size));
|
||||
impulse = FIR::fir_bandpass(a->size + 1, a->f_low, a->f_high, a->samplerate, a->wintype, 1, 1.0 / (float)(2 * a->size));
|
||||
a->mults = FIR::fftcv_mults (2 * a->size, impulse);
|
||||
delete[] (impulse);
|
||||
}
|
||||
@ -271,7 +271,7 @@ void BPS::SetBPSWindow (TXA& txa, int wintype)
|
||||
{
|
||||
a->wintype = wintype;
|
||||
delete[] (a->mults);
|
||||
impulse = FIR::fir_bandpass (a->size + 1, a->f_low, a->f_high, a->samplerate, a->wintype, 1, 1.0 / (double)(2 * a->size));
|
||||
impulse = FIR::fir_bandpass (a->size + 1, a->f_low, a->f_high, a->samplerate, a->wintype, 1, 1.0 / (float)(2 * a->size));
|
||||
a->mults = FIR::fftcv_mults (2 * a->size, impulse);
|
||||
delete[] (impulse);
|
||||
}
|
||||
|
34
wdsp/bps.hpp
34
wdsp/bps.hpp
@ -48,35 +48,35 @@ public:
|
||||
int run;
|
||||
int position;
|
||||
int size;
|
||||
double* in;
|
||||
double* out;
|
||||
double f_low;
|
||||
double f_high;
|
||||
double* infilt;
|
||||
double* product;
|
||||
double* mults;
|
||||
double samplerate;
|
||||
float* in;
|
||||
float* out;
|
||||
float f_low;
|
||||
float f_high;
|
||||
float* infilt;
|
||||
float* product;
|
||||
float* mults;
|
||||
float samplerate;
|
||||
int wintype;
|
||||
double gain;
|
||||
fftw_plan CFor;
|
||||
fftw_plan CRev;
|
||||
float gain;
|
||||
fftwf_plan CFor;
|
||||
fftwf_plan CRev;
|
||||
|
||||
static BPS* create_bps (int run, int position, int size, double* in, double* out,
|
||||
double f_low, double f_high, int samplerate, int wintype, double gain);
|
||||
static BPS* create_bps (int run, int position, int size, float* in, float* out,
|
||||
float f_low, float f_high, int samplerate, int wintype, float gain);
|
||||
static void destroy_bps (BPS *a);
|
||||
static void flush_bps (BPS *a);
|
||||
static void xbps (BPS *a, int pos);
|
||||
static void setBuffers_bps (BPS *a, double* in, double* out);
|
||||
static void setBuffers_bps (BPS *a, float* in, float* out);
|
||||
static void setSamplerate_bps (BPS *a, int rate);
|
||||
static void setSize_bps (BPS *a, int size);
|
||||
static void setFreqs_bps (BPS *a, double f_low, double f_high);
|
||||
static void setFreqs_bps (BPS *a, float f_low, float f_high);
|
||||
// RXA Prototypes
|
||||
static void SetBPSRun (RXA& rxa, int run);
|
||||
static void SetBPSFreqs (RXA& rxa, double low, double high);
|
||||
static void SetBPSFreqs (RXA& rxa, float low, float high);
|
||||
static void SetBPSWindow (RXA& rxa, int wintype);
|
||||
// TXA Prototypes
|
||||
static void SetBPSRun (TXA& txa, int run);
|
||||
static void SetBPSFreqs (TXA& txa, double low, double high);
|
||||
static void SetBPSFreqs (TXA& txa, float low, float high);
|
||||
static void SetBPSWindow (TXA& txa, int wintype);
|
||||
|
||||
private:
|
||||
|
@ -33,7 +33,7 @@ namespace WDSP {
|
||||
class BufferProbe
|
||||
{
|
||||
public:
|
||||
virtual void proceed(const double *buffer, int nb_samples) = 0;
|
||||
virtual void proceed(const float *buffer, int nb_samples) = 0;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
@ -29,7 +29,7 @@ warren@wpratt.com
|
||||
|
||||
namespace WDSP {
|
||||
|
||||
const double Calculus::GG[241 * 241] = {
|
||||
const float Calculus::GG[241 * 241] = {
|
||||
7.25654181154076983e-01, 7.05038822098223439e-01, 6.85008217584843870e-01, 6.65545775927326222e-01,
|
||||
6.46635376294157682e-01, 6.28261355371665386e-01, 6.10408494407843394e-01, 5.93062006626410732e-01,
|
||||
5.76207525000389742e-01, 5.59831090374464435e-01, 5.43919139925240769e-01, 5.28458495948192608e-01,
|
||||
@ -14552,7 +14552,7 @@ const double Calculus::GG[241 * 241] = {
|
||||
1.00000000000000000e+00, 1.00000000000000000e+00, 1.00000000000000000e+00, 1.00000000000000000e+00,
|
||||
1.00000000000000000e+00 };
|
||||
|
||||
const double Calculus::GGS[241 * 241] = {
|
||||
const float Calculus::GGS[241 * 241] = {
|
||||
8.00014908335353492e-01, 8.00020707540703313e-01, 8.00026700706648830e-01, 8.00032894400760863e-01,
|
||||
8.00039295417528384e-01, 8.00045910786425396e-01, 8.00052747780268358e-01, 8.00059813923879481e-01,
|
||||
8.00067117003061101e-01, 8.00074665073896907e-01, 8.00082466472385456e-01, 8.00090529824419749e-01,
|
||||
|
@ -36,8 +36,8 @@ namespace WDSP {
|
||||
class WDSP_API Calculus
|
||||
{
|
||||
public:
|
||||
static const double GG[];
|
||||
static const double GGS[];
|
||||
static const float GG[];
|
||||
static const float GGS[];
|
||||
};
|
||||
|
||||
} // namespace WDSP
|
||||
|
@ -44,11 +44,11 @@ CBL* CBL::create_cbl
|
||||
(
|
||||
int run,
|
||||
int buff_size,
|
||||
double *in_buff,
|
||||
double *out_buff,
|
||||
float *in_buff,
|
||||
float *out_buff,
|
||||
int mode,
|
||||
int sample_rate,
|
||||
double tau
|
||||
float tau
|
||||
)
|
||||
{
|
||||
CBL *a = new CBL;
|
||||
@ -57,7 +57,7 @@ CBL* CBL::create_cbl
|
||||
a->in_buff = in_buff;
|
||||
a->out_buff = out_buff;
|
||||
a->mode = mode;
|
||||
a->sample_rate = (double)sample_rate;
|
||||
a->sample_rate = (float)sample_rate;
|
||||
a->tau = tau;
|
||||
calc_cbl (a);
|
||||
return a;
|
||||
@ -81,7 +81,7 @@ void CBL::xcbl (CBL *a)
|
||||
if (a->run)
|
||||
{
|
||||
int i;
|
||||
double tempI, tempQ;
|
||||
float tempI, tempQ;
|
||||
for (i = 0; i < a->buff_size; i++)
|
||||
{
|
||||
tempI = a->in_buff[2 * i + 0];
|
||||
@ -98,7 +98,7 @@ void CBL::xcbl (CBL *a)
|
||||
memcpy (a->out_buff, a->in_buff, a->buff_size * sizeof (wcomplex));
|
||||
}
|
||||
|
||||
void CBL::setBuffers_cbl (CBL *a, double* in, double* out)
|
||||
void CBL::setBuffers_cbl (CBL *a, float* in, float* out)
|
||||
{
|
||||
a->in_buff = in;
|
||||
a->out_buff = out;
|
||||
|
@ -39,31 +39,31 @@ class WDSP_API CBL
|
||||
public:
|
||||
int run; //run
|
||||
int buff_size; //buffer size
|
||||
double *in_buff; //pointer to input buffer
|
||||
double *out_buff; //pointer to output buffer
|
||||
float *in_buff; //pointer to input buffer
|
||||
float *out_buff; //pointer to output buffer
|
||||
int mode;
|
||||
double sample_rate; //sample rate
|
||||
double prevIin;
|
||||
double prevQin;
|
||||
double prevIout;
|
||||
double prevQout;
|
||||
double tau; //carrier removal time constant
|
||||
double mtau; //carrier removal multiplier
|
||||
float sample_rate; //sample rate
|
||||
float prevIin;
|
||||
float prevQin;
|
||||
float prevIout;
|
||||
float prevQout;
|
||||
float tau; //carrier removal time constant
|
||||
float mtau; //carrier removal multiplier
|
||||
|
||||
static CBL* create_cbl
|
||||
(
|
||||
int run,
|
||||
int buff_size,
|
||||
double *in_buff,
|
||||
double *out_buff,
|
||||
float *in_buff,
|
||||
float *out_buff,
|
||||
int mode,
|
||||
int sample_rate,
|
||||
double tau
|
||||
float tau
|
||||
);
|
||||
static void destroy_cbl (CBL *a);
|
||||
static void flush_cbl (CBL *a);
|
||||
static void xcbl (CBL *a);
|
||||
static void setBuffers_cbl (CBL *a, double* in, double* out);
|
||||
static void setBuffers_cbl (CBL *a, float* in, float* out);
|
||||
static void setSamplerate_cbl (CBL *a, int rate);
|
||||
static void setSize_cbl (CBL *a, int size);
|
||||
// RXA Properties
|
||||
|
158
wdsp/cfcomp.cpp
158
wdsp/cfcomp.cpp
@ -35,33 +35,33 @@ namespace WDSP {
|
||||
void CFCOMP::calc_cfcwindow (CFCOMP *a)
|
||||
{
|
||||
int i;
|
||||
double arg0, arg1, cgsum, igsum, coherent_gain, inherent_power_gain, wmult;
|
||||
float arg0, arg1, cgsum, igsum, coherent_gain, inherent_power_gain, wmult;
|
||||
switch (a->wintype)
|
||||
{
|
||||
case 0:
|
||||
arg0 = 2.0 * PI / (double)a->fsize;
|
||||
arg0 = 2.0 * PI / (float)a->fsize;
|
||||
cgsum = 0.0;
|
||||
igsum = 0.0;
|
||||
for (i = 0; i < a->fsize; i++)
|
||||
{
|
||||
a->window[i] = sqrt (0.54 - 0.46 * cos((double)i * arg0));
|
||||
a->window[i] = sqrt (0.54 - 0.46 * cos((float)i * arg0));
|
||||
cgsum += a->window[i];
|
||||
igsum += a->window[i] * a->window[i];
|
||||
}
|
||||
coherent_gain = cgsum / (double)a->fsize;
|
||||
inherent_power_gain = igsum / (double)a->fsize;
|
||||
coherent_gain = cgsum / (float)a->fsize;
|
||||
inherent_power_gain = igsum / (float)a->fsize;
|
||||
wmult = 1.0 / sqrt (inherent_power_gain);
|
||||
for (i = 0; i < a->fsize; i++)
|
||||
a->window[i] *= wmult;
|
||||
a->winfudge = sqrt (1.0 / coherent_gain);
|
||||
break;
|
||||
case 1:
|
||||
arg0 = 2.0 * PI / (double)a->fsize;
|
||||
arg0 = 2.0 * PI / (float)a->fsize;
|
||||
cgsum = 0.0;
|
||||
igsum = 0.0;
|
||||
for (i = 0; i < a->fsize; i++)
|
||||
{
|
||||
arg1 = cos(arg0 * (double)i);
|
||||
arg1 = cos(arg0 * (float)i);
|
||||
a->window[i] = sqrt (+0.21747
|
||||
+ arg1 * (-0.45325
|
||||
+ arg1 * (+0.28256
|
||||
@ -69,8 +69,8 @@ void CFCOMP::calc_cfcwindow (CFCOMP *a)
|
||||
cgsum += a->window[i];
|
||||
igsum += a->window[i] * a->window[i];
|
||||
}
|
||||
coherent_gain = cgsum / (double)a->fsize;
|
||||
inherent_power_gain = igsum / (double)a->fsize;
|
||||
coherent_gain = cgsum / (float)a->fsize;
|
||||
inherent_power_gain = igsum / (float)a->fsize;
|
||||
wmult = 1.0 / sqrt (inherent_power_gain);
|
||||
for (i = 0; i < a->fsize; i++)
|
||||
a->window[i] *= wmult;
|
||||
@ -81,9 +81,9 @@ void CFCOMP::calc_cfcwindow (CFCOMP *a)
|
||||
|
||||
int CFCOMP::fCOMPcompare (const void *a, const void *b)
|
||||
{
|
||||
if (*(double*)a < *(double*)b)
|
||||
if (*(float*)a < *(float*)b)
|
||||
return -1;
|
||||
else if (*(double*)a == *(double*)b)
|
||||
else if (*(float*)a == *(float*)b)
|
||||
return 0;
|
||||
else
|
||||
return 1;
|
||||
@ -92,25 +92,25 @@ int CFCOMP::fCOMPcompare (const void *a, const void *b)
|
||||
void CFCOMP::calc_comp (CFCOMP *a)
|
||||
{
|
||||
int i, j;
|
||||
double f, frac, fincr, fmax;
|
||||
double* sary;
|
||||
float f, frac, fincr, fmax;
|
||||
float* sary;
|
||||
a->precomplin = pow (10.0, 0.05 * a->precomp);
|
||||
a->prepeqlin = pow (10.0, 0.05 * a->prepeq);
|
||||
fmax = 0.5 * a->rate;
|
||||
for (i = 0; i < a->nfreqs; i++)
|
||||
{
|
||||
a->F[i] = std::max (a->F[i], 0.0);
|
||||
a->F[i] = std::max (a->F[i], 0.0f);
|
||||
a->F[i] = std::min (a->F[i], fmax);
|
||||
a->G[i] = std::max (a->G[i], 0.0);
|
||||
a->G[i] = std::max (a->G[i], 0.0f);
|
||||
}
|
||||
sary = new double[3 * a->nfreqs]; // (double *)malloc0 (3 * a->nfreqs * sizeof (double));
|
||||
sary = new float[3 * a->nfreqs]; // (float *)malloc0 (3 * a->nfreqs * sizeof (float));
|
||||
for (i = 0; i < a->nfreqs; i++)
|
||||
{
|
||||
sary[3 * i + 0] = a->F[i];
|
||||
sary[3 * i + 1] = a->G[i];
|
||||
sary[3 * i + 2] = a->E[i];
|
||||
}
|
||||
qsort (sary, a->nfreqs, 3 * sizeof (double), fCOMPcompare);
|
||||
qsort (sary, a->nfreqs, 3 * sizeof (float), fCOMPcompare);
|
||||
for (i = 0; i < a->nfreqs; i++)
|
||||
{
|
||||
a->F[i] = sary[3 * i + 0];
|
||||
@ -130,12 +130,12 @@ void CFCOMP::calc_comp (CFCOMP *a)
|
||||
a->gp[j] = a->G[i];
|
||||
a->ep[j] = a->E[i];
|
||||
}
|
||||
fincr = a->rate / (double)a->fsize;
|
||||
fincr = a->rate / (float)a->fsize;
|
||||
j = 0;
|
||||
// print_impulse ("gp.txt", a->nfreqs+2, a->gp, 0, 0);
|
||||
for (i = 0; i < a->msize; i++)
|
||||
{
|
||||
f = fincr * (double)i;
|
||||
f = fincr * (float)i;
|
||||
while (f >= a->fp[j + 1] && j < a->nfreqs) j++;
|
||||
frac = (f - a->fp[j]) / (a->fp[j + 1] - a->fp[j]);
|
||||
a->comp[i] = pow (10.0, 0.05 * (frac * a->gp[j + 1] + (1.0 - frac) * a->gp[j]));
|
||||
@ -170,42 +170,42 @@ void CFCOMP::calc_cfcomp(CFCOMP *a)
|
||||
a->init_oainidx = a->oainidx;
|
||||
a->oaoutidx = 0;
|
||||
a->msize = a->fsize / 2 + 1;
|
||||
a->window = new double[a->fsize]; // (double *)malloc0 (a->fsize * sizeof(double));
|
||||
a->inaccum = new double[a->iasize]; // (double *)malloc0 (a->iasize * sizeof(double));
|
||||
a->forfftin = new double[a->fsize]; // (double *)malloc0 (a->fsize * sizeof(double));
|
||||
a->forfftout = new double[a->msize * 2]; // (double *)malloc0 (a->msize * sizeof(complex));
|
||||
a->cmask = new double[a->msize]; // (double *)malloc0 (a->msize * sizeof(double));
|
||||
a->mask = new double[a->msize]; // (double *)malloc0 (a->msize * sizeof(double));
|
||||
a->cfc_gain = new double[a->msize]; // (double *)malloc0 (a->msize * sizeof(double));
|
||||
a->revfftin = new double[a->msize * 2]; // (double *)malloc0 (a->msize * sizeof(complex));
|
||||
a->revfftout = new double[a->fsize]; // (double *)malloc0 (a->fsize * sizeof(double));
|
||||
a->save = new double*[a->ovrlp]; // (double **)malloc0(a->ovrlp * sizeof(double *));
|
||||
a->window = new float[a->fsize]; // (float *)malloc0 (a->fsize * sizeof(float));
|
||||
a->inaccum = new float[a->iasize]; // (float *)malloc0 (a->iasize * sizeof(float));
|
||||
a->forfftin = new float[a->fsize]; // (float *)malloc0 (a->fsize * sizeof(float));
|
||||
a->forfftout = new float[a->msize * 2]; // (float *)malloc0 (a->msize * sizeof(complex));
|
||||
a->cmask = new float[a->msize]; // (float *)malloc0 (a->msize * sizeof(float));
|
||||
a->mask = new float[a->msize]; // (float *)malloc0 (a->msize * sizeof(float));
|
||||
a->cfc_gain = new float[a->msize]; // (float *)malloc0 (a->msize * sizeof(float));
|
||||
a->revfftin = new float[a->msize * 2]; // (float *)malloc0 (a->msize * sizeof(complex));
|
||||
a->revfftout = new float[a->fsize]; // (float *)malloc0 (a->fsize * sizeof(float));
|
||||
a->save = new float*[a->ovrlp]; // (float **)malloc0(a->ovrlp * sizeof(float *));
|
||||
for (i = 0; i < a->ovrlp; i++)
|
||||
a->save[i] = new double[a->fsize]; // (double *)malloc0(a->fsize * sizeof(double));
|
||||
a->outaccum = new double[a->oasize]; // (double *)malloc0(a->oasize * sizeof(double));
|
||||
a->save[i] = new float[a->fsize]; // (float *)malloc0(a->fsize * sizeof(float));
|
||||
a->outaccum = new float[a->oasize]; // (float *)malloc0(a->oasize * sizeof(float));
|
||||
a->nsamps = 0;
|
||||
a->saveidx = 0;
|
||||
a->Rfor = fftw_plan_dft_r2c_1d(a->fsize, a->forfftin, (fftw_complex *)a->forfftout, FFTW_ESTIMATE);
|
||||
a->Rrev = fftw_plan_dft_c2r_1d(a->fsize, (fftw_complex *)a->revfftin, a->revfftout, FFTW_ESTIMATE);
|
||||
a->Rfor = fftwf_plan_dft_r2c_1d(a->fsize, a->forfftin, (fftwf_complex *)a->forfftout, FFTW_ESTIMATE);
|
||||
a->Rrev = fftwf_plan_dft_c2r_1d(a->fsize, (fftwf_complex *)a->revfftin, a->revfftout, FFTW_ESTIMATE);
|
||||
calc_cfcwindow(a);
|
||||
|
||||
a->pregain = (2.0 * a->winfudge) / (double)a->fsize;
|
||||
a->postgain = 0.5 / ((double)a->ovrlp * a->winfudge);
|
||||
a->pregain = (2.0 * a->winfudge) / (float)a->fsize;
|
||||
a->postgain = 0.5 / ((float)a->ovrlp * a->winfudge);
|
||||
|
||||
a->fp = new double[a->nfreqs + 2]; // (double *) malloc0 ((a->nfreqs + 2) * sizeof (double));
|
||||
a->gp = new double[a->nfreqs + 2]; // (double *) malloc0 ((a->nfreqs + 2) * sizeof (double));
|
||||
a->ep = new double[a->nfreqs + 2]; // (double *) malloc0 ((a->nfreqs + 2) * sizeof (double));
|
||||
a->comp = new double[a->msize]; // (double *) malloc0 (a->msize * sizeof (double));
|
||||
a->peq = new double[a->msize]; // (double *) malloc0 (a->msize * sizeof (double));
|
||||
a->fp = new float[a->nfreqs + 2]; // (float *) malloc0 ((a->nfreqs + 2) * sizeof (float));
|
||||
a->gp = new float[a->nfreqs + 2]; // (float *) malloc0 ((a->nfreqs + 2) * sizeof (float));
|
||||
a->ep = new float[a->nfreqs + 2]; // (float *) malloc0 ((a->nfreqs + 2) * sizeof (float));
|
||||
a->comp = new float[a->msize]; // (float *) malloc0 (a->msize * sizeof (float));
|
||||
a->peq = new float[a->msize]; // (float *) malloc0 (a->msize * sizeof (float));
|
||||
calc_comp (a);
|
||||
|
||||
a->gain = 0.0;
|
||||
a->mmult = exp (-1.0 / (a->rate * a->ovrlp * a->mtau));
|
||||
a->dmult = exp (-(double)a->fsize / (a->rate * a->ovrlp * a->dtau));
|
||||
a->dmult = exp (-(float)a->fsize / (a->rate * a->ovrlp * a->dtau));
|
||||
|
||||
a->delta = new double[a->msize]; // (double*)malloc0 (a->msize * sizeof(double));
|
||||
a->delta_copy = new double[a->msize]; // (double*)malloc0 (a->msize * sizeof(double));
|
||||
a->cfc_gain_copy = new double[a->msize]; // (double*)malloc0 (a->msize * sizeof(double));
|
||||
a->delta = new float[a->msize]; // (float*)malloc0 (a->msize * sizeof(float));
|
||||
a->delta_copy = new float[a->msize]; // (float*)malloc0 (a->msize * sizeof(float));
|
||||
a->cfc_gain_copy = new float[a->msize]; // (float*)malloc0 (a->msize * sizeof(float));
|
||||
}
|
||||
|
||||
void CFCOMP::decalc_cfcomp(CFCOMP *a)
|
||||
@ -220,8 +220,8 @@ void CFCOMP::decalc_cfcomp(CFCOMP *a)
|
||||
delete[] (a->gp);
|
||||
delete[] (a->fp);
|
||||
|
||||
fftw_destroy_plan(a->Rrev);
|
||||
fftw_destroy_plan(a->Rfor);
|
||||
fftwf_destroy_plan(a->Rrev);
|
||||
fftwf_destroy_plan(a->Rfor);
|
||||
delete[](a->outaccum);
|
||||
for (i = 0; i < a->ovrlp; i++)
|
||||
delete[](a->save[i]);
|
||||
@ -237,8 +237,8 @@ void CFCOMP::decalc_cfcomp(CFCOMP *a)
|
||||
delete[](a->window);
|
||||
}
|
||||
|
||||
CFCOMP* CFCOMP::create_cfcomp (int run, int position, int peq_run, int size, double* in, double* out, int fsize, int ovrlp,
|
||||
int rate, int wintype, int comp_method, int nfreqs, double precomp, double prepeq, double* F, double* G, double* E, double mtau, double dtau)
|
||||
CFCOMP* CFCOMP::create_cfcomp (int run, int position, int peq_run, int size, float* in, float* out, int fsize, int ovrlp,
|
||||
int rate, int wintype, int comp_method, int nfreqs, float precomp, float prepeq, float* F, float* G, float* E, float mtau, float dtau)
|
||||
{
|
||||
CFCOMP *a = new CFCOMP;
|
||||
a->run = run;
|
||||
@ -257,12 +257,12 @@ CFCOMP* CFCOMP::create_cfcomp (int run, int position, int peq_run, int size, dou
|
||||
a->prepeq = prepeq;
|
||||
a->mtau = mtau; // compression metering time constant
|
||||
a->dtau = dtau; // compression display time constant
|
||||
a->F = new double[a->nfreqs]; // (double *)malloc0 (a->nfreqs * sizeof (double));
|
||||
a->G = new double[a->nfreqs]; // (double *)malloc0 (a->nfreqs * sizeof (double));
|
||||
a->E = new double[a->nfreqs]; // (double *)malloc0 (a->nfreqs * sizeof (double));
|
||||
memcpy (a->F, F, a->nfreqs * sizeof (double));
|
||||
memcpy (a->G, G, a->nfreqs * sizeof (double));
|
||||
memcpy (a->E, E, a->nfreqs * sizeof (double));
|
||||
a->F = new float[a->nfreqs]; // (float *)malloc0 (a->nfreqs * sizeof (float));
|
||||
a->G = new float[a->nfreqs]; // (float *)malloc0 (a->nfreqs * sizeof (float));
|
||||
a->E = new float[a->nfreqs]; // (float *)malloc0 (a->nfreqs * sizeof (float));
|
||||
memcpy (a->F, F, a->nfreqs * sizeof (float));
|
||||
memcpy (a->G, G, a->nfreqs * sizeof (float));
|
||||
memcpy (a->E, E, a->nfreqs * sizeof (float));
|
||||
calc_cfcomp (a);
|
||||
return a;
|
||||
}
|
||||
@ -270,10 +270,10 @@ CFCOMP* CFCOMP::create_cfcomp (int run, int position, int peq_run, int size, dou
|
||||
void CFCOMP::flush_cfcomp (CFCOMP *a)
|
||||
{
|
||||
int i;
|
||||
memset (a->inaccum, 0, a->iasize * sizeof (double));
|
||||
memset (a->inaccum, 0, a->iasize * sizeof (float));
|
||||
for (i = 0; i < a->ovrlp; i++)
|
||||
memset (a->save[i], 0, a->fsize * sizeof (double));
|
||||
memset (a->outaccum, 0, a->oasize * sizeof (double));
|
||||
memset (a->save[i], 0, a->fsize * sizeof (float));
|
||||
memset (a->outaccum, 0, a->oasize * sizeof (float));
|
||||
a->nsamps = 0;
|
||||
a->iainidx = 0;
|
||||
a->iaoutidx = 0;
|
||||
@ -281,7 +281,7 @@ void CFCOMP::flush_cfcomp (CFCOMP *a)
|
||||
a->oaoutidx = 0;
|
||||
a->saveidx = 0;
|
||||
a->gain = 0.0;
|
||||
memset(a->delta, 0, a->msize * sizeof(double));
|
||||
memset(a->delta, 0, a->msize * sizeof(float));
|
||||
}
|
||||
|
||||
void CFCOMP::destroy_cfcomp (CFCOMP *a)
|
||||
@ -297,12 +297,12 @@ void CFCOMP::destroy_cfcomp (CFCOMP *a)
|
||||
void CFCOMP::calc_mask (CFCOMP *a)
|
||||
{
|
||||
int i;
|
||||
double comp, mask, delta;
|
||||
float comp, mask, delta;
|
||||
switch (a->comp_method)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
double mag, test;
|
||||
float mag, test;
|
||||
for (i = 0; i < a->msize; i++)
|
||||
{
|
||||
mag = sqrt (a->forfftout[2 * i + 0] * a->forfftout[2 * i + 0]
|
||||
@ -332,7 +332,7 @@ void CFCOMP::calc_mask (CFCOMP *a)
|
||||
}
|
||||
}
|
||||
else
|
||||
memcpy (a->mask, a->cmask, a->msize * sizeof (double));
|
||||
memcpy (a->mask, a->cmask, a->msize * sizeof (float));
|
||||
// print_impulse ("mask.txt", a->msize, a->mask, 0, 0);
|
||||
a->mask_ready = 1;
|
||||
}
|
||||
@ -354,14 +354,14 @@ void CFCOMP::xcfcomp (CFCOMP *a, int pos)
|
||||
a->forfftin[i] = a->pregain * a->window[i] * a->inaccum[j];
|
||||
a->iaoutidx = (a->iaoutidx + a->incr) % a->iasize;
|
||||
a->nsamps -= a->incr;
|
||||
fftw_execute (a->Rfor);
|
||||
fftwf_execute (a->Rfor);
|
||||
calc_mask(a);
|
||||
for (i = 0; i < a->msize; i++)
|
||||
{
|
||||
a->revfftin[2 * i + 0] = a->mask[i] * a->forfftout[2 * i + 0];
|
||||
a->revfftin[2 * i + 1] = a->mask[i] * a->forfftout[2 * i + 1];
|
||||
}
|
||||
fftw_execute (a->Rrev);
|
||||
fftwf_execute (a->Rrev);
|
||||
for (i = 0; i < a->fsize; i++)
|
||||
a->save[a->saveidx][i] = a->postgain * a->window[i] * a->revfftout[i];
|
||||
for (i = a->ovrlp; i > 0; i--)
|
||||
@ -390,7 +390,7 @@ void CFCOMP::xcfcomp (CFCOMP *a, int pos)
|
||||
memcpy (a->out, a->in, a->bsize * sizeof (wcomplex));
|
||||
}
|
||||
|
||||
void CFCOMP::setBuffers_cfcomp (CFCOMP *a, double* in, double* out)
|
||||
void CFCOMP::setBuffers_cfcomp (CFCOMP *a, float* in, float* out)
|
||||
{
|
||||
a->in = in;
|
||||
a->out = out;
|
||||
@ -438,7 +438,7 @@ void CFCOMP::SetCFCOMPPosition (TXA& txa, int pos)
|
||||
}
|
||||
}
|
||||
|
||||
void CFCOMP::SetCFCOMPprofile (TXA& txa, int nfreqs, double* F, double* G, double *E)
|
||||
void CFCOMP::SetCFCOMPprofile (TXA& txa, int nfreqs, float* F, float* G, float *E)
|
||||
{
|
||||
CFCOMP *a = txa.cfcomp.p;
|
||||
txa.csDSP.lock();
|
||||
@ -446,23 +446,23 @@ void CFCOMP::SetCFCOMPprofile (TXA& txa, int nfreqs, double* F, double* G, doubl
|
||||
delete[] (a->E);
|
||||
delete[] (a->F);
|
||||
delete[] (a->G);
|
||||
a->F = new double[a->nfreqs]; // (double *)malloc0 (a->nfreqs * sizeof (double));
|
||||
a->G = new double[a->nfreqs]; // (double *)malloc0 (a->nfreqs * sizeof (double));
|
||||
a->E = new double[a->nfreqs]; // (double *)malloc0 (a->nfreqs * sizeof (double));
|
||||
memcpy (a->F, F, a->nfreqs * sizeof (double));
|
||||
memcpy (a->G, G, a->nfreqs * sizeof (double));
|
||||
memcpy (a->E, E, a->nfreqs * sizeof (double));
|
||||
a->F = new float[a->nfreqs]; // (float *)malloc0 (a->nfreqs * sizeof (float));
|
||||
a->G = new float[a->nfreqs]; // (float *)malloc0 (a->nfreqs * sizeof (float));
|
||||
a->E = new float[a->nfreqs]; // (float *)malloc0 (a->nfreqs * sizeof (float));
|
||||
memcpy (a->F, F, a->nfreqs * sizeof (float));
|
||||
memcpy (a->G, G, a->nfreqs * sizeof (float));
|
||||
memcpy (a->E, E, a->nfreqs * sizeof (float));
|
||||
delete[] (a->ep);
|
||||
delete[] (a->gp);
|
||||
delete[] (a->fp);
|
||||
a->fp = new double[a->nfreqs]; // (double *) malloc0 ((a->nfreqs + 2) * sizeof (double));
|
||||
a->gp = new double[a->nfreqs]; // (double *) malloc0 ((a->nfreqs + 2) * sizeof (double));
|
||||
a->ep = new double[a->nfreqs]; // (double *) malloc0 ((a->nfreqs + 2) * sizeof (double));
|
||||
a->fp = new float[a->nfreqs]; // (float *) malloc0 ((a->nfreqs + 2) * sizeof (float));
|
||||
a->gp = new float[a->nfreqs]; // (float *) malloc0 ((a->nfreqs + 2) * sizeof (float));
|
||||
a->ep = new float[a->nfreqs]; // (float *) malloc0 ((a->nfreqs + 2) * sizeof (float));
|
||||
calc_comp(a);
|
||||
txa.csDSP.unlock();
|
||||
}
|
||||
|
||||
void CFCOMP::SetCFCOMPPrecomp (TXA& txa, double precomp)
|
||||
void CFCOMP::SetCFCOMPPrecomp (TXA& txa, float precomp)
|
||||
{
|
||||
CFCOMP *a = txa.cfcomp.p;
|
||||
if (a->precomp != precomp)
|
||||
@ -489,7 +489,7 @@ void CFCOMP::SetCFCOMPPeqRun (TXA& txa, int run)
|
||||
}
|
||||
}
|
||||
|
||||
void CFCOMP::SetCFCOMPPrePeq (TXA& txa, double prepeq)
|
||||
void CFCOMP::SetCFCOMPPrePeq (TXA& txa, float prepeq)
|
||||
{
|
||||
CFCOMP *a = txa.cfcomp.p;
|
||||
txa.csDSP.lock();
|
||||
@ -498,15 +498,15 @@ void CFCOMP::SetCFCOMPPrePeq (TXA& txa, double prepeq)
|
||||
txa.csDSP.unlock();
|
||||
}
|
||||
|
||||
void CFCOMP::GetCFCOMPDisplayCompression (TXA& txa, double* comp_values, int* ready)
|
||||
void CFCOMP::GetCFCOMPDisplayCompression (TXA& txa, float* comp_values, int* ready)
|
||||
{
|
||||
int i;
|
||||
CFCOMP *a = txa.cfcomp.p;
|
||||
txa.csDSP.lock();
|
||||
if ((*ready = a->mask_ready))
|
||||
{
|
||||
memcpy(a->delta_copy, a->delta, a->msize * sizeof(double));
|
||||
memcpy(a->cfc_gain_copy, a->cfc_gain, a->msize * sizeof(double));
|
||||
memcpy(a->delta_copy, a->delta, a->msize * sizeof(float));
|
||||
memcpy(a->cfc_gain_copy, a->cfc_gain, a->msize * sizeof(float));
|
||||
a->mask_ready = 0;
|
||||
}
|
||||
txa.csDSP.unlock();
|
||||
|
106
wdsp/cfcomp.hpp
106
wdsp/cfcomp.hpp
@ -41,30 +41,30 @@ public:
|
||||
int run;
|
||||
int position;
|
||||
int bsize;
|
||||
double* in;
|
||||
double* out;
|
||||
float* in;
|
||||
float* out;
|
||||
int fsize;
|
||||
int ovrlp;
|
||||
int incr;
|
||||
double* window;
|
||||
float* window;
|
||||
int iasize;
|
||||
double* inaccum;
|
||||
double* forfftin;
|
||||
double* forfftout;
|
||||
float* inaccum;
|
||||
float* forfftin;
|
||||
float* forfftout;
|
||||
int msize;
|
||||
double* cmask;
|
||||
double* mask;
|
||||
float* cmask;
|
||||
float* mask;
|
||||
int mask_ready;
|
||||
double* cfc_gain;
|
||||
double* revfftin;
|
||||
double* revfftout;
|
||||
double** save;
|
||||
float* cfc_gain;
|
||||
float* revfftin;
|
||||
float* revfftout;
|
||||
float** save;
|
||||
int oasize;
|
||||
double* outaccum;
|
||||
double rate;
|
||||
float* outaccum;
|
||||
float rate;
|
||||
int wintype;
|
||||
double pregain;
|
||||
double postgain;
|
||||
float pregain;
|
||||
float postgain;
|
||||
int nsamps;
|
||||
int iainidx;
|
||||
int iaoutidx;
|
||||
@ -72,71 +72,71 @@ public:
|
||||
int oainidx;
|
||||
int oaoutidx;
|
||||
int saveidx;
|
||||
fftw_plan Rfor;
|
||||
fftw_plan Rrev;
|
||||
fftwf_plan Rfor;
|
||||
fftwf_plan Rrev;
|
||||
|
||||
int comp_method;
|
||||
int nfreqs;
|
||||
double* F;
|
||||
double* G;
|
||||
double* E;
|
||||
double* fp;
|
||||
double* gp;
|
||||
double* ep;
|
||||
double* comp;
|
||||
double precomp;
|
||||
double precomplin;
|
||||
double* peq;
|
||||
float* F;
|
||||
float* G;
|
||||
float* E;
|
||||
float* fp;
|
||||
float* gp;
|
||||
float* ep;
|
||||
float* comp;
|
||||
float precomp;
|
||||
float precomplin;
|
||||
float* peq;
|
||||
int peq_run;
|
||||
double prepeq;
|
||||
double prepeqlin;
|
||||
double winfudge;
|
||||
float prepeq;
|
||||
float prepeqlin;
|
||||
float winfudge;
|
||||
|
||||
double gain;
|
||||
double mtau;
|
||||
double mmult;
|
||||
float gain;
|
||||
float mtau;
|
||||
float mmult;
|
||||
// display stuff
|
||||
double dtau;
|
||||
double dmult;
|
||||
double* delta;
|
||||
double* delta_copy;
|
||||
double* cfc_gain_copy;
|
||||
float dtau;
|
||||
float dmult;
|
||||
float* delta;
|
||||
float* delta_copy;
|
||||
float* cfc_gain_copy;
|
||||
|
||||
static CFCOMP* create_cfcomp (
|
||||
int run,
|
||||
int position,
|
||||
int peq_run,
|
||||
int size,
|
||||
double* in,
|
||||
double* out,
|
||||
float* in,
|
||||
float* out,
|
||||
int fsize,
|
||||
int ovrlp,
|
||||
int rate,
|
||||
int wintype,
|
||||
int comp_method,
|
||||
int nfreqs,
|
||||
double precomp,
|
||||
double prepeq,
|
||||
double* F,
|
||||
double* G,
|
||||
double* E,
|
||||
double mtau,
|
||||
double dtau
|
||||
float precomp,
|
||||
float prepeq,
|
||||
float* F,
|
||||
float* G,
|
||||
float* E,
|
||||
float mtau,
|
||||
float dtau
|
||||
);
|
||||
static void destroy_cfcomp (CFCOMP *a);
|
||||
static void flush_cfcomp (CFCOMP *a);
|
||||
static void xcfcomp (CFCOMP *a, int pos);
|
||||
static void setBuffers_cfcomp (CFCOMP *a, double* in, double* out);
|
||||
static void setBuffers_cfcomp (CFCOMP *a, float* in, float* out);
|
||||
static void setSamplerate_cfcomp (CFCOMP *a, int rate);
|
||||
static void setSize_cfcomp (CFCOMP *a, int size);
|
||||
// TXA Properties
|
||||
static void SetCFCOMPRun (TXA& txa, int run);
|
||||
static void SetCFCOMPPosition (TXA& txa, int pos);
|
||||
static void SetCFCOMPprofile (TXA& txa, int nfreqs, double* F, double* G, double *E);
|
||||
static void SetCFCOMPPrecomp (TXA& txa, double precomp);
|
||||
static void SetCFCOMPprofile (TXA& txa, int nfreqs, float* F, float* G, float *E);
|
||||
static void SetCFCOMPPrecomp (TXA& txa, float precomp);
|
||||
static void SetCFCOMPPeqRun (TXA& txa, int run);
|
||||
static void SetCFCOMPPrePeq (TXA& txa, double prepeq);
|
||||
static void GetCFCOMPDisplayCompression (TXA& txa, double* comp_values, int* ready);
|
||||
static void SetCFCOMPPrePeq (TXA& txa, float prepeq);
|
||||
static void GetCFCOMPDisplayCompression (TXA& txa, float* comp_values, int* ready);
|
||||
|
||||
private:
|
||||
static void calc_cfcwindow (CFCOMP *a);
|
||||
|
@ -34,8 +34,8 @@ namespace WDSP {
|
||||
|
||||
void CFIR::calc_cfir (CFIR *a)
|
||||
{
|
||||
double* impulse;
|
||||
a->scale = 1.0 / (double)(2 * a->size);
|
||||
float* impulse;
|
||||
a->scale = 1.0 / (float)(2 * a->size);
|
||||
impulse = cfir_impulse (a->nc, a->DD, a->R, a->Pairs, a->runrate, a->cicrate, a->cutoff, a->xtype, a->xbw, 1, a->scale, a->wintype);
|
||||
a->p = FIRCORE::create_fircore (a->size, a->in, a->out, a->nc, a->mp, impulse);
|
||||
delete[] (impulse);
|
||||
@ -46,8 +46,8 @@ void CFIR::decalc_cfir (CFIR *a)
|
||||
FIRCORE::destroy_fircore (a->p);
|
||||
}
|
||||
|
||||
CFIR* CFIR::create_cfir (int run, int size, int nc, int mp, double* in, double* out, int runrate, int cicrate,
|
||||
int DD, int R, int Pairs, double cutoff, int xtype, double xbw, int wintype)
|
||||
CFIR* CFIR::create_cfir (int run, int size, int nc, int mp, float* in, float* out, int runrate, int cicrate,
|
||||
int DD, int R, int Pairs, float cutoff, int xtype, float xbw, int wintype)
|
||||
// run: 0 - no action; 1 - operate
|
||||
// size: number of complex samples in an input buffer to the CFIR filter
|
||||
// nc: number of filter coefficients
|
||||
@ -101,7 +101,7 @@ void CFIR::xcfir (CFIR *a)
|
||||
memcpy (a->out, a->in, a->size * sizeof (wcomplex));
|
||||
}
|
||||
|
||||
void CFIR::setBuffers_cfir (CFIR *a, double* in, double* out)
|
||||
void CFIR::setBuffers_cfir (CFIR *a, float* in, float* out)
|
||||
{
|
||||
decalc_cfir (a);
|
||||
a->in = in;
|
||||
@ -130,7 +130,7 @@ void CFIR::setOutRate_cfir (CFIR *a, int rate)
|
||||
calc_cfir (a);
|
||||
}
|
||||
|
||||
double* CFIR::cfir_impulse (int N, int DD, int R, int Pairs, double runrate, double cicrate, double cutoff, int xtype, double xbw, int rtype, double scale, int wintype)
|
||||
float* CFIR::cfir_impulse (int N, int DD, int R, int Pairs, float runrate, float cicrate, float cutoff, int xtype, float xbw, int rtype, float scale, int wintype)
|
||||
{
|
||||
// N: number of impulse response samples
|
||||
// DD: differential delay used in the CIC filter
|
||||
@ -144,18 +144,18 @@ double* CFIR::cfir_impulse (int N, int DD, int R, int Pairs, double runrate, dou
|
||||
// rtype: 0 for real output, 1 for complex output
|
||||
// scale: scale factor to be applied to the output
|
||||
int i, j;
|
||||
double tmp, local_scale, ri, mag, fn;
|
||||
double* impulse;
|
||||
double* A = new double[N]; // (double *) malloc0 (N * sizeof (double));
|
||||
double ft = cutoff / cicrate; // normalized cutoff frequency
|
||||
float tmp, local_scale, ri, mag, fn;
|
||||
float* impulse;
|
||||
float* A = new float[N]; // (float *) malloc0 (N * sizeof (float));
|
||||
float ft = cutoff / cicrate; // normalized cutoff frequency
|
||||
int u_samps = (N + 1) / 2; // number of unique samples, OK for odd or even N
|
||||
int c_samps = (int)(cutoff / runrate * N) + (N + 1) / 2 - N / 2; // number of unique samples within bandpass, OK for odd or even N
|
||||
int x_samps = (int)(xbw / runrate * N); // number of unique samples in transition region, OK for odd or even N
|
||||
double offset = 0.5 - 0.5 * (double)((N + 1) / 2 - N / 2); // sample offset from center, OK for odd or even N
|
||||
double* xistion = new double[x_samps + 1]; // (double *) malloc0 ((x_samps + 1) * sizeof (double));
|
||||
double delta = PI / (double)x_samps;
|
||||
double L = cicrate / runrate;
|
||||
double phs = 0.0;
|
||||
float offset = 0.5 - 0.5 * (float)((N + 1) / 2 - N / 2); // sample offset from center, OK for odd or even N
|
||||
float* xistion = new float[x_samps + 1]; // (float *) malloc0 ((x_samps + 1) * sizeof (float));
|
||||
float delta = PI / (float)x_samps;
|
||||
float L = cicrate / runrate;
|
||||
float phs = 0.0;
|
||||
for (i = 0; i <= x_samps; i++)
|
||||
{
|
||||
xistion[i] = 0.5 * (cos (phs) + 1.0);
|
||||
@ -168,7 +168,7 @@ double* CFIR::cfir_impulse (int N, int DD, int R, int Pairs, double runrate, dou
|
||||
{
|
||||
for (i = 0, ri = offset; i < u_samps; i++, ri += 1.0)
|
||||
{
|
||||
fn = ri / (L * (double)N);
|
||||
fn = ri / (L * (float)N);
|
||||
if (fn <= ft)
|
||||
{
|
||||
if (fn == 0.0) tmp = 1.0;
|
||||
@ -185,7 +185,7 @@ double* CFIR::cfir_impulse (int N, int DD, int R, int Pairs, double runrate, dou
|
||||
{
|
||||
for (i = 0, ri = offset; i < u_samps; i++, ri += 1.0)
|
||||
{
|
||||
fn = ri / (L *(double)N);
|
||||
fn = ri / (L *(float)N);
|
||||
if (i < c_samps)
|
||||
{
|
||||
if (fn == 0.0) tmp = 1.0;
|
||||
@ -204,7 +204,7 @@ double* CFIR::cfir_impulse (int N, int DD, int R, int Pairs, double runrate, dou
|
||||
{
|
||||
for (i = 0, ri = offset; i < u_samps; i++, ri += 1.0)
|
||||
{
|
||||
fn = ri / (L * (double)N);
|
||||
fn = ri / (L * (float)N);
|
||||
if (fn <= ft)
|
||||
{
|
||||
if (fn == 0.0) tmp = 1.0;
|
||||
|
@ -42,17 +42,17 @@ public:
|
||||
int size;
|
||||
int nc;
|
||||
int mp;
|
||||
double* in;
|
||||
double* out;
|
||||
float* in;
|
||||
float* out;
|
||||
int runrate;
|
||||
int cicrate;
|
||||
int DD;
|
||||
int R;
|
||||
int Pairs;
|
||||
double cutoff;
|
||||
double scale;
|
||||
float cutoff;
|
||||
float scale;
|
||||
int xtype;
|
||||
double xbw;
|
||||
float xbw;
|
||||
int wintype;
|
||||
FIRCORE *p;
|
||||
|
||||
@ -61,37 +61,37 @@ public:
|
||||
int size,
|
||||
int nc,
|
||||
int mp,
|
||||
double* in,
|
||||
double* out,
|
||||
float* in,
|
||||
float* out,
|
||||
int runrate,
|
||||
int cicrate,
|
||||
int DD,
|
||||
int R,
|
||||
int Pairs,
|
||||
double cutoff,
|
||||
float cutoff,
|
||||
int xtype,
|
||||
double xbw,
|
||||
float xbw,
|
||||
int wintype
|
||||
);
|
||||
static void destroy_cfir (CFIR *a);
|
||||
static void flush_cfir (CFIR *a);
|
||||
static void xcfir (CFIR *a);
|
||||
static void setBuffers_cfir (CFIR *a, double* in, double* out);
|
||||
static void setBuffers_cfir (CFIR *a, float* in, float* out);
|
||||
static void setSamplerate_cfir (CFIR *a, int rate);
|
||||
static void setSize_cfir (CFIR *a, int size);
|
||||
static void setOutRate_cfir (CFIR *a, int rate);
|
||||
static double* cfir_impulse (
|
||||
static float* cfir_impulse (
|
||||
int N,
|
||||
int DD,
|
||||
int R,
|
||||
int Pairs,
|
||||
double runrate,
|
||||
double cicrate,
|
||||
double cutoff,
|
||||
float runrate,
|
||||
float cicrate,
|
||||
float cutoff,
|
||||
int xtype,
|
||||
double xbw,
|
||||
float xbw,
|
||||
int rtype,
|
||||
double scale,
|
||||
float scale,
|
||||
int wintype
|
||||
);
|
||||
// TXA Properties
|
||||
|
@ -51,10 +51,10 @@ public:
|
||||
QRecursiveMutex csDSP; // used to block dsp while parameters are updated or buffers flushed
|
||||
QRecursiveMutex csEXCH; // used to block fexchange() while parameters are updated or buffers flushed
|
||||
int state; // 0 for channel OFF; 1 for channel ON
|
||||
double tdelayup;
|
||||
double tslewup;
|
||||
double tdelaydown;
|
||||
double tslewdown;
|
||||
float tdelayup;
|
||||
float tslewup;
|
||||
float tdelaydown;
|
||||
float tslewdown;
|
||||
int bfo; // 'block_for_output', block fexchange until output is available
|
||||
volatile long flushflag;
|
||||
QThread channelThread;
|
||||
@ -74,10 +74,10 @@ public:
|
||||
int output_samplerate,
|
||||
int type,
|
||||
int state,
|
||||
double tdelayup,
|
||||
double tslewup,
|
||||
double tdelaydown,
|
||||
double tslewdown,
|
||||
float tdelayup,
|
||||
float tslewup,
|
||||
float tdelaydown,
|
||||
float tslewdown,
|
||||
int bfo
|
||||
);
|
||||
static void destroy_channel (int channel);
|
||||
|
@ -54,7 +54,7 @@ warren@wpratt.com
|
||||
#define dMAX_PIXELS 16384 // maximum number of pixels that can be requested
|
||||
#define dMAX_AVERAGE 60 // maximum number of pixel frames that will be window-averaged
|
||||
#ifdef _Thetis
|
||||
#define dINREAL double
|
||||
#define dINREAL float
|
||||
#else
|
||||
#define dINREAL float
|
||||
#endif
|
||||
@ -76,7 +76,7 @@ warren@wpratt.com
|
||||
|
||||
namespace WDSP {
|
||||
// miscellaneous
|
||||
typedef double wcomplex[2];
|
||||
typedef float wcomplex[2];
|
||||
}
|
||||
|
||||
#include <string.h>
|
||||
|
@ -37,9 +37,9 @@ namespace WDSP {
|
||||
COMPRESSOR* create_compressor (
|
||||
int run,
|
||||
int buffsize,
|
||||
double* inbuff,
|
||||
double* outbuff,
|
||||
double gain )
|
||||
float* inbuff,
|
||||
float* outbuff,
|
||||
float gain )
|
||||
{
|
||||
COMPRESSOR *a = new COMPRESSOR;
|
||||
a->run = run;
|
||||
@ -62,7 +62,7 @@ void COMPRESSOR::flush_compressor (COMPRESSOR *)
|
||||
void COMPRESSOR::xcompressor (COMPRESSOR *a)
|
||||
{
|
||||
int i;
|
||||
double mag;
|
||||
float mag;
|
||||
if (a->run)
|
||||
for (i = 0; i < a->buffsize; i++)
|
||||
{
|
||||
@ -77,7 +77,7 @@ void COMPRESSOR::xcompressor (COMPRESSOR *a)
|
||||
memcpy(a->outbuff, a->inbuff, a->buffsize * sizeof (wcomplex));
|
||||
}
|
||||
|
||||
void COMPRESSOR::setBuffers_compressor (COMPRESSOR *a, double* in, double* out)
|
||||
void COMPRESSOR::setBuffers_compressor (COMPRESSOR *a, float* in, float* out)
|
||||
{
|
||||
a->inbuff = in;
|
||||
a->outbuff = out;
|
||||
@ -109,7 +109,7 @@ void COMPRESSOR::SetCompressorRun (TXA& txa, int run)
|
||||
}
|
||||
}
|
||||
|
||||
void COMPRESSOR::SetCompressorGain (TXA& txa, double gain)
|
||||
void COMPRESSOR::SetCompressorGain (TXA& txa, float gain)
|
||||
{
|
||||
txa.csDSP.lock();
|
||||
txa.compressor.p->gain = pow (10.0, gain / 20.0);
|
||||
|
@ -39,26 +39,26 @@ class WDSP_API COMPRESSOR
|
||||
public:
|
||||
int run;
|
||||
int buffsize;
|
||||
double *inbuff;
|
||||
double *outbuff;
|
||||
double gain;
|
||||
float *inbuff;
|
||||
float *outbuff;
|
||||
float gain;
|
||||
|
||||
static COMPRESSOR* create_compressor (
|
||||
int run,
|
||||
int buffsize,
|
||||
double* inbuff,
|
||||
double* outbuff,
|
||||
double gain
|
||||
float* inbuff,
|
||||
float* outbuff,
|
||||
float gain
|
||||
);
|
||||
static void destroy_compressor (COMPRESSOR *a);
|
||||
static void flush_compressor (COMPRESSOR *a);
|
||||
static void xcompressor (COMPRESSOR *a);
|
||||
static void setBuffers_compressor (COMPRESSOR *a, double* in, double* out);
|
||||
static void setBuffers_compressor (COMPRESSOR *a, float* in, float* out);
|
||||
static void setSamplerate_compressor (COMPRESSOR *a, int rate);
|
||||
static void setSize_compressor (COMPRESSOR *a, int size);
|
||||
// TXA Properties
|
||||
static void SetCompressorRun (TXA& txa, int run);
|
||||
static void SetCompressorGain (TXA& txa, double gain);
|
||||
static void SetCompressorGain (TXA& txa, float gain);
|
||||
};
|
||||
|
||||
} // namespace WDSP
|
||||
|
@ -31,7 +31,7 @@ warren@wpratt.com
|
||||
|
||||
namespace WDSP {
|
||||
|
||||
DELAY* create_delay (int run, int size, double* in, double* out, int rate, double tdelta, double tdelay)
|
||||
DELAY* create_delay (int run, int size, float* in, float* out, int rate, float tdelta, float tdelay)
|
||||
{
|
||||
DELAY *a = new DELAY;
|
||||
a->run = run;
|
||||
@ -41,9 +41,9 @@ DELAY* create_delay (int run, int size, double* in, double* out, int rate, doubl
|
||||
a->rate = rate;
|
||||
a->tdelta = tdelta;
|
||||
a->tdelay = tdelay;
|
||||
a->L = (int)(0.5 + 1.0 / (a->tdelta * (double)a->rate));
|
||||
a->L = (int)(0.5 + 1.0 / (a->tdelta * (float)a->rate));
|
||||
a->adelta = 1.0 / (a->rate * a->L);
|
||||
a->ft = 0.45 / (double)a->L;
|
||||
a->ft = 0.45 / (float)a->L;
|
||||
a->ncoef = (int)(60.0 / a->ft);
|
||||
a->ncoef = (a->ncoef / a->L + 1) * a->L;
|
||||
a->cpp = a->ncoef / a->L;
|
||||
@ -52,9 +52,9 @@ DELAY* create_delay (int run, int size, double* in, double* out, int rate, doubl
|
||||
a->phnum %= a->L;
|
||||
a->idx_in = 0;
|
||||
a->adelay = a->adelta * (a->snum * a->L + a->phnum);
|
||||
a->h = FIR::fir_bandpass (a->ncoef,-a->ft, +a->ft, 1.0, 1, 0, (double)a->L);
|
||||
a->h = FIR::fir_bandpass (a->ncoef,-a->ft, +a->ft, 1.0, 1, 0, (float)a->L);
|
||||
a->rsize = a->cpp + (WSDEL - 1);
|
||||
a->ring = new double[a->rsize * 2]; // (double *) malloc0 (a->rsize * sizeof (complex));
|
||||
a->ring = new float[a->rsize * 2]; // (float *) malloc0 (a->rsize * sizeof (complex));
|
||||
return a;
|
||||
}
|
||||
|
||||
@ -77,7 +77,7 @@ void DELAY::xdelay (DELAY *a)
|
||||
if (a->run)
|
||||
{
|
||||
int i, j, k, idx, n;
|
||||
double Itmp, Qtmp;
|
||||
float Itmp, Qtmp;
|
||||
for (i = 0; i < a->size; i++)
|
||||
{
|
||||
a->ring[2 * a->idx_in + 0] = a->in[2 * i + 0];
|
||||
@ -114,9 +114,9 @@ void DELAY::SetDelayRun (DELAY *a, int run)
|
||||
a->cs_update.unlock();
|
||||
}
|
||||
|
||||
double DELAY::SetDelayValue (DELAY *a, double tdelay)
|
||||
float DELAY::SetDelayValue (DELAY *a, float tdelay)
|
||||
{
|
||||
double adelay;
|
||||
float adelay;
|
||||
a->cs_update.lock();
|
||||
a->tdelay = tdelay;
|
||||
a->phnum = (int)(0.5 + a->tdelay / a->adelta);
|
||||
@ -128,7 +128,7 @@ double DELAY::SetDelayValue (DELAY *a, double tdelay)
|
||||
return adelay;
|
||||
}
|
||||
|
||||
void DELAY::SetDelayBuffs (DELAY *a, int size, double* in, double* out)
|
||||
void DELAY::SetDelayBuffs (DELAY *a, int size, float* in, float* out)
|
||||
{
|
||||
a->cs_update.lock();
|
||||
a->size = size;
|
||||
|
@ -41,37 +41,37 @@ class WDSP_API DELAY
|
||||
public:
|
||||
int run; // run
|
||||
int size; // number of input samples per buffer
|
||||
double* in; // input buffer
|
||||
double* out; // output buffer
|
||||
float* in; // input buffer
|
||||
float* out; // output buffer
|
||||
int rate; // samplerate
|
||||
double tdelta; // delay increment required (seconds)
|
||||
double tdelay; // delay requested (seconds)
|
||||
float tdelta; // delay increment required (seconds)
|
||||
float tdelay; // delay requested (seconds)
|
||||
|
||||
int L; // interpolation factor
|
||||
int ncoef; // number of coefficients
|
||||
int cpp; // coefficients per phase
|
||||
double ft; // normalized cutoff frequency
|
||||
double* h; // coefficients
|
||||
float ft; // normalized cutoff frequency
|
||||
float* h; // coefficients
|
||||
int snum; // starting sample number (0 for sub-sample delay)
|
||||
int phnum; // phase number
|
||||
|
||||
int idx_in; // index for input into ring
|
||||
int rsize; // ring size in complex samples
|
||||
double* ring; // ring buffer
|
||||
float* ring; // ring buffer
|
||||
|
||||
double adelta; // actual delay increment
|
||||
double adelay; // actual delay
|
||||
float adelta; // actual delay increment
|
||||
float adelay; // actual delay
|
||||
|
||||
QRecursiveMutex cs_update;
|
||||
|
||||
static DELAY* create_delay (int run, int size, double* in, double* out, int rate, double tdelta, double tdelay);
|
||||
static DELAY* create_delay (int run, int size, float* in, float* out, int rate, float tdelta, float tdelay);
|
||||
static void destroy_delay (DELAY *a);
|
||||
static void flush_delay (DELAY *a);
|
||||
static void xdelay (DELAY *a);
|
||||
// Properties
|
||||
static void SetDelayRun (DELAY *a, int run);
|
||||
static double SetDelayValue (DELAY *a, double delay); // returns actual delay in seconds
|
||||
static void SetDelayBuffs (DELAY *a, int size, double* in, double* out);
|
||||
static float SetDelayValue (DELAY *a, float delay); // returns actual delay in seconds
|
||||
static void SetDelayBuffs (DELAY *a, int size, float* in, float* out);
|
||||
};
|
||||
|
||||
} // namespace WDSP
|
||||
|
234
wdsp/emnr.cpp
234
wdsp/emnr.cpp
@ -48,9 +48,9 @@ namespace WDSP {
|
||||
// Shanjie Zhang and Jianming Jin, "Computation of Special Functions." New York, NY, John Wiley and Sons,
|
||||
// Inc., 1996. [Sample code given in FORTRAN]
|
||||
|
||||
double EMNR::bessI0 (double x)
|
||||
float EMNR::bessI0 (float x)
|
||||
{
|
||||
double res, p;
|
||||
float res, p;
|
||||
if (x == 0.0)
|
||||
res = 1.0;
|
||||
else
|
||||
@ -86,10 +86,10 @@ double EMNR::bessI0 (double x)
|
||||
return res;
|
||||
}
|
||||
|
||||
double EMNR::bessI1 (double x)
|
||||
float EMNR::bessI1 (float x)
|
||||
{
|
||||
|
||||
double res, p;
|
||||
float res, p;
|
||||
if (x == 0.0)
|
||||
res = 0.0;
|
||||
else
|
||||
@ -132,9 +132,9 @@ double EMNR::bessI1 (double x)
|
||||
// Shanjie Zhang and Jianming Jin, "Computation of Special Functions." New York, NY, John Wiley and Sons,
|
||||
// Inc., 1996. [Sample code given in FORTRAN]
|
||||
|
||||
double EMNR::e1xb (double x)
|
||||
float EMNR::e1xb (float x)
|
||||
{
|
||||
double e1, ga, r, t, t0;
|
||||
float e1, ga, r, t, t0;
|
||||
int k, m;
|
||||
if (x == 0.0)
|
||||
e1 = 1.0e300;
|
||||
@ -159,7 +159,7 @@ double EMNR::e1xb (double x)
|
||||
m = 20 + (int)(80.0 / x);
|
||||
t0 = 0.0;
|
||||
for (k = m; k >= 1; k--)
|
||||
t0 = (double)k / (1.0 + k / (x + t0));
|
||||
t0 = (float)k / (1.0 + k / (x + t0));
|
||||
t = 1.0 / (x + t0);
|
||||
e1 = exp (- x) * t;
|
||||
}
|
||||
@ -175,25 +175,25 @@ double EMNR::e1xb (double x)
|
||||
void EMNR::calc_window (EMNR *a)
|
||||
{
|
||||
int i;
|
||||
double arg, sum, inv_coherent_gain;
|
||||
float arg, sum, inv_coherent_gain;
|
||||
switch (a->wintype)
|
||||
{
|
||||
case 0:
|
||||
arg = 2.0 * PI / (double)a->fsize;
|
||||
arg = 2.0 * PI / (float)a->fsize;
|
||||
sum = 0.0;
|
||||
for (i = 0; i < a->fsize; i++)
|
||||
{
|
||||
a->window[i] = sqrt (0.54 - 0.46 * cos((double)i * arg));
|
||||
a->window[i] = sqrt (0.54 - 0.46 * cos((float)i * arg));
|
||||
sum += a->window[i];
|
||||
}
|
||||
inv_coherent_gain = (double)a->fsize / sum;
|
||||
inv_coherent_gain = (float)a->fsize / sum;
|
||||
for (i = 0; i < a->fsize; i++)
|
||||
a->window[i] *= inv_coherent_gain;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void EMNR::interpM (double* res, double x, int nvals, double* xvals, double* yvals)
|
||||
void EMNR::interpM (float* res, float x, int nvals, float* xvals, float* yvals)
|
||||
{
|
||||
if (x <= xvals[0])
|
||||
*res = yvals[0];
|
||||
@ -202,7 +202,7 @@ void EMNR::interpM (double* res, double x, int nvals, double* xvals, double* yva
|
||||
else
|
||||
{
|
||||
int idx = 0;
|
||||
double xllow, xlhigh, frac;
|
||||
float xllow, xlhigh, frac;
|
||||
while (x >= xvals[idx]) idx++;
|
||||
xllow = log10 (xvals[idx - 1]);
|
||||
xlhigh = log10(xvals[idx]);
|
||||
@ -214,14 +214,14 @@ void EMNR::interpM (double* res, double x, int nvals, double* xvals, double* yva
|
||||
void EMNR::calc_emnr(EMNR *a)
|
||||
{
|
||||
int i;
|
||||
double Dvals[18] = { 1.0, 2.0, 5.0, 8.0, 10.0, 15.0, 20.0, 30.0, 40.0,
|
||||
float Dvals[18] = { 1.0, 2.0, 5.0, 8.0, 10.0, 15.0, 20.0, 30.0, 40.0,
|
||||
60.0, 80.0, 120.0, 140.0, 160.0, 180.0, 220.0, 260.0, 300.0 };
|
||||
double Mvals[18] = { 0.000, 0.260, 0.480, 0.580, 0.610, 0.668, 0.705, 0.762, 0.800,
|
||||
float Mvals[18] = { 0.000, 0.260, 0.480, 0.580, 0.610, 0.668, 0.705, 0.762, 0.800,
|
||||
0.841, 0.865, 0.890, 0.900, 0.910, 0.920, 0.930, 0.935, 0.940 };
|
||||
// double Hvals[18] = { 0.000, 0.150, 0.480, 0.780, 0.980, 1.550, 2.000, 2.300, 2.520,
|
||||
// float Hvals[18] = { 0.000, 0.150, 0.480, 0.780, 0.980, 1.550, 2.000, 2.300, 2.520,
|
||||
// 3.100, 3.380, 4.150, 4.350, 4.250, 3.900, 4.100, 4.700, 5.000 };
|
||||
a->incr = a->fsize / a->ovrlp;
|
||||
a->gain = a->ogain / a->fsize / (double)a->ovrlp;
|
||||
a->gain = a->ogain / a->fsize / (float)a->ovrlp;
|
||||
if (a->fsize > a->bsize)
|
||||
a->iasize = a->fsize;
|
||||
else
|
||||
@ -242,34 +242,34 @@ void EMNR::calc_emnr(EMNR *a)
|
||||
a->init_oainidx = a->oainidx;
|
||||
a->oaoutidx = 0;
|
||||
a->msize = a->fsize / 2 + 1;
|
||||
a->window = new double[a->fsize]; // (double *)malloc0(a->fsize * sizeof(double));
|
||||
a->inaccum = new double[a->iasize]; // (double *)malloc0(a->iasize * sizeof(double));
|
||||
a->forfftin = new double[a->fsize]; // (double *)malloc0(a->fsize * sizeof(double));
|
||||
a->forfftout = new double[a->msize * 2]; // (double *)malloc0(a->msize * sizeof(complex));
|
||||
a->mask = new double[a->msize]; // (double *)malloc0(a->msize * sizeof(double));
|
||||
a->revfftin = new double[a->msize * 2]; // (double *)malloc0(a->msize * sizeof(complex));
|
||||
a->revfftout = new double[a->fsize]; // (double *)malloc0(a->fsize * sizeof(double));
|
||||
a->save = new double*[a->ovrlp]; // (double **)malloc0(a->ovrlp * sizeof(double *));
|
||||
a->window = new float[a->fsize]; // (float *)malloc0(a->fsize * sizeof(float));
|
||||
a->inaccum = new float[a->iasize]; // (float *)malloc0(a->iasize * sizeof(float));
|
||||
a->forfftin = new float[a->fsize]; // (float *)malloc0(a->fsize * sizeof(float));
|
||||
a->forfftout = new float[a->msize * 2]; // (float *)malloc0(a->msize * sizeof(complex));
|
||||
a->mask = new float[a->msize]; // (float *)malloc0(a->msize * sizeof(float));
|
||||
a->revfftin = new float[a->msize * 2]; // (float *)malloc0(a->msize * sizeof(complex));
|
||||
a->revfftout = new float[a->fsize]; // (float *)malloc0(a->fsize * sizeof(float));
|
||||
a->save = new float*[a->ovrlp]; // (float **)malloc0(a->ovrlp * sizeof(float *));
|
||||
for (i = 0; i < a->ovrlp; i++)
|
||||
a->save[i] = new double[a->fsize]; // (double *)malloc0(a->fsize * sizeof(double));
|
||||
a->outaccum = new double[a->oasize]; // (double *)malloc0(a->oasize * sizeof(double));
|
||||
a->save[i] = new float[a->fsize]; // (float *)malloc0(a->fsize * sizeof(float));
|
||||
a->outaccum = new float[a->oasize]; // (float *)malloc0(a->oasize * sizeof(float));
|
||||
a->nsamps = 0;
|
||||
a->saveidx = 0;
|
||||
a->Rfor = fftw_plan_dft_r2c_1d(a->fsize, a->forfftin, (fftw_complex *)a->forfftout, FFTW_ESTIMATE);
|
||||
a->Rrev = fftw_plan_dft_c2r_1d(a->fsize, (fftw_complex *)a->revfftin, a->revfftout, FFTW_ESTIMATE);
|
||||
a->Rfor = fftwf_plan_dft_r2c_1d(a->fsize, a->forfftin, (fftwf_complex *)a->forfftout, FFTW_ESTIMATE);
|
||||
a->Rrev = fftwf_plan_dft_c2r_1d(a->fsize, (fftwf_complex *)a->revfftin, a->revfftout, FFTW_ESTIMATE);
|
||||
calc_window(a);
|
||||
|
||||
a->g.msize = a->msize;
|
||||
a->g.mask = a->mask;
|
||||
a->g.y = a->forfftout;
|
||||
a->g.lambda_y = new double[a->msize]; // (double *)malloc0(a->msize * sizeof(double));
|
||||
a->g.lambda_d = new double[a->msize]; // (double *)malloc0(a->msize * sizeof(double));
|
||||
a->g.prev_gamma = new double[a->msize]; // (double *)malloc0(a->msize * sizeof(double));
|
||||
a->g.prev_mask = new double[a->msize]; // (double *)malloc0(a->msize * sizeof(double));
|
||||
a->g.lambda_y = new float[a->msize]; // (float *)malloc0(a->msize * sizeof(float));
|
||||
a->g.lambda_d = new float[a->msize]; // (float *)malloc0(a->msize * sizeof(float));
|
||||
a->g.prev_gamma = new float[a->msize]; // (float *)malloc0(a->msize * sizeof(float));
|
||||
a->g.prev_mask = new float[a->msize]; // (float *)malloc0(a->msize * sizeof(float));
|
||||
|
||||
a->g.gf1p5 = sqrt(PI) / 2.0;
|
||||
{
|
||||
double tau = -128.0 / 8000.0 / log(0.98);
|
||||
float tau = -128.0 / 8000.0 / log(0.98);
|
||||
a->g.alpha = exp(-a->incr / a->rate / tau);
|
||||
}
|
||||
a->g.eps_floor = 1.0e-300;
|
||||
@ -282,15 +282,15 @@ void EMNR::calc_emnr(EMNR *a)
|
||||
}
|
||||
a->g.gmax = 10000.0;
|
||||
//
|
||||
a->g.GG = new double[241 * 241]; // (double *)malloc0(241 * 241 * sizeof(double));
|
||||
a->g.GGS = new double[241 * 241]; // (double *)malloc0(241 * 241 * sizeof(double));
|
||||
a->g.GG = new float[241 * 241]; // (float *)malloc0(241 * 241 * sizeof(float));
|
||||
a->g.GGS = new float[241 * 241]; // (float *)malloc0(241 * 241 * sizeof(float));
|
||||
if ((a->g.fileb = fopen("calculus", "rb")))
|
||||
{
|
||||
std::size_t lgg = fread(a->g.GG, sizeof(double), 241 * 241, a->g.fileb);
|
||||
std::size_t lgg = fread(a->g.GG, sizeof(float), 241 * 241, a->g.fileb);
|
||||
if (lgg != 241 * 241) {
|
||||
fprintf(stderr, "GG file has an invalid size\n");
|
||||
}
|
||||
std::size_t lggs =fread(a->g.GGS, sizeof(double), 241 * 241, a->g.fileb);
|
||||
std::size_t lggs =fread(a->g.GGS, sizeof(float), 241 * 241, a->g.fileb);
|
||||
if (lggs != 241 * 241) {
|
||||
fprintf(stderr, "GGS file has an invalid size\n");
|
||||
}
|
||||
@ -298,8 +298,8 @@ void EMNR::calc_emnr(EMNR *a)
|
||||
}
|
||||
else
|
||||
{
|
||||
memcpy (a->g.GG, Calculus::GG, 241 * 241 * sizeof(double));
|
||||
memcpy (a->g.GGS, Calculus::GGS, 241 * 241 * sizeof(double));
|
||||
memcpy (a->g.GG, Calculus::GG, 241 * 241 * sizeof(float));
|
||||
memcpy (a->g.GGS, Calculus::GGS, 241 * 241 * sizeof(float));
|
||||
}
|
||||
//
|
||||
|
||||
@ -310,24 +310,24 @@ void EMNR::calc_emnr(EMNR *a)
|
||||
a->np.lambda_d = a->g.lambda_d;
|
||||
|
||||
{
|
||||
double tau = -128.0 / 8000.0 / log(0.7);
|
||||
float tau = -128.0 / 8000.0 / log(0.7);
|
||||
a->np.alphaCsmooth = exp(-a->np.incr / a->np.rate / tau);
|
||||
}
|
||||
{
|
||||
double tau = -128.0 / 8000.0 / log(0.96);
|
||||
float tau = -128.0 / 8000.0 / log(0.96);
|
||||
a->np.alphaMax = exp(-a->np.incr / a->np.rate / tau);
|
||||
}
|
||||
{
|
||||
double tau = -128.0 / 8000.0 / log(0.7);
|
||||
float tau = -128.0 / 8000.0 / log(0.7);
|
||||
a->np.alphaCmin = exp(-a->np.incr / a->np.rate / tau);
|
||||
}
|
||||
{
|
||||
double tau = -128.0 / 8000.0 / log(0.3);
|
||||
float tau = -128.0 / 8000.0 / log(0.3);
|
||||
a->np.alphaMin_max_value = exp(-a->np.incr / a->np.rate / tau);
|
||||
}
|
||||
a->np.snrq = -a->np.incr / (0.064 * a->np.rate);
|
||||
{
|
||||
double tau = -128.0 / 8000.0 / log(0.8);
|
||||
float tau = -128.0 / 8000.0 / log(0.8);
|
||||
a->np.betamax = exp(-a->np.incr / a->np.rate / tau);
|
||||
}
|
||||
a->np.invQeqMax = 0.5;
|
||||
@ -345,7 +345,7 @@ void EMNR::calc_emnr(EMNR *a)
|
||||
a->np.invQbar_points[2] = 0.06;
|
||||
a->np.invQbar_points[3] = 1.0e300;
|
||||
{
|
||||
double db;
|
||||
float db;
|
||||
db = 10.0 * log10(8.0) / (12.0 * 128 / 8000);
|
||||
a->np.nsmax[0] = pow(10.0, db / 10.0 * a->np.V * a->np.incr / a->np.rate);
|
||||
db = 10.0 * log10(4.0) / (12.0 * 128 / 8000);
|
||||
@ -356,23 +356,23 @@ void EMNR::calc_emnr(EMNR *a)
|
||||
a->np.nsmax[3] = pow(10.0, db / 10.0 * a->np.V * a->np.incr / a->np.rate);
|
||||
}
|
||||
|
||||
a->np.p = new double[a->np.msize]; // (double *)malloc0(a->np.msize * sizeof(double));
|
||||
a->np.alphaOptHat = new double[a->np.msize]; // (double *)malloc0(a->np.msize * sizeof(double));
|
||||
a->np.alphaHat = new double[a->np.msize]; // (double *)malloc0(a->np.msize * sizeof(double));
|
||||
a->np.sigma2N = new double[a->np.msize]; // (double *)malloc0(a->np.msize * sizeof(double));
|
||||
a->np.pbar = new double[a->np.msize]; // (double *)malloc0(a->np.msize * sizeof(double));
|
||||
a->np.p2bar = new double[a->np.msize]; // (double *)malloc0(a->np.msize * sizeof(double));
|
||||
a->np.Qeq = new double[a->np.msize]; // (double *)malloc0(a->np.msize * sizeof(double));
|
||||
a->np.bmin = new double[a->np.msize]; // (double *)malloc0(a->np.msize * sizeof(double));
|
||||
a->np.bmin_sub = new double[a->np.msize]; // (double *)malloc0(a->np.msize * sizeof(double));
|
||||
a->np.p = new float[a->np.msize]; // (float *)malloc0(a->np.msize * sizeof(float));
|
||||
a->np.alphaOptHat = new float[a->np.msize]; // (float *)malloc0(a->np.msize * sizeof(float));
|
||||
a->np.alphaHat = new float[a->np.msize]; // (float *)malloc0(a->np.msize * sizeof(float));
|
||||
a->np.sigma2N = new float[a->np.msize]; // (float *)malloc0(a->np.msize * sizeof(float));
|
||||
a->np.pbar = new float[a->np.msize]; // (float *)malloc0(a->np.msize * sizeof(float));
|
||||
a->np.p2bar = new float[a->np.msize]; // (float *)malloc0(a->np.msize * sizeof(float));
|
||||
a->np.Qeq = new float[a->np.msize]; // (float *)malloc0(a->np.msize * sizeof(float));
|
||||
a->np.bmin = new float[a->np.msize]; // (float *)malloc0(a->np.msize * sizeof(float));
|
||||
a->np.bmin_sub = new float[a->np.msize]; // (float *)malloc0(a->np.msize * sizeof(float));
|
||||
a->np.k_mod = new int[a->np.msize]; // (int *)malloc0(a->np.msize * sizeof(int));
|
||||
a->np.actmin = new double[a->np.msize]; // (double *)malloc0(a->np.msize * sizeof(double));
|
||||
a->np.actmin_sub = new double[a->np.msize]; // (double *)malloc0(a->np.msize * sizeof(double));
|
||||
a->np.actmin = new float[a->np.msize]; // (float *)malloc0(a->np.msize * sizeof(float));
|
||||
a->np.actmin_sub = new float[a->np.msize]; // (float *)malloc0(a->np.msize * sizeof(float));
|
||||
a->np.lmin_flag = new int[a->np.msize]; // (int *)malloc0(a->np.msize * sizeof(int));
|
||||
a->np.pmin_u = new double[a->np.msize]; // (double *)malloc0(a->np.msize * sizeof(double));
|
||||
a->np.actminbuff = new double*[a->np.U]; // (double**)malloc0(a->np.U * sizeof(double*));
|
||||
a->np.pmin_u = new float[a->np.msize]; // (float *)malloc0(a->np.msize * sizeof(float));
|
||||
a->np.actminbuff = new float*[a->np.U]; // (float**)malloc0(a->np.U * sizeof(float*));
|
||||
for (i = 0; i < a->np.U; i++)
|
||||
a->np.actminbuff[i] = new double[a->np.msize]; // (double *)malloc0(a->np.msize * sizeof(double));
|
||||
a->np.actminbuff[i] = new float[a->np.msize]; // (float *)malloc0(a->np.msize * sizeof(float));
|
||||
|
||||
{
|
||||
int k, ku;
|
||||
@ -380,10 +380,10 @@ void EMNR::calc_emnr(EMNR *a)
|
||||
a->np.subwc = a->np.V;
|
||||
a->np.amb_idx = 0;
|
||||
for (k = 0; k < a->np.msize; k++) a->np.lambda_y[k] = 0.5;
|
||||
memcpy(a->np.p, a->np.lambda_y, a->np.msize * sizeof(double));
|
||||
memcpy(a->np.sigma2N, a->np.lambda_y, a->np.msize * sizeof(double));
|
||||
memcpy(a->np.pbar, a->np.lambda_y, a->np.msize * sizeof(double));
|
||||
memcpy(a->np.pmin_u, a->np.lambda_y, a->np.msize * sizeof(double));
|
||||
memcpy(a->np.p, a->np.lambda_y, a->np.msize * sizeof(float));
|
||||
memcpy(a->np.sigma2N, a->np.lambda_y, a->np.msize * sizeof(float));
|
||||
memcpy(a->np.pbar, a->np.lambda_y, a->np.msize * sizeof(float));
|
||||
memcpy(a->np.pmin_u, a->np.lambda_y, a->np.msize * sizeof(float));
|
||||
for (k = 0; k < a->np.msize; k++)
|
||||
{
|
||||
a->np.p2bar[k] = a->np.lambda_y[k] * a->np.lambda_y[k];
|
||||
@ -402,20 +402,20 @@ void EMNR::calc_emnr(EMNR *a)
|
||||
a->nps.lambda_d = a->g.lambda_d;
|
||||
|
||||
{
|
||||
double tau = -128.0 / 8000.0 / log(0.8);
|
||||
float tau = -128.0 / 8000.0 / log(0.8);
|
||||
a->nps.alpha_pow = exp(-a->nps.incr / a->nps.rate / tau);
|
||||
}
|
||||
{
|
||||
double tau = -128.0 / 8000.0 / log(0.9);
|
||||
float tau = -128.0 / 8000.0 / log(0.9);
|
||||
a->nps.alpha_Pbar = exp(-a->nps.incr / a->nps.rate / tau);
|
||||
}
|
||||
a->nps.epsH1 = pow(10.0, 15.0 / 10.0);
|
||||
a->nps.epsH1r = a->nps.epsH1 / (1.0 + a->nps.epsH1);
|
||||
|
||||
a->nps.sigma2N = new double[a->nps.msize]; // (double *)malloc0(a->nps.msize * sizeof(double));
|
||||
a->nps.PH1y = new double[a->nps.msize]; // (double *)malloc0(a->nps.msize * sizeof(double));
|
||||
a->nps.Pbar = new double[a->nps.msize]; // (double *)malloc0(a->nps.msize * sizeof(double));
|
||||
a->nps.EN2y = new double[a->nps.msize]; // (double *)malloc0(a->nps.msize * sizeof(double));
|
||||
a->nps.sigma2N = new float[a->nps.msize]; // (float *)malloc0(a->nps.msize * sizeof(float));
|
||||
a->nps.PH1y = new float[a->nps.msize]; // (float *)malloc0(a->nps.msize * sizeof(float));
|
||||
a->nps.Pbar = new float[a->nps.msize]; // (float *)malloc0(a->nps.msize * sizeof(float));
|
||||
a->nps.EN2y = new float[a->nps.msize]; // (float *)malloc0(a->nps.msize * sizeof(float));
|
||||
|
||||
for (i = 0; i < a->nps.msize; i++)
|
||||
{
|
||||
@ -429,7 +429,7 @@ void EMNR::calc_emnr(EMNR *a)
|
||||
a->ae.zetaThresh = 0.75;
|
||||
a->ae.psi = 10.0;
|
||||
|
||||
a->ae.nmask = new double[a->ae.msize]; // (double *)malloc0(a->ae.msize * sizeof(double));
|
||||
a->ae.nmask = new float[a->ae.msize]; // (float *)malloc0(a->ae.msize * sizeof(float));
|
||||
}
|
||||
|
||||
void EMNR::decalc_emnr(EMNR *a)
|
||||
@ -467,8 +467,8 @@ void EMNR::decalc_emnr(EMNR *a)
|
||||
delete[] (a->g.lambda_d);
|
||||
delete[] (a->g.lambda_y);
|
||||
|
||||
fftw_destroy_plan(a->Rrev);
|
||||
fftw_destroy_plan(a->Rfor);
|
||||
fftwf_destroy_plan(a->Rrev);
|
||||
fftwf_destroy_plan(a->Rfor);
|
||||
delete[] (a->outaccum);
|
||||
for (i = 0; i < a->ovrlp; i++)
|
||||
delete[] (a->save[i]);
|
||||
@ -482,8 +482,8 @@ void EMNR::decalc_emnr(EMNR *a)
|
||||
delete[] (a->window);
|
||||
}
|
||||
|
||||
EMNR* EMNR::create_emnr (int run, int position, int size, double* in, double* out, int fsize, int ovrlp,
|
||||
int rate, int wintype, double gain, int gain_method, int npe_method, int ae_run)
|
||||
EMNR* EMNR::create_emnr (int run, int position, int size, float* in, float* out, int fsize, int ovrlp,
|
||||
int rate, int wintype, float gain, int gain_method, int npe_method, int ae_run)
|
||||
{
|
||||
EMNR *a = new EMNR;
|
||||
|
||||
@ -507,10 +507,10 @@ EMNR* EMNR::create_emnr (int run, int position, int size, double* in, double* ou
|
||||
void EMNR::flush_emnr (EMNR *a)
|
||||
{
|
||||
int i;
|
||||
memset (a->inaccum, 0, a->iasize * sizeof (double));
|
||||
memset (a->inaccum, 0, a->iasize * sizeof (float));
|
||||
for (i = 0; i < a->ovrlp; i++)
|
||||
memset (a->save[i], 0, a->fsize * sizeof (double));
|
||||
memset (a->outaccum, 0, a->oasize * sizeof (double));
|
||||
memset (a->save[i], 0, a->fsize * sizeof (float));
|
||||
memset (a->outaccum, 0, a->oasize * sizeof (float));
|
||||
a->nsamps = 0;
|
||||
a->iainidx = 0;
|
||||
a->iaoutidx = 0;
|
||||
@ -528,17 +528,17 @@ void EMNR::destroy_emnr (EMNR *a)
|
||||
void EMNR::LambdaD(EMNR *a)
|
||||
{
|
||||
int k;
|
||||
double f0, f1, f2, f3;
|
||||
double sum_prev_p;
|
||||
double sum_lambda_y;
|
||||
double alphaCtilda;
|
||||
double sum_prev_sigma2N;
|
||||
double alphaMin, SNR;
|
||||
double beta, varHat, invQeq;
|
||||
double invQbar;
|
||||
double bc;
|
||||
double QeqTilda, QeqTildaSub;
|
||||
double noise_slope_max;
|
||||
float f0, f1, f2, f3;
|
||||
float sum_prev_p;
|
||||
float sum_lambda_y;
|
||||
float alphaCtilda;
|
||||
float sum_prev_sigma2N;
|
||||
float alphaMin, SNR;
|
||||
float beta, varHat, invQeq;
|
||||
float invQbar;
|
||||
float bc;
|
||||
float QeqTilda, QeqTildaSub;
|
||||
float noise_slope_max;
|
||||
|
||||
sum_prev_p = 0.0;
|
||||
sum_lambda_y = 0.0;
|
||||
@ -578,7 +578,7 @@ void EMNR::LambdaD(EMNR *a)
|
||||
a->np.Qeq[k] = 1.0 / invQeq;
|
||||
invQbar += invQeq;
|
||||
}
|
||||
invQbar /= (double)a->np.msize;
|
||||
invQbar /= (float)a->np.msize;
|
||||
bc = 1.0 + a->np.av * sqrt (invQbar);
|
||||
for (k = 0; k < a->np.msize; k++)
|
||||
{
|
||||
@ -608,7 +608,7 @@ void EMNR::LambdaD(EMNR *a)
|
||||
for (k = 0; k < a->np.msize; k++)
|
||||
{
|
||||
int ku;
|
||||
double min;
|
||||
float min;
|
||||
if (a->np.k_mod[k])
|
||||
a->np.lmin_flag[k] = 0;
|
||||
a->np.actminbuff[a->np.amb_idx][k] = a->np.actmin[k];
|
||||
@ -647,7 +647,7 @@ void EMNR::LambdaD(EMNR *a)
|
||||
}
|
||||
++a->np.subwc;
|
||||
}
|
||||
memcpy (a->np.lambda_d, a->np.sigma2N, a->np.msize * sizeof (double));
|
||||
memcpy (a->np.lambda_d, a->np.sigma2N, a->np.msize * sizeof (float));
|
||||
}
|
||||
|
||||
void EMNR::LambdaDs (EMNR *a)
|
||||
@ -658,18 +658,18 @@ void EMNR::LambdaDs (EMNR *a)
|
||||
a->nps.PH1y[k] = 1.0 / (1.0 + (1.0 + a->nps.epsH1) * exp (- a->nps.epsH1r * a->nps.lambda_y[k] / a->nps.sigma2N[k]));
|
||||
a->nps.Pbar[k] = a->nps.alpha_Pbar * a->nps.Pbar[k] + (1.0 - a->nps.alpha_Pbar) * a->nps.PH1y[k];
|
||||
if (a->nps.Pbar[k] > 0.99)
|
||||
a->nps.PH1y[k] = std::min (a->nps.PH1y[k], 0.99);
|
||||
a->nps.PH1y[k] = std::min (a->nps.PH1y[k], 0.99f);
|
||||
a->nps.EN2y[k] = (1.0 - a->nps.PH1y[k]) * a->nps.lambda_y[k] + a->nps.PH1y[k] * a->nps.sigma2N[k];
|
||||
a->nps.sigma2N[k] = a->nps.alpha_pow * a->nps.sigma2N[k] + (1.0 - a->nps.alpha_pow) * a->nps.EN2y[k];
|
||||
}
|
||||
memcpy (a->nps.lambda_d, a->nps.sigma2N, a->nps.msize * sizeof (double));
|
||||
memcpy (a->nps.lambda_d, a->nps.sigma2N, a->nps.msize * sizeof (float));
|
||||
}
|
||||
|
||||
void EMNR::aepf(EMNR *a)
|
||||
{
|
||||
int k, m;
|
||||
int N, n;
|
||||
double sumPre, sumPost, zeta, zetaT;
|
||||
float sumPre, sumPost, zeta, zetaT;
|
||||
sumPre = 0.0;
|
||||
sumPost = 0.0;
|
||||
for (k = 0; k < a->ae.msize; k++)
|
||||
@ -692,17 +692,17 @@ void EMNR::aepf(EMNR *a)
|
||||
a->ae.nmask[k] = 0.0;
|
||||
for (m = k - n; m <= (k + n); m++)
|
||||
a->ae.nmask[k] += a->mask[m];
|
||||
a->ae.nmask[k] /= (double)N;
|
||||
a->ae.nmask[k] /= (float)N;
|
||||
}
|
||||
memcpy (a->mask + n, a->ae.nmask, (a->ae.msize - 2 * n) * sizeof (double));
|
||||
memcpy (a->mask + n, a->ae.nmask, (a->ae.msize - 2 * n) * sizeof (float));
|
||||
}
|
||||
|
||||
double EMNR::getKey(double* type, double gamma, double xi)
|
||||
float EMNR::getKey(float* type, float gamma, float xi)
|
||||
{
|
||||
int ngamma1, ngamma2, nxi1, nxi2;
|
||||
double tg, tx, dg, dx;
|
||||
const double dmin = 0.001;
|
||||
const double dmax = 1000.0;
|
||||
float tg, tx, dg, dx;
|
||||
const float dmin = 0.001;
|
||||
const float dmax = 1000.0;
|
||||
if (gamma <= dmin)
|
||||
{
|
||||
ngamma1 = ngamma2 = 0;
|
||||
@ -763,20 +763,20 @@ void EMNR::calc_gain (EMNR *a)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
double gamma, eps_hat, v;
|
||||
float gamma, eps_hat, v;
|
||||
for (k = 0; k < a->msize; k++)
|
||||
{
|
||||
gamma = std::min (a->g.lambda_y[k] / a->g.lambda_d[k], a->g.gamma_max);
|
||||
eps_hat = a->g.alpha * a->g.prev_mask[k] * a->g.prev_mask[k] * a->g.prev_gamma[k]
|
||||
+ (1.0 - a->g.alpha) * std::max (gamma - 1.0, a->g.eps_floor);
|
||||
+ (1.0 - a->g.alpha) * std::max (gamma - 1.0f, a->g.eps_floor);
|
||||
v = (eps_hat / (1.0 + eps_hat)) * gamma;
|
||||
a->g.mask[k] = a->g.gf1p5 * sqrt (v) / gamma * exp (- 0.5 * v)
|
||||
* ((1.0 + v) * bessI0 (0.5 * v) + v * bessI1 (0.5 * v));
|
||||
{
|
||||
double v2 = std::min (v, 700.0);
|
||||
double eta = a->g.mask[k] * a->g.mask[k] * a->g.lambda_y[k] / a->g.lambda_d[k];
|
||||
double eps = eta / (1.0 - a->g.q);
|
||||
double witchHat = (1.0 - a->g.q) / a->g.q * exp (v2) / (1.0 + eps);
|
||||
float v2 = std::min (v, 700.0f);
|
||||
float eta = a->g.mask[k] * a->g.mask[k] * a->g.lambda_y[k] / a->g.lambda_d[k];
|
||||
float eps = eta / (1.0 - a->g.q);
|
||||
float witchHat = (1.0 - a->g.q) / a->g.q * exp (v2) / (1.0 + eps);
|
||||
a->g.mask[k] *= witchHat / (1.0 + witchHat);
|
||||
}
|
||||
if (a->g.mask[k] > a->g.gmax) a->g.mask[k] = a->g.gmax;
|
||||
@ -788,12 +788,12 @@ void EMNR::calc_gain (EMNR *a)
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
double gamma, eps_hat, v, ehr;
|
||||
float gamma, eps_hat, v, ehr;
|
||||
for (k = 0; k < a->g.msize; k++)
|
||||
{
|
||||
gamma = std::min (a->g.lambda_y[k] / a->g.lambda_d[k], a->g.gamma_max);
|
||||
eps_hat = a->g.alpha * a->g.prev_mask[k] * a->g.prev_mask[k] * a->g.prev_gamma[k]
|
||||
+ (1.0 - a->g.alpha) * std::max (gamma - 1.0, a->g.eps_floor);
|
||||
+ (1.0 - a->g.alpha) * std::max (gamma - 1.0f, a->g.eps_floor);
|
||||
ehr = eps_hat / (1.0 + eps_hat);
|
||||
v = ehr * gamma;
|
||||
if((a->g.mask[k] = ehr * exp (std::min (700.0, 0.5 * e1xb(v)))) > a->g.gmax) a->g.mask[k] = a->g.gmax;
|
||||
@ -805,12 +805,12 @@ void EMNR::calc_gain (EMNR *a)
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
double gamma, eps_hat, eps_p;
|
||||
float gamma, eps_hat, eps_p;
|
||||
for (k = 0; k < a->msize; k++)
|
||||
{
|
||||
gamma = std::min(a->g.lambda_y[k] / a->g.lambda_d[k], a->g.gamma_max);
|
||||
eps_hat = a->g.alpha * a->g.prev_mask[k] * a->g.prev_mask[k] * a->g.prev_gamma[k]
|
||||
+ (1.0 - a->g.alpha) * std::max(gamma - 1.0, a->g.eps_floor);
|
||||
+ (1.0 - a->g.alpha) * std::max(gamma - 1.0f, a->g.eps_floor);
|
||||
eps_p = eps_hat / (1.0 - a->g.q);
|
||||
a->g.mask[k] = getKey(a->g.GG, gamma, eps_hat) * getKey(a->g.GGS, gamma, eps_p);
|
||||
a->g.prev_gamma[k] = gamma;
|
||||
@ -827,7 +827,7 @@ void EMNR::xemnr (EMNR *a, int pos)
|
||||
if (a->run && pos == a->position)
|
||||
{
|
||||
int i, j, k, sbuff, sbegin;
|
||||
double g1;
|
||||
float g1;
|
||||
for (i = 0; i < 2 * a->bsize; i += 2)
|
||||
{
|
||||
a->inaccum[a->iainidx] = a->in[i];
|
||||
@ -840,7 +840,7 @@ void EMNR::xemnr (EMNR *a, int pos)
|
||||
a->forfftin[i] = a->window[i] * a->inaccum[j];
|
||||
a->iaoutidx = (a->iaoutidx + a->incr) % a->iasize;
|
||||
a->nsamps -= a->incr;
|
||||
fftw_execute (a->Rfor);
|
||||
fftwf_execute (a->Rfor);
|
||||
calc_gain(a);
|
||||
for (i = 0; i < a->msize; i++)
|
||||
{
|
||||
@ -848,7 +848,7 @@ void EMNR::xemnr (EMNR *a, int pos)
|
||||
a->revfftin[2 * i + 0] = g1 * a->forfftout[2 * i + 0];
|
||||
a->revfftin[2 * i + 1] = g1 * a->forfftout[2 * i + 1];
|
||||
}
|
||||
fftw_execute (a->Rrev);
|
||||
fftwf_execute (a->Rrev);
|
||||
for (i = 0; i < a->fsize; i++)
|
||||
a->save[a->saveidx][i] = a->window[i] * a->revfftout[i];
|
||||
for (i = a->ovrlp; i > 0; i--)
|
||||
@ -877,7 +877,7 @@ void EMNR::xemnr (EMNR *a, int pos)
|
||||
memcpy (a->out, a->in, a->bsize * sizeof (wcomplex));
|
||||
}
|
||||
|
||||
void EMNR::setBuffers_emnr (EMNR *a, double* in, double* out)
|
||||
void EMNR::setBuffers_emnr (EMNR *a, float* in, float* out)
|
||||
{
|
||||
a->in = in;
|
||||
a->out = out;
|
||||
@ -946,14 +946,14 @@ void EMNR::SetEMNRPosition (RXA& rxa, int position)
|
||||
rxa.csDSP.unlock();
|
||||
}
|
||||
|
||||
void EMNR::SetEMNRaeZetaThresh (RXA& rxa, double zetathresh)
|
||||
void EMNR::SetEMNRaeZetaThresh (RXA& rxa, float zetathresh)
|
||||
{
|
||||
rxa.csDSP.lock();
|
||||
rxa.emnr.p->ae.zetaThresh = zetathresh;
|
||||
rxa.csDSP.unlock();
|
||||
}
|
||||
|
||||
void EMNR::SetEMNRaePsi (RXA& rxa, double psi)
|
||||
void EMNR::SetEMNRaePsi (RXA& rxa, float psi)
|
||||
{
|
||||
rxa.csDSP.lock();
|
||||
rxa.emnr.p->ae.psi = psi;
|
||||
|
172
wdsp/emnr.hpp
172
wdsp/emnr.hpp
@ -41,27 +41,27 @@ public:
|
||||
int run;
|
||||
int position;
|
||||
int bsize;
|
||||
double* in;
|
||||
double* out;
|
||||
float* in;
|
||||
float* out;
|
||||
int fsize;
|
||||
int ovrlp;
|
||||
int incr;
|
||||
double* window;
|
||||
float* window;
|
||||
int iasize;
|
||||
double* inaccum;
|
||||
double* forfftin;
|
||||
double* forfftout;
|
||||
float* inaccum;
|
||||
float* forfftin;
|
||||
float* forfftout;
|
||||
int msize;
|
||||
double* mask;
|
||||
double* revfftin;
|
||||
double* revfftout;
|
||||
double** save;
|
||||
float* mask;
|
||||
float* revfftin;
|
||||
float* revfftout;
|
||||
float** save;
|
||||
int oasize;
|
||||
double* outaccum;
|
||||
double rate;
|
||||
float* outaccum;
|
||||
float rate;
|
||||
int wintype;
|
||||
double ogain;
|
||||
double gain;
|
||||
float ogain;
|
||||
float gain;
|
||||
int nsamps;
|
||||
int iainidx;
|
||||
int iaoutidx;
|
||||
@ -69,106 +69,106 @@ public:
|
||||
int oainidx;
|
||||
int oaoutidx;
|
||||
int saveidx;
|
||||
fftw_plan Rfor;
|
||||
fftw_plan Rrev;
|
||||
fftwf_plan Rfor;
|
||||
fftwf_plan Rrev;
|
||||
struct _g
|
||||
{
|
||||
int gain_method;
|
||||
int npe_method;
|
||||
int ae_run;
|
||||
double msize;
|
||||
double* mask;
|
||||
double* y;
|
||||
double* lambda_y;
|
||||
double* lambda_d;
|
||||
double* prev_mask;
|
||||
double* prev_gamma;
|
||||
double gf1p5;
|
||||
double alpha;
|
||||
double eps_floor;
|
||||
double gamma_max;
|
||||
double q;
|
||||
double gmax;
|
||||
float msize;
|
||||
float* mask;
|
||||
float* y;
|
||||
float* lambda_y;
|
||||
float* lambda_d;
|
||||
float* prev_mask;
|
||||
float* prev_gamma;
|
||||
float gf1p5;
|
||||
float alpha;
|
||||
float eps_floor;
|
||||
float gamma_max;
|
||||
float q;
|
||||
float gmax;
|
||||
//
|
||||
double* GG;
|
||||
double* GGS;
|
||||
float* GG;
|
||||
float* GGS;
|
||||
FILE* fileb;
|
||||
} g;
|
||||
struct _npest
|
||||
{
|
||||
int incr;
|
||||
double rate;
|
||||
float rate;
|
||||
int msize;
|
||||
double* lambda_y;
|
||||
double* lambda_d;
|
||||
double* p;
|
||||
double* alphaOptHat;
|
||||
double alphaC;
|
||||
double alphaCsmooth;
|
||||
double alphaCmin;
|
||||
double* alphaHat;
|
||||
double alphaMax;
|
||||
double* sigma2N;
|
||||
double alphaMin_max_value;
|
||||
double snrq;
|
||||
double betamax;
|
||||
double* pbar;
|
||||
double* p2bar;
|
||||
double invQeqMax;
|
||||
double av;
|
||||
double* Qeq;
|
||||
float* lambda_y;
|
||||
float* lambda_d;
|
||||
float* p;
|
||||
float* alphaOptHat;
|
||||
float alphaC;
|
||||
float alphaCsmooth;
|
||||
float alphaCmin;
|
||||
float* alphaHat;
|
||||
float alphaMax;
|
||||
float* sigma2N;
|
||||
float alphaMin_max_value;
|
||||
float snrq;
|
||||
float betamax;
|
||||
float* pbar;
|
||||
float* p2bar;
|
||||
float invQeqMax;
|
||||
float av;
|
||||
float* Qeq;
|
||||
int U;
|
||||
double Dtime;
|
||||
float Dtime;
|
||||
int V;
|
||||
int D;
|
||||
double MofD;
|
||||
double MofV;
|
||||
double* bmin;
|
||||
double* bmin_sub;
|
||||
float MofD;
|
||||
float MofV;
|
||||
float* bmin;
|
||||
float* bmin_sub;
|
||||
int* k_mod;
|
||||
double* actmin;
|
||||
double* actmin_sub;
|
||||
float* actmin;
|
||||
float* actmin_sub;
|
||||
int subwc;
|
||||
int* lmin_flag;
|
||||
double* pmin_u;
|
||||
double invQbar_points[4];
|
||||
double nsmax[4];
|
||||
double** actminbuff;
|
||||
float* pmin_u;
|
||||
float invQbar_points[4];
|
||||
float nsmax[4];
|
||||
float** actminbuff;
|
||||
int amb_idx;
|
||||
} np;
|
||||
struct _npests
|
||||
{
|
||||
int incr;
|
||||
double rate;
|
||||
float rate;
|
||||
int msize;
|
||||
double* lambda_y;
|
||||
double* lambda_d;
|
||||
float* lambda_y;
|
||||
float* lambda_d;
|
||||
|
||||
double alpha_pow;
|
||||
double alpha_Pbar;
|
||||
double epsH1;
|
||||
double epsH1r;
|
||||
float alpha_pow;
|
||||
float alpha_Pbar;
|
||||
float epsH1;
|
||||
float epsH1r;
|
||||
|
||||
double* sigma2N;
|
||||
double* PH1y;
|
||||
double* Pbar;
|
||||
double* EN2y;
|
||||
float* sigma2N;
|
||||
float* PH1y;
|
||||
float* Pbar;
|
||||
float* EN2y;
|
||||
} nps;
|
||||
struct _ae
|
||||
{
|
||||
int msize;
|
||||
double* lambda_y;
|
||||
double zetaThresh;
|
||||
double psi;
|
||||
double* nmask;
|
||||
float* lambda_y;
|
||||
float zetaThresh;
|
||||
float psi;
|
||||
float* nmask;
|
||||
} ae;
|
||||
|
||||
static EMNR* create_emnr (int run, int position, int size, double* in, double* out, int fsize, int ovrlp,
|
||||
int rate, int wintype, double gain, int gain_method, int npe_method, int ae_run);
|
||||
static EMNR* create_emnr (int run, int position, int size, float* in, float* out, int fsize, int ovrlp,
|
||||
int rate, int wintype, float gain, int gain_method, int npe_method, int ae_run);
|
||||
static void destroy_emnr (EMNR *a);
|
||||
static void flush_emnr (EMNR *a);
|
||||
static void xemnr (EMNR *a, int pos);
|
||||
static void setBuffers_emnr (EMNR *a, double* in, double* out);
|
||||
static void setBuffers_emnr (EMNR *a, float* in, float* out);
|
||||
static void setSamplerate_emnr (EMNR *a, int rate);
|
||||
static void setSize_emnr (EMNR *a, int size);
|
||||
// RXA Properties
|
||||
@ -177,21 +177,21 @@ public:
|
||||
static void SetEMNRnpeMethod (RXA& rxa, int method);
|
||||
static void SetEMNRaeRun (RXA& rxa, int run);
|
||||
static void SetEMNRPosition (RXA& rxa, int position);
|
||||
static void SetEMNRaeZetaThresh (RXA& rxa, double zetathresh);
|
||||
static void SetEMNRaePsi (RXA& rxa, double psi);
|
||||
static void SetEMNRaeZetaThresh (RXA& rxa, float zetathresh);
|
||||
static void SetEMNRaePsi (RXA& rxa, float psi);
|
||||
|
||||
private:
|
||||
static double bessI0 (double x);
|
||||
static double bessI1 (double x);
|
||||
static double e1xb (double x);
|
||||
static float bessI0 (float x);
|
||||
static float bessI1 (float x);
|
||||
static float e1xb (float x);
|
||||
static void calc_window (EMNR *a);
|
||||
static void interpM (double* res, double x, int nvals, double* xvals, double* yvals);
|
||||
static void interpM (float* res, float x, int nvals, float* xvals, float* yvals);
|
||||
static void calc_emnr(EMNR *a);
|
||||
static void decalc_emnr(EMNR *a);
|
||||
static void LambdaD(EMNR *a);
|
||||
static void LambdaDs (EMNR *a);
|
||||
static void aepf(EMNR *a);
|
||||
static double getKey(double* type, double gamma, double xi);
|
||||
static float getKey(float* type, float gamma, float xi);
|
||||
static void calc_gain (EMNR *a);
|
||||
};
|
||||
|
||||
|
@ -39,10 +39,10 @@ namespace WDSP {
|
||||
* *
|
||||
********************************************************************************************************/
|
||||
|
||||
EMPHP* EMPHP::create_emphp (int run, int position, int size, int nc, int mp, double* in, double* out, int rate, int ctype, double f_low, double f_high)
|
||||
EMPHP* EMPHP::create_emphp (int run, int position, int size, int nc, int mp, float* in, float* out, int rate, int ctype, float f_low, float f_high)
|
||||
{
|
||||
EMPHP *a = new EMPHP;
|
||||
double* impulse;
|
||||
float* impulse;
|
||||
a->run = run;
|
||||
a->position = position;
|
||||
a->size = size;
|
||||
@ -79,7 +79,7 @@ void EMPHP::xemphp (EMPHP *a, int position)
|
||||
memcpy (a->out, a->in, a->size * sizeof (wcomplex));
|
||||
}
|
||||
|
||||
void EMPHP::setBuffers_emphp (EMPHP *a, double* in, double* out)
|
||||
void EMPHP::setBuffers_emphp (EMPHP *a, float* in, float* out)
|
||||
{
|
||||
a->in = in;
|
||||
a->out = out;
|
||||
@ -88,7 +88,7 @@ void EMPHP::setBuffers_emphp (EMPHP *a, double* in, double* out)
|
||||
|
||||
void EMPHP::setSamplerate_emphp (EMPHP *a, int rate)
|
||||
{
|
||||
double* impulse;
|
||||
float* impulse;
|
||||
a->rate = rate;
|
||||
impulse = FCurve::fc_impulse (a->nc, a->f_low, a->f_high, -20.0 * log10(a->f_high / a->f_low), 0.0, a->ctype, a->rate, 1.0 / (2.0 * a->size), 0, 0);
|
||||
FIRCORE::setImpulse_fircore (a->p, impulse, 1);
|
||||
@ -97,7 +97,7 @@ void EMPHP::setSamplerate_emphp (EMPHP *a, int rate)
|
||||
|
||||
void EMPHP::setSize_emphp (EMPHP *a, int size)
|
||||
{
|
||||
double* impulse;
|
||||
float* impulse;
|
||||
a->size = size;
|
||||
FIRCORE::setSize_fircore (a->p, a->size);
|
||||
impulse = FCurve::fc_impulse (a->nc, a->f_low, a->f_high, -20.0 * log10(a->f_high / a->f_low), 0.0, a->ctype, a->rate, 1.0 / (2.0 * a->size), 0, 0);
|
||||
@ -132,7 +132,7 @@ void EMPHP::SetFMEmphMP (TXA& txa, int mp)
|
||||
void EMPHP::SetFMEmphNC (TXA& txa, int nc)
|
||||
{
|
||||
EMPHP *a;
|
||||
double* impulse;
|
||||
float* impulse;
|
||||
txa.csDSP.lock();
|
||||
a = txa.preemph.p;
|
||||
if (a->nc != nc)
|
||||
@ -145,10 +145,10 @@ void EMPHP::SetFMEmphNC (TXA& txa, int nc)
|
||||
txa.csDSP.unlock();
|
||||
}
|
||||
|
||||
void EMPHP::SetFMPreEmphFreqs (TXA& txa, double low, double high)
|
||||
void EMPHP::SetFMPreEmphFreqs (TXA& txa, float low, float high)
|
||||
{
|
||||
EMPHP *a;
|
||||
double* impulse;
|
||||
float* impulse;
|
||||
txa.csDSP.lock();
|
||||
a = txa.preemph.p;
|
||||
if (a->f_low != low || a->f_high != high)
|
||||
@ -170,23 +170,23 @@ void EMPHP::SetFMPreEmphFreqs (TXA& txa, double low, double high)
|
||||
|
||||
void EMPH::calc_emph (EMPH *a)
|
||||
{
|
||||
a->infilt = new double[2 * a->size * 2]; // (double *)malloc0(2 * a->size * sizeof(complex));
|
||||
a->product = new double[2 * a->size * 2]; // (double *)malloc0(2 * a->size * sizeof(complex));
|
||||
a->infilt = new float[2 * a->size * 2]; // (float *)malloc0(2 * a->size * sizeof(complex));
|
||||
a->product = new float[2 * a->size * 2]; // (float *)malloc0(2 * a->size * sizeof(complex));
|
||||
a->mults = FCurve::fc_mults(a->size, a->f_low, a->f_high, -20.0 * log10(a->f_high / a->f_low), 0.0, a->ctype, a->rate, 1.0 / (2.0 * a->size), 0, 0);
|
||||
a->CFor = fftw_plan_dft_1d(2 * a->size, (fftw_complex *)a->infilt, (fftw_complex *)a->product, FFTW_FORWARD, FFTW_PATIENT);
|
||||
a->CRev = fftw_plan_dft_1d(2 * a->size, (fftw_complex *)a->product, (fftw_complex *)a->out, FFTW_BACKWARD, FFTW_PATIENT);
|
||||
a->CFor = fftwf_plan_dft_1d(2 * a->size, (fftwf_complex *)a->infilt, (fftwf_complex *)a->product, FFTW_FORWARD, FFTW_PATIENT);
|
||||
a->CRev = fftwf_plan_dft_1d(2 * a->size, (fftwf_complex *)a->product, (fftwf_complex *)a->out, FFTW_BACKWARD, FFTW_PATIENT);
|
||||
}
|
||||
|
||||
void EMPH::decalc_emph (EMPH *a)
|
||||
{
|
||||
fftw_destroy_plan(a->CRev);
|
||||
fftw_destroy_plan(a->CFor);
|
||||
fftwf_destroy_plan(a->CRev);
|
||||
fftwf_destroy_plan(a->CFor);
|
||||
delete[] (a->mults);
|
||||
delete[] (a->product);
|
||||
delete[] (a->infilt);
|
||||
}
|
||||
|
||||
EMPH* EMPH::create_emph (int run, int position, int size, double* in, double* out, int rate, int ctype, double f_low, double f_high)
|
||||
EMPH* EMPH::create_emph (int run, int position, int size, float* in, float* out, int rate, int ctype, float f_low, float f_high)
|
||||
{
|
||||
EMPH *a = new EMPH;
|
||||
a->run = run;
|
||||
@ -194,7 +194,7 @@ EMPH* EMPH::create_emph (int run, int position, int size, double* in, double* ou
|
||||
a->size = size;
|
||||
a->in = in;
|
||||
a->out = out;
|
||||
a->rate = (double)rate;
|
||||
a->rate = (float)rate;
|
||||
a->ctype = ctype;
|
||||
a->f_low = f_low;
|
||||
a->f_high = f_high;
|
||||
@ -216,11 +216,11 @@ void EMPH::flush_emph (EMPH *a)
|
||||
void EMPH::xemph (EMPH *a, int position)
|
||||
{
|
||||
int i;
|
||||
double I, Q;
|
||||
float I, Q;
|
||||
if (a->run && a->position == position)
|
||||
{
|
||||
memcpy (&(a->infilt[2 * a->size]), a->in, a->size * sizeof (wcomplex));
|
||||
fftw_execute (a->CFor);
|
||||
fftwf_execute (a->CFor);
|
||||
for (i = 0; i < 2 * a->size; i++)
|
||||
{
|
||||
I = a->product[2 * i + 0];
|
||||
@ -228,14 +228,14 @@ void EMPH::xemph (EMPH *a, int position)
|
||||
a->product[2 * i + 0] = I * a->mults[2 * i + 0] - Q * a->mults[2 * i + 1];
|
||||
a->product[2 * i + 1] = I * a->mults[2 * i + 1] + Q * a->mults[2 * i + 0];
|
||||
}
|
||||
fftw_execute (a->CRev);
|
||||
fftwf_execute (a->CRev);
|
||||
memcpy (a->infilt, &(a->infilt[2 * a->size]), a->size * sizeof(wcomplex));
|
||||
}
|
||||
else if (a->in != a->out)
|
||||
memcpy (a->out, a->in, a->size * sizeof (wcomplex));
|
||||
}
|
||||
|
||||
void EMPH::setBuffers_emph (EMPH *a, double* in, double* out)
|
||||
void EMPH::setBuffers_emph (EMPH *a, float* in, float* out)
|
||||
{
|
||||
decalc_emph (a);
|
||||
a->in = in;
|
||||
|
@ -49,27 +49,27 @@ public:
|
||||
int size;
|
||||
int nc;
|
||||
int mp;
|
||||
double* in;
|
||||
double* out;
|
||||
float* in;
|
||||
float* out;
|
||||
int ctype;
|
||||
double f_low;
|
||||
double f_high;
|
||||
double rate;
|
||||
float f_low;
|
||||
float f_high;
|
||||
float rate;
|
||||
FIRCORE *p;
|
||||
|
||||
static EMPHP* create_emphp (int run, int position, int size, int nc, int mp,
|
||||
double* in, double* out, int rate, int ctype, double f_low, double f_high);
|
||||
float* in, float* out, int rate, int ctype, float f_low, float f_high);
|
||||
static void destroy_emphp (EMPHP *a);
|
||||
static void flush_emphp (EMPHP *a);
|
||||
static void xemphp (EMPHP *a, int position);
|
||||
static void setBuffers_emphp (EMPHP *a, double* in, double* out);
|
||||
static void setBuffers_emphp (EMPHP *a, float* in, float* out);
|
||||
static void setSamplerate_emphp (EMPHP *a, int rate);
|
||||
static void setSize_emphp (EMPHP *a, int size);
|
||||
// TXA Properties
|
||||
static void SetFMEmphPosition (TXA& txa, int position);
|
||||
static void SetFMEmphMP (TXA& txa, int mp);
|
||||
static void SetFMEmphNC (TXA& txa, int nc);
|
||||
static void SetFMPreEmphFreqs(TXA& txa, double low, double high);
|
||||
static void SetFMPreEmphFreqs(TXA& txa, float low, float high);
|
||||
};
|
||||
|
||||
} // namespace WDSP
|
||||
@ -95,23 +95,23 @@ class WDSP_API EMPH
|
||||
int run;
|
||||
int position;
|
||||
int size;
|
||||
double* in;
|
||||
double* out;
|
||||
float* in;
|
||||
float* out;
|
||||
int ctype;
|
||||
double f_low;
|
||||
double f_high;
|
||||
double* infilt;
|
||||
double* product;
|
||||
double* mults;
|
||||
double rate;
|
||||
fftw_plan CFor;
|
||||
fftw_plan CRev;
|
||||
float f_low;
|
||||
float f_high;
|
||||
float* infilt;
|
||||
float* product;
|
||||
float* mults;
|
||||
float rate;
|
||||
fftwf_plan CFor;
|
||||
fftwf_plan CRev;
|
||||
|
||||
static EMPH* create_emph (int run, int position, int size, double* in, double* out, int rate, int ctype, double f_low, double f_high);
|
||||
static EMPH* create_emph (int run, int position, int size, float* in, float* out, int rate, int ctype, float f_low, float f_high);
|
||||
static void destroy_emph (EMPH *a);
|
||||
static void flush_emph (EMPH *a);
|
||||
static void xemph (EMPH *a, int position);
|
||||
static void setBuffers_emph (EMPH *a, double* in, double* out);
|
||||
static void setBuffers_emph (EMPH *a, float* in, float* out);
|
||||
static void setSamplerate_emph (EMPH *a, int rate);
|
||||
static void setSize_emph (EMPH *a, int size);
|
||||
|
||||
|
252
wdsp/eq.cpp
252
wdsp/eq.cpp
@ -36,22 +36,22 @@ namespace WDSP {
|
||||
|
||||
int EQP::fEQcompare (const void * a, const void * b)
|
||||
{
|
||||
if (*(double*)a < *(double*)b)
|
||||
if (*(float*)a < *(float*)b)
|
||||
return -1;
|
||||
else if (*(double*)a == *(double*)b)
|
||||
else if (*(float*)a == *(float*)b)
|
||||
return 0;
|
||||
else
|
||||
return 1;
|
||||
}
|
||||
|
||||
double* EQP::eq_impulse (int N, int nfreqs, double* F, double* G, double samplerate, double scale, int ctfmode, int wintype)
|
||||
float* EQP::eq_impulse (int N, int nfreqs, float* F, float* G, float samplerate, float scale, int ctfmode, int wintype)
|
||||
{
|
||||
double* fp = new double[nfreqs + 2]; // (double *) malloc0 ((nfreqs + 2) * sizeof (double));
|
||||
double* gp = new double[nfreqs + 2]; // (double *) malloc0 ((nfreqs + 2) * sizeof (double));
|
||||
double* A = new double[N / 2 + 1]; // (double *) malloc0 ((N / 2 + 1) * sizeof (double));
|
||||
double* sary = new double[2 * nfreqs]; // (double *) malloc0 (2 * nfreqs * sizeof (double));
|
||||
double gpreamp, f, frac;
|
||||
double* impulse;
|
||||
float* fp = new float[nfreqs + 2]; // (float *) malloc0 ((nfreqs + 2) * sizeof (float));
|
||||
float* gp = new float[nfreqs + 2]; // (float *) malloc0 ((nfreqs + 2) * sizeof (float));
|
||||
float* A = new float[N / 2 + 1]; // (float *) malloc0 ((N / 2 + 1) * sizeof (float));
|
||||
float* sary = new float[2 * nfreqs]; // (float *) malloc0 (2 * nfreqs * sizeof (float));
|
||||
float gpreamp, f, frac;
|
||||
float* impulse;
|
||||
int i, j, mid;
|
||||
fp[0] = 0.0;
|
||||
fp[nfreqs + 1] = 1.0;
|
||||
@ -68,7 +68,7 @@ double* EQP::eq_impulse (int N, int nfreqs, double* F, double* G, double sampler
|
||||
sary[j + 0] = fp[i];
|
||||
sary[j + 1] = gp[i];
|
||||
}
|
||||
qsort (sary, nfreqs, 2 * sizeof (double), fEQcompare);
|
||||
qsort (sary, nfreqs, 2 * sizeof (float), fEQcompare);
|
||||
for (i = 1, j = 0; i <= nfreqs; i++, j+=2)
|
||||
{
|
||||
fp[i] = sary[j + 0];
|
||||
@ -82,7 +82,7 @@ double* EQP::eq_impulse (int N, int nfreqs, double* F, double* G, double sampler
|
||||
{
|
||||
for (i = 0; i <= mid; i++)
|
||||
{
|
||||
f = (double)i / (double)mid;
|
||||
f = (float)i / (float)mid;
|
||||
while (f > fp[j + 1]) j++;
|
||||
frac = (f - fp[j]) / (fp[j + 1] - fp[j]);
|
||||
A[i] = pow (10.0, 0.05 * (frac * gp[j + 1] + (1.0 - frac) * gp[j] + gpreamp)) * scale;
|
||||
@ -92,7 +92,7 @@ double* EQP::eq_impulse (int N, int nfreqs, double* F, double* G, double sampler
|
||||
{
|
||||
for (i = 0; i < mid; i++)
|
||||
{
|
||||
f = ((double)i + 0.5) / (double)mid;
|
||||
f = ((float)i + 0.5) / (float)mid;
|
||||
while (f > fp[j + 1]) j++;
|
||||
frac = (f - fp[j]) / (fp[j + 1] - fp[j]);
|
||||
A[i] = pow (10.0, 0.05 * (frac * gp[j + 1] + (1.0 - frac) * gp[j] + gpreamp)) * scale;
|
||||
@ -101,19 +101,19 @@ double* EQP::eq_impulse (int N, int nfreqs, double* F, double* G, double sampler
|
||||
if (ctfmode == 0)
|
||||
{
|
||||
int k, low, high;
|
||||
double lowmag, highmag, flow4, fhigh4;
|
||||
float lowmag, highmag, flow4, fhigh4;
|
||||
if (N & 1)
|
||||
{
|
||||
low = (int)(fp[1] * mid);
|
||||
high = (int)(fp[nfreqs] * mid + 0.5);
|
||||
lowmag = A[low];
|
||||
highmag = A[high];
|
||||
flow4 = pow((double)low / (double)mid, 4.0);
|
||||
fhigh4 = pow((double)high / (double)mid, 4.0);
|
||||
flow4 = pow((float)low / (float)mid, 4.0);
|
||||
fhigh4 = pow((float)high / (float)mid, 4.0);
|
||||
k = low;
|
||||
while (--k >= 0)
|
||||
{
|
||||
f = (double)k / (double)mid;
|
||||
f = (float)k / (float)mid;
|
||||
lowmag *= (f * f * f * f) / flow4;
|
||||
if (lowmag < 1.0e-100) lowmag = 1.0e-100;
|
||||
A[k] = lowmag;
|
||||
@ -121,7 +121,7 @@ double* EQP::eq_impulse (int N, int nfreqs, double* F, double* G, double sampler
|
||||
k = high;
|
||||
while (++k <= mid)
|
||||
{
|
||||
f = (double)k / (double)mid;
|
||||
f = (float)k / (float)mid;
|
||||
highmag *= fhigh4 / (f * f * f * f);
|
||||
if (highmag < 1.0e-100) highmag = 1.0e-100;
|
||||
A[k] = highmag;
|
||||
@ -133,12 +133,12 @@ double* EQP::eq_impulse (int N, int nfreqs, double* F, double* G, double sampler
|
||||
high = (int)(fp[nfreqs] * mid - 0.5);
|
||||
lowmag = A[low];
|
||||
highmag = A[high];
|
||||
flow4 = pow((double)low / (double)mid, 4.0);
|
||||
fhigh4 = pow((double)high / (double)mid, 4.0);
|
||||
flow4 = pow((float)low / (float)mid, 4.0);
|
||||
fhigh4 = pow((float)high / (float)mid, 4.0);
|
||||
k = low;
|
||||
while (--k >= 0)
|
||||
{
|
||||
f = (double)k / (double)mid;
|
||||
f = (float)k / (float)mid;
|
||||
lowmag *= (f * f * f * f) / flow4;
|
||||
if (lowmag < 1.0e-100) lowmag = 1.0e-100;
|
||||
A[k] = lowmag;
|
||||
@ -146,7 +146,7 @@ double* EQP::eq_impulse (int N, int nfreqs, double* F, double* G, double sampler
|
||||
k = high;
|
||||
while (++k < mid)
|
||||
{
|
||||
f = (double)k / (double)mid;
|
||||
f = (float)k / (float)mid;
|
||||
highmag *= fhigh4 / (f * f * f * f);
|
||||
if (highmag < 1.0e-100) highmag = 1.0e-100;
|
||||
A[k] = highmag;
|
||||
@ -176,11 +176,11 @@ EQP* EQP::create_eqp (
|
||||
int size,
|
||||
int nc,
|
||||
int mp,
|
||||
double *in,
|
||||
double *out,
|
||||
float *in,
|
||||
float *out,
|
||||
int nfreqs,
|
||||
double* F,
|
||||
double* G,
|
||||
float* F,
|
||||
float* G,
|
||||
int ctfmode,
|
||||
int wintype,
|
||||
int samplerate
|
||||
@ -188,7 +188,7 @@ EQP* EQP::create_eqp (
|
||||
{
|
||||
// NOTE: 'nc' must be >= 'size'
|
||||
EQP *a = new EQP;
|
||||
double* impulse;
|
||||
float* impulse;
|
||||
a->run = run;
|
||||
a->size = size;
|
||||
a->nc = nc;
|
||||
@ -196,13 +196,13 @@ EQP* EQP::create_eqp (
|
||||
a->in = in;
|
||||
a->out = out;
|
||||
a->nfreqs = nfreqs;
|
||||
a->F = new double[a->nfreqs + 1]; // (double *) malloc0 ((a->nfreqs + 1) * sizeof (double));
|
||||
a->G = new double[a->nfreqs + 1]; // (double *) malloc0 ((a->nfreqs + 1) * sizeof (double));
|
||||
memcpy (a->F, F, (nfreqs + 1) * sizeof (double));
|
||||
memcpy (a->G, G, (nfreqs + 1) * sizeof (double));
|
||||
a->F = new float[a->nfreqs + 1]; // (float *) malloc0 ((a->nfreqs + 1) * sizeof (float));
|
||||
a->G = new float[a->nfreqs + 1]; // (float *) malloc0 ((a->nfreqs + 1) * sizeof (float));
|
||||
memcpy (a->F, F, (nfreqs + 1) * sizeof (float));
|
||||
memcpy (a->G, G, (nfreqs + 1) * sizeof (float));
|
||||
a->ctfmode = ctfmode;
|
||||
a->wintype = wintype;
|
||||
a->samplerate = (double)samplerate;
|
||||
a->samplerate = (float)samplerate;
|
||||
impulse = eq_impulse (a->nc, a->nfreqs, a->F, a->G, a->samplerate, 1.0 / (2.0 * a->size), a->ctfmode, a->wintype);
|
||||
a->p = FIRCORE::create_fircore (a->size, a->in, a->out, a->nc, a->mp, impulse);
|
||||
delete[] (impulse);
|
||||
@ -228,7 +228,7 @@ void EQP::xeqp (EQP *a)
|
||||
memcpy (a->out, a->in, a->size * sizeof (wcomplex));
|
||||
}
|
||||
|
||||
void EQP::setBuffers_eqp (EQP *a, double* in, double* out)
|
||||
void EQP::setBuffers_eqp (EQP *a, float* in, float* out)
|
||||
{
|
||||
a->in = in;
|
||||
a->out = out;
|
||||
@ -237,7 +237,7 @@ void EQP::setBuffers_eqp (EQP *a, double* in, double* out)
|
||||
|
||||
void EQP::setSamplerate_eqp (EQP *a, int rate)
|
||||
{
|
||||
double* impulse;
|
||||
float* impulse;
|
||||
a->samplerate = rate;
|
||||
impulse = eq_impulse (a->nc, a->nfreqs, a->F, a->G, a->samplerate, 1.0 / (2.0 * a->size), a->ctfmode, a->wintype);
|
||||
FIRCORE::setImpulse_fircore (a->p, impulse, 1);
|
||||
@ -246,7 +246,7 @@ void EQP::setSamplerate_eqp (EQP *a, int rate)
|
||||
|
||||
void EQP::setSize_eqp (EQP *a, int size)
|
||||
{
|
||||
double* impulse;
|
||||
float* impulse;
|
||||
a->size = size;
|
||||
FIRCORE::setSize_fircore (a->p, a->size);
|
||||
impulse = eq_impulse (a->nc, a->nfreqs, a->F, a->G, a->samplerate, 1.0 / (2.0 * a->size), a->ctfmode, a->wintype);
|
||||
@ -270,7 +270,7 @@ void EQP::SetEQRun (RXA& rxa, int run)
|
||||
void EQP::SetEQNC (RXA& rxa, int nc)
|
||||
{
|
||||
EQP *a;
|
||||
double* impulse;
|
||||
float* impulse;
|
||||
rxa.csDSP.lock();
|
||||
a = rxa.eqp.p;
|
||||
if (a->nc != nc)
|
||||
@ -294,18 +294,18 @@ void EQP::SetEQMP (RXA& rxa, int mp)
|
||||
}
|
||||
}
|
||||
|
||||
void EQP::SetEQProfile (RXA& rxa, int nfreqs, double* F, double* G)
|
||||
void EQP::SetEQProfile (RXA& rxa, int nfreqs, float* F, float* G)
|
||||
{
|
||||
EQP *a;
|
||||
double* impulse;
|
||||
float* impulse;
|
||||
a = rxa.eqp.p;
|
||||
delete[] (a->G);
|
||||
delete[] (a->F);
|
||||
a->nfreqs = nfreqs;
|
||||
a->F = new double[a->nfreqs + 1]; // (double *) malloc0 ((a->nfreqs + 1) * sizeof (double));
|
||||
a->G = new double[a->nfreqs + 1]; // (double *) malloc0 ((a->nfreqs + 1) * sizeof (double));
|
||||
memcpy (a->F, F, (nfreqs + 1) * sizeof (double));
|
||||
memcpy (a->G, G, (nfreqs + 1) * sizeof (double));
|
||||
a->F = new float[a->nfreqs + 1]; // (float *) malloc0 ((a->nfreqs + 1) * sizeof (float));
|
||||
a->G = new float[a->nfreqs + 1]; // (float *) malloc0 ((a->nfreqs + 1) * sizeof (float));
|
||||
memcpy (a->F, F, (nfreqs + 1) * sizeof (float));
|
||||
memcpy (a->G, G, (nfreqs + 1) * sizeof (float));
|
||||
impulse = eq_impulse (a->nc, a->nfreqs, a->F, a->G,
|
||||
a->samplerate, 1.0 / (2.0 * a->size), a->ctfmode, a->wintype);
|
||||
FIRCORE::setImpulse_fircore (a->p, impulse, 1);
|
||||
@ -315,7 +315,7 @@ void EQP::SetEQProfile (RXA& rxa, int nfreqs, double* F, double* G)
|
||||
void EQP::SetEQCtfmode (RXA& rxa, int mode)
|
||||
{
|
||||
EQP *a;
|
||||
double* impulse;
|
||||
float* impulse;
|
||||
a = rxa.eqp.p;
|
||||
a->ctfmode = mode;
|
||||
impulse = eq_impulse (a->nc, a->nfreqs, a->F, a->G, a->samplerate, 1.0 / (2.0 * a->size), a->ctfmode, a->wintype);
|
||||
@ -326,7 +326,7 @@ void EQP::SetEQCtfmode (RXA& rxa, int mode)
|
||||
void EQP::SetEQWintype (RXA& rxa, int wintype)
|
||||
{
|
||||
EQP *a;
|
||||
double* impulse;
|
||||
float* impulse;
|
||||
a = rxa.eqp.p;
|
||||
a->wintype = wintype;
|
||||
impulse = eq_impulse (a->nc, a->nfreqs, a->F, a->G, a->samplerate, 1.0 / (2.0 * a->size), a->ctfmode, a->wintype);
|
||||
@ -337,22 +337,22 @@ void EQP::SetEQWintype (RXA& rxa, int wintype)
|
||||
void EQP::SetGrphEQ (RXA& rxa, int *rxeq)
|
||||
{ // three band equalizer (legacy compatibility)
|
||||
EQP *a;
|
||||
double* impulse;
|
||||
float* impulse;
|
||||
a = rxa.eqp.p;
|
||||
delete[] (a->G);
|
||||
delete[] (a->F);
|
||||
a->nfreqs = 4;
|
||||
a->F = new double[a->nfreqs + 1]; // (double *) malloc0 ((a->nfreqs + 1) * sizeof (double));
|
||||
a->G = new double[a->nfreqs + 1]; // (double *) malloc0 ((a->nfreqs + 1) * sizeof (double));
|
||||
a->F = new float[a->nfreqs + 1]; // (float *) malloc0 ((a->nfreqs + 1) * sizeof (float));
|
||||
a->G = new float[a->nfreqs + 1]; // (float *) malloc0 ((a->nfreqs + 1) * sizeof (float));
|
||||
a->F[1] = 150.0;
|
||||
a->F[2] = 400.0;
|
||||
a->F[3] = 1500.0;
|
||||
a->F[4] = 6000.0;
|
||||
a->G[0] = (double)rxeq[0];
|
||||
a->G[1] = (double)rxeq[1];
|
||||
a->G[2] = (double)rxeq[1];
|
||||
a->G[3] = (double)rxeq[2];
|
||||
a->G[4] = (double)rxeq[3];
|
||||
a->G[0] = (float)rxeq[0];
|
||||
a->G[1] = (float)rxeq[1];
|
||||
a->G[2] = (float)rxeq[1];
|
||||
a->G[3] = (float)rxeq[2];
|
||||
a->G[4] = (float)rxeq[3];
|
||||
a->ctfmode = 0;
|
||||
impulse = eq_impulse (a->nc, a->nfreqs, a->F, a->G, a->samplerate, 1.0 / (2.0 * a->size), a->ctfmode, a->wintype);
|
||||
FIRCORE::setImpulse_fircore (a->p, impulse, 1);
|
||||
@ -362,14 +362,14 @@ void EQP::SetGrphEQ (RXA& rxa, int *rxeq)
|
||||
void EQP::SetGrphEQ10 (RXA& rxa, int *rxeq)
|
||||
{ // ten band equalizer (legacy compatibility)
|
||||
EQP *a;
|
||||
double* impulse;
|
||||
float* impulse;
|
||||
int i;
|
||||
a = rxa.eqp.p;
|
||||
delete[] (a->G);
|
||||
delete[] (a->F);
|
||||
a->nfreqs = 10;
|
||||
a->F = new double[a->nfreqs + 1]; // (double *) malloc0 ((a->nfreqs + 1) * sizeof (double));
|
||||
a->G = new double[a->nfreqs + 1]; // (double *) malloc0 ((a->nfreqs + 1) * sizeof (double));
|
||||
a->F = new float[a->nfreqs + 1]; // (float *) malloc0 ((a->nfreqs + 1) * sizeof (float));
|
||||
a->G = new float[a->nfreqs + 1]; // (float *) malloc0 ((a->nfreqs + 1) * sizeof (float));
|
||||
a->F[1] = 32.0;
|
||||
a->F[2] = 63.0;
|
||||
a->F[3] = 125.0;
|
||||
@ -381,7 +381,7 @@ void EQP::SetGrphEQ10 (RXA& rxa, int *rxeq)
|
||||
a->F[9] = 8000.0;
|
||||
a->F[10] = 16000.0;
|
||||
for (i = 0; i <= a->nfreqs; i++)
|
||||
a->G[i] = (double)rxeq[i];
|
||||
a->G[i] = (float)rxeq[i];
|
||||
a->ctfmode = 0;
|
||||
impulse = eq_impulse (a->nc, a->nfreqs, a->F, a->G, a->samplerate, 1.0 / (2.0 * a->size), a->ctfmode, a->wintype);
|
||||
// print_impulse ("rxeq.txt", a->nc, impulse, 1, 0);
|
||||
@ -405,7 +405,7 @@ void EQP::SetEQRun (TXA& txa, int run)
|
||||
void EQP::SetEQNC (TXA& txa, int nc)
|
||||
{
|
||||
EQP *a;
|
||||
double* impulse;
|
||||
float* impulse;
|
||||
txa.csDSP.lock();
|
||||
a = txa.eqp.p;
|
||||
if (a->nc != nc)
|
||||
@ -429,18 +429,18 @@ void EQP::SetEQMP (TXA& txa, int mp)
|
||||
}
|
||||
}
|
||||
|
||||
void EQP::SetEQProfile (TXA& txa, int nfreqs, double* F, double* G)
|
||||
void EQP::SetEQProfile (TXA& txa, int nfreqs, float* F, float* G)
|
||||
{
|
||||
EQP *a;
|
||||
double* impulse;
|
||||
float* impulse;
|
||||
a = txa.eqp.p;
|
||||
delete[] (a->G);
|
||||
delete[] (a->F);
|
||||
a->nfreqs = nfreqs;
|
||||
a->F = new double[a->nfreqs + 1]; // (double *) malloc0 ((a->nfreqs + 1) * sizeof (double));
|
||||
a->G = new double[a->nfreqs + 1]; // (double *) malloc0 ((a->nfreqs + 1) * sizeof (double));
|
||||
memcpy (a->F, F, (nfreqs + 1) * sizeof (double));
|
||||
memcpy (a->G, G, (nfreqs + 1) * sizeof (double));
|
||||
a->F = new float[a->nfreqs + 1]; // (float *) malloc0 ((a->nfreqs + 1) * sizeof (float));
|
||||
a->G = new float[a->nfreqs + 1]; // (float *) malloc0 ((a->nfreqs + 1) * sizeof (float));
|
||||
memcpy (a->F, F, (nfreqs + 1) * sizeof (float));
|
||||
memcpy (a->G, G, (nfreqs + 1) * sizeof (float));
|
||||
impulse = eq_impulse (a->nc, a->nfreqs, a->F, a->G, a->samplerate, 1.0 / (2.0 * a->size), a->ctfmode, a->wintype);
|
||||
FIRCORE::setImpulse_fircore (a->p, impulse, 1);
|
||||
delete[] (impulse);
|
||||
@ -449,7 +449,7 @@ void EQP::SetEQProfile (TXA& txa, int nfreqs, double* F, double* G)
|
||||
void EQP::SetEQCtfmode (TXA& txa, int mode)
|
||||
{
|
||||
EQP *a;
|
||||
double* impulse;
|
||||
float* impulse;
|
||||
a = txa.eqp.p;
|
||||
a->ctfmode = mode;
|
||||
impulse = eq_impulse (a->nc, a->nfreqs, a->F, a->G, a->samplerate, 1.0 / (2.0 * a->size), a->ctfmode, a->wintype);
|
||||
@ -460,7 +460,7 @@ void EQP::SetEQCtfmode (TXA& txa, int mode)
|
||||
void EQP::SetEQWintype (TXA& txa, int wintype)
|
||||
{
|
||||
EQP *a;
|
||||
double* impulse;
|
||||
float* impulse;
|
||||
a = txa.eqp.p;
|
||||
a->wintype = wintype;
|
||||
impulse = eq_impulse (a->nc, a->nfreqs, a->F, a->G, a->samplerate, 1.0 / (2.0 * a->size), a->ctfmode, a->wintype);
|
||||
@ -471,22 +471,22 @@ void EQP::SetEQWintype (TXA& txa, int wintype)
|
||||
void EQP::SetGrphEQ (TXA& txa, int *txeq)
|
||||
{ // three band equalizer (legacy compatibility)
|
||||
EQP *a;
|
||||
double* impulse;
|
||||
float* impulse;
|
||||
a = txa.eqp.p;
|
||||
delete[] (a->G);
|
||||
delete[] (a->F);
|
||||
a->nfreqs = 4;
|
||||
a->F = new double[a->nfreqs + 1]; // (double *) malloc0 ((a->nfreqs + 1) * sizeof (double));
|
||||
a->G = new double[a->nfreqs + 1]; // (double *) malloc0 ((a->nfreqs + 1) * sizeof (double));
|
||||
a->F = new float[a->nfreqs + 1]; // (float *) malloc0 ((a->nfreqs + 1) * sizeof (float));
|
||||
a->G = new float[a->nfreqs + 1]; // (float *) malloc0 ((a->nfreqs + 1) * sizeof (float));
|
||||
a->F[1] = 150.0;
|
||||
a->F[2] = 400.0;
|
||||
a->F[3] = 1500.0;
|
||||
a->F[4] = 6000.0;
|
||||
a->G[0] = (double)txeq[0];
|
||||
a->G[1] = (double)txeq[1];
|
||||
a->G[2] = (double)txeq[1];
|
||||
a->G[3] = (double)txeq[2];
|
||||
a->G[4] = (double)txeq[3];
|
||||
a->G[0] = (float)txeq[0];
|
||||
a->G[1] = (float)txeq[1];
|
||||
a->G[2] = (float)txeq[1];
|
||||
a->G[3] = (float)txeq[2];
|
||||
a->G[4] = (float)txeq[3];
|
||||
a->ctfmode = 0;
|
||||
impulse = eq_impulse (a->nc, a->nfreqs, a->F, a->G, a->samplerate, 1.0 / (2.0 * a->size), a->ctfmode, a->wintype);
|
||||
FIRCORE::setImpulse_fircore (a->p, impulse, 1);
|
||||
@ -496,14 +496,14 @@ void EQP::SetGrphEQ (TXA& txa, int *txeq)
|
||||
void EQP::SetGrphEQ10 (TXA& txa, int *txeq)
|
||||
{ // ten band equalizer (legacy compatibility)
|
||||
EQP *a;
|
||||
double* impulse;
|
||||
float* impulse;
|
||||
int i;
|
||||
a = txa.eqp.p;
|
||||
delete[] (a->G);
|
||||
delete[] (a->F);
|
||||
a->nfreqs = 10;
|
||||
a->F = new double[a->nfreqs + 1]; // (double *) malloc0 ((a->nfreqs + 1) * sizeof (double));
|
||||
a->G = new double[a->nfreqs + 1]; // (double *) malloc0 ((a->nfreqs + 1) * sizeof (double));
|
||||
a->F = new float[a->nfreqs + 1]; // (float *) malloc0 ((a->nfreqs + 1) * sizeof (float));
|
||||
a->G = new float[a->nfreqs + 1]; // (float *) malloc0 ((a->nfreqs + 1) * sizeof (float));
|
||||
a->F[1] = 32.0;
|
||||
a->F[2] = 63.0;
|
||||
a->F[3] = 125.0;
|
||||
@ -515,7 +515,7 @@ void EQP::SetGrphEQ10 (TXA& txa, int *txeq)
|
||||
a->F[9] = 8000.0;
|
||||
a->F[10] = 16000.0;
|
||||
for (i = 0; i <= a->nfreqs; i++)
|
||||
a->G[i] = (double)txeq[i];
|
||||
a->G[i] = (float)txeq[i];
|
||||
a->ctfmode = 0;
|
||||
impulse = eq_impulse (a->nc, a->nfreqs, a->F, a->G, a->samplerate, 1.0 / (2.0 * a->size), a->ctfmode, a->wintype);
|
||||
FIRCORE::setImpulse_fircore (a->p, impulse, 1);
|
||||
@ -529,34 +529,34 @@ void EQP::SetGrphEQ10 (TXA& txa, int *txeq)
|
||||
********************************************************************************************************/
|
||||
|
||||
|
||||
double* EQP::eq_mults (int size, int nfreqs, double* F, double* G, double samplerate, double scale, int ctfmode, int wintype)
|
||||
float* EQP::eq_mults (int size, int nfreqs, float* F, float* G, float samplerate, float scale, int ctfmode, int wintype)
|
||||
{
|
||||
double* impulse = eq_impulse (size + 1, nfreqs, F, G, samplerate, scale, ctfmode, wintype);
|
||||
double* mults = FIR::fftcv_mults(2 * size, impulse);
|
||||
float* impulse = eq_impulse (size + 1, nfreqs, F, G, samplerate, scale, ctfmode, wintype);
|
||||
float* mults = FIR::fftcv_mults(2 * size, impulse);
|
||||
delete[] (impulse);
|
||||
return mults;
|
||||
}
|
||||
|
||||
void EQ::calc_eq (EQ *a)
|
||||
{
|
||||
a->scale = 1.0 / (double)(2 * a->size);
|
||||
a->infilt = new double[2 * a->size * 2]; // (double *)malloc0(2 * a->size * sizeof(complex));
|
||||
a->product = new double[2 * a->size * 2]; // (double *)malloc0(2 * a->size * sizeof(complex));
|
||||
a->CFor = fftw_plan_dft_1d(2 * a->size, (fftw_complex *)a->infilt, (fftw_complex *)a->product, FFTW_FORWARD, FFTW_PATIENT);
|
||||
a->CRev = fftw_plan_dft_1d(2 * a->size, (fftw_complex *)a->product, (fftw_complex *)a->out, FFTW_BACKWARD, FFTW_PATIENT);
|
||||
a->scale = 1.0 / (float)(2 * a->size);
|
||||
a->infilt = new float[2 * a->size * 2]; // (float *)malloc0(2 * a->size * sizeof(complex));
|
||||
a->product = new float[2 * a->size * 2]; // (float *)malloc0(2 * a->size * sizeof(complex));
|
||||
a->CFor = fftwf_plan_dft_1d(2 * a->size, (fftwf_complex *)a->infilt, (fftwf_complex *)a->product, FFTW_FORWARD, FFTW_PATIENT);
|
||||
a->CRev = fftwf_plan_dft_1d(2 * a->size, (fftwf_complex *)a->product, (fftwf_complex *)a->out, FFTW_BACKWARD, FFTW_PATIENT);
|
||||
a->mults = EQP::eq_mults(a->size, a->nfreqs, a->F, a->G, a->samplerate, a->scale, a->ctfmode, a->wintype);
|
||||
}
|
||||
|
||||
void EQ::decalc_eq (EQ *a)
|
||||
{
|
||||
fftw_destroy_plan(a->CRev);
|
||||
fftw_destroy_plan(a->CFor);
|
||||
fftwf_destroy_plan(a->CRev);
|
||||
fftwf_destroy_plan(a->CFor);
|
||||
delete[] (a->mults);
|
||||
delete[] (a->product);
|
||||
delete[] (a->infilt);
|
||||
}
|
||||
|
||||
EQ* EQ::create_eq (int run, int size, double *in, double *out, int nfreqs, double* F, double* G, int ctfmode, int wintype, int samplerate)
|
||||
EQ* EQ::create_eq (int run, int size, float *in, float *out, int nfreqs, float* F, float* G, int ctfmode, int wintype, int samplerate)
|
||||
{
|
||||
EQ *a = new EQ;
|
||||
a->run = run;
|
||||
@ -564,13 +564,13 @@ EQ* EQ::create_eq (int run, int size, double *in, double *out, int nfreqs, doubl
|
||||
a->in = in;
|
||||
a->out = out;
|
||||
a->nfreqs = nfreqs;
|
||||
a->F = new double[a->nfreqs + 1]; // (double *) malloc0 ((a->nfreqs + 1) * sizeof (double));
|
||||
a->G = new double[a->nfreqs + 1]; // (double *) malloc0 ((a->nfreqs + 1) * sizeof (double));
|
||||
memcpy (a->F, F, (nfreqs + 1) * sizeof (double));
|
||||
memcpy (a->G, G, (nfreqs + 1) * sizeof (double));
|
||||
a->F = new float[a->nfreqs + 1]; // (float *) malloc0 ((a->nfreqs + 1) * sizeof (float));
|
||||
a->G = new float[a->nfreqs + 1]; // (float *) malloc0 ((a->nfreqs + 1) * sizeof (float));
|
||||
memcpy (a->F, F, (nfreqs + 1) * sizeof (float));
|
||||
memcpy (a->G, G, (nfreqs + 1) * sizeof (float));
|
||||
a->ctfmode = ctfmode;
|
||||
a->wintype = wintype;
|
||||
a->samplerate = (double)samplerate;
|
||||
a->samplerate = (float)samplerate;
|
||||
calc_eq (a);
|
||||
return a;
|
||||
}
|
||||
@ -591,11 +591,11 @@ void EQ::flush_eq (EQ *a)
|
||||
void EQ::xeq (EQ *a)
|
||||
{
|
||||
int i;
|
||||
double I, Q;
|
||||
float I, Q;
|
||||
if (a->run)
|
||||
{
|
||||
memcpy (&(a->infilt[2 * a->size]), a->in, a->size * sizeof (wcomplex));
|
||||
fftw_execute (a->CFor);
|
||||
fftwf_execute (a->CFor);
|
||||
for (i = 0; i < 2 * a->size; i++)
|
||||
{
|
||||
I = a->product[2 * i + 0];
|
||||
@ -603,14 +603,14 @@ void EQ::xeq (EQ *a)
|
||||
a->product[2 * i + 0] = I * a->mults[2 * i + 0] - Q * a->mults[2 * i + 1];
|
||||
a->product[2 * i + 1] = I * a->mults[2 * i + 1] + Q * a->mults[2 * i + 0];
|
||||
}
|
||||
fftw_execute (a->CRev);
|
||||
fftwf_execute (a->CRev);
|
||||
memcpy (a->infilt, &(a->infilt[2 * a->size]), a->size * sizeof(wcomplex));
|
||||
}
|
||||
else if (a->in != a->out)
|
||||
memcpy (a->out, a->in, a->size * sizeof (wcomplex));
|
||||
}
|
||||
|
||||
void EQ::setBuffers_eq (EQ *a, double* in, double* out)
|
||||
void EQ::setBuffers_eq (EQ *a, float* in, float* out)
|
||||
{
|
||||
decalc_eq (a);
|
||||
a->in = in;
|
||||
@ -647,7 +647,7 @@ void SetRXAEQRun (int channel, int run)
|
||||
}
|
||||
|
||||
PORT
|
||||
void SetRXAEQProfile (int channel, int nfreqs, double* F, double* G)
|
||||
void SetRXAEQProfile (int channel, int nfreqs, float* F, float* G)
|
||||
{
|
||||
EQ a;
|
||||
ch.csDSP.lock();
|
||||
@ -655,10 +655,10 @@ void SetRXAEQProfile (int channel, int nfreqs, double* F, double* G)
|
||||
delete[] (a->G);
|
||||
delete[] (a->F);
|
||||
a->nfreqs = nfreqs;
|
||||
a->F = (double *) malloc0 ((a->nfreqs + 1) * sizeof (double));
|
||||
a->G = (double *) malloc0 ((a->nfreqs + 1) * sizeof (double));
|
||||
memcpy (a->F, F, (nfreqs + 1) * sizeof (double));
|
||||
memcpy (a->G, G, (nfreqs + 1) * sizeof (double));
|
||||
a->F = (float *) malloc0 ((a->nfreqs + 1) * sizeof (float));
|
||||
a->G = (float *) malloc0 ((a->nfreqs + 1) * sizeof (float));
|
||||
memcpy (a->F, F, (nfreqs + 1) * sizeof (float));
|
||||
memcpy (a->G, G, (nfreqs + 1) * sizeof (float));
|
||||
delete[] (a->mults);
|
||||
a->mults = eq_mults (a->size, a->nfreqs, a->F, a->G, a->samplerate, a->scale, a->ctfmode, a->wintype);
|
||||
ch.csDSP.unlock();
|
||||
@ -697,17 +697,17 @@ void SetRXAGrphEQ (int channel, int *rxeq)
|
||||
delete[] (a->G);
|
||||
delete[] (a->F);
|
||||
a->nfreqs = 4;
|
||||
a->F = (double *) malloc0 ((a->nfreqs + 1) * sizeof (double));
|
||||
a->G = (double *) malloc0 ((a->nfreqs + 1) * sizeof (double));
|
||||
a->F = (float *) malloc0 ((a->nfreqs + 1) * sizeof (float));
|
||||
a->G = (float *) malloc0 ((a->nfreqs + 1) * sizeof (float));
|
||||
a->F[1] = 150.0;
|
||||
a->F[2] = 400.0;
|
||||
a->F[3] = 1500.0;
|
||||
a->F[4] = 6000.0;
|
||||
a->G[0] = (double)rxeq[0];
|
||||
a->G[1] = (double)rxeq[1];
|
||||
a->G[2] = (double)rxeq[1];
|
||||
a->G[3] = (double)rxeq[2];
|
||||
a->G[4] = (double)rxeq[3];
|
||||
a->G[0] = (float)rxeq[0];
|
||||
a->G[1] = (float)rxeq[1];
|
||||
a->G[2] = (float)rxeq[1];
|
||||
a->G[3] = (float)rxeq[2];
|
||||
a->G[4] = (float)rxeq[3];
|
||||
a->ctfmode = 0;
|
||||
delete[] (a->mults);
|
||||
a->mults = eq_mults (a->size, a->nfreqs, a->F, a->G, a->samplerate, a->scale, a->ctfmode, a->wintype);
|
||||
@ -724,8 +724,8 @@ void SetRXAGrphEQ10 (int channel, int *rxeq)
|
||||
delete[] (a->G);
|
||||
delete[] (a->F);
|
||||
a->nfreqs = 10;
|
||||
a->F = (double *) malloc0 ((a->nfreqs + 1) * sizeof (double));
|
||||
a->G = (double *) malloc0 ((a->nfreqs + 1) * sizeof (double));
|
||||
a->F = (float *) malloc0 ((a->nfreqs + 1) * sizeof (float));
|
||||
a->G = (float *) malloc0 ((a->nfreqs + 1) * sizeof (float));
|
||||
a->F[1] = 32.0;
|
||||
a->F[2] = 63.0;
|
||||
a->F[3] = 125.0;
|
||||
@ -737,7 +737,7 @@ void SetRXAGrphEQ10 (int channel, int *rxeq)
|
||||
a->F[9] = 8000.0;
|
||||
a->F[10] = 16000.0;
|
||||
for (i = 0; i <= a->nfreqs; i++)
|
||||
a->G[i] = (double)rxeq[i];
|
||||
a->G[i] = (float)rxeq[i];
|
||||
a->ctfmode = 0;
|
||||
delete[] (a->mults);
|
||||
a->mults = eq_mults (a->size, a->nfreqs, a->F, a->G, a->samplerate, a->scale, a->ctfmode, a->wintype);
|
||||
@ -759,7 +759,7 @@ void SetTXAEQRun (int channel, int run)
|
||||
}
|
||||
|
||||
PORT
|
||||
void SetTXAEQProfile (int channel, int nfreqs, double* F, double* G)
|
||||
void SetTXAEQProfile (int channel, int nfreqs, float* F, float* G)
|
||||
{
|
||||
EQ a;
|
||||
ch.csDSP.lock();
|
||||
@ -767,10 +767,10 @@ void SetTXAEQProfile (int channel, int nfreqs, double* F, double* G)
|
||||
delete[] (a->G);
|
||||
delete[] (a->F);
|
||||
a->nfreqs = nfreqs;
|
||||
a->F = (double *) malloc0 ((a->nfreqs + 1) * sizeof (double));
|
||||
a->G = (double *) malloc0 ((a->nfreqs + 1) * sizeof (double));
|
||||
memcpy (a->F, F, (nfreqs + 1) * sizeof (double));
|
||||
memcpy (a->G, G, (nfreqs + 1) * sizeof (double));
|
||||
a->F = (float *) malloc0 ((a->nfreqs + 1) * sizeof (float));
|
||||
a->G = (float *) malloc0 ((a->nfreqs + 1) * sizeof (float));
|
||||
memcpy (a->F, F, (nfreqs + 1) * sizeof (float));
|
||||
memcpy (a->G, G, (nfreqs + 1) * sizeof (float));
|
||||
delete[] (a->mults);
|
||||
a->mults = eq_mults (a->size, a->nfreqs, a->F, a->G, a->samplerate, a->scale, a->ctfmode, a->wintype);
|
||||
ch.csDSP.unlock();
|
||||
@ -809,17 +809,17 @@ void SetTXAGrphEQ (int channel, int *txeq)
|
||||
delete[] (a->G);
|
||||
delete[] (a->F);
|
||||
a->nfreqs = 4;
|
||||
a->F = (double *) malloc0 ((a->nfreqs + 1) * sizeof (double));
|
||||
a->G = (double *) malloc0 ((a->nfreqs + 1) * sizeof (double));
|
||||
a->F = (float *) malloc0 ((a->nfreqs + 1) * sizeof (float));
|
||||
a->G = (float *) malloc0 ((a->nfreqs + 1) * sizeof (float));
|
||||
a->F[1] = 150.0;
|
||||
a->F[2] = 400.0;
|
||||
a->F[3] = 1500.0;
|
||||
a->F[4] = 6000.0;
|
||||
a->G[0] = (double)txeq[0];
|
||||
a->G[1] = (double)txeq[1];
|
||||
a->G[2] = (double)txeq[1];
|
||||
a->G[3] = (double)txeq[2];
|
||||
a->G[4] = (double)txeq[3];
|
||||
a->G[0] = (float)txeq[0];
|
||||
a->G[1] = (float)txeq[1];
|
||||
a->G[2] = (float)txeq[1];
|
||||
a->G[3] = (float)txeq[2];
|
||||
a->G[4] = (float)txeq[3];
|
||||
a->ctfmode = 0;
|
||||
delete[] (a->mults);
|
||||
a->mults = eq_mults (a->size, a->nfreqs, a->F, a->G, a->samplerate, a->scale, a->ctfmode, a->wintype);
|
||||
@ -836,8 +836,8 @@ void SetTXAGrphEQ10 (int channel, int *txeq)
|
||||
delete[] (a->G);
|
||||
delete[] (a->F);
|
||||
a->nfreqs = 10;
|
||||
a->F = (double *) malloc0 ((a->nfreqs + 1) * sizeof (double));
|
||||
a->G = (double *) malloc0 ((a->nfreqs + 1) * sizeof (double));
|
||||
a->F = (float *) malloc0 ((a->nfreqs + 1) * sizeof (float));
|
||||
a->G = (float *) malloc0 ((a->nfreqs + 1) * sizeof (float));
|
||||
a->F[1] = 32.0;
|
||||
a->F[2] = 63.0;
|
||||
a->F[3] = 125.0;
|
||||
@ -849,7 +849,7 @@ void SetTXAGrphEQ10 (int channel, int *txeq)
|
||||
a->F[9] = 8000.0;
|
||||
a->F[10] = 16000.0;
|
||||
for (i = 0; i <= a->nfreqs; i++)
|
||||
a->G[i] = (double)txeq[i];
|
||||
a->G[i] = (float)txeq[i];
|
||||
a->ctfmode = 0;
|
||||
delete[] (a->mults);
|
||||
a->mults = eq_mults (a->size, a->nfreqs, a->F, a->G, a->samplerate, a->scale, a->ctfmode, a->wintype);
|
||||
|
56
wdsp/eq.hpp
56
wdsp/eq.hpp
@ -49,14 +49,14 @@ public:
|
||||
int size;
|
||||
int nc;
|
||||
int mp;
|
||||
double* in;
|
||||
double* out;
|
||||
float* in;
|
||||
float* out;
|
||||
int nfreqs;
|
||||
double* F;
|
||||
double* G;
|
||||
float* F;
|
||||
float* G;
|
||||
int ctfmode;
|
||||
int wintype;
|
||||
double samplerate;
|
||||
float samplerate;
|
||||
FIRCORE *p;
|
||||
|
||||
static EQP* create_eqp (
|
||||
@ -64,27 +64,27 @@ public:
|
||||
int size,
|
||||
int nc,
|
||||
int mp,
|
||||
double *in,
|
||||
double *out,
|
||||
float *in,
|
||||
float *out,
|
||||
int nfreqs,
|
||||
double* F,
|
||||
double* G,
|
||||
float* F,
|
||||
float* G,
|
||||
int ctfmode,
|
||||
int wintype,
|
||||
int samplerate
|
||||
);
|
||||
static double* eq_impulse (int N, int nfreqs, double* F, double* G, double samplerate, double scale, int ctfmode, int wintype);
|
||||
static float* eq_impulse (int N, int nfreqs, float* F, float* G, float samplerate, float scale, int ctfmode, int wintype);
|
||||
static void destroy_eqp (EQP *a);
|
||||
static void flush_eqp (EQP *a);
|
||||
static void xeqp (EQP *a);
|
||||
static void setBuffers_eqp (EQP *a, double* in, double* out);
|
||||
static void setBuffers_eqp (EQP *a, float* in, float* out);
|
||||
static void setSamplerate_eqp (EQP *a, int rate);
|
||||
static void setSize_eqp (EQP *a, int size);
|
||||
// RXA
|
||||
static void SetEQRun (RXA& rxa, int run);
|
||||
static void SetEQNC (RXA& rxa, int nc);
|
||||
static void SetEQMP (RXA& rxa, int mp);
|
||||
static void SetEQProfile (RXA& rxa, int nfreqs, double* F, double* G);
|
||||
static void SetEQProfile (RXA& rxa, int nfreqs, float* F, float* G);
|
||||
static void SetEQCtfmode (RXA& rxa, int mode);
|
||||
static void SetEQWintype (RXA& rxa, int wintype);
|
||||
static void SetGrphEQ (RXA& rxa, int *rxeq);
|
||||
@ -93,13 +93,13 @@ public:
|
||||
static void SetEQRun (TXA& txa, int run);
|
||||
static void SetEQNC (TXA& txa, int nc);
|
||||
static void SetEQMP (TXA& txa, int mp);
|
||||
static void SetEQProfile (TXA& txa, int nfreqs, double* F, double* G);
|
||||
static void SetEQProfile (TXA& txa, int nfreqs, float* F, float* G);
|
||||
static void SetEQCtfmode (TXA& txa, int mode);
|
||||
static void SetEQWintype (TXA& txa, int wintype);
|
||||
static void SetGrphEQ (TXA& txa, int *txeq);
|
||||
static void SetGrphEQ10 (TXA& txa, int *txeq);
|
||||
|
||||
static double* eq_mults (int size, int nfreqs, double* F, double* G, double samplerate, double scale, int ctfmode, int wintype);
|
||||
static float* eq_mults (int size, int nfreqs, float* F, float* G, float samplerate, float scale, int ctfmode, int wintype);
|
||||
|
||||
private:
|
||||
static int fEQcompare (const void * a, const void * b);
|
||||
@ -130,27 +130,27 @@ class WDSP_API EQ
|
||||
public:
|
||||
int run;
|
||||
int size;
|
||||
double* in;
|
||||
double* out;
|
||||
float* in;
|
||||
float* out;
|
||||
int nfreqs;
|
||||
double* F;
|
||||
double* G;
|
||||
double* infilt;
|
||||
double* product;
|
||||
double* mults;
|
||||
double scale;
|
||||
float* F;
|
||||
float* G;
|
||||
float* infilt;
|
||||
float* product;
|
||||
float* mults;
|
||||
float scale;
|
||||
int ctfmode;
|
||||
int wintype;
|
||||
double samplerate;
|
||||
fftw_plan CFor;
|
||||
fftw_plan CRev;
|
||||
float samplerate;
|
||||
fftwf_plan CFor;
|
||||
fftwf_plan CRev;
|
||||
|
||||
static EQ* create_eq (int run, int size, double *in, double *out, int nfreqs, double* F, double* G, int ctfmode, int wintype, int samplerate);
|
||||
// static double* eq_mults (int size, int nfreqs, double* F, double* G, double samplerate, double scale, int ctfmode, int wintype);
|
||||
static EQ* create_eq (int run, int size, float *in, float *out, int nfreqs, float* F, float* G, int ctfmode, int wintype, int samplerate);
|
||||
// static float* eq_mults (int size, int nfreqs, float* F, float* G, float samplerate, float scale, int ctfmode, int wintype);
|
||||
static void destroy_eq (EQ *a);
|
||||
static void flush_eq (EQ *a);
|
||||
static void xeq (EQ *a);
|
||||
static void setBuffers_eq (EQ *a, double* in, double* out);
|
||||
static void setBuffers_eq (EQ *a, float* in, float* out);
|
||||
static void setSamplerate_eq (EQ *a, int rate);
|
||||
static void setSize_eq (EQ *a, int size);
|
||||
|
||||
|
@ -31,19 +31,19 @@ warren@wpratt.com
|
||||
|
||||
namespace WDSP {
|
||||
|
||||
double* FCurve::fc_impulse (int nc, double f0, double f1, double g0, double, int curve, double samplerate, double scale, int ctfmode, int wintype)
|
||||
float* FCurve::fc_impulse (int nc, float f0, float f1, float g0, float, int curve, float samplerate, float scale, int ctfmode, int wintype)
|
||||
{
|
||||
double* A = new double[nc / 2 + 1]; // (double *) malloc0 ((nc / 2 + 1) * sizeof (double));
|
||||
float* A = new float[nc / 2 + 1]; // (float *) malloc0 ((nc / 2 + 1) * sizeof (float));
|
||||
int i;
|
||||
double fn, f;
|
||||
double* impulse;
|
||||
float fn, f;
|
||||
float* impulse;
|
||||
int mid = nc / 2;
|
||||
double g0_lin = pow(10.0, g0 / 20.0);
|
||||
float g0_lin = pow(10.0, g0 / 20.0);
|
||||
if (nc & 1)
|
||||
{
|
||||
for (i = 0; i <= mid; i++)
|
||||
{
|
||||
fn = (double)i / (double)mid;
|
||||
fn = (float)i / (float)mid;
|
||||
f = fn * samplerate / 2.0;
|
||||
switch (curve)
|
||||
{
|
||||
@ -66,7 +66,7 @@ double* FCurve::fc_impulse (int nc, double f0, double f1, double g0, double, int
|
||||
{
|
||||
for (i = 0; i < mid; i++)
|
||||
{
|
||||
fn = ((double)i + 0.5) / (double)mid;
|
||||
fn = ((float)i + 0.5) / (float)mid;
|
||||
f = fn * samplerate / 2.0;
|
||||
switch (curve)
|
||||
{
|
||||
@ -88,19 +88,19 @@ double* FCurve::fc_impulse (int nc, double f0, double f1, double g0, double, int
|
||||
if (ctfmode == 0)
|
||||
{
|
||||
int k, low, high;
|
||||
double lowmag, highmag, flow4, fhigh4;
|
||||
float lowmag, highmag, flow4, fhigh4;
|
||||
if (nc & 1)
|
||||
{
|
||||
low = (int)(2.0 * f0 / samplerate * mid);
|
||||
high = (int)(2.0 * f1 / samplerate * mid + 0.5);
|
||||
lowmag = A[low];
|
||||
highmag = A[high];
|
||||
flow4 = pow((double)low / (double)mid, 4.0);
|
||||
fhigh4 = pow((double)high / (double)mid, 4.0);
|
||||
flow4 = pow((float)low / (float)mid, 4.0);
|
||||
fhigh4 = pow((float)high / (float)mid, 4.0);
|
||||
k = low;
|
||||
while (--k >= 0)
|
||||
{
|
||||
f = (double)k / (double)mid;
|
||||
f = (float)k / (float)mid;
|
||||
lowmag *= (f * f * f * f) / flow4;
|
||||
if (lowmag < 1.0e-100) lowmag = 1.0e-100;
|
||||
A[k] = lowmag;
|
||||
@ -108,7 +108,7 @@ double* FCurve::fc_impulse (int nc, double f0, double f1, double g0, double, int
|
||||
k = high;
|
||||
while (++k <= mid)
|
||||
{
|
||||
f = (double)k / (double)mid;
|
||||
f = (float)k / (float)mid;
|
||||
highmag *= fhigh4 / (f * f * f * f);
|
||||
if (highmag < 1.0e-100) highmag = 1.0e-100;
|
||||
A[k] = highmag;
|
||||
@ -120,12 +120,12 @@ double* FCurve::fc_impulse (int nc, double f0, double f1, double g0, double, int
|
||||
high = (int)(2.0 * f1 / samplerate * mid - 0.5);
|
||||
lowmag = A[low];
|
||||
highmag = A[high];
|
||||
flow4 = pow((double)low / (double)mid, 4.0);
|
||||
fhigh4 = pow((double)high / (double)mid, 4.0);
|
||||
flow4 = pow((float)low / (float)mid, 4.0);
|
||||
fhigh4 = pow((float)high / (float)mid, 4.0);
|
||||
k = low;
|
||||
while (--k >= 0)
|
||||
{
|
||||
f = (double)k / (double)mid;
|
||||
f = (float)k / (float)mid;
|
||||
lowmag *= (f * f * f * f) / flow4;
|
||||
if (lowmag < 1.0e-100) lowmag = 1.0e-100;
|
||||
A[k] = lowmag;
|
||||
@ -133,7 +133,7 @@ double* FCurve::fc_impulse (int nc, double f0, double f1, double g0, double, int
|
||||
k = high;
|
||||
while (++k < mid)
|
||||
{
|
||||
f = (double)k / (double)mid;
|
||||
f = (float)k / (float)mid;
|
||||
highmag *= fhigh4 / (f * f * f * f);
|
||||
if (highmag < 1.0e-100) highmag = 1.0e-100;
|
||||
A[k] = highmag;
|
||||
@ -150,10 +150,10 @@ double* FCurve::fc_impulse (int nc, double f0, double f1, double g0, double, int
|
||||
}
|
||||
|
||||
// generate mask for Overlap-Save Filter
|
||||
double* FCurve::fc_mults (int size, double f0, double f1, double g0, double g1, int curve, double samplerate, double scale, int ctfmode, int wintype)
|
||||
float* FCurve::fc_mults (int size, float f0, float f1, float g0, float g1, int curve, float samplerate, float scale, int ctfmode, int wintype)
|
||||
{
|
||||
double* impulse = fc_impulse (size + 1, f0, f1, g0, g1, curve, samplerate, scale, ctfmode, wintype);
|
||||
double* mults = FIR::fftcv_mults(2 * size, impulse);
|
||||
float* impulse = fc_impulse (size + 1, f0, f1, g0, g1, curve, samplerate, scale, ctfmode, wintype);
|
||||
float* mults = FIR::fftcv_mults(2 * size, impulse);
|
||||
delete[] (impulse);
|
||||
return mults;
|
||||
}
|
||||
|
@ -35,8 +35,8 @@ namespace WDSP {
|
||||
class WDSP_API FCurve
|
||||
{
|
||||
public:
|
||||
static double* fc_impulse (int nc, double f0, double f1, double g0, double g1, int curve, double samplerate, double scale, int ctfmode, int wintype);
|
||||
static double* fc_mults (int size, double f0, double f1, double g0, double g1, int curve, double samplerate, double scale, int ctfmode, int wintype);
|
||||
static float* fc_impulse (int nc, float f0, float f1, float g0, float g1, int curve, float samplerate, float scale, int ctfmode, int wintype);
|
||||
static float* fc_mults (int size, float f0, float f1, float g0, float g1, int curve, float samplerate, float scale, int ctfmode, int wintype);
|
||||
};
|
||||
|
||||
} // namespace WDSP
|
||||
|
168
wdsp/fir.cpp
168
wdsp/fir.cpp
@ -31,33 +31,33 @@ warren@pratt.one
|
||||
|
||||
namespace WDSP {
|
||||
|
||||
double* FIR::fftcv_mults (int NM, double* c_impulse)
|
||||
float* FIR::fftcv_mults (int NM, float* c_impulse)
|
||||
{
|
||||
double* mults = new double[NM * 2]; // (double *) malloc0 (NM * sizeof (wcomplex));
|
||||
double* cfft_impulse = new double[NM * 2]; // (double *) malloc0 (NM * sizeof (wcomplex));
|
||||
fftw_plan ptmp = fftw_plan_dft_1d(NM, (fftw_complex *) cfft_impulse,
|
||||
(fftw_complex *) mults, FFTW_FORWARD, FFTW_PATIENT);
|
||||
float* mults = new float[NM * 2]; // (float *) malloc0 (NM * sizeof (wcomplex));
|
||||
float* cfft_impulse = new float[NM * 2]; // (float *) malloc0 (NM * sizeof (wcomplex));
|
||||
fftwf_plan ptmp = fftwf_plan_dft_1d(NM, (fftwf_complex *) cfft_impulse,
|
||||
(fftwf_complex *) mults, FFTW_FORWARD, FFTW_PATIENT);
|
||||
memset (cfft_impulse, 0, NM * sizeof (wcomplex));
|
||||
// store complex coefs right-justified in the buffer
|
||||
memcpy (&(cfft_impulse[NM - 2]), c_impulse, (NM / 2 + 1) * sizeof(wcomplex));
|
||||
fftw_execute (ptmp);
|
||||
fftw_destroy_plan (ptmp);
|
||||
fftwf_execute (ptmp);
|
||||
fftwf_destroy_plan (ptmp);
|
||||
delete[] cfft_impulse;
|
||||
return mults;
|
||||
}
|
||||
|
||||
double* FIR::get_fsamp_window(int N, int wintype)
|
||||
float* FIR::get_fsamp_window(int N, int wintype)
|
||||
{
|
||||
int i;
|
||||
double arg0, arg1;
|
||||
double* window = new double[N]; // (double *) malloc0 (N * sizeof(double));
|
||||
float arg0, arg1;
|
||||
float* window = new float[N]; // (float *) malloc0 (N * sizeof(float));
|
||||
switch (wintype)
|
||||
{
|
||||
case 0:
|
||||
arg0 = 2.0 * PI / ((double)N - 1.0);
|
||||
arg0 = 2.0 * PI / ((float)N - 1.0);
|
||||
for (i = 0; i < N; i++)
|
||||
{
|
||||
arg1 = cos(arg0 * (double)i);
|
||||
arg1 = cos(arg0 * (float)i);
|
||||
window[i] = +0.21747
|
||||
+ arg1 * (-0.45325
|
||||
+ arg1 * (+0.28256
|
||||
@ -65,10 +65,10 @@ double* FIR::get_fsamp_window(int N, int wintype)
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
arg0 = 2.0 * PI / ((double)N - 1.0);
|
||||
arg0 = 2.0 * PI / ((float)N - 1.0);
|
||||
for (i = 0; i < N; ++i)
|
||||
{
|
||||
arg1 = cos(arg0 * (double)i);
|
||||
arg1 = cos(arg0 * (float)i);
|
||||
window[i] = +6.3964424114390378e-02
|
||||
+ arg1 * (-2.3993864599352804e-01
|
||||
+ arg1 * (+3.5015956323820469e-01
|
||||
@ -85,20 +85,20 @@ double* FIR::get_fsamp_window(int N, int wintype)
|
||||
return window;
|
||||
}
|
||||
|
||||
double* FIR::fir_fsamp_odd (int N, double* A, int rtype, double scale, int wintype)
|
||||
float* FIR::fir_fsamp_odd (int N, float* A, int rtype, float scale, int wintype)
|
||||
{
|
||||
int i, j;
|
||||
int mid = (N - 1) / 2;
|
||||
double mag, phs;
|
||||
double* window;
|
||||
double *fcoef = new double[N * 2]; // (double *) malloc0 (N * sizeof (wcomplex));
|
||||
double *c_impulse = new double[N * 2]; // (double *) malloc0 (N * sizeof (wcomplex));
|
||||
fftw_plan ptmp = fftw_plan_dft_1d(N, (fftw_complex *)fcoef, (fftw_complex *)c_impulse, FFTW_BACKWARD, FFTW_PATIENT);
|
||||
double local_scale = 1.0 / (double)N;
|
||||
float mag, phs;
|
||||
float* window;
|
||||
float *fcoef = new float[N * 2]; // (float *) malloc0 (N * sizeof (wcomplex));
|
||||
float *c_impulse = new float[N * 2]; // (float *) malloc0 (N * sizeof (wcomplex));
|
||||
fftwf_plan ptmp = fftwf_plan_dft_1d(N, (fftwf_complex *)fcoef, (fftwf_complex *)c_impulse, FFTW_BACKWARD, FFTW_PATIENT);
|
||||
float local_scale = 1.0 / (float)N;
|
||||
for (i = 0; i <= mid; i++)
|
||||
{
|
||||
mag = A[i] * local_scale;
|
||||
phs = - (double)mid * TWOPI * (double)i / (double)N;
|
||||
phs = - (float)mid * TWOPI * (float)i / (float)N;
|
||||
fcoef[2 * i + 0] = mag * cos (phs);
|
||||
fcoef[2 * i + 1] = mag * sin (phs);
|
||||
}
|
||||
@ -107,8 +107,8 @@ double* FIR::fir_fsamp_odd (int N, double* A, int rtype, double scale, int winty
|
||||
fcoef[2 * i + 0] = + fcoef[2 * (mid - j) + 0];
|
||||
fcoef[2 * i + 1] = - fcoef[2 * (mid - j) + 1];
|
||||
}
|
||||
fftw_execute (ptmp);
|
||||
fftw_destroy_plan (ptmp);
|
||||
fftwf_execute (ptmp);
|
||||
fftwf_destroy_plan (ptmp);
|
||||
delete[] fcoef;
|
||||
window = get_fsamp_window(N, wintype);
|
||||
switch (rtype)
|
||||
@ -129,12 +129,12 @@ double* FIR::fir_fsamp_odd (int N, double* A, int rtype, double scale, int winty
|
||||
return c_impulse;
|
||||
}
|
||||
|
||||
double* FIR::fir_fsamp (int N, double* A, int rtype, double scale, int wintype)
|
||||
float* FIR::fir_fsamp (int N, float* A, int rtype, float scale, int wintype)
|
||||
{
|
||||
int n, i, j, k;
|
||||
double sum;
|
||||
double* window;
|
||||
double *c_impulse = new double[N * 2]; // (double *) malloc0 (N * sizeof (complex));
|
||||
float sum;
|
||||
float* window;
|
||||
float *c_impulse = new float[N * 2]; // (float *) malloc0 (N * sizeof (complex));
|
||||
|
||||
if (N & 1)
|
||||
{
|
||||
@ -155,7 +155,7 @@ double* FIR::fir_fsamp (int N, double* A, int rtype, double scale, int wintype)
|
||||
}
|
||||
else
|
||||
{
|
||||
double M = (double)(N - 1) / 2.0;
|
||||
float M = (float)(N - 1) / 2.0;
|
||||
for (n = 0; n < N / 2; n++)
|
||||
{
|
||||
sum = 0.0;
|
||||
@ -189,18 +189,18 @@ double* FIR::fir_fsamp (int N, double* A, int rtype, double scale, int wintype)
|
||||
return c_impulse;
|
||||
}
|
||||
|
||||
double* FIR::fir_bandpass (int N, double f_low, double f_high, double samplerate, int wintype, int rtype, double scale)
|
||||
float* FIR::fir_bandpass (int N, float f_low, float f_high, float samplerate, int wintype, int rtype, float scale)
|
||||
{
|
||||
double *c_impulse = new double[N * 2]; // (double *) malloc0 (N * sizeof (complex));
|
||||
double ft = (f_high - f_low) / (2.0 * samplerate);
|
||||
double ft_rad = TWOPI * ft;
|
||||
double w_osc = PI * (f_high + f_low) / samplerate;
|
||||
float *c_impulse = new float[N * 2]; // (float *) malloc0 (N * sizeof (complex));
|
||||
float ft = (f_high - f_low) / (2.0 * samplerate);
|
||||
float ft_rad = TWOPI * ft;
|
||||
float w_osc = PI * (f_high + f_low) / samplerate;
|
||||
int i, j;
|
||||
double m = 0.5 * (double)(N - 1);
|
||||
double delta = PI / m;
|
||||
double cosphi;
|
||||
double posi, posj;
|
||||
double sinc, window, coef;
|
||||
float m = 0.5 * (float)(N - 1);
|
||||
float delta = PI / m;
|
||||
float cosphi;
|
||||
float posi, posj;
|
||||
float sinc, window, coef;
|
||||
|
||||
if (N & 1)
|
||||
{
|
||||
@ -217,8 +217,8 @@ double* FIR::fir_bandpass (int N, double f_low, double f_high, double samplerate
|
||||
}
|
||||
for (i = (N + 1) / 2, j = N / 2 - 1; i < N; i++, j--)
|
||||
{
|
||||
posi = (double)i - m;
|
||||
posj = (double)j - m;
|
||||
posi = (float)i - m;
|
||||
posj = (float)j - m;
|
||||
sinc = sin (ft_rad * posi) / (PI * posi);
|
||||
switch (wintype)
|
||||
{
|
||||
@ -258,7 +258,7 @@ double* FIR::fir_bandpass (int N, double f_low, double f_high, double samplerate
|
||||
return c_impulse;
|
||||
}
|
||||
|
||||
double *FIR::fir_read (int N, const char *filename, int rtype, double scale)
|
||||
float *FIR::fir_read (int N, const char *filename, int rtype, float scale)
|
||||
// N = number of real or complex coefficients (see rtype)
|
||||
// *filename = filename
|
||||
// rtype = 0: real coefficients
|
||||
@ -269,8 +269,8 @@ double *FIR::fir_read (int N, const char *filename, int rtype, double scale)
|
||||
{
|
||||
FILE *file;
|
||||
int i;
|
||||
double I, Q;
|
||||
double *c_impulse = new double[N * 2]; // (double *) malloc0 (N * sizeof (complex));
|
||||
float I, Q;
|
||||
float *c_impulse = new float[N * 2]; // (float *) malloc0 (N * sizeof (complex));
|
||||
file = fopen (filename, "r");
|
||||
for (i = 0; i < N; i++)
|
||||
{
|
||||
@ -280,16 +280,16 @@ double *FIR::fir_read (int N, const char *filename, int rtype, double scale)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
int r = fscanf (file, "%le", &I);
|
||||
int r = fscanf (file, "%e", &I);
|
||||
fprintf(stderr, "^%d parameters read\n", r);
|
||||
c_impulse[i] = + scale * I;
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
int r = fscanf (file, "%le", &I);
|
||||
int r = fscanf (file, "%e", &I);
|
||||
fprintf(stderr, "%d parameters read\n", r);
|
||||
r = fscanf (file, "%le", &Q);
|
||||
r = fscanf (file, "%e", &Q);
|
||||
fprintf(stderr, "%d parameters read\n", r);
|
||||
c_impulse[2 * i + 0] = + scale * I;
|
||||
c_impulse[2 * i + 1] = - scale * Q;
|
||||
@ -301,17 +301,17 @@ double *FIR::fir_read (int N, const char *filename, int rtype, double scale)
|
||||
return c_impulse;
|
||||
}
|
||||
|
||||
void FIR::analytic (int N, double* in, double* out)
|
||||
void FIR::analytic (int N, float* in, float* out)
|
||||
{
|
||||
int i;
|
||||
double inv_N = 1.0 / (double)N;
|
||||
double two_inv_N = 2.0 * inv_N;
|
||||
double* x = new double[N * 2]; // (double *) malloc0 (N * sizeof (complex));
|
||||
fftw_plan pfor = fftw_plan_dft_1d (N, (fftw_complex *) in,
|
||||
(fftw_complex *) x, FFTW_FORWARD, FFTW_PATIENT);
|
||||
fftw_plan prev = fftw_plan_dft_1d (N, (fftw_complex *) x,
|
||||
(fftw_complex *) out, FFTW_BACKWARD, FFTW_PATIENT);
|
||||
fftw_execute (pfor);
|
||||
float inv_N = 1.0 / (float)N;
|
||||
float two_inv_N = 2.0 * inv_N;
|
||||
float* x = new float[N * 2]; // (float *) malloc0 (N * sizeof (complex));
|
||||
fftwf_plan pfor = fftwf_plan_dft_1d (N, (fftwf_complex *) in,
|
||||
(fftwf_complex *) x, FFTW_FORWARD, FFTW_PATIENT);
|
||||
fftwf_plan prev = fftwf_plan_dft_1d (N, (fftwf_complex *) x,
|
||||
(fftwf_complex *) out, FFTW_BACKWARD, FFTW_PATIENT);
|
||||
fftwf_execute (pfor);
|
||||
x[0] *= inv_N;
|
||||
x[1] *= inv_N;
|
||||
for (i = 1; i < N / 2; i++)
|
||||
@ -321,31 +321,31 @@ void FIR::analytic (int N, double* in, double* out)
|
||||
}
|
||||
x[N + 0] *= inv_N;
|
||||
x[N + 1] *= inv_N;
|
||||
memset (&x[N + 2], 0, (N - 2) * sizeof (double));
|
||||
fftw_execute (prev);
|
||||
fftw_destroy_plan (prev);
|
||||
fftw_destroy_plan (pfor);
|
||||
memset (&x[N + 2], 0, (N - 2) * sizeof (float));
|
||||
fftwf_execute (prev);
|
||||
fftwf_destroy_plan (prev);
|
||||
fftwf_destroy_plan (pfor);
|
||||
delete[] x;
|
||||
}
|
||||
|
||||
void FIR::mp_imp (int N, double* fir, double* mpfir, int pfactor, int polarity)
|
||||
void FIR::mp_imp (int N, float* fir, float* mpfir, int pfactor, int polarity)
|
||||
{
|
||||
int i;
|
||||
int size = N * pfactor;
|
||||
double inv_PN = 1.0 / (double)size;
|
||||
double* firpad = new double[size * 2]; // (double *) malloc0 (size * sizeof (complex));
|
||||
double* firfreq = new double[size * 2]; // (double *) malloc0 (size * sizeof (complex));
|
||||
double* mag = new double[size]; // (double *) malloc0 (size * sizeof (double));
|
||||
double* ana = new double[size * 2]; // (double *) malloc0 (size * sizeof (complex));
|
||||
double* impulse = new double[size * 2]; // (double *) malloc0 (size * sizeof (complex));
|
||||
double* newfreq = new double[size * 2]; // (double *) malloc0 (size * sizeof (complex));
|
||||
float inv_PN = 1.0 / (float)size;
|
||||
float* firpad = new float[size * 2]; // (float *) malloc0 (size * sizeof (complex));
|
||||
float* firfreq = new float[size * 2]; // (float *) malloc0 (size * sizeof (complex));
|
||||
float* mag = new float[size]; // (float *) malloc0 (size * sizeof (float));
|
||||
float* ana = new float[size * 2]; // (float *) malloc0 (size * sizeof (complex));
|
||||
float* impulse = new float[size * 2]; // (float *) malloc0 (size * sizeof (complex));
|
||||
float* newfreq = new float[size * 2]; // (float *) malloc0 (size * sizeof (complex));
|
||||
memcpy (firpad, fir, N * sizeof (wcomplex));
|
||||
fftw_plan pfor = fftw_plan_dft_1d (size, (fftw_complex *) firpad,
|
||||
(fftw_complex *) firfreq, FFTW_FORWARD, FFTW_PATIENT);
|
||||
fftw_plan prev = fftw_plan_dft_1d (size, (fftw_complex *) newfreq,
|
||||
(fftw_complex *) impulse, FFTW_BACKWARD, FFTW_PATIENT);
|
||||
fftwf_plan pfor = fftwf_plan_dft_1d (size, (fftwf_complex *) firpad,
|
||||
(fftwf_complex *) firfreq, FFTW_FORWARD, FFTW_PATIENT);
|
||||
fftwf_plan prev = fftwf_plan_dft_1d (size, (fftwf_complex *) newfreq,
|
||||
(fftwf_complex *) impulse, FFTW_BACKWARD, FFTW_PATIENT);
|
||||
// print_impulse("orig_imp.txt", N, fir, 1, 0);
|
||||
fftw_execute (pfor);
|
||||
fftwf_execute (pfor);
|
||||
for (i = 0; i < size; i++)
|
||||
{
|
||||
mag[i] = sqrt (firfreq[2 * i + 0] * firfreq[2 * i + 0] + firfreq[2 * i + 1] * firfreq[2 * i + 1]) * inv_PN;
|
||||
@ -363,14 +363,14 @@ void FIR::mp_imp (int N, double* fir, double* mpfir, int pfactor, int polarity)
|
||||
else
|
||||
newfreq[2 * i + 1] = - mag[i] * sin (ana[2 * i + 1]);
|
||||
}
|
||||
fftw_execute (prev);
|
||||
fftwf_execute (prev);
|
||||
if (polarity)
|
||||
memcpy (mpfir, &impulse[2 * (pfactor - 1) * N], N * sizeof (wcomplex));
|
||||
else
|
||||
memcpy (mpfir, impulse, N * sizeof (wcomplex));
|
||||
// print_impulse("min_imp.txt", N, mpfir, 1, 0);
|
||||
fftw_destroy_plan (prev);
|
||||
fftw_destroy_plan (pfor);
|
||||
fftwf_destroy_plan (prev);
|
||||
fftwf_destroy_plan (pfor);
|
||||
delete[] (newfreq);
|
||||
delete[] (impulse);
|
||||
delete[] (ana);
|
||||
@ -381,21 +381,21 @@ void FIR::mp_imp (int N, double* fir, double* mpfir, int pfactor, int polarity)
|
||||
|
||||
// impulse response of a zero frequency filter comprising a cascade of two resonators,
|
||||
// each followed by a detrending filter
|
||||
double* FIR::zff_impulse(int nc, double scale)
|
||||
float* FIR::zff_impulse(int nc, float scale)
|
||||
{
|
||||
// nc = number of coefficients (power of two)
|
||||
int n_resdet = nc / 2 - 1; // size of single zero-frequency resonator with detrender
|
||||
int n_dresdet = 2 * n_resdet - 1; // size of two cascaded units; when we convolve these we get 2 * n - 1 length
|
||||
// allocate the single and make the values
|
||||
double* resdet = new double[n_resdet]; // (double*)malloc0 (n_resdet * sizeof(double));
|
||||
float* resdet = new float[n_resdet]; // (float*)malloc0 (n_resdet * sizeof(float));
|
||||
for (int i = 1, j = 0, k = n_resdet - 1; i < nc / 4; i++, j++, k--)
|
||||
resdet[j] = resdet[k] = (double)(i * (i + 1) / 2);
|
||||
resdet[nc / 4 - 1] = (double)(nc / 4 * (nc / 4 + 1) / 2);
|
||||
resdet[j] = resdet[k] = (float)(i * (i + 1) / 2);
|
||||
resdet[nc / 4 - 1] = (float)(nc / 4 * (nc / 4 + 1) / 2);
|
||||
// print_impulse ("resdet", n_resdet, resdet, 0, 0);
|
||||
// allocate the double and complex versions and make the values
|
||||
double* dresdet = new double[n_dresdet]; // (double*)malloc0 (n_dresdet * sizeof(double));
|
||||
double div = (double)((nc / 2 + 1) * (nc / 2 + 1)); // calculate divisor
|
||||
double* c_dresdet = new double[nc * 2]; // (double*)malloc0 (nc * sizeof(complex));
|
||||
// allocate the float and complex versions and make the values
|
||||
float* dresdet = new float[n_dresdet]; // (float*)malloc0 (n_dresdet * sizeof(float));
|
||||
float div = (float)((nc / 2 + 1) * (nc / 2 + 1)); // calculate divisor
|
||||
float* c_dresdet = new float[nc * 2]; // (float*)malloc0 (nc * sizeof(complex));
|
||||
for (int n = 0; n < n_dresdet; n++) // convolve to make the cascade
|
||||
{
|
||||
for (int k = 0; k < n_resdet; k++)
|
||||
|
18
wdsp/fir.hpp
18
wdsp/fir.hpp
@ -34,17 +34,17 @@ namespace WDSP {
|
||||
class WDSP_API FIR
|
||||
{
|
||||
public:
|
||||
static double* fftcv_mults (int NM, double* c_impulse);
|
||||
static double* fir_fsamp_odd (int N, double* A, int rtype, double scale, int wintype);
|
||||
static double* fir_fsamp (int N, double* A, int rtype, double scale, int wintype);
|
||||
static double* fir_bandpass (int N, double f_low, double f_high, double samplerate, int wintype, int rtype, double scale);
|
||||
static double* get_fsamp_window(int N, int wintype);
|
||||
static double *fir_read (int N, const char *filename, int rtype, double scale);
|
||||
static void mp_imp (int N, double* fir, double* mpfir, int pfactor, int polarity);
|
||||
static double* zff_impulse(int nc, double scale);
|
||||
static float* fftcv_mults (int NM, float* c_impulse);
|
||||
static float* fir_fsamp_odd (int N, float* A, int rtype, float scale, int wintype);
|
||||
static float* fir_fsamp (int N, float* A, int rtype, float scale, int wintype);
|
||||
static float* fir_bandpass (int N, float f_low, float f_high, float samplerate, int wintype, int rtype, float scale);
|
||||
static float* get_fsamp_window(int N, int wintype);
|
||||
static float *fir_read (int N, const char *filename, int rtype, float scale);
|
||||
static void mp_imp (int N, float* fir, float* mpfir, int pfactor, int polarity);
|
||||
static float* zff_impulse(int nc, float scale);
|
||||
|
||||
private:
|
||||
static void analytic (int N, double* in, double* out);
|
||||
static void analytic (int N, float* in, float* out);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
124
wdsp/firmin.cpp
124
wdsp/firmin.cpp
@ -42,12 +42,12 @@ void FIRMIN::calc_firmin (FIRMIN *a)
|
||||
a->h = FIR::fir_bandpass (a->nc, a->f_low, a->f_high, a->samplerate, a->wintype, 1, a->gain);
|
||||
a->rsize = a->nc;
|
||||
a->mask = a->rsize - 1;
|
||||
a->ring = new double[a->rsize * 2]; // (double *) malloc0 (a->rsize * sizeof (complex));
|
||||
a->ring = new float[a->rsize * 2]; // (float *) malloc0 (a->rsize * sizeof (complex));
|
||||
a->idx = 0;
|
||||
}
|
||||
|
||||
FIRMIN* FIRMIN::create_firmin (int run, int position, int size, double* in, double* out,
|
||||
int nc, double f_low, double f_high, int samplerate, int wintype, double gain)
|
||||
FIRMIN* FIRMIN::create_firmin (int run, int position, int size, float* in, float* out,
|
||||
int nc, float f_low, float f_high, int samplerate, int wintype, float gain)
|
||||
{
|
||||
FIRMIN *a = new FIRMIN;
|
||||
a->run = run;
|
||||
@ -103,7 +103,7 @@ void FIRMIN::xfirmin (FIRMIN *a, int pos)
|
||||
memcpy (a->out, a->in, a->size * sizeof (wcomplex));
|
||||
}
|
||||
|
||||
void FIRMIN::setBuffers_firmin (FIRMIN *a, double* in, double* out)
|
||||
void FIRMIN::setBuffers_firmin (FIRMIN *a, float* in, float* out)
|
||||
{
|
||||
a->in = in;
|
||||
a->out = out;
|
||||
@ -111,7 +111,7 @@ void FIRMIN::setBuffers_firmin (FIRMIN *a, double* in, double* out)
|
||||
|
||||
void FIRMIN::setSamplerate_firmin (FIRMIN *a, int rate)
|
||||
{
|
||||
a->samplerate = (double)rate;
|
||||
a->samplerate = (float)rate;
|
||||
calc_firmin (a);
|
||||
}
|
||||
|
||||
@ -120,7 +120,7 @@ void FIRMIN::setSize_firmin (FIRMIN *a, int size)
|
||||
a->size = size;
|
||||
}
|
||||
|
||||
void FIRMIN::setFreqs_firmin (FIRMIN *a, double f_low, double f_high)
|
||||
void FIRMIN::setFreqs_firmin (FIRMIN *a, float f_low, float f_high)
|
||||
{
|
||||
a->f_low = f_low;
|
||||
a->f_high = f_high;
|
||||
@ -140,21 +140,21 @@ void FIROPT::plan_firopt (FIROPT *a)
|
||||
a->nfor = a->nc / a->size;
|
||||
a->buffidx = 0;
|
||||
a->idxmask = a->nfor - 1;
|
||||
a->fftin = new double[2 * a->size * 2]; // (double *) malloc0 (2 * a->size * sizeof (complex));
|
||||
a->fftout = new double*[a->nfor]; // (double **) malloc0 (a->nfor * sizeof (double *));
|
||||
a->fmask = new double*[a->nfor]; // (double **) malloc0 (a->nfor * sizeof (double *));
|
||||
a->maskgen = new double[2 * a->size * 2]; // (double *) malloc0 (2 * a->size * sizeof (complex));
|
||||
a->pcfor = new fftw_plan[a->nfor]; // (fftw_plan *) malloc0 (a->nfor * sizeof (fftw_plan));
|
||||
a->maskplan = new fftw_plan[a->nfor]; // (fftw_plan *) malloc0 (a->nfor * sizeof (fftw_plan));
|
||||
a->fftin = new float[2 * a->size * 2]; // (float *) malloc0 (2 * a->size * sizeof (complex));
|
||||
a->fftout = new float*[a->nfor]; // (float **) malloc0 (a->nfor * sizeof (float *));
|
||||
a->fmask = new float*[a->nfor]; // (float **) malloc0 (a->nfor * sizeof (float *));
|
||||
a->maskgen = new float[2 * a->size * 2]; // (float *) malloc0 (2 * a->size * sizeof (complex));
|
||||
a->pcfor = new fftwf_plan[a->nfor]; // (fftwf_plan *) malloc0 (a->nfor * sizeof (fftwf_plan));
|
||||
a->maskplan = new fftwf_plan[a->nfor]; // (fftwf_plan *) malloc0 (a->nfor * sizeof (fftwf_plan));
|
||||
for (i = 0; i < a->nfor; i++)
|
||||
{
|
||||
a->fftout[i] = new double[2 * a->size * 2]; // (double *) malloc0 (2 * a->size * sizeof (complex));
|
||||
a->fmask[i] = new double[2 * a->size * 2]; // (double *) malloc0 (2 * a->size * sizeof (complex));
|
||||
a->pcfor[i] = fftw_plan_dft_1d(2 * a->size, (fftw_complex *)a->fftin, (fftw_complex *)a->fftout[i], FFTW_FORWARD, FFTW_PATIENT);
|
||||
a->maskplan[i] = fftw_plan_dft_1d(2 * a->size, (fftw_complex *)a->maskgen, (fftw_complex *)a->fmask[i], FFTW_FORWARD, FFTW_PATIENT);
|
||||
a->fftout[i] = new float[2 * a->size * 2]; // (float *) malloc0 (2 * a->size * sizeof (complex));
|
||||
a->fmask[i] = new float[2 * a->size * 2]; // (float *) malloc0 (2 * a->size * sizeof (complex));
|
||||
a->pcfor[i] = fftwf_plan_dft_1d(2 * a->size, (fftwf_complex *)a->fftin, (fftwf_complex *)a->fftout[i], FFTW_FORWARD, FFTW_PATIENT);
|
||||
a->maskplan[i] = fftwf_plan_dft_1d(2 * a->size, (fftwf_complex *)a->maskgen, (fftwf_complex *)a->fmask[i], FFTW_FORWARD, FFTW_PATIENT);
|
||||
}
|
||||
a->accum = new double[2 * a->size * 2]; // (double *) malloc0 (2 * a->size * sizeof (complex));
|
||||
a->crev = fftw_plan_dft_1d(2 * a->size, (fftw_complex *)a->accum, (fftw_complex *)a->out, FFTW_BACKWARD, FFTW_PATIENT);
|
||||
a->accum = new float[2 * a->size * 2]; // (float *) malloc0 (2 * a->size * sizeof (complex));
|
||||
a->crev = fftwf_plan_dft_1d(2 * a->size, (fftwf_complex *)a->accum, (fftwf_complex *)a->out, FFTW_BACKWARD, FFTW_PATIENT);
|
||||
}
|
||||
|
||||
void FIROPT::calc_firopt (FIROPT *a)
|
||||
@ -162,20 +162,20 @@ void FIROPT::calc_firopt (FIROPT *a)
|
||||
// call for change in frequency, rate, wintype, gain
|
||||
// must also call after a call to plan_firopt()
|
||||
int i;
|
||||
double* impulse = FIR::fir_bandpass (a->nc, a->f_low, a->f_high, a->samplerate, a->wintype, 1, a->gain);
|
||||
float* impulse = FIR::fir_bandpass (a->nc, a->f_low, a->f_high, a->samplerate, a->wintype, 1, a->gain);
|
||||
a->buffidx = 0;
|
||||
for (i = 0; i < a->nfor; i++)
|
||||
{
|
||||
// I right-justified the impulse response => take output from left side of output buff, discard right side
|
||||
// Be careful about flipping an asymmetrical impulse response.
|
||||
memcpy (&(a->maskgen[2 * a->size]), &(impulse[2 * a->size * i]), a->size * sizeof(wcomplex));
|
||||
fftw_execute (a->maskplan[i]);
|
||||
fftwf_execute (a->maskplan[i]);
|
||||
}
|
||||
delete[] (impulse);
|
||||
}
|
||||
|
||||
FIROPT* FIROPT::create_firopt (int run, int position, int size, double* in, double* out,
|
||||
int nc, double f_low, double f_high, int samplerate, int wintype, double gain)
|
||||
FIROPT* FIROPT::create_firopt (int run, int position, int size, float* in, float* out,
|
||||
int nc, float f_low, float f_high, int samplerate, int wintype, float gain)
|
||||
{
|
||||
FIROPT *a = new FIROPT;
|
||||
a->run = run;
|
||||
@ -197,14 +197,14 @@ FIROPT* FIROPT::create_firopt (int run, int position, int size, double* in, doub
|
||||
void FIROPT::deplan_firopt (FIROPT *a)
|
||||
{
|
||||
int i;
|
||||
fftw_destroy_plan (a->crev);
|
||||
fftwf_destroy_plan (a->crev);
|
||||
delete[] (a->accum);
|
||||
for (i = 0; i < a->nfor; i++)
|
||||
{
|
||||
delete[] (a->fftout[i]);
|
||||
delete[] (a->fmask[i]);
|
||||
fftw_destroy_plan (a->pcfor[i]);
|
||||
fftw_destroy_plan (a->maskplan[i]);
|
||||
fftwf_destroy_plan (a->pcfor[i]);
|
||||
fftwf_destroy_plan (a->maskplan[i]);
|
||||
}
|
||||
delete[] (a->maskplan);
|
||||
delete[] (a->pcfor);
|
||||
@ -235,7 +235,7 @@ void FIROPT::xfiropt (FIROPT *a, int pos)
|
||||
{
|
||||
int i, j, k;
|
||||
memcpy (&(a->fftin[2 * a->size]), a->in, a->size * sizeof (wcomplex));
|
||||
fftw_execute (a->pcfor[a->buffidx]);
|
||||
fftwf_execute (a->pcfor[a->buffidx]);
|
||||
k = a->buffidx;
|
||||
memset (a->accum, 0, 2 * a->size * sizeof (wcomplex));
|
||||
for (j = 0; j < a->nfor; j++)
|
||||
@ -248,14 +248,14 @@ void FIROPT::xfiropt (FIROPT *a, int pos)
|
||||
k = (k + a->idxmask) & a->idxmask;
|
||||
}
|
||||
a->buffidx = (a->buffidx + 1) & a->idxmask;
|
||||
fftw_execute (a->crev);
|
||||
fftwf_execute (a->crev);
|
||||
memcpy (a->fftin, &(a->fftin[2 * a->size]), a->size * sizeof(wcomplex));
|
||||
}
|
||||
else if (a->in != a->out)
|
||||
memcpy (a->out, a->in, a->size * sizeof (wcomplex));
|
||||
}
|
||||
|
||||
void FIROPT::setBuffers_firopt (FIROPT *a, double* in, double* out)
|
||||
void FIROPT::setBuffers_firopt (FIROPT *a, float* in, float* out)
|
||||
{
|
||||
a->in = in;
|
||||
a->out = out;
|
||||
@ -278,7 +278,7 @@ void FIROPT::setSize_firopt (FIROPT *a, int size)
|
||||
calc_firopt (a);
|
||||
}
|
||||
|
||||
void FIROPT::setFreqs_firopt (FIROPT *a, double f_low, double f_high)
|
||||
void FIROPT::setFreqs_firopt (FIROPT *a, float f_low, float f_high)
|
||||
{
|
||||
a->f_low = f_low;
|
||||
a->f_high = f_high;
|
||||
@ -300,27 +300,27 @@ void FIRCORE::plan_fircore (FIRCORE *a)
|
||||
a->cset = 0;
|
||||
a->buffidx = 0;
|
||||
a->idxmask = a->nfor - 1;
|
||||
a->fftin = new double[2 * a->size * 2]; // (double *) malloc0 (2 * a->size * sizeof (complex));
|
||||
a->fftout = new double*[a->nfor]; // (double **) malloc0 (a->nfor * sizeof (double *));
|
||||
a->fmask = new double**[2]; // (double ***) malloc0 (2 * sizeof (double **));
|
||||
a->fmask[0] = new double*[a->nfor]; // (double **) malloc0 (a->nfor * sizeof (double *));
|
||||
a->fmask[1] = new double*[a->nfor]; // (double **) malloc0 (a->nfor * sizeof (double *));
|
||||
a->maskgen = new double[2 * a->size * 2]; // (double *) malloc0 (2 * a->size * sizeof (complex));
|
||||
a->pcfor = new fftw_plan[a->nfor]; // (fftw_plan *) malloc0 (a->nfor * sizeof (fftw_plan));
|
||||
a->maskplan = new fftw_plan*[2]; // (fftw_plan **) malloc0 (2 * sizeof (fftw_plan *));
|
||||
a->maskplan[0] = new fftw_plan[a->nfor]; // (fftw_plan *) malloc0 (a->nfor * sizeof (fftw_plan));
|
||||
a->maskplan[1] = new fftw_plan[a->nfor]; // (fftw_plan *) malloc0 (a->nfor * sizeof (fftw_plan));
|
||||
a->fftin = new float[2 * a->size * 2]; // (float *) malloc0 (2 * a->size * sizeof (complex));
|
||||
a->fftout = new float*[a->nfor]; // (float **) malloc0 (a->nfor * sizeof (float *));
|
||||
a->fmask = new float**[2]; // (float ***) malloc0 (2 * sizeof (float **));
|
||||
a->fmask[0] = new float*[a->nfor]; // (float **) malloc0 (a->nfor * sizeof (float *));
|
||||
a->fmask[1] = new float*[a->nfor]; // (float **) malloc0 (a->nfor * sizeof (float *));
|
||||
a->maskgen = new float[2 * a->size * 2]; // (float *) malloc0 (2 * a->size * sizeof (complex));
|
||||
a->pcfor = new fftwf_plan[a->nfor]; // (fftwf_plan *) malloc0 (a->nfor * sizeof (fftwf_plan));
|
||||
a->maskplan = new fftwf_plan*[2]; // (fftwf_plan **) malloc0 (2 * sizeof (fftwf_plan *));
|
||||
a->maskplan[0] = new fftwf_plan[a->nfor]; // (fftwf_plan *) malloc0 (a->nfor * sizeof (fftwf_plan));
|
||||
a->maskplan[1] = new fftwf_plan[a->nfor]; // (fftwf_plan *) malloc0 (a->nfor * sizeof (fftwf_plan));
|
||||
for (i = 0; i < a->nfor; i++)
|
||||
{
|
||||
a->fftout[i] = new double[2 * a->size * 2]; // (double *) malloc0 (2 * a->size * sizeof (complex));
|
||||
a->fmask[0][i] = new double[2 * a->size * 2]; // (double *) malloc0 (2 * a->size * sizeof (complex));
|
||||
a->fmask[1][i] = new double[2 * a->size * 2]; // (double *) malloc0 (2 * a->size * sizeof (complex));
|
||||
a->pcfor[i] = fftw_plan_dft_1d(2 * a->size, (fftw_complex *)a->fftin, (fftw_complex *)a->fftout[i], FFTW_FORWARD, FFTW_PATIENT);
|
||||
a->maskplan[0][i] = fftw_plan_dft_1d(2 * a->size, (fftw_complex *)a->maskgen, (fftw_complex *)a->fmask[0][i], FFTW_FORWARD, FFTW_PATIENT);
|
||||
a->maskplan[1][i] = fftw_plan_dft_1d(2 * a->size, (fftw_complex *)a->maskgen, (fftw_complex *)a->fmask[1][i], FFTW_FORWARD, FFTW_PATIENT);
|
||||
a->fftout[i] = new float[2 * a->size * 2]; // (float *) malloc0 (2 * a->size * sizeof (complex));
|
||||
a->fmask[0][i] = new float[2 * a->size * 2]; // (float *) malloc0 (2 * a->size * sizeof (complex));
|
||||
a->fmask[1][i] = new float[2 * a->size * 2]; // (float *) malloc0 (2 * a->size * sizeof (complex));
|
||||
a->pcfor[i] = fftwf_plan_dft_1d(2 * a->size, (fftwf_complex *)a->fftin, (fftwf_complex *)a->fftout[i], FFTW_FORWARD, FFTW_PATIENT);
|
||||
a->maskplan[0][i] = fftwf_plan_dft_1d(2 * a->size, (fftwf_complex *)a->maskgen, (fftwf_complex *)a->fmask[0][i], FFTW_FORWARD, FFTW_PATIENT);
|
||||
a->maskplan[1][i] = fftwf_plan_dft_1d(2 * a->size, (fftwf_complex *)a->maskgen, (fftwf_complex *)a->fmask[1][i], FFTW_FORWARD, FFTW_PATIENT);
|
||||
}
|
||||
a->accum = new double[2 * a->size * 2]; // (double *) malloc0 (2 * a->size * sizeof (complex));
|
||||
a->crev = fftw_plan_dft_1d(2 * a->size, (fftw_complex *)a->accum, (fftw_complex *)a->out, FFTW_BACKWARD, FFTW_PATIENT);
|
||||
a->accum = new float[2 * a->size * 2]; // (float *) malloc0 (2 * a->size * sizeof (complex));
|
||||
a->crev = fftwf_plan_dft_1d(2 * a->size, (fftwf_complex *)a->accum, (fftwf_complex *)a->out, FFTW_BACKWARD, FFTW_PATIENT);
|
||||
a->masks_ready = 0;
|
||||
}
|
||||
|
||||
@ -338,7 +338,7 @@ void FIRCORE::calc_fircore (FIRCORE *a, int flip)
|
||||
// I right-justified the impulse response => take output from left side of output buff, discard right side
|
||||
// Be careful about flipping an asymmetrical impulse response.
|
||||
memcpy (&(a->maskgen[2 * a->size]), &(a->imp[2 * a->size * i]), a->size * sizeof(wcomplex));
|
||||
fftw_execute (a->maskplan[1 - a->cset][i]);
|
||||
fftwf_execute (a->maskplan[1 - a->cset][i]);
|
||||
}
|
||||
a->masks_ready = 1;
|
||||
if (flip)
|
||||
@ -350,7 +350,7 @@ void FIRCORE::calc_fircore (FIRCORE *a, int flip)
|
||||
}
|
||||
}
|
||||
|
||||
FIRCORE* FIRCORE::create_fircore (int size, double* in, double* out, int nc, int mp, double* impulse)
|
||||
FIRCORE* FIRCORE::create_fircore (int size, float* in, float* out, int nc, int mp, float* impulse)
|
||||
{
|
||||
FIRCORE *a = new FIRCORE;
|
||||
a->size = size;
|
||||
@ -360,8 +360,8 @@ FIRCORE* FIRCORE::create_fircore (int size, double* in, double* out, int nc, int
|
||||
a->mp = mp;
|
||||
// InitializeCriticalSectionAndSpinCount (&a->update, 2500);
|
||||
plan_fircore (a);
|
||||
a->impulse = new double[a->nc * 2]; // (double *) malloc0 (a->nc * sizeof (complex));
|
||||
a->imp = new double[a->nc * 2]; // (double *) malloc0 (a->nc * sizeof (complex));
|
||||
a->impulse = new float[a->nc * 2]; // (float *) malloc0 (a->nc * sizeof (complex));
|
||||
a->imp = new float[a->nc * 2]; // (float *) malloc0 (a->nc * sizeof (complex));
|
||||
memcpy (a->impulse, impulse, a->nc * sizeof (wcomplex));
|
||||
calc_fircore (a, 1);
|
||||
return a;
|
||||
@ -370,16 +370,16 @@ FIRCORE* FIRCORE::create_fircore (int size, double* in, double* out, int nc, int
|
||||
void FIRCORE::deplan_fircore (FIRCORE *a)
|
||||
{
|
||||
int i;
|
||||
fftw_destroy_plan (a->crev);
|
||||
fftwf_destroy_plan (a->crev);
|
||||
delete[] (a->accum);
|
||||
for (i = 0; i < a->nfor; i++)
|
||||
{
|
||||
delete[] (a->fftout[i]);
|
||||
delete[] (a->fmask[0][i]);
|
||||
delete[] (a->fmask[1][i]);
|
||||
fftw_destroy_plan (a->pcfor[i]);
|
||||
fftw_destroy_plan (a->maskplan[0][i]);
|
||||
fftw_destroy_plan (a->maskplan[1][i]);
|
||||
fftwf_destroy_plan (a->pcfor[i]);
|
||||
fftwf_destroy_plan (a->maskplan[0][i]);
|
||||
fftwf_destroy_plan (a->maskplan[1][i]);
|
||||
}
|
||||
delete[] (a->maskplan[0]);
|
||||
delete[] (a->maskplan[1]);
|
||||
@ -414,7 +414,7 @@ void FIRCORE::xfircore (FIRCORE *a)
|
||||
{
|
||||
int i, j, k;
|
||||
memcpy (&(a->fftin[2 * a->size]), a->in, a->size * sizeof (wcomplex));
|
||||
fftw_execute (a->pcfor[a->buffidx]);
|
||||
fftwf_execute (a->pcfor[a->buffidx]);
|
||||
k = a->buffidx;
|
||||
memset (a->accum, 0, 2 * a->size * sizeof (wcomplex));
|
||||
a->update.lock();
|
||||
@ -429,11 +429,11 @@ void FIRCORE::xfircore (FIRCORE *a)
|
||||
}
|
||||
a->update.unlock();
|
||||
a->buffidx = (a->buffidx + 1) & a->idxmask;
|
||||
fftw_execute (a->crev);
|
||||
fftwf_execute (a->crev);
|
||||
memcpy (a->fftin, &(a->fftin[2 * a->size]), a->size * sizeof(wcomplex));
|
||||
}
|
||||
|
||||
void FIRCORE::setBuffers_fircore (FIRCORE *a, double* in, double* out)
|
||||
void FIRCORE::setBuffers_fircore (FIRCORE *a, float* in, float* out)
|
||||
{
|
||||
a->in = in;
|
||||
a->out = out;
|
||||
@ -450,13 +450,13 @@ void FIRCORE::setSize_fircore (FIRCORE *a, int size)
|
||||
calc_fircore (a, 1);
|
||||
}
|
||||
|
||||
void FIRCORE::setImpulse_fircore (FIRCORE *a, double* impulse, int update)
|
||||
void FIRCORE::setImpulse_fircore (FIRCORE *a, float* impulse, int update)
|
||||
{
|
||||
memcpy (a->impulse, impulse, a->nc * sizeof (wcomplex));
|
||||
calc_fircore (a, update);
|
||||
}
|
||||
|
||||
void FIRCORE::setNc_fircore (FIRCORE *a, int nc, double* impulse)
|
||||
void FIRCORE::setNc_fircore (FIRCORE *a, int nc, float* impulse)
|
||||
{
|
||||
// because of FFT planning, this will probably cause a glitch in audio if done during dataflow
|
||||
deplan_fircore (a);
|
||||
@ -464,8 +464,8 @@ void FIRCORE::setNc_fircore (FIRCORE *a, int nc, double* impulse)
|
||||
delete[] (a->imp);
|
||||
a->nc = nc;
|
||||
plan_fircore (a);
|
||||
a->imp = new double[a->nc * 2]; // (double *) malloc0 (a->nc * sizeof (complex));
|
||||
a->impulse = new double[a->nc * 2]; // (double *) malloc0 (a->nc * sizeof (complex));
|
||||
a->imp = new float[a->nc * 2]; // (float *) malloc0 (a->nc * sizeof (complex));
|
||||
a->impulse = new float[a->nc * 2]; // (float *) malloc0 (a->nc * sizeof (complex));
|
||||
memcpy (a->impulse, impulse, a->nc * sizeof (wcomplex));
|
||||
calc_fircore (a, 1);
|
||||
}
|
||||
|
@ -45,29 +45,29 @@ public:
|
||||
int run; // run control
|
||||
int position; // position at which to execute
|
||||
int size; // input/output buffer size, power of two
|
||||
double* in; // input buffer
|
||||
double* out; // output buffer, can be same as input
|
||||
float* in; // input buffer
|
||||
float* out; // output buffer, can be same as input
|
||||
int nc; // number of filter coefficients, power of two
|
||||
double f_low; // low cutoff frequency
|
||||
double f_high; // high cutoff frequency
|
||||
double* ring; // internal complex ring buffer
|
||||
double* h; // complex filter coefficients
|
||||
float f_low; // low cutoff frequency
|
||||
float f_high; // high cutoff frequency
|
||||
float* ring; // internal complex ring buffer
|
||||
float* h; // complex filter coefficients
|
||||
int rsize; // ring size, number of complex samples, power of two
|
||||
int mask; // mask to update indexes
|
||||
int idx; // ring input/output index
|
||||
double samplerate; // sample rate
|
||||
float samplerate; // sample rate
|
||||
int wintype; // filter window type
|
||||
double gain; // filter gain
|
||||
float gain; // filter gain
|
||||
|
||||
static FIRMIN* create_firmin (int run, int position, int size, double* in, double* out,
|
||||
int nc, double f_low, double f_high, int samplerate, int wintype, double gain);
|
||||
static FIRMIN* create_firmin (int run, int position, int size, float* in, float* out,
|
||||
int nc, float f_low, float f_high, int samplerate, int wintype, float gain);
|
||||
static void destroy_firmin (FIRMIN *a);
|
||||
static void flush_firmin (FIRMIN *a);
|
||||
static void xfirmin (FIRMIN *a, int pos);
|
||||
static void setBuffers_firmin (FIRMIN *a, double* in, double* out);
|
||||
static void setBuffers_firmin (FIRMIN *a, float* in, float* out);
|
||||
static void setSamplerate_firmin (FIRMIN *a, int rate);
|
||||
static void setSize_firmin (FIRMIN *a, int size);
|
||||
static void setFreqs_firmin (FIRMIN *a, double f_low, double f_high);
|
||||
static void setFreqs_firmin (FIRMIN *a, float f_low, float f_high);
|
||||
|
||||
private:
|
||||
static void calc_firmin (FIRMIN *a);
|
||||
@ -97,35 +97,35 @@ class WDSP_API FIROPT
|
||||
int run; // run control
|
||||
int position; // position at which to execute
|
||||
int size; // input/output buffer size, power of two
|
||||
double* in; // input buffer
|
||||
double* out; // output buffer, can be same as input
|
||||
float* in; // input buffer
|
||||
float* out; // output buffer, can be same as input
|
||||
int nc; // number of filter coefficients, power of two, >= size
|
||||
double f_low; // low cutoff frequency
|
||||
double f_high; // high cutoff frequency
|
||||
double samplerate; // sample rate
|
||||
float f_low; // low cutoff frequency
|
||||
float f_high; // high cutoff frequency
|
||||
float samplerate; // sample rate
|
||||
int wintype; // filter window type
|
||||
double gain; // filter gain
|
||||
float gain; // filter gain
|
||||
int nfor; // number of buffers in delay line
|
||||
double* fftin; // fft input buffer
|
||||
double** fmask; // frequency domain masks
|
||||
double** fftout; // fftout delay line
|
||||
double* accum; // frequency domain accumulator
|
||||
float* fftin; // fft input buffer
|
||||
float** fmask; // frequency domain masks
|
||||
float** fftout; // fftout delay line
|
||||
float* accum; // frequency domain accumulator
|
||||
int buffidx; // fft out buffer index
|
||||
int idxmask; // mask for index computations
|
||||
double* maskgen; // input for mask generation FFT
|
||||
fftw_plan* pcfor; // array of forward FFT plans
|
||||
fftw_plan crev; // reverse fft plan
|
||||
fftw_plan* maskplan; // plans for frequency domain masks
|
||||
float* maskgen; // input for mask generation FFT
|
||||
fftwf_plan* pcfor; // array of forward FFT plans
|
||||
fftwf_plan crev; // reverse fft plan
|
||||
fftwf_plan* maskplan; // plans for frequency domain masks
|
||||
|
||||
static FIROPT* create_firopt (int run, int position, int size, double* in, double* out,
|
||||
int nc, double f_low, double f_high, int samplerate, int wintype, double gain);
|
||||
static FIROPT* create_firopt (int run, int position, int size, float* in, float* out,
|
||||
int nc, float f_low, float f_high, int samplerate, int wintype, float gain);
|
||||
static void xfiropt (FIROPT *a, int pos);
|
||||
static void destroy_firopt (FIROPT *a);
|
||||
static void flush_firopt (FIROPT *a);
|
||||
static void setBuffers_firopt (FIROPT *a, double* in, double* out);
|
||||
static void setBuffers_firopt (FIROPT *a, float* in, float* out);
|
||||
static void setSamplerate_firopt (FIROPT *a, int rate);
|
||||
static void setSize_firopt (FIROPT *a, int size);
|
||||
static void setFreqs_firopt (FIROPT *a, double f_low, double f_high);
|
||||
static void setFreqs_firopt (FIROPT *a, float f_low, float f_high);
|
||||
|
||||
private:
|
||||
static void plan_firopt (FIROPT *a);
|
||||
@ -156,36 +156,36 @@ class WDSP_API FIRCORE
|
||||
{
|
||||
public:
|
||||
int size; // input/output buffer size, power of two
|
||||
double* in; // input buffer
|
||||
double* out; // output buffer, can be same as input
|
||||
float* in; // input buffer
|
||||
float* out; // output buffer, can be same as input
|
||||
int nc; // number of filter coefficients, power of two, >= size
|
||||
double* impulse; // impulse response of filter
|
||||
double* imp;
|
||||
float* impulse; // impulse response of filter
|
||||
float* imp;
|
||||
int nfor; // number of buffers in delay line
|
||||
double* fftin; // fft input buffer
|
||||
double*** fmask; // frequency domain masks
|
||||
double** fftout; // fftout delay line
|
||||
double* accum; // frequency domain accumulator
|
||||
float* fftin; // fft input buffer
|
||||
float*** fmask; // frequency domain masks
|
||||
float** fftout; // fftout delay line
|
||||
float* accum; // frequency domain accumulator
|
||||
int buffidx; // fft out buffer index
|
||||
int idxmask; // mask for index computations
|
||||
double* maskgen; // input for mask generation FFT
|
||||
fftw_plan* pcfor; // array of forward FFT plans
|
||||
fftw_plan crev; // reverse fft plan
|
||||
fftw_plan** maskplan; // plans for frequency domain masks
|
||||
float* maskgen; // input for mask generation FFT
|
||||
fftwf_plan* pcfor; // array of forward FFT plans
|
||||
fftwf_plan crev; // reverse fft plan
|
||||
fftwf_plan** maskplan; // plans for frequency domain masks
|
||||
QRecursiveMutex update;
|
||||
int cset;
|
||||
int mp;
|
||||
int masks_ready;
|
||||
|
||||
static FIRCORE* create_fircore (int size, double* in, double* out,
|
||||
int nc, int mp, double* impulse);
|
||||
static FIRCORE* create_fircore (int size, float* in, float* out,
|
||||
int nc, int mp, float* impulse);
|
||||
static void xfircore (FIRCORE *a);
|
||||
static void destroy_fircore (FIRCORE *a);
|
||||
static void flush_fircore (FIRCORE *a);
|
||||
static void setBuffers_fircore (FIRCORE *a, double* in, double* out);
|
||||
static void setBuffers_fircore (FIRCORE *a, float* in, float* out);
|
||||
static void setSize_fircore (FIRCORE *a, int size);
|
||||
static void setImpulse_fircore (FIRCORE *a, double* impulse, int update);
|
||||
static void setNc_fircore (FIRCORE *a, int nc, double* impulse);
|
||||
static void setImpulse_fircore (FIRCORE *a, float* impulse, int update);
|
||||
static void setNc_fircore (FIRCORE *a, int nc, float* impulse);
|
||||
static void setMp_fircore (FIRCORE *a, int mp);
|
||||
static void setUpdate_fircore (FIRCORE *a);
|
||||
|
||||
|
58
wdsp/fmd.cpp
58
wdsp/fmd.cpp
@ -91,20 +91,20 @@ void FMD::decalc_fmd (FMD *a)
|
||||
FMD* FMD::create_fmd(
|
||||
int run,
|
||||
int size,
|
||||
double* in,
|
||||
double* out,
|
||||
float* in,
|
||||
float* out,
|
||||
int rate,
|
||||
double deviation,
|
||||
double f_low,
|
||||
double f_high,
|
||||
double fmin,
|
||||
double fmax,
|
||||
double zeta,
|
||||
double omegaN,
|
||||
double tau,
|
||||
double afgain,
|
||||
float deviation,
|
||||
float f_low,
|
||||
float f_high,
|
||||
float fmin,
|
||||
float fmax,
|
||||
float zeta,
|
||||
float omegaN,
|
||||
float tau,
|
||||
float afgain,
|
||||
int sntch_run,
|
||||
double ctcss_freq,
|
||||
float ctcss_freq,
|
||||
int nc_de,
|
||||
int mp_de,
|
||||
int nc_aud,
|
||||
@ -112,12 +112,12 @@ FMD* FMD::create_fmd(
|
||||
)
|
||||
{
|
||||
FMD *a = new FMD;
|
||||
double* impulse;
|
||||
float* impulse;
|
||||
a->run = run;
|
||||
a->size = size;
|
||||
a->in = in;
|
||||
a->out = out;
|
||||
a->rate = (double)rate;
|
||||
a->rate = (float)rate;
|
||||
a->deviation = deviation;
|
||||
a->f_low = f_low;
|
||||
a->f_high = f_high;
|
||||
@ -138,7 +138,7 @@ FMD* FMD::create_fmd(
|
||||
a->lim_gain = 2.5;
|
||||
calc_fmd (a);
|
||||
// de-emphasis filter
|
||||
a->audio = new double[a->size * 2]; // (double *) malloc0 (a->size * sizeof (complex));
|
||||
a->audio = new float[a->size * 2]; // (float *) malloc0 (a->size * sizeof (complex));
|
||||
impulse = FCurve::fc_impulse (a->nc_de, a->f_low, a->f_high, +20.0 * log10(a->f_high / a->f_low), 0.0, 1, a->rate, 1.0 / (2.0 * a->size), 0, 0);
|
||||
a->pde = FIRCORE::create_fircore (a->size, a->audio, a->out, a->nc_de, a->mp_de, impulse);
|
||||
delete[] (impulse);
|
||||
@ -176,8 +176,8 @@ void FMD::xfmd (FMD *a)
|
||||
if (a->run)
|
||||
{
|
||||
int i;
|
||||
double det, del_out;
|
||||
double vco[2], corr[2];
|
||||
float det, del_out;
|
||||
float vco[2], corr[2];
|
||||
for (i = 0; i < a->size; i++)
|
||||
{
|
||||
// pll
|
||||
@ -217,7 +217,7 @@ void FMD::xfmd (FMD *a)
|
||||
memcpy (a->out, a->in, a->size * sizeof (wcomplex));
|
||||
}
|
||||
|
||||
void FMD::setBuffers_fmd (FMD *a, double* in, double* out)
|
||||
void FMD::setBuffers_fmd (FMD *a, float* in, float* out)
|
||||
{
|
||||
decalc_fmd (a);
|
||||
a->in = in;
|
||||
@ -230,7 +230,7 @@ void FMD::setBuffers_fmd (FMD *a, double* in, double* out)
|
||||
|
||||
void FMD::setSamplerate_fmd (FMD *a, int rate)
|
||||
{
|
||||
double* impulse;
|
||||
float* impulse;
|
||||
decalc_fmd (a);
|
||||
a->rate = rate;
|
||||
calc_fmd (a);
|
||||
@ -247,12 +247,12 @@ void FMD::setSamplerate_fmd (FMD *a, int rate)
|
||||
|
||||
void FMD::setSize_fmd (FMD *a, int size)
|
||||
{
|
||||
double* impulse;
|
||||
float* impulse;
|
||||
decalc_fmd (a);
|
||||
delete[] (a->audio);
|
||||
a->size = size;
|
||||
calc_fmd (a);
|
||||
a->audio = new double[a->size * 2]; // (double *) malloc0 (a->size * sizeof (complex));
|
||||
a->audio = new float[a->size * 2]; // (float *) malloc0 (a->size * sizeof (complex));
|
||||
// de-emphasis filter
|
||||
FIRCORE::destroy_fircore (a->pde);
|
||||
impulse = FCurve::fc_impulse (a->nc_de, a->f_low, a->f_high, +20.0 * log10(a->f_high / a->f_low), 0.0, 1, a->rate, 1.0 / (2.0 * a->size), 0, 0);
|
||||
@ -272,7 +272,7 @@ void FMD::setSize_fmd (FMD *a, int size)
|
||||
* *
|
||||
********************************************************************************************************/
|
||||
|
||||
void FMD::SetFMDeviation (RXA& rxa, double deviation)
|
||||
void FMD::SetFMDeviation (RXA& rxa, float deviation)
|
||||
{
|
||||
FMD *a;
|
||||
rxa.csDSP.lock();
|
||||
@ -282,7 +282,7 @@ void FMD::SetFMDeviation (RXA& rxa, double deviation)
|
||||
rxa.csDSP.unlock();
|
||||
}
|
||||
|
||||
void FMD::SetCTCSSFreq (RXA& rxa, double freq)
|
||||
void FMD::SetCTCSSFreq (RXA& rxa, float freq)
|
||||
{
|
||||
FMD *a;
|
||||
rxa.csDSP.lock();
|
||||
@ -305,7 +305,7 @@ void FMD::SetCTCSSRun (RXA& rxa, int run)
|
||||
void FMD::SetFMNCde (RXA& rxa, int nc)
|
||||
{
|
||||
FMD *a;
|
||||
double* impulse;
|
||||
float* impulse;
|
||||
rxa.csDSP.lock();
|
||||
a = rxa.fmd.p;
|
||||
if (a->nc_de != nc)
|
||||
@ -332,7 +332,7 @@ void FMD::SetFMMPde (RXA& rxa, int mp)
|
||||
void FMD::SetFMNCaud (RXA& rxa, int nc)
|
||||
{
|
||||
FMD *a;
|
||||
double* impulse;
|
||||
float* impulse;
|
||||
rxa.csDSP.lock();
|
||||
a = rxa.fmd.p;
|
||||
if (a->nc_aud != nc)
|
||||
@ -368,9 +368,9 @@ void FMD::SetFMLimRun (RXA& rxa, int run)
|
||||
rxa.csDSP.unlock();
|
||||
}
|
||||
|
||||
void FMD::SetFMLimGain (RXA& rxa, double gaindB)
|
||||
void FMD::SetFMLimGain (RXA& rxa, float gaindB)
|
||||
{
|
||||
double gain = pow(10.0, gaindB / 20.0);
|
||||
float gain = pow(10.0, gaindB / 20.0);
|
||||
FMD *a = rxa.fmd.p;
|
||||
rxa.csDSP.lock();
|
||||
if (a->lim_gain != gain)
|
||||
@ -382,10 +382,10 @@ void FMD::SetFMLimGain (RXA& rxa, double gaindB)
|
||||
rxa.csDSP.unlock();
|
||||
}
|
||||
|
||||
void FMD::SetFMAFFilter(RXA& rxa, double low, double high)
|
||||
void FMD::SetFMAFFilter(RXA& rxa, float low, float high)
|
||||
{
|
||||
FMD *a = rxa.fmd.p;
|
||||
double* impulse;
|
||||
float* impulse;
|
||||
rxa.csDSP.lock();
|
||||
if (a->f_low != low || a->f_high != high)
|
||||
{
|
||||
|
88
wdsp/fmd.hpp
88
wdsp/fmd.hpp
@ -42,33 +42,33 @@ class WDSP_API FMD
|
||||
public:
|
||||
int run;
|
||||
int size;
|
||||
double* in;
|
||||
double* out;
|
||||
double rate;
|
||||
double f_low; // audio low cutoff
|
||||
double f_high; // audio high cutoff
|
||||
float* in;
|
||||
float* out;
|
||||
float rate;
|
||||
float f_low; // audio low cutoff
|
||||
float f_high; // audio high cutoff
|
||||
// pll
|
||||
double fmin; // pll - minimum carrier freq to lock
|
||||
double fmax; // pll - maximum carrier freq to lock
|
||||
double omega_min; // pll - minimum lock check parameter
|
||||
double omega_max; // pll - maximum lock check parameter
|
||||
double zeta; // pll - damping factor; as coded, must be <=1.0
|
||||
double omegaN; // pll - natural frequency
|
||||
double phs; // pll - phase accumulator
|
||||
double omega; // pll - locked pll frequency
|
||||
double fil_out; // pll - filter output
|
||||
double g1, g2; // pll - filter gain parameters
|
||||
double pllpole; // pll - pole frequency
|
||||
float fmin; // pll - minimum carrier freq to lock
|
||||
float fmax; // pll - maximum carrier freq to lock
|
||||
float omega_min; // pll - minimum lock check parameter
|
||||
float omega_max; // pll - maximum lock check parameter
|
||||
float zeta; // pll - damping factor; as coded, must be <=1.0
|
||||
float omegaN; // pll - natural frequency
|
||||
float phs; // pll - phase accumulator
|
||||
float omega; // pll - locked pll frequency
|
||||
float fil_out; // pll - filter output
|
||||
float g1, g2; // pll - filter gain parameters
|
||||
float pllpole; // pll - pole frequency
|
||||
// for dc removal
|
||||
double tau;
|
||||
double mtau;
|
||||
double onem_mtau;
|
||||
double fmdc;
|
||||
float tau;
|
||||
float mtau;
|
||||
float onem_mtau;
|
||||
float fmdc;
|
||||
// pll audio gain
|
||||
double deviation;
|
||||
double again;
|
||||
float deviation;
|
||||
float again;
|
||||
// for de-emphasis filter
|
||||
double* audio;
|
||||
float* audio;
|
||||
FIRCORE *pde;
|
||||
int nc_de;
|
||||
int mp_de;
|
||||
@ -76,34 +76,34 @@ public:
|
||||
FIRCORE *paud;
|
||||
int nc_aud;
|
||||
int mp_aud;
|
||||
double afgain;
|
||||
float afgain;
|
||||
// CTCSS removal
|
||||
SNOTCH *sntch;
|
||||
int sntch_run;
|
||||
double ctcss_freq;
|
||||
float ctcss_freq;
|
||||
// detector limiter
|
||||
WCPAGC *plim;
|
||||
int lim_run;
|
||||
double lim_gain;
|
||||
double lim_pre_gain;
|
||||
float lim_gain;
|
||||
float lim_pre_gain;
|
||||
|
||||
static FMD* create_fmd (
|
||||
int run,
|
||||
int size,
|
||||
double* in,
|
||||
double* out,
|
||||
float* in,
|
||||
float* out,
|
||||
int rate,
|
||||
double deviation,
|
||||
double f_low,
|
||||
double f_high,
|
||||
double fmin,
|
||||
double fmax,
|
||||
double zeta,
|
||||
double omegaN,
|
||||
double tau,
|
||||
double afgain,
|
||||
float deviation,
|
||||
float f_low,
|
||||
float f_high,
|
||||
float fmin,
|
||||
float fmax,
|
||||
float zeta,
|
||||
float omegaN,
|
||||
float tau,
|
||||
float afgain,
|
||||
int sntch_run,
|
||||
double ctcss_freq,
|
||||
float ctcss_freq,
|
||||
int nc_de,
|
||||
int mp_de,
|
||||
int nc_aud,
|
||||
@ -112,20 +112,20 @@ public:
|
||||
static void destroy_fmd (FMD *a);
|
||||
static void flush_fmd (FMD *a);
|
||||
static void xfmd (FMD *a);
|
||||
static void setBuffers_fmd (FMD *a, double* in, double* out);
|
||||
static void setBuffers_fmd (FMD *a, float* in, float* out);
|
||||
static void setSamplerate_fmd (FMD *a, int rate);
|
||||
static void setSize_fmd (FMD *a, int size);
|
||||
// RXA Properties
|
||||
static void SetFMDeviation (RXA& rxa, double deviation);
|
||||
static void SetCTCSSFreq (RXA& rxa, double freq);
|
||||
static void SetFMDeviation (RXA& rxa, float deviation);
|
||||
static void SetCTCSSFreq (RXA& rxa, float freq);
|
||||
static void SetCTCSSRun (RXA& rxa, int run);
|
||||
static void SetFMNCde (RXA& rxa, int nc);
|
||||
static void SetFMMPde (RXA& rxa, int mp);
|
||||
static void SetFMNCaud (RXA& rxa, int nc);
|
||||
static void SetFMMPaud (RXA& rxa, int mp);
|
||||
static void SetFMLimRun (RXA& rxa, int run);
|
||||
static void SetFMLimGain (RXA& rxa, double gaindB);
|
||||
static void SetFMAFFilter(RXA& rxa, double low, double high);
|
||||
static void SetFMLimGain (RXA& rxa, float gaindB);
|
||||
static void SetFMAFFilter(RXA& rxa, float low, float high);
|
||||
|
||||
private:
|
||||
static void calc_fmd (FMD *a);
|
||||
|
@ -49,27 +49,27 @@ void FMMOD::calc_fmmod (FMMOD *a)
|
||||
FMMOD* FMMOD::create_fmmod (
|
||||
int run,
|
||||
int size,
|
||||
double* in,
|
||||
double* out,
|
||||
float* in,
|
||||
float* out,
|
||||
int rate,
|
||||
double dev,
|
||||
double f_low,
|
||||
double f_high,
|
||||
float dev,
|
||||
float f_low,
|
||||
float f_high,
|
||||
int ctcss_run,
|
||||
double ctcss_level,
|
||||
double ctcss_freq,
|
||||
float ctcss_level,
|
||||
float ctcss_freq,
|
||||
int bp_run,
|
||||
int nc,
|
||||
int mp
|
||||
)
|
||||
{
|
||||
FMMOD *a = new FMMOD;
|
||||
double* impulse;
|
||||
float* impulse;
|
||||
a->run = run;
|
||||
a->size = size;
|
||||
a->in = in;
|
||||
a->out = out;
|
||||
a->samplerate = (double)rate;
|
||||
a->samplerate = (float)rate;
|
||||
a->deviation = dev;
|
||||
a->f_low = f_low;
|
||||
a->f_high = f_high;
|
||||
@ -101,7 +101,7 @@ void FMMOD::flush_fmmod (FMMOD *a)
|
||||
void FMMOD::xfmmod (FMMOD *a)
|
||||
{
|
||||
int i;
|
||||
double dp, magdp, peak;
|
||||
float dp, magdp, peak;
|
||||
if (a->run)
|
||||
{
|
||||
peak = 0.0;
|
||||
@ -130,7 +130,7 @@ void FMMOD::xfmmod (FMMOD *a)
|
||||
memcpy (a->out, a->in, a->size * sizeof (wcomplex));
|
||||
}
|
||||
|
||||
void FMMOD::setBuffers_fmmod (FMMOD *a, double* in, double* out)
|
||||
void FMMOD::setBuffers_fmmod (FMMOD *a, float* in, float* out)
|
||||
{
|
||||
a->in = in;
|
||||
a->out = out;
|
||||
@ -140,7 +140,7 @@ void FMMOD::setBuffers_fmmod (FMMOD *a, double* in, double* out)
|
||||
|
||||
void FMMOD::setSamplerate_fmmod (FMMOD *a, int rate)
|
||||
{
|
||||
double* impulse;
|
||||
float* impulse;
|
||||
a->samplerate = rate;
|
||||
calc_fmmod (a);
|
||||
impulse = FIR::fir_bandpass(a->nc, -a->bp_fc, +a->bp_fc, a->samplerate, 0, 1, 1.0 / (2 * a->size));
|
||||
@ -150,7 +150,7 @@ void FMMOD::setSamplerate_fmmod (FMMOD *a, int rate)
|
||||
|
||||
void FMMOD::setSize_fmmod (FMMOD *a, int size)
|
||||
{
|
||||
double* impulse;
|
||||
float* impulse;
|
||||
a->size = size;
|
||||
calc_fmmod (a);
|
||||
FIRCORE::setSize_fircore (a->p, a->size);
|
||||
@ -165,11 +165,11 @@ void FMMOD::setSize_fmmod (FMMOD *a, int size)
|
||||
* *
|
||||
********************************************************************************************************/
|
||||
|
||||
void FMMOD::SetFMDeviation (TXA& txa, double deviation)
|
||||
void FMMOD::SetFMDeviation (TXA& txa, float deviation)
|
||||
{
|
||||
FMMOD *a = txa.fmmod.p;
|
||||
double bp_fc = a->f_high + deviation;
|
||||
double* impulse = FIR::fir_bandpass (a->nc, -bp_fc, +bp_fc, a->samplerate, 0, 1, 1.0 / (2 * a->size));
|
||||
float bp_fc = a->f_high + deviation;
|
||||
float* impulse = FIR::fir_bandpass (a->nc, -bp_fc, +bp_fc, a->samplerate, 0, 1, 1.0 / (2 * a->size));
|
||||
FIRCORE::setImpulse_fircore (a->p, impulse, 0);
|
||||
delete[] (impulse);
|
||||
txa.csDSP.lock();
|
||||
@ -183,7 +183,7 @@ void FMMOD::SetFMDeviation (TXA& txa, double deviation)
|
||||
txa.csDSP.unlock();
|
||||
}
|
||||
|
||||
void FMMOD::SetCTCSSFreq (TXA& txa, double freq)
|
||||
void FMMOD::SetCTCSSFreq (TXA& txa, float freq)
|
||||
{
|
||||
FMMOD *a;
|
||||
txa.csDSP.lock();
|
||||
@ -204,7 +204,7 @@ void FMMOD::SetCTCSSRun (TXA& txa, int run)
|
||||
void FMMOD::SetFMNC (TXA& txa, int nc)
|
||||
{
|
||||
FMMOD *a;
|
||||
double* impulse;
|
||||
float* impulse;
|
||||
txa.csDSP.lock();
|
||||
a = txa.fmmod.p;
|
||||
if (a->nc != nc)
|
||||
@ -228,10 +228,10 @@ void FMMOD::SetFMMP (TXA& txa, int mp)
|
||||
}
|
||||
}
|
||||
|
||||
void FMMOD::SetFMAFFreqs (TXA& txa, double low, double high)
|
||||
void FMMOD::SetFMAFFreqs (TXA& txa, float low, float high)
|
||||
{
|
||||
FMMOD *a;
|
||||
double* impulse;
|
||||
float* impulse;
|
||||
txa.csDSP.lock();
|
||||
a = txa.fmmod.p;
|
||||
if (a->f_low != low || a->f_high != high)
|
||||
|
@ -40,25 +40,25 @@ class WDSP_API FMMOD
|
||||
public:
|
||||
int run;
|
||||
int size;
|
||||
double* in;
|
||||
double* out;
|
||||
double samplerate;
|
||||
double deviation;
|
||||
double f_low;
|
||||
double f_high;
|
||||
float* in;
|
||||
float* out;
|
||||
float samplerate;
|
||||
float deviation;
|
||||
float f_low;
|
||||
float f_high;
|
||||
int ctcss_run;
|
||||
double ctcss_level;
|
||||
double ctcss_freq;
|
||||
float ctcss_level;
|
||||
float ctcss_freq;
|
||||
// for ctcss gen
|
||||
double tscale;
|
||||
double tphase;
|
||||
double tdelta;
|
||||
float tscale;
|
||||
float tphase;
|
||||
float tdelta;
|
||||
// mod
|
||||
double sphase;
|
||||
double sdelta;
|
||||
float sphase;
|
||||
float sdelta;
|
||||
// bandpass
|
||||
int bp_run;
|
||||
double bp_fc;
|
||||
float bp_fc;
|
||||
int nc;
|
||||
int mp;
|
||||
FIRCORE *p;
|
||||
@ -66,15 +66,15 @@ public:
|
||||
static FMMOD* create_fmmod (
|
||||
int run,
|
||||
int size,
|
||||
double* in,
|
||||
double* out,
|
||||
float* in,
|
||||
float* out,
|
||||
int rate,
|
||||
double dev,
|
||||
double f_low,
|
||||
double f_high,
|
||||
float dev,
|
||||
float f_low,
|
||||
float f_high,
|
||||
int ctcss_run,
|
||||
double ctcss_level,
|
||||
double ctcss_freq,
|
||||
float ctcss_level,
|
||||
float ctcss_freq,
|
||||
int bp_run,
|
||||
int nc,
|
||||
int mp
|
||||
@ -82,16 +82,16 @@ public:
|
||||
static void destroy_fmmod (FMMOD *a);
|
||||
static void flush_fmmod (FMMOD *a);
|
||||
static void xfmmod (FMMOD *a);
|
||||
static void setBuffers_fmmod (FMMOD *a, double* in, double* out);
|
||||
static void setBuffers_fmmod (FMMOD *a, float* in, float* out);
|
||||
static void setSamplerate_fmmod (FMMOD *a, int rate);
|
||||
static void setSize_fmmod (FMMOD *a, int size);
|
||||
// TXA Properties
|
||||
static void SetFMDeviation (TXA& txa, double deviation);
|
||||
static void SetCTCSSFreq (TXA& txa, double freq);
|
||||
static void SetFMDeviation (TXA& txa, float deviation);
|
||||
static void SetCTCSSFreq (TXA& txa, float freq);
|
||||
static void SetCTCSSRun (TXA& txa, int run);
|
||||
static void SetFMMP (TXA& txa, int mp);
|
||||
static void SetFMNC (TXA& txa, int nc);
|
||||
static void SetFMAFFreqs (TXA& txa, double low, double high);
|
||||
static void SetFMAFFreqs (TXA& txa, float low, float high);
|
||||
|
||||
private:
|
||||
static void calc_fmmod (FMMOD *a);
|
||||
|
@ -35,11 +35,11 @@ namespace WDSP {
|
||||
|
||||
void FMSQ::calc_fmsq (FMSQ *a)
|
||||
{
|
||||
double delta, theta;
|
||||
double* impulse;
|
||||
float delta, theta;
|
||||
float* impulse;
|
||||
int i;
|
||||
// noise filter
|
||||
a->noise = new double[2 * a->size * 2]; // (double *)malloc0(2 * a->size * sizeof(complex));
|
||||
a->noise = new float[2 * a->size * 2]; // (float *)malloc0(2 * a->size * sizeof(complex));
|
||||
a->F[0] = 0.0;
|
||||
a->F[1] = a->fc;
|
||||
a->F[2] = *a->pllpole;
|
||||
@ -61,16 +61,16 @@ void FMSQ::calc_fmsq (FMSQ *a)
|
||||
// level change
|
||||
a->ntup = (int)(a->tup * a->rate);
|
||||
a->ntdown = (int)(a->tdown * a->rate);
|
||||
a->cup = new double[a->ntup + 1]; // (double *)malloc0 ((a->ntup + 1) * sizeof(double));
|
||||
a->cdown = new double[a->ntdown + 1]; //(double *)malloc0 ((a->ntdown + 1) * sizeof(double));
|
||||
delta = PI / (double)a->ntup;
|
||||
a->cup = new float[a->ntup + 1]; // (float *)malloc0 ((a->ntup + 1) * sizeof(float));
|
||||
a->cdown = new float[a->ntdown + 1]; //(float *)malloc0 ((a->ntdown + 1) * sizeof(float));
|
||||
delta = PI / (float)a->ntup;
|
||||
theta = 0.0;
|
||||
for (i = 0; i <= a->ntup; i++)
|
||||
{
|
||||
a->cup[i] = 0.5 * (1.0 - cos(theta));
|
||||
theta += delta;
|
||||
}
|
||||
delta = PI / (double)a->ntdown;
|
||||
delta = PI / (float)a->ntdown;
|
||||
theta = 0.0;
|
||||
for (i = 0; i <= a->ntdown; i++)
|
||||
{
|
||||
@ -95,21 +95,21 @@ void FMSQ::decalc_fmsq (FMSQ *a)
|
||||
FMSQ* FMSQ::create_fmsq (
|
||||
int run,
|
||||
int size,
|
||||
double* insig,
|
||||
double* outsig,
|
||||
double* trigger,
|
||||
float* insig,
|
||||
float* outsig,
|
||||
float* trigger,
|
||||
int rate,
|
||||
double fc,
|
||||
double* pllpole,
|
||||
double tdelay,
|
||||
double avtau,
|
||||
double longtau,
|
||||
double tup,
|
||||
double tdown,
|
||||
double tail_thresh,
|
||||
double unmute_thresh,
|
||||
double min_tail,
|
||||
double max_tail,
|
||||
float fc,
|
||||
float* pllpole,
|
||||
float tdelay,
|
||||
float avtau,
|
||||
float longtau,
|
||||
float tup,
|
||||
float tdown,
|
||||
float tail_thresh,
|
||||
float unmute_thresh,
|
||||
float min_tail,
|
||||
float max_tail,
|
||||
int nc,
|
||||
int mp
|
||||
)
|
||||
@ -120,7 +120,7 @@ FMSQ* FMSQ::create_fmsq (
|
||||
a->insig = insig;
|
||||
a->outsig = outsig;
|
||||
a->trigger = trigger;
|
||||
a->rate = (double)rate;
|
||||
a->rate = (float)rate;
|
||||
a->fc = fc;
|
||||
a->pllpole = pllpole;
|
||||
a->tdelay = tdelay;
|
||||
@ -168,7 +168,7 @@ void FMSQ::xfmsq (FMSQ *a)
|
||||
if (a->run)
|
||||
{
|
||||
int i;
|
||||
double noise, lnlimit;
|
||||
float noise, lnlimit;
|
||||
FIRCORE::xfircore (a->p);
|
||||
for (i = 0; i < a->size; i++)
|
||||
{
|
||||
@ -229,7 +229,7 @@ void FMSQ::xfmsq (FMSQ *a)
|
||||
memcpy (a->outsig, a->insig, a->size * sizeof (wcomplex));
|
||||
}
|
||||
|
||||
void FMSQ::setBuffers_fmsq (FMSQ *a, double* in, double* out, double* trig)
|
||||
void FMSQ::setBuffers_fmsq (FMSQ *a, float* in, float* out, float* trig)
|
||||
{
|
||||
a->insig = in;
|
||||
a->outsig = out;
|
||||
@ -264,7 +264,7 @@ void FMSQ::SetFMSQRun (RXA& rxa, int run)
|
||||
rxa.csDSP.unlock();
|
||||
}
|
||||
|
||||
void FMSQ::SetFMSQThreshold (RXA& rxa, double threshold)
|
||||
void FMSQ::SetFMSQThreshold (RXA& rxa, float threshold)
|
||||
{
|
||||
rxa.csDSP.lock();
|
||||
rxa.fmsq.p->tail_thresh = threshold;
|
||||
@ -275,7 +275,7 @@ void FMSQ::SetFMSQThreshold (RXA& rxa, double threshold)
|
||||
void FMSQ::SetFMSQNC (RXA& rxa, int nc)
|
||||
{
|
||||
FMSQ *a;
|
||||
double* impulse;
|
||||
float* impulse;
|
||||
rxa.csDSP.lock();
|
||||
a = rxa.fmsq.p;
|
||||
if (a->nc != nc)
|
||||
|
@ -40,39 +40,39 @@ class WDSP_API FMSQ
|
||||
public:
|
||||
int run; // 0 if squelch system is OFF; 1 if it's ON
|
||||
int size; // size of input/output buffers
|
||||
double* insig; // squelch input signal buffer
|
||||
double* outsig; // squelch output signal buffer
|
||||
double* trigger; // buffer used to trigger mute/unmute (may be same as input; matches timing of input buffer)
|
||||
double rate; // sample rate
|
||||
double* noise;
|
||||
double fc; // corner frequency for sig / noise detection
|
||||
double* pllpole; // pointer to pole frequency of the fm demodulator pll
|
||||
double F[4];
|
||||
double G[4];
|
||||
double avtau; // time constant for averaging noise
|
||||
double avm;
|
||||
double onem_avm;
|
||||
double avnoise;
|
||||
double longtau; // time constant for long averaging
|
||||
double longavm;
|
||||
double onem_longavm;
|
||||
double longnoise;
|
||||
float* insig; // squelch input signal buffer
|
||||
float* outsig; // squelch output signal buffer
|
||||
float* trigger; // buffer used to trigger mute/unmute (may be same as input; matches timing of input buffer)
|
||||
float rate; // sample rate
|
||||
float* noise;
|
||||
float fc; // corner frequency for sig / noise detection
|
||||
float* pllpole; // pointer to pole frequency of the fm demodulator pll
|
||||
float F[4];
|
||||
float G[4];
|
||||
float avtau; // time constant for averaging noise
|
||||
float avm;
|
||||
float onem_avm;
|
||||
float avnoise;
|
||||
float longtau; // time constant for long averaging
|
||||
float longavm;
|
||||
float onem_longavm;
|
||||
float longnoise;
|
||||
int state; // state machine control
|
||||
int count;
|
||||
double tup;
|
||||
double tdown;
|
||||
float tup;
|
||||
float tdown;
|
||||
int ntup;
|
||||
int ntdown;
|
||||
double* cup;
|
||||
double* cdown;
|
||||
double tail_thresh;
|
||||
double unmute_thresh;
|
||||
double min_tail;
|
||||
double max_tail;
|
||||
float* cup;
|
||||
float* cdown;
|
||||
float tail_thresh;
|
||||
float unmute_thresh;
|
||||
float min_tail;
|
||||
float max_tail;
|
||||
int ready;
|
||||
double ramp;
|
||||
double rstep;
|
||||
double tdelay;
|
||||
float ramp;
|
||||
float rstep;
|
||||
float tdelay;
|
||||
int nc;
|
||||
int mp;
|
||||
FIRCORE *p;
|
||||
@ -80,33 +80,33 @@ public:
|
||||
static FMSQ* create_fmsq (
|
||||
int run,
|
||||
int size,
|
||||
double* insig,
|
||||
double* outsig,
|
||||
double* trigger,
|
||||
float* insig,
|
||||
float* outsig,
|
||||
float* trigger,
|
||||
int rate,
|
||||
double fc,
|
||||
double* pllpole,
|
||||
double tdelay,
|
||||
double avtau,
|
||||
double longtau,
|
||||
double tup,
|
||||
double tdown,
|
||||
double tail_thresh,
|
||||
double unmute_thresh,
|
||||
double min_tail,
|
||||
double max_tail,
|
||||
float fc,
|
||||
float* pllpole,
|
||||
float tdelay,
|
||||
float avtau,
|
||||
float longtau,
|
||||
float tup,
|
||||
float tdown,
|
||||
float tail_thresh,
|
||||
float unmute_thresh,
|
||||
float min_tail,
|
||||
float max_tail,
|
||||
int nc,
|
||||
int mp
|
||||
);
|
||||
static void destroy_fmsq (FMSQ *a);
|
||||
static void flush_fmsq (FMSQ *a);
|
||||
static void xfmsq (FMSQ *a);
|
||||
static void setBuffers_fmsq (FMSQ *a, double* in, double* out, double* trig);
|
||||
static void setBuffers_fmsq (FMSQ *a, float* in, float* out, float* trig);
|
||||
static void setSamplerate_fmsq (FMSQ *a, int rate);
|
||||
static void setSize_fmsq (FMSQ *a, int size);
|
||||
// RXA Properties
|
||||
static void SetFMSQRun (RXA& rxa, int run);
|
||||
static void SetFMSQThreshold (RXA& rxa, double threshold);
|
||||
static void SetFMSQThreshold (RXA& rxa, float threshold);
|
||||
static void SetFMSQNC (RXA& rxa, int nc);
|
||||
static void SetFMSQMP (RXA& rxa, int mp);
|
||||
|
||||
|
@ -30,7 +30,7 @@ warren@wpratt.com
|
||||
|
||||
namespace WDSP {
|
||||
|
||||
GAIN* GAIN::create_gain (int run, int* prun, int size, double* in, double* out, double Igain, double Qgain)
|
||||
GAIN* GAIN::create_gain (int run, int* prun, int size, float* in, float* out, float Igain, float Qgain)
|
||||
{
|
||||
GAIN *a = new GAIN;
|
||||
a->run = run;
|
||||
@ -75,7 +75,7 @@ void GAIN::xgain (GAIN *a)
|
||||
a->cs_update.unlock();
|
||||
}
|
||||
|
||||
void GAIN::setBuffers_gain (GAIN *a, double* in, double* out)
|
||||
void GAIN::setBuffers_gain (GAIN *a, float* in, float* out)
|
||||
{
|
||||
a->in = in;
|
||||
a->out = out;
|
||||
@ -97,7 +97,7 @@ void GAIN::setSize_gain (GAIN *a, int size)
|
||||
* *
|
||||
********************************************************************************************************/
|
||||
|
||||
void GAIN::pSetTXOutputLevel (GAIN *a, double level)
|
||||
void GAIN::pSetTXOutputLevel (GAIN *a, float level)
|
||||
{
|
||||
a->cs_update.lock();
|
||||
a->Igain = level;
|
||||
|
@ -40,22 +40,22 @@ public:
|
||||
int run;
|
||||
int* prun;
|
||||
int size;
|
||||
double* in;
|
||||
double* out;
|
||||
double Igain;
|
||||
double Qgain;
|
||||
float* in;
|
||||
float* out;
|
||||
float Igain;
|
||||
float Qgain;
|
||||
QRecursiveMutex cs_update;
|
||||
|
||||
static GAIN* create_gain (int run, int* prun, int size, double* in, double* out, double Igain, double Qgain);
|
||||
static GAIN* create_gain (int run, int* prun, int size, float* in, float* out, float Igain, float Qgain);
|
||||
static void destroy_gain (GAIN *a);
|
||||
static void flush_gain (GAIN *a);
|
||||
static void xgain (GAIN *a);
|
||||
static void setBuffers_gain (GAIN *a, double* in, double* out);
|
||||
static void setBuffers_gain (GAIN *a, float* in, float* out);
|
||||
static void setSamplerate_gain (GAIN *a, int rate);
|
||||
static void setSize_gain (GAIN *a, int size);
|
||||
// TXA Properties
|
||||
// POINTER-BASED Properties
|
||||
static void pSetTXOutputLevel (GAIN *a, double level);
|
||||
static void pSetTXOutputLevel (GAIN *a, float level);
|
||||
static void pSetTXOutputLevelRun (GAIN *a, int run);
|
||||
static void pSetTXOutputLevelSize (GAIN *a, int size);
|
||||
};
|
||||
|
96
wdsp/gen.cpp
96
wdsp/gen.cpp
@ -79,7 +79,7 @@ void GEN::calc_triangle (GEN *a)
|
||||
void GEN::calc_pulse (GEN *a)
|
||||
{
|
||||
int i;
|
||||
double delta, theta;
|
||||
float delta, theta;
|
||||
a->pulse.pperiod = 1.0 / a->pulse.pf;
|
||||
a->pulse.tphs = 0.0;
|
||||
a->pulse.tdelta = TWOPI * a->pulse.tf / a->rate;
|
||||
@ -91,8 +91,8 @@ void GEN::calc_pulse (GEN *a)
|
||||
if (a->pulse.pnoff < 0) a->pulse.pnoff = 0;
|
||||
a->pulse.pcount = a->pulse.pnoff;
|
||||
a->pulse.state = 0;
|
||||
a->pulse.ctrans = new double[a->pulse.pntrans + 1]; // (double *) malloc0 ((a->pulse.pntrans + 1) * sizeof (double));
|
||||
delta = PI / (double)a->pulse.pntrans;
|
||||
a->pulse.ctrans = new float[a->pulse.pntrans + 1]; // (float *) malloc0 ((a->pulse.pntrans + 1) * sizeof (float));
|
||||
delta = PI / (float)a->pulse.pntrans;
|
||||
theta = 0.0;
|
||||
for (i = 0; i <= a->pulse.pntrans; i++)
|
||||
{
|
||||
@ -116,14 +116,14 @@ void GEN::decalc_gen (GEN *a)
|
||||
delete[] (a->pulse.ctrans);
|
||||
}
|
||||
|
||||
GEN* GEN::create_gen (int run, int size, double* in, double* out, int rate, int mode)
|
||||
GEN* GEN::create_gen (int run, int size, float* in, float* out, int rate, int mode)
|
||||
{
|
||||
GEN *a = new GEN;
|
||||
a->run = run;
|
||||
a->size = size;
|
||||
a->in = in;
|
||||
a->out = out;
|
||||
a->rate = (double)rate;
|
||||
a->rate = (float)rate;
|
||||
a->mode = mode;
|
||||
// tone
|
||||
a->tone.mag = 1.0;
|
||||
@ -185,9 +185,9 @@ void GEN::xgen (GEN *a)
|
||||
case 0: // tone
|
||||
{
|
||||
int i;
|
||||
double t1, t2;
|
||||
double cosphase = cos (a->tone.phs);
|
||||
double sinphase = sin (a->tone.phs);
|
||||
float t1, t2;
|
||||
float cosphase = cos (a->tone.phs);
|
||||
float sinphase = sin (a->tone.phs);
|
||||
for (i = 0; i < a->size; i++)
|
||||
{
|
||||
a->out[2 * i + 0] = + a->tone.mag * cosphase;
|
||||
@ -205,11 +205,11 @@ void GEN::xgen (GEN *a)
|
||||
case 1: // two-tone
|
||||
{
|
||||
int i;
|
||||
double tcos, tsin;
|
||||
double cosphs1 = cos (a->tt.phs1);
|
||||
double sinphs1 = sin (a->tt.phs1);
|
||||
double cosphs2 = cos (a->tt.phs2);
|
||||
double sinphs2 = sin (a->tt.phs2);
|
||||
float tcos, tsin;
|
||||
float cosphs1 = cos (a->tt.phs1);
|
||||
float sinphs1 = sin (a->tt.phs1);
|
||||
float cosphs2 = cos (a->tt.phs2);
|
||||
float sinphs2 = sin (a->tt.phs2);
|
||||
for (i = 0; i < a->size; i++)
|
||||
{
|
||||
a->out[2 * i + 0] = + a->tt.mag1 * cosphs1 + a->tt.mag2 * cosphs2;
|
||||
@ -234,13 +234,13 @@ void GEN::xgen (GEN *a)
|
||||
case 2: // noise
|
||||
{
|
||||
int i;
|
||||
double r1, r2, c, rad;
|
||||
float r1, r2, c, rad;
|
||||
for (i = 0; i < a->size; i++)
|
||||
{
|
||||
do
|
||||
{
|
||||
r1 = 2.0 * (double)rand() / (double)RAND_MAX - 1.0;
|
||||
r2 = 2.0 * (double)rand() / (double)RAND_MAX - 1.0;
|
||||
r1 = 2.0 * (float)rand() / (float)RAND_MAX - 1.0;
|
||||
r2 = 2.0 * (float)rand() / (float)RAND_MAX - 1.0;
|
||||
c = r1 * r1 + r2 * r2;
|
||||
} while (c >= 1.0);
|
||||
rad = sqrt (-2.0 * log (c) / c);
|
||||
@ -294,9 +294,9 @@ void GEN::xgen (GEN *a)
|
||||
case 6: // pulse (audio only)
|
||||
{
|
||||
int i;
|
||||
double t1, t2;
|
||||
double cosphase = cos (a->pulse.tphs);
|
||||
double sinphase = sin (a->pulse.tphs);
|
||||
float t1, t2;
|
||||
float cosphase = cos (a->pulse.tphs);
|
||||
float sinphase = sin (a->pulse.tphs);
|
||||
for (i = 0; i < a->size; i++)
|
||||
{
|
||||
if (a->pulse.pnoff != 0)
|
||||
@ -359,7 +359,7 @@ void GEN::xgen (GEN *a)
|
||||
memcpy (a->out, a->in, a->size * sizeof (wcomplex));
|
||||
}
|
||||
|
||||
void GEN::setBuffers_gen (GEN *a, double* in, double* out)
|
||||
void GEN::setBuffers_gen (GEN *a, float* in, float* out)
|
||||
{
|
||||
a->in = in;
|
||||
a->out = out;
|
||||
@ -401,14 +401,14 @@ void GEN::SetPreGenMode (RXA& rxa, int mode)
|
||||
rxa.csDSP.unlock();
|
||||
}
|
||||
|
||||
void GEN::SetPreGenToneMag (RXA& rxa, double mag)
|
||||
void GEN::SetPreGenToneMag (RXA& rxa, float mag)
|
||||
{
|
||||
rxa.csDSP.lock();
|
||||
rxa.gen0.p->tone.mag = mag;
|
||||
rxa.csDSP.unlock();
|
||||
}
|
||||
|
||||
void GEN::SetPreGenToneFreq (RXA& rxa, double freq)
|
||||
void GEN::SetPreGenToneFreq (RXA& rxa, float freq)
|
||||
{
|
||||
rxa.csDSP.lock();
|
||||
rxa.gen0.p->tone.freq = freq;
|
||||
@ -416,21 +416,21 @@ void GEN::SetPreGenToneFreq (RXA& rxa, double freq)
|
||||
rxa.csDSP.unlock();
|
||||
}
|
||||
|
||||
void GEN::SetPreGenNoiseMag (RXA& rxa, double mag)
|
||||
void GEN::SetPreGenNoiseMag (RXA& rxa, float mag)
|
||||
{
|
||||
rxa.csDSP.lock();
|
||||
rxa.gen0.p->noise.mag = mag;
|
||||
rxa.csDSP.unlock();
|
||||
}
|
||||
|
||||
void GEN::SetPreGenSweepMag (RXA& rxa, double mag)
|
||||
void GEN::SetPreGenSweepMag (RXA& rxa, float mag)
|
||||
{
|
||||
rxa.csDSP.lock();
|
||||
rxa.gen0.p->sweep.mag = mag;
|
||||
rxa.csDSP.unlock();
|
||||
}
|
||||
|
||||
void GEN::SetPreGenSweepFreq (RXA& rxa, double freq1, double freq2)
|
||||
void GEN::SetPreGenSweepFreq (RXA& rxa, float freq1, float freq2)
|
||||
{
|
||||
rxa.csDSP.lock();
|
||||
rxa.gen0.p->sweep.f1 = freq1;
|
||||
@ -439,7 +439,7 @@ void GEN::SetPreGenSweepFreq (RXA& rxa, double freq1, double freq2)
|
||||
rxa.csDSP.unlock();
|
||||
}
|
||||
|
||||
void GEN::SetPreGenSweepRate (RXA& rxa, double rate)
|
||||
void GEN::SetPreGenSweepRate (RXA& rxa, float rate)
|
||||
{
|
||||
rxa.csDSP.lock();
|
||||
rxa.gen0.p->sweep.sweeprate = rate;
|
||||
@ -470,14 +470,14 @@ void GEN::SetPreGenMode (TXA& txa, int mode)
|
||||
txa.csDSP.unlock();
|
||||
}
|
||||
|
||||
void GEN::SetPreGenToneMag (TXA& txa, double mag)
|
||||
void GEN::SetPreGenToneMag (TXA& txa, float mag)
|
||||
{
|
||||
txa.csDSP.lock();
|
||||
txa.gen0.p->tone.mag = mag;
|
||||
txa.csDSP.unlock();
|
||||
}
|
||||
|
||||
void GEN::SetPreGenToneFreq (TXA& txa, double freq)
|
||||
void GEN::SetPreGenToneFreq (TXA& txa, float freq)
|
||||
{
|
||||
txa.csDSP.lock();
|
||||
txa.gen0.p->tone.freq = freq;
|
||||
@ -485,21 +485,21 @@ void GEN::SetPreGenToneFreq (TXA& txa, double freq)
|
||||
txa.csDSP.unlock();
|
||||
}
|
||||
|
||||
void GEN::SetPreGenNoiseMag (TXA& txa, double mag)
|
||||
void GEN::SetPreGenNoiseMag (TXA& txa, float mag)
|
||||
{
|
||||
txa.csDSP.lock();
|
||||
txa.gen0.p->noise.mag = mag;
|
||||
txa.csDSP.unlock();
|
||||
}
|
||||
|
||||
void GEN::SetPreGenSweepMag (TXA& txa, double mag)
|
||||
void GEN::SetPreGenSweepMag (TXA& txa, float mag)
|
||||
{
|
||||
txa.csDSP.lock();
|
||||
txa.gen0.p->sweep.mag = mag;
|
||||
txa.csDSP.unlock();
|
||||
}
|
||||
|
||||
void GEN::SetPreGenSweepFreq (TXA& txa, double freq1, double freq2)
|
||||
void GEN::SetPreGenSweepFreq (TXA& txa, float freq1, float freq2)
|
||||
{
|
||||
txa.csDSP.lock();
|
||||
txa.gen0.p->sweep.f1 = freq1;
|
||||
@ -508,7 +508,7 @@ void GEN::SetPreGenSweepFreq (TXA& txa, double freq1, double freq2)
|
||||
txa.csDSP.unlock();
|
||||
}
|
||||
|
||||
void GEN::SetPreGenSweepRate (TXA& txa, double rate)
|
||||
void GEN::SetPreGenSweepRate (TXA& txa, float rate)
|
||||
{
|
||||
txa.csDSP.lock();
|
||||
txa.gen0.p->sweep.sweeprate = rate;
|
||||
@ -516,14 +516,14 @@ void GEN::SetPreGenSweepRate (TXA& txa, double rate)
|
||||
txa.csDSP.unlock();
|
||||
}
|
||||
|
||||
void GEN::SetPreGenSawtoothMag (TXA& txa, double mag)
|
||||
void GEN::SetPreGenSawtoothMag (TXA& txa, float mag)
|
||||
{
|
||||
txa.csDSP.lock();
|
||||
txa.gen0.p->saw.mag = mag;
|
||||
txa.csDSP.unlock();
|
||||
}
|
||||
|
||||
void GEN::SetPreGenSawtoothFreq (TXA& txa, double freq)
|
||||
void GEN::SetPreGenSawtoothFreq (TXA& txa, float freq)
|
||||
{
|
||||
txa.csDSP.lock();
|
||||
txa.gen0.p->saw.f = freq;
|
||||
@ -531,14 +531,14 @@ void GEN::SetPreGenSawtoothFreq (TXA& txa, double freq)
|
||||
txa.csDSP.unlock();
|
||||
}
|
||||
|
||||
void GEN::SetPreGenTriangleMag (TXA& txa, double mag)
|
||||
void GEN::SetPreGenTriangleMag (TXA& txa, float mag)
|
||||
{
|
||||
txa.csDSP.lock();
|
||||
txa.gen0.p->tri.mag = mag;
|
||||
txa.csDSP.unlock();
|
||||
}
|
||||
|
||||
void GEN::SetPreGenTriangleFreq (TXA& txa, double freq)
|
||||
void GEN::SetPreGenTriangleFreq (TXA& txa, float freq)
|
||||
{
|
||||
txa.csDSP.lock();
|
||||
txa.gen0.p->tri.f = freq;
|
||||
@ -546,14 +546,14 @@ void GEN::SetPreGenTriangleFreq (TXA& txa, double freq)
|
||||
txa.csDSP.unlock();
|
||||
}
|
||||
|
||||
void GEN::SetPreGenPulseMag (TXA& txa, double mag)
|
||||
void GEN::SetPreGenPulseMag (TXA& txa, float mag)
|
||||
{
|
||||
txa.csDSP.lock();
|
||||
txa.gen0.p->pulse.mag = mag;
|
||||
txa.csDSP.unlock();
|
||||
}
|
||||
|
||||
void GEN::SetPreGenPulseFreq (TXA& txa, double freq)
|
||||
void GEN::SetPreGenPulseFreq (TXA& txa, float freq)
|
||||
{
|
||||
txa.csDSP.lock();
|
||||
txa.gen0.p->pulse.pf = freq;
|
||||
@ -561,7 +561,7 @@ void GEN::SetPreGenPulseFreq (TXA& txa, double freq)
|
||||
txa.csDSP.unlock();
|
||||
}
|
||||
|
||||
void GEN::SetPreGenPulseDutyCycle (TXA& txa, double dc)
|
||||
void GEN::SetPreGenPulseDutyCycle (TXA& txa, float dc)
|
||||
{
|
||||
txa.csDSP.lock();
|
||||
txa.gen0.p->pulse.pdutycycle = dc;
|
||||
@ -569,7 +569,7 @@ void GEN::SetPreGenPulseDutyCycle (TXA& txa, double dc)
|
||||
txa.csDSP.unlock();
|
||||
}
|
||||
|
||||
void GEN::SetPreGenPulseToneFreq (TXA& txa, double freq)
|
||||
void GEN::SetPreGenPulseToneFreq (TXA& txa, float freq)
|
||||
{
|
||||
txa.csDSP.lock();
|
||||
txa.gen0.p->pulse.tf = freq;
|
||||
@ -577,7 +577,7 @@ void GEN::SetPreGenPulseToneFreq (TXA& txa, double freq)
|
||||
txa.csDSP.unlock();
|
||||
}
|
||||
|
||||
void GEN::SetPreGenPulseTransition (TXA& txa, double transtime)
|
||||
void GEN::SetPreGenPulseTransition (TXA& txa, float transtime)
|
||||
{
|
||||
txa.csDSP.lock();
|
||||
txa.gen0.p->pulse.ptranstime = transtime;
|
||||
@ -601,14 +601,14 @@ void GEN::SetPostGenMode (TXA& txa, int mode)
|
||||
txa.csDSP.unlock();
|
||||
}
|
||||
|
||||
void GEN::SetPostGenToneMag (TXA& txa, double mag)
|
||||
void GEN::SetPostGenToneMag (TXA& txa, float mag)
|
||||
{
|
||||
txa.csDSP.lock();
|
||||
txa.gen1.p->tone.mag = mag;
|
||||
txa.csDSP.unlock();
|
||||
}
|
||||
|
||||
void GEN::SetPostGenToneFreq (TXA& txa, double freq)
|
||||
void GEN::SetPostGenToneFreq (TXA& txa, float freq)
|
||||
{
|
||||
txa.csDSP.lock();
|
||||
txa.gen1.p->tone.freq = freq;
|
||||
@ -616,7 +616,7 @@ void GEN::SetPostGenToneFreq (TXA& txa, double freq)
|
||||
txa.csDSP.unlock();
|
||||
}
|
||||
|
||||
void GEN::SetPostGenTTMag (TXA& txa, double mag1, double mag2)
|
||||
void GEN::SetPostGenTTMag (TXA& txa, float mag1, float mag2)
|
||||
{
|
||||
txa.csDSP.lock();
|
||||
txa.gen1.p->tt.mag1 = mag1;
|
||||
@ -624,7 +624,7 @@ void GEN::SetPostGenTTMag (TXA& txa, double mag1, double mag2)
|
||||
txa.csDSP.unlock();
|
||||
}
|
||||
|
||||
void GEN::SetPostGenTTFreq (TXA& txa, double freq1, double freq2)
|
||||
void GEN::SetPostGenTTFreq (TXA& txa, float freq1, float freq2)
|
||||
{
|
||||
txa.csDSP.lock();
|
||||
txa.gen1.p->tt.f1 = freq1;
|
||||
@ -633,14 +633,14 @@ void GEN::SetPostGenTTFreq (TXA& txa, double freq1, double freq2)
|
||||
txa.csDSP.unlock();
|
||||
}
|
||||
|
||||
void GEN::SetPostGenSweepMag (TXA& txa, double mag)
|
||||
void GEN::SetPostGenSweepMag (TXA& txa, float mag)
|
||||
{
|
||||
txa.csDSP.lock();
|
||||
txa.gen1.p->sweep.mag = mag;
|
||||
txa.csDSP.unlock();
|
||||
}
|
||||
|
||||
void GEN::SetPostGenSweepFreq (TXA& txa, double freq1, double freq2)
|
||||
void GEN::SetPostGenSweepFreq (TXA& txa, float freq1, float freq2)
|
||||
{
|
||||
txa.csDSP.lock();
|
||||
txa.gen1.p->sweep.f1 = freq1;
|
||||
@ -649,7 +649,7 @@ void GEN::SetPostGenSweepFreq (TXA& txa, double freq1, double freq2)
|
||||
txa.csDSP.unlock();
|
||||
}
|
||||
|
||||
void GEN::SetPostGenSweepRate (TXA& txa, double rate)
|
||||
void GEN::SetPostGenSweepRate (TXA& txa, float rate)
|
||||
{
|
||||
txa.csDSP.lock();
|
||||
txa.gen1.p->sweep.sweeprate = rate;
|
||||
|
166
wdsp/gen.hpp
166
wdsp/gen.hpp
@ -40,132 +40,132 @@ class WDSP_API GEN
|
||||
public:
|
||||
int run; // run
|
||||
int size; // number of samples per buffer
|
||||
double* in; // input buffer (retained in case I want to mix in a generated signal)
|
||||
double* out; // output buffer
|
||||
double rate; // sample rate
|
||||
float* in; // input buffer (retained in case I want to mix in a generated signal)
|
||||
float* out; // output buffer
|
||||
float rate; // sample rate
|
||||
int mode;
|
||||
struct _tone
|
||||
{
|
||||
double mag;
|
||||
double freq;
|
||||
double phs;
|
||||
double delta;
|
||||
double cosdelta;
|
||||
double sindelta;
|
||||
float mag;
|
||||
float freq;
|
||||
float phs;
|
||||
float delta;
|
||||
float cosdelta;
|
||||
float sindelta;
|
||||
} tone;
|
||||
struct _tt
|
||||
{
|
||||
double mag1;
|
||||
double mag2;
|
||||
double f1;
|
||||
double f2;
|
||||
double phs1;
|
||||
double phs2;
|
||||
double delta1;
|
||||
double delta2;
|
||||
double cosdelta1;
|
||||
double cosdelta2;
|
||||
double sindelta1;
|
||||
double sindelta2;
|
||||
float mag1;
|
||||
float mag2;
|
||||
float f1;
|
||||
float f2;
|
||||
float phs1;
|
||||
float phs2;
|
||||
float delta1;
|
||||
float delta2;
|
||||
float cosdelta1;
|
||||
float cosdelta2;
|
||||
float sindelta1;
|
||||
float sindelta2;
|
||||
} tt;
|
||||
struct _noise
|
||||
{
|
||||
double mag;
|
||||
float mag;
|
||||
} noise;
|
||||
struct _sweep
|
||||
{
|
||||
double mag;
|
||||
double f1;
|
||||
double f2;
|
||||
double sweeprate;
|
||||
double phs;
|
||||
double dphs;
|
||||
double d2phs;
|
||||
double dphsmax;
|
||||
float mag;
|
||||
float f1;
|
||||
float f2;
|
||||
float sweeprate;
|
||||
float phs;
|
||||
float dphs;
|
||||
float d2phs;
|
||||
float dphsmax;
|
||||
} sweep;
|
||||
struct _saw
|
||||
{
|
||||
double mag;
|
||||
double f;
|
||||
double period;
|
||||
double delta;
|
||||
double t;
|
||||
float mag;
|
||||
float f;
|
||||
float period;
|
||||
float delta;
|
||||
float t;
|
||||
} saw;
|
||||
struct _tri
|
||||
{
|
||||
double mag;
|
||||
double f;
|
||||
double period;
|
||||
double half;
|
||||
double delta;
|
||||
double t;
|
||||
double t1;
|
||||
float mag;
|
||||
float f;
|
||||
float period;
|
||||
float half;
|
||||
float delta;
|
||||
float t;
|
||||
float t1;
|
||||
} tri;
|
||||
struct _pulse
|
||||
{
|
||||
double mag;
|
||||
double pf;
|
||||
double pdutycycle;
|
||||
double ptranstime;
|
||||
double* ctrans;
|
||||
float mag;
|
||||
float pf;
|
||||
float pdutycycle;
|
||||
float ptranstime;
|
||||
float* ctrans;
|
||||
int pcount;
|
||||
int pnon;
|
||||
int pntrans;
|
||||
int pnoff;
|
||||
double pperiod;
|
||||
double tf;
|
||||
double tphs;
|
||||
double tdelta;
|
||||
double tcosdelta;
|
||||
double tsindelta;
|
||||
float pperiod;
|
||||
float tf;
|
||||
float tphs;
|
||||
float tdelta;
|
||||
float tcosdelta;
|
||||
float tsindelta;
|
||||
int state;
|
||||
} pulse;
|
||||
|
||||
static GEN* create_gen (int run, int size, double* in, double* out, int rate, int mode);
|
||||
static GEN* create_gen (int run, int size, float* in, float* out, int rate, int mode);
|
||||
static void destroy_gen (GEN *a);
|
||||
static void flush_gen (GEN *a);
|
||||
static void xgen (GEN *a);
|
||||
static void setBuffers_gen (GEN *a, double* in, double* out);
|
||||
static void setBuffers_gen (GEN *a, float* in, float* out);
|
||||
static void setSamplerate_gen (GEN *a, int rate);
|
||||
static void setSize_gen (GEN *a, int size);
|
||||
// RXA Properties
|
||||
static void SetPreGenRun (RXA& rxa, int run);
|
||||
static void SetPreGenMode (RXA& rxa, int mode);
|
||||
static void SetPreGenToneMag (RXA& rxa, double mag);
|
||||
static void SetPreGenToneFreq (RXA& rxa, double freq);
|
||||
static void SetPreGenNoiseMag (RXA& rxa, double mag);
|
||||
static void SetPreGenSweepMag (RXA& rxa, double mag);
|
||||
static void SetPreGenSweepFreq (RXA& rxa, double freq1, double freq2);
|
||||
static void SetPreGenSweepRate (RXA& rxa, double rate);
|
||||
static void SetPreGenToneMag (RXA& rxa, float mag);
|
||||
static void SetPreGenToneFreq (RXA& rxa, float freq);
|
||||
static void SetPreGenNoiseMag (RXA& rxa, float mag);
|
||||
static void SetPreGenSweepMag (RXA& rxa, float mag);
|
||||
static void SetPreGenSweepFreq (RXA& rxa, float freq1, float freq2);
|
||||
static void SetPreGenSweepRate (RXA& rxa, float rate);
|
||||
// TXA Properties
|
||||
static void SetPreGenRun (TXA& txa, int run);
|
||||
static void SetPreGenMode (TXA& txa, int mode);
|
||||
static void SetPreGenToneMag (TXA& txa, double mag);
|
||||
static void SetPreGenToneFreq (TXA& txa, double freq);
|
||||
static void SetPreGenNoiseMag (TXA& txa, double mag);
|
||||
static void SetPreGenSweepMag (TXA& txa, double mag);
|
||||
static void SetPreGenSweepFreq (TXA& txal, double freq1, double freq2);
|
||||
static void SetPreGenSweepRate (TXA& txa, double rate);
|
||||
static void SetPreGenSawtoothMag (TXA& txa, double mag);
|
||||
static void SetPreGenSawtoothFreq (TXA& txa, double freq);
|
||||
static void SetPreGenTriangleMag (TXA& txa, double mag);
|
||||
static void SetPreGenTriangleFreq (TXA& txa, double freq);
|
||||
static void SetPreGenPulseMag (TXA& txa, double mag);
|
||||
static void SetPreGenPulseFreq (TXA& txa, double freq);
|
||||
static void SetPreGenPulseDutyCycle (TXA& txa, double dc);
|
||||
static void SetPreGenPulseToneFreq (TXA& txa, double freq);
|
||||
static void SetPreGenPulseTransition (TXA& txa, double transtime);
|
||||
static void SetPreGenToneMag (TXA& txa, float mag);
|
||||
static void SetPreGenToneFreq (TXA& txa, float freq);
|
||||
static void SetPreGenNoiseMag (TXA& txa, float mag);
|
||||
static void SetPreGenSweepMag (TXA& txa, float mag);
|
||||
static void SetPreGenSweepFreq (TXA& txal, float freq1, float freq2);
|
||||
static void SetPreGenSweepRate (TXA& txa, float rate);
|
||||
static void SetPreGenSawtoothMag (TXA& txa, float mag);
|
||||
static void SetPreGenSawtoothFreq (TXA& txa, float freq);
|
||||
static void SetPreGenTriangleMag (TXA& txa, float mag);
|
||||
static void SetPreGenTriangleFreq (TXA& txa, float freq);
|
||||
static void SetPreGenPulseMag (TXA& txa, float mag);
|
||||
static void SetPreGenPulseFreq (TXA& txa, float freq);
|
||||
static void SetPreGenPulseDutyCycle (TXA& txa, float dc);
|
||||
static void SetPreGenPulseToneFreq (TXA& txa, float freq);
|
||||
static void SetPreGenPulseTransition (TXA& txa, float transtime);
|
||||
// 'PostGen', gen1
|
||||
static void SetPostGenRun (TXA& txa, int run);
|
||||
static void SetPostGenMode (TXA& txa, int mode);
|
||||
static void SetPostGenToneMag (TXA& txa, double mag);
|
||||
static void SetPostGenToneFreq (TXA& txa, double freq);
|
||||
static void SetPostGenTTMag (TXA& txa, double mag1, double mag2);
|
||||
static void SetPostGenToneMag (TXA& txa, float mag);
|
||||
static void SetPostGenToneFreq (TXA& txa, float freq);
|
||||
static void SetPostGenTTMag (TXA& txa, float mag1, float mag2);
|
||||
static void SetgenRun (TXA& txa, int run);
|
||||
static void SetPostGenTTFreq (TXA& txa, double freq1, double freq2);
|
||||
static void SetPostGenSweepMag (TXA& txa, double mag);
|
||||
static void SetPostGenSweepFreq (TXA& txa, double freq1, double freq2);
|
||||
static void SetPostGenSweepRate (TXA& txa, double rate);
|
||||
static void SetPostGenTTFreq (TXA& txa, float freq1, float freq2);
|
||||
static void SetPostGenSweepMag (TXA& txa, float mag);
|
||||
static void SetPostGenSweepFreq (TXA& txa, float freq1, float freq2);
|
||||
static void SetPostGenSweepRate (TXA& txa, float rate);
|
||||
|
||||
private:
|
||||
static void calc_tone (GEN *a);
|
||||
|
@ -34,8 +34,8 @@ namespace WDSP {
|
||||
|
||||
void ICFIR::calc_icfir (ICFIR *a)
|
||||
{
|
||||
double* impulse;
|
||||
a->scale = 1.0 / (double)(2 * a->size);
|
||||
float* impulse;
|
||||
a->scale = 1.0 / (float)(2 * a->size);
|
||||
impulse = icfir_impulse (a->nc, a->DD, a->R, a->Pairs, a->runrate, a->cicrate, a->cutoff, a->xtype, a->xbw, 1, a->scale, a->wintype);
|
||||
a->p = FIRCORE::create_fircore (a->size, a->in, a->out, a->nc, a->mp, impulse);
|
||||
delete[] (impulse);
|
||||
@ -51,16 +51,16 @@ ICFIR* ICFIR::create_icfir (
|
||||
int size,
|
||||
int nc,
|
||||
int mp,
|
||||
double* in,
|
||||
double* out,
|
||||
float* in,
|
||||
float* out,
|
||||
int runrate,
|
||||
int cicrate,
|
||||
int DD,
|
||||
int R,
|
||||
int Pairs,
|
||||
double cutoff,
|
||||
float cutoff,
|
||||
int xtype,
|
||||
double xbw,
|
||||
float xbw,
|
||||
int wintype
|
||||
)
|
||||
// run: 0 - no action; 1 - operate
|
||||
@ -116,7 +116,7 @@ void ICFIR::xicfir (ICFIR *a)
|
||||
memcpy (a->out, a->in, a->size * sizeof (wcomplex));
|
||||
}
|
||||
|
||||
void ICFIR::setBuffers_icfir (ICFIR *a, double* in, double* out)
|
||||
void ICFIR::setBuffers_icfir (ICFIR *a, float* in, float* out)
|
||||
{
|
||||
decalc_icfir (a);
|
||||
a->in = in;
|
||||
@ -145,18 +145,18 @@ void ICFIR::setOutRate_icfir (ICFIR *a, int rate)
|
||||
calc_icfir (a);
|
||||
}
|
||||
|
||||
double* ICFIR::icfir_impulse (
|
||||
float* ICFIR::icfir_impulse (
|
||||
int N,
|
||||
int DD,
|
||||
int R,
|
||||
int Pairs,
|
||||
double runrate,
|
||||
double cicrate,
|
||||
double cutoff,
|
||||
float runrate,
|
||||
float cicrate,
|
||||
float cutoff,
|
||||
int xtype,
|
||||
double xbw,
|
||||
float xbw,
|
||||
int rtype,
|
||||
double scale,
|
||||
float scale,
|
||||
int wintype
|
||||
)
|
||||
{
|
||||
@ -172,18 +172,18 @@ double* ICFIR::icfir_impulse (
|
||||
// rtype: 0 for real output, 1 for complex output
|
||||
// scale: scale factor to be applied to the output
|
||||
int i, j;
|
||||
double tmp, local_scale, ri, mag, fn;
|
||||
double* impulse;
|
||||
double* A = new double[N]; // (double *) malloc0 (N * sizeof (double));
|
||||
double ft = cutoff / cicrate; // normalized cutoff frequency
|
||||
float tmp, local_scale, ri, mag, fn;
|
||||
float* impulse;
|
||||
float* A = new float[N]; // (float *) malloc0 (N * sizeof (float));
|
||||
float ft = cutoff / cicrate; // normalized cutoff frequency
|
||||
int u_samps = (N + 1) / 2; // number of unique samples, OK for odd or even N
|
||||
int c_samps = (int)(cutoff / runrate * N) + (N + 1) / 2 - N / 2; // number of unique samples within bandpass, OK for odd or even N
|
||||
int x_samps = (int)(xbw / runrate * N); // number of unique samples in transition region, OK for odd or even N
|
||||
double offset = 0.5 - 0.5 * (double)((N + 1) / 2 - N / 2); // sample offset from center, OK for odd or even N
|
||||
double* xistion = new double[x_samps + 1]; // (double *) malloc0 ((x_samps + 1) * sizeof (double));
|
||||
double delta = PI / (double)x_samps;
|
||||
double L = cicrate / runrate;
|
||||
double phs = 0.0;
|
||||
float offset = 0.5 - 0.5 * (float)((N + 1) / 2 - N / 2); // sample offset from center, OK for odd or even N
|
||||
float* xistion = new float[x_samps + 1]; // (float *) malloc0 ((x_samps + 1) * sizeof (float));
|
||||
float delta = PI / (float)x_samps;
|
||||
float L = cicrate / runrate;
|
||||
float phs = 0.0;
|
||||
for (i = 0; i <= x_samps; i++)
|
||||
{
|
||||
xistion[i] = 0.5 * (cos (phs) + 1.0);
|
||||
@ -196,7 +196,7 @@ double* ICFIR::icfir_impulse (
|
||||
{
|
||||
for (i = 0, ri = offset; i < u_samps; i++, ri += 1.0)
|
||||
{
|
||||
fn = ri / (L * (double)N);
|
||||
fn = ri / (L * (float)N);
|
||||
if (fn <= ft)
|
||||
{
|
||||
if (fn == 0.0) tmp = 1.0;
|
||||
@ -213,7 +213,7 @@ double* ICFIR::icfir_impulse (
|
||||
{
|
||||
for (i = 0, ri = offset; i < u_samps; i++, ri += 1.0)
|
||||
{
|
||||
fn = ri / (L *(double)N);
|
||||
fn = ri / (L *(float)N);
|
||||
if (i < c_samps)
|
||||
{
|
||||
if (fn == 0.0) tmp = 1.0;
|
||||
|
@ -41,17 +41,17 @@ public:
|
||||
int size;
|
||||
int nc;
|
||||
int mp;
|
||||
double* in;
|
||||
double* out;
|
||||
float* in;
|
||||
float* out;
|
||||
int runrate;
|
||||
int cicrate;
|
||||
int DD;
|
||||
int R;
|
||||
int Pairs;
|
||||
double cutoff;
|
||||
double scale;
|
||||
float cutoff;
|
||||
float scale;
|
||||
int xtype;
|
||||
double xbw;
|
||||
float xbw;
|
||||
int wintype;
|
||||
FIRCORE *p;
|
||||
|
||||
@ -60,37 +60,37 @@ public:
|
||||
int size,
|
||||
int nc,
|
||||
int mp,
|
||||
double* in,
|
||||
double* out,
|
||||
float* in,
|
||||
float* out,
|
||||
int runrate,
|
||||
int cicrate,
|
||||
int DD,
|
||||
int R,
|
||||
int Pairs,
|
||||
double cutoff,
|
||||
float cutoff,
|
||||
int xtype,
|
||||
double xbw,
|
||||
float xbw,
|
||||
int wintype
|
||||
);
|
||||
static void destroy_icfir (ICFIR *a);
|
||||
static void flush_icfir (ICFIR *a);
|
||||
static void xicfir (ICFIR *a);
|
||||
static void setBuffers_icfir (ICFIR *a, double* in, double* out);
|
||||
static void setBuffers_icfir (ICFIR *a, float* in, float* out);
|
||||
static void setSamplerate_icfir (ICFIR *a, int rate);
|
||||
static void setSize_icfir (ICFIR *a, int size);
|
||||
static void setOutRate_icfir (ICFIR *a, int rate);
|
||||
static double* icfir_impulse (
|
||||
static float* icfir_impulse (
|
||||
int N,
|
||||
int DD,
|
||||
int R,
|
||||
int Pairs,
|
||||
double runrate,
|
||||
double cicrate,
|
||||
double cutoff,
|
||||
float runrate,
|
||||
float cicrate,
|
||||
float cutoff,
|
||||
int xtype,
|
||||
double xbw,
|
||||
float xbw,
|
||||
int rtype,
|
||||
double scale,
|
||||
float scale,
|
||||
int wintype
|
||||
);
|
||||
|
||||
|
218
wdsp/iir.cpp
218
wdsp/iir.cpp
@ -40,8 +40,8 @@ namespace WDSP {
|
||||
|
||||
void SNOTCH::calc_snotch (SNOTCH *a)
|
||||
{
|
||||
double fn, qk, qr, csn;
|
||||
fn = a->f / (double)a->rate;
|
||||
float fn, qk, qr, csn;
|
||||
fn = a->f / (float)a->rate;
|
||||
csn = cos (TWOPI * fn);
|
||||
qr = 1.0 - 3.0 * a->bw;
|
||||
qk = (1.0 - 2.0 * qr * csn + qr * qr) / (2.0 * (1.0 - csn));
|
||||
@ -53,7 +53,7 @@ void SNOTCH::calc_snotch (SNOTCH *a)
|
||||
flush_snotch (a);
|
||||
}
|
||||
|
||||
SNOTCH* SNOTCH::create_snotch (int run, int size, double* in, double* out, int rate, double f, double bw)
|
||||
SNOTCH* SNOTCH::create_snotch (int run, int size, float* in, float* out, int rate, float f, float bw)
|
||||
{
|
||||
SNOTCH *a = new SNOTCH;
|
||||
a->run = run;
|
||||
@ -98,7 +98,7 @@ void SNOTCH::xsnotch (SNOTCH *a)
|
||||
a->cs_update.unlock();
|
||||
}
|
||||
|
||||
void SNOTCH::setBuffers_snotch (SNOTCH *a, double* in, double* out)
|
||||
void SNOTCH::setBuffers_snotch (SNOTCH *a, float* in, float* out)
|
||||
{
|
||||
a->in = in;
|
||||
a->out = out;
|
||||
@ -122,7 +122,7 @@ void SNOTCH::setSize_snotch (SNOTCH *a, int size)
|
||||
* *
|
||||
********************************************************************************************************/
|
||||
|
||||
void SNOTCH::SetSNCTCSSFreq (SNOTCH *a, double freq)
|
||||
void SNOTCH::SetSNCTCSSFreq (SNOTCH *a, float freq)
|
||||
{
|
||||
a->cs_update.lock();
|
||||
a->f = freq;
|
||||
@ -146,8 +146,8 @@ void SNOTCH::SetSNCTCSSRun (SNOTCH *a, int run)
|
||||
|
||||
void SPEAK::calc_speak (SPEAK *a)
|
||||
{
|
||||
double ratio;
|
||||
double f_corr, g_corr, bw_corr, bw_parm, A, f_min;
|
||||
float ratio;
|
||||
float f_corr, g_corr, bw_corr, bw_parm, A, f_min;
|
||||
|
||||
switch (a->design)
|
||||
{
|
||||
@ -167,11 +167,11 @@ void SPEAK::calc_speak (SPEAK *a)
|
||||
break;
|
||||
}
|
||||
{
|
||||
double fn, qk, qr, csn;
|
||||
float fn, qk, qr, csn;
|
||||
a->fgain = a->gain / g_corr;
|
||||
fn = a->f / (double)a->rate / f_corr;
|
||||
fn = a->f / (float)a->rate / f_corr;
|
||||
csn = cos (TWOPI * fn);
|
||||
qr = 1.0 - 3.0 * a->bw / (double)a->rate * bw_parm;
|
||||
qr = 1.0 - 3.0 * a->bw / (float)a->rate * bw_parm;
|
||||
qk = (1.0 - 2.0 * qr * csn + qr * qr) / (2.0 * (1.0 - csn));
|
||||
a->a0 = 1.0 - qk;
|
||||
a->a1 = 2.0 * (qk - qr) * csn;
|
||||
@ -201,9 +201,9 @@ void SPEAK::calc_speak (SPEAK *a)
|
||||
break;
|
||||
}
|
||||
{
|
||||
double w0, sn, c, den;
|
||||
float w0, sn, c, den;
|
||||
if (a->f < f_min) a->f = f_min;
|
||||
w0 = TWOPI * a->f / (double)a->rate;
|
||||
w0 = TWOPI * a->f / (float)a->rate;
|
||||
sn = sin (w0);
|
||||
a->cbw = bw_corr * a->f;
|
||||
c = sn * sinh(0.5 * log((a->f + 0.5 * a->cbw * bw_parm) / (a->f - 0.5 * a->cbw * bw_parm)) * w0 / sn);
|
||||
@ -213,14 +213,14 @@ void SPEAK::calc_speak (SPEAK *a)
|
||||
a->a2 = (1 - c * A) / den;
|
||||
a->b1 = - a->a1;
|
||||
a->b2 = - (1 - c / A ) / den;
|
||||
a->fgain = a->gain / pow (A * A, (double)a->nstages);
|
||||
a->fgain = a->gain / pow (A * A, (float)a->nstages);
|
||||
}
|
||||
break;
|
||||
}
|
||||
flush_speak (a);
|
||||
}
|
||||
|
||||
SPEAK* SPEAK::create_speak (int run, int size, double* in, double* out, int rate, double f, double bw, double gain, int nstages, int design)
|
||||
SPEAK* SPEAK::create_speak (int run, int size, float* in, float* out, int rate, float f, float bw, float gain, int nstages, int design)
|
||||
{
|
||||
SPEAK *a = new SPEAK;
|
||||
a->run = run;
|
||||
@ -233,12 +233,12 @@ SPEAK* SPEAK::create_speak (int run, int size, double* in, double* out, int rate
|
||||
a->gain = gain;
|
||||
a->nstages = nstages;
|
||||
a->design = design;
|
||||
a->x0 = new double[a->nstages * 2]; // (double *) malloc0 (a->nstages * sizeof (complex));
|
||||
a->x1 = new double[a->nstages * 2]; // (double *) malloc0 (a->nstages * sizeof (complex));
|
||||
a->x2 = new double[a->nstages * 2]; //(double *) malloc0 (a->nstages * sizeof (complex));
|
||||
a->y0 = new double[a->nstages * 2]; // (double *) malloc0 (a->nstages * sizeof (complex));
|
||||
a->y1 = new double[a->nstages * 2]; // (double *) malloc0 (a->nstages * sizeof (complex));
|
||||
a->y2 = new double[a->nstages * 2]; // (double *) malloc0 (a->nstages * sizeof (complex));
|
||||
a->x0 = new float[a->nstages * 2]; // (float *) malloc0 (a->nstages * sizeof (complex));
|
||||
a->x1 = new float[a->nstages * 2]; // (float *) malloc0 (a->nstages * sizeof (complex));
|
||||
a->x2 = new float[a->nstages * 2]; //(float *) malloc0 (a->nstages * sizeof (complex));
|
||||
a->y0 = new float[a->nstages * 2]; // (float *) malloc0 (a->nstages * sizeof (complex));
|
||||
a->y1 = new float[a->nstages * 2]; // (float *) malloc0 (a->nstages * sizeof (complex));
|
||||
a->y2 = new float[a->nstages * 2]; // (float *) malloc0 (a->nstages * sizeof (complex));
|
||||
calc_speak (a);
|
||||
return a;
|
||||
}
|
||||
@ -297,7 +297,7 @@ void SPEAK::xspeak (SPEAK *a)
|
||||
a->cs_update.unlock();
|
||||
}
|
||||
|
||||
void SPEAK::setBuffers_speak (SPEAK *a, double* in, double* out)
|
||||
void SPEAK::setBuffers_speak (SPEAK *a, float* in, float* out)
|
||||
{
|
||||
a->in = in;
|
||||
a->out = out;
|
||||
@ -329,7 +329,7 @@ void SPEAK::SetSPCWRun (RXA& rxa, int run)
|
||||
a->cs_update.unlock();
|
||||
}
|
||||
|
||||
void SPEAK::SetSPCWFreq (RXA& rxa, double freq)
|
||||
void SPEAK::SetSPCWFreq (RXA& rxa, float freq)
|
||||
{
|
||||
SPEAK *a = rxa.speak.p;
|
||||
a->cs_update.lock();
|
||||
@ -338,7 +338,7 @@ void SPEAK::SetSPCWFreq (RXA& rxa, double freq)
|
||||
a->cs_update.unlock();
|
||||
}
|
||||
|
||||
void SPEAK::SetSPCWBandwidth (RXA& rxa, double bw)
|
||||
void SPEAK::SetSPCWBandwidth (RXA& rxa, float bw)
|
||||
{
|
||||
SPEAK *a = rxa.speak.p;
|
||||
a->cs_update.lock();
|
||||
@ -347,7 +347,7 @@ void SPEAK::SetSPCWBandwidth (RXA& rxa, double bw)
|
||||
a->cs_update.unlock();
|
||||
}
|
||||
|
||||
void SPEAK::SetSPCWGain (RXA& rxa, double gain)
|
||||
void SPEAK::SetSPCWGain (RXA& rxa, float gain)
|
||||
{
|
||||
SPEAK *a = rxa.speak.p;
|
||||
a->cs_update.lock();
|
||||
@ -365,8 +365,8 @@ void SPEAK::SetSPCWGain (RXA& rxa, double gain)
|
||||
void MPEAK::calc_mpeak (MPEAK *a)
|
||||
{
|
||||
int i;
|
||||
a->tmp = new double[a->size * 2]; // (double *) malloc0 (a->size * sizeof (complex));
|
||||
a->mix = new double[a->size * 2]; // (double *) malloc0 (a->size * sizeof (complex));
|
||||
a->tmp = new float[a->size * 2]; // (float *) malloc0 (a->size * sizeof (complex));
|
||||
a->mix = new float[a->size * 2]; // (float *) malloc0 (a->size * sizeof (complex));
|
||||
for (i = 0; i < a->npeaks; i++)
|
||||
{
|
||||
a->pfil[i] = SPEAK::create_speak (
|
||||
@ -393,7 +393,7 @@ void MPEAK::decalc_mpeak (MPEAK *a)
|
||||
delete[] (a->tmp);
|
||||
}
|
||||
|
||||
MPEAK* MPEAK::create_mpeak (int run, int size, double* in, double* out, int rate, int npeaks, int* enable, double* f, double* bw, double* gain, int nstages)
|
||||
MPEAK* MPEAK::create_mpeak (int run, int size, float* in, float* out, int rate, int npeaks, int* enable, float* f, float* bw, float* gain, int nstages)
|
||||
{
|
||||
MPEAK *a = new MPEAK;
|
||||
a->run = run;
|
||||
@ -404,13 +404,13 @@ MPEAK* MPEAK::create_mpeak (int run, int size, double* in, double* out, int rate
|
||||
a->npeaks = npeaks;
|
||||
a->nstages = nstages;
|
||||
a->enable = new int[a->npeaks]; // (int *) malloc0 (a->npeaks * sizeof (int));
|
||||
a->f = new double[a->npeaks]; // (double *) malloc0 (a->npeaks * sizeof (double));
|
||||
a->bw = new double[a->npeaks]; // (double *) malloc0 (a->npeaks * sizeof (double));
|
||||
a->gain = new double[a->npeaks]; // (double *) malloc0 (a->npeaks * sizeof (double));
|
||||
a->f = new float[a->npeaks]; // (float *) malloc0 (a->npeaks * sizeof (float));
|
||||
a->bw = new float[a->npeaks]; // (float *) malloc0 (a->npeaks * sizeof (float));
|
||||
a->gain = new float[a->npeaks]; // (float *) malloc0 (a->npeaks * sizeof (float));
|
||||
memcpy (a->enable, enable, a->npeaks * sizeof (int));
|
||||
memcpy (a->f, f, a->npeaks * sizeof (double));
|
||||
memcpy (a->bw, bw, a->npeaks * sizeof (double));
|
||||
memcpy (a->gain, gain, a->npeaks * sizeof (double));
|
||||
memcpy (a->f, f, a->npeaks * sizeof (float));
|
||||
memcpy (a->bw, bw, a->npeaks * sizeof (float));
|
||||
memcpy (a->gain, gain, a->npeaks * sizeof (float));
|
||||
a->pfil = new SPEAK*[a->npeaks]; // (SPEAK *) malloc0 (a->npeaks * sizeof (SPEAK));
|
||||
calc_mpeak (a);
|
||||
return a;
|
||||
@ -457,7 +457,7 @@ void MPEAK::xmpeak (MPEAK *a)
|
||||
a->cs_update.unlock();
|
||||
}
|
||||
|
||||
void MPEAK::setBuffers_mpeak (MPEAK *a, double* in, double* out)
|
||||
void MPEAK::setBuffers_mpeak (MPEAK *a, float* in, float* out)
|
||||
{
|
||||
decalc_mpeak (a);
|
||||
a->in = in;
|
||||
@ -509,7 +509,7 @@ void MPEAK::SetmpeakFilEnable (RXA& rxa, int fil, int enable)
|
||||
a->cs_update.unlock();
|
||||
}
|
||||
|
||||
void MPEAK::SetmpeakFilFreq (RXA& rxa, int fil, double freq)
|
||||
void MPEAK::SetmpeakFilFreq (RXA& rxa, int fil, float freq)
|
||||
{
|
||||
MPEAK *a = rxa.mpeak.p;
|
||||
a->cs_update.lock();
|
||||
@ -519,7 +519,7 @@ void MPEAK::SetmpeakFilFreq (RXA& rxa, int fil, double freq)
|
||||
a->cs_update.unlock();
|
||||
}
|
||||
|
||||
void MPEAK::SetmpeakFilBw (RXA& rxa, int fil, double bw)
|
||||
void MPEAK::SetmpeakFilBw (RXA& rxa, int fil, float bw)
|
||||
{
|
||||
MPEAK *a = rxa.mpeak.p;
|
||||
a->cs_update.lock();
|
||||
@ -529,7 +529,7 @@ void MPEAK::SetmpeakFilBw (RXA& rxa, int fil, double bw)
|
||||
a->cs_update.unlock();
|
||||
}
|
||||
|
||||
void MPEAK::SetmpeakFilGain (RXA& rxa, int fil, double gain)
|
||||
void MPEAK::SetmpeakFilGain (RXA& rxa, int fil, float gain)
|
||||
{
|
||||
MPEAK *a = rxa.mpeak.p;
|
||||
a->cs_update.lock();
|
||||
@ -548,12 +548,12 @@ void MPEAK::SetmpeakFilGain (RXA& rxa, int fil, double gain)
|
||||
|
||||
void PHROT::calc_phrot (PHROT *a)
|
||||
{
|
||||
double g;
|
||||
a->x0 = new double[a->nstages]; // (double *) malloc0 (a->nstages * sizeof (double));
|
||||
a->x1 = new double[a->nstages]; // (double *) malloc0 (a->nstages * sizeof (double));
|
||||
a->y0 = new double[a->nstages]; // (double *) malloc0 (a->nstages * sizeof (double));
|
||||
a->y1 = new double[a->nstages]; // (double *) malloc0 (a->nstages * sizeof (double));
|
||||
g = tan (PI * a->fc / (double)a->rate);
|
||||
float g;
|
||||
a->x0 = new float[a->nstages]; // (float *) malloc0 (a->nstages * sizeof (float));
|
||||
a->x1 = new float[a->nstages]; // (float *) malloc0 (a->nstages * sizeof (float));
|
||||
a->y0 = new float[a->nstages]; // (float *) malloc0 (a->nstages * sizeof (float));
|
||||
a->y1 = new float[a->nstages]; // (float *) malloc0 (a->nstages * sizeof (float));
|
||||
g = tan (PI * a->fc / (float)a->rate);
|
||||
a->b0 = (g - 1.0) / (g + 1.0);
|
||||
a->b1 = 1.0;
|
||||
a->a1 = a->b0;
|
||||
@ -567,7 +567,7 @@ void PHROT::decalc_phrot (PHROT *a)
|
||||
delete[] (a->x0);
|
||||
}
|
||||
|
||||
PHROT* PHROT::create_phrot (int run, int size, double* in, double* out, int rate, double fc, int nstages)
|
||||
PHROT* PHROT::create_phrot (int run, int size, float* in, float* out, int rate, float fc, int nstages)
|
||||
{
|
||||
PHROT *a = new PHROT;
|
||||
a->reverse = 0;
|
||||
@ -590,10 +590,10 @@ void PHROT::destroy_phrot (PHROT *a)
|
||||
|
||||
void PHROT::flush_phrot (PHROT *a)
|
||||
{
|
||||
memset (a->x0, 0, a->nstages * sizeof (double));
|
||||
memset (a->x1, 0, a->nstages * sizeof (double));
|
||||
memset (a->y0, 0, a->nstages * sizeof (double));
|
||||
memset (a->y1, 0, a->nstages * sizeof (double));
|
||||
memset (a->x0, 0, a->nstages * sizeof (float));
|
||||
memset (a->x1, 0, a->nstages * sizeof (float));
|
||||
memset (a->y0, 0, a->nstages * sizeof (float));
|
||||
memset (a->y1, 0, a->nstages * sizeof (float));
|
||||
}
|
||||
|
||||
void PHROT::xphrot (PHROT *a)
|
||||
@ -627,7 +627,7 @@ void PHROT::xphrot (PHROT *a)
|
||||
a->cs_update.unlock();
|
||||
}
|
||||
|
||||
void PHROT::setBuffers_phrot (PHROT *a, double* in, double* out)
|
||||
void PHROT::setBuffers_phrot (PHROT *a, float* in, float* out)
|
||||
{
|
||||
a->in = in;
|
||||
a->out = out;
|
||||
@ -661,7 +661,7 @@ void PHROT::SetPHROTRun (TXA& txa, int run)
|
||||
a->cs_update.unlock();
|
||||
}
|
||||
|
||||
void PHROT::SetPHROTCorner (TXA& txa, double corner)
|
||||
void PHROT::SetPHROTCorner (TXA& txa, float corner)
|
||||
{
|
||||
PHROT *a = txa.phrot.p;
|
||||
a->cs_update.lock();
|
||||
@ -697,8 +697,8 @@ void PHROT::SetPHROTReverse (TXA& txa, int reverse)
|
||||
|
||||
void BQLP::calc_bqlp(BQLP *a)
|
||||
{
|
||||
double w0, cs, c, den;
|
||||
w0 = TWOPI * a->fc / (double)a->rate;
|
||||
float w0, cs, c, den;
|
||||
w0 = TWOPI * a->fc / (float)a->rate;
|
||||
cs = cos(w0);
|
||||
c = sin(w0) / (2.0 * a->Q);
|
||||
den = 1.0 + c;
|
||||
@ -710,7 +710,7 @@ void BQLP::calc_bqlp(BQLP *a)
|
||||
flush_bqlp(a);
|
||||
}
|
||||
|
||||
BQLP* BQLP::create_bqlp(int run, int size, double* in, double* out, double rate, double fc, double Q, double gain, int nstages)
|
||||
BQLP* BQLP::create_bqlp(int run, int size, float* in, float* out, float rate, float fc, float Q, float gain, int nstages)
|
||||
{
|
||||
BQLP *a = new BQLP;
|
||||
a->run = run;
|
||||
@ -722,12 +722,12 @@ BQLP* BQLP::create_bqlp(int run, int size, double* in, double* out, double rate,
|
||||
a->Q = Q;
|
||||
a->gain = gain;
|
||||
a->nstages = nstages;
|
||||
a->x0 = new double[a->nstages * 2]; // (double*)malloc0(a->nstages * sizeof(complex));
|
||||
a->x1 = new double[a->nstages * 2]; // (double*)malloc0(a->nstages * sizeof(complex));
|
||||
a->x2 = new double[a->nstages * 2]; // (double*)malloc0(a->nstages * sizeof(complex));
|
||||
a->y0 = new double[a->nstages * 2]; // (double*)malloc0(a->nstages * sizeof(complex));
|
||||
a->y1 = new double[a->nstages * 2]; // (double*)malloc0(a->nstages * sizeof(complex));
|
||||
a->y2 = new double[a->nstages * 2]; // (double*)malloc0(a->nstages * sizeof(complex));
|
||||
a->x0 = new float[a->nstages * 2]; // (float*)malloc0(a->nstages * sizeof(complex));
|
||||
a->x1 = new float[a->nstages * 2]; // (float*)malloc0(a->nstages * sizeof(complex));
|
||||
a->x2 = new float[a->nstages * 2]; // (float*)malloc0(a->nstages * sizeof(complex));
|
||||
a->y0 = new float[a->nstages * 2]; // (float*)malloc0(a->nstages * sizeof(complex));
|
||||
a->y1 = new float[a->nstages * 2]; // (float*)malloc0(a->nstages * sizeof(complex));
|
||||
a->y2 = new float[a->nstages * 2]; // (float*)malloc0(a->nstages * sizeof(complex));
|
||||
calc_bqlp(a);
|
||||
return a;
|
||||
}
|
||||
@ -786,7 +786,7 @@ void BQLP::xbqlp(BQLP *a)
|
||||
a->cs_update.unlock();
|
||||
}
|
||||
|
||||
void BQLP::setBuffers_bqlp(BQLP *a, double* in, double* out)
|
||||
void BQLP::setBuffers_bqlp(BQLP *a, float* in, float* out)
|
||||
{
|
||||
a->in = in;
|
||||
a->out = out;
|
||||
@ -812,8 +812,8 @@ void BQLP::setSize_bqlp(BQLP *a, int size)
|
||||
|
||||
void DBQLP::calc_dbqlp(BQLP *a)
|
||||
{
|
||||
double w0, cs, c, den;
|
||||
w0 = TWOPI * a->fc / (double)a->rate;
|
||||
float w0, cs, c, den;
|
||||
w0 = TWOPI * a->fc / (float)a->rate;
|
||||
cs = cos(w0);
|
||||
c = sin(w0) / (2.0 * a->Q);
|
||||
den = 1.0 + c;
|
||||
@ -825,7 +825,7 @@ void DBQLP::calc_dbqlp(BQLP *a)
|
||||
flush_dbqlp(a);
|
||||
}
|
||||
|
||||
BQLP* DBQLP::create_dbqlp(int run, int size, double* in, double* out, double rate, double fc, double Q, double gain, int nstages)
|
||||
BQLP* DBQLP::create_dbqlp(int run, int size, float* in, float* out, float rate, float fc, float Q, float gain, int nstages)
|
||||
{
|
||||
BQLP *a = new BQLP;
|
||||
a->run = run;
|
||||
@ -837,12 +837,12 @@ BQLP* DBQLP::create_dbqlp(int run, int size, double* in, double* out, double rat
|
||||
a->Q = Q;
|
||||
a->gain = gain;
|
||||
a->nstages = nstages;
|
||||
a->x0 = new double[a->nstages]; // (double*)malloc0(a->nstages * sizeof(double));
|
||||
a->x1 = new double[a->nstages]; // (double*)malloc0(a->nstages * sizeof(double));
|
||||
a->x2 = new double[a->nstages]; // (double*)malloc0(a->nstages * sizeof(double));
|
||||
a->y0 = new double[a->nstages]; // (double*)malloc0(a->nstages * sizeof(double));
|
||||
a->y1 = new double[a->nstages]; // (double*)malloc0(a->nstages * sizeof(double));
|
||||
a->y2 = new double[a->nstages]; // (double*)malloc0(a->nstages * sizeof(double));
|
||||
a->x0 = new float[a->nstages]; // (float*)malloc0(a->nstages * sizeof(float));
|
||||
a->x1 = new float[a->nstages]; // (float*)malloc0(a->nstages * sizeof(float));
|
||||
a->x2 = new float[a->nstages]; // (float*)malloc0(a->nstages * sizeof(float));
|
||||
a->y0 = new float[a->nstages]; // (float*)malloc0(a->nstages * sizeof(float));
|
||||
a->y1 = new float[a->nstages]; // (float*)malloc0(a->nstages * sizeof(float));
|
||||
a->y2 = new float[a->nstages]; // (float*)malloc0(a->nstages * sizeof(float));
|
||||
calc_dbqlp(a);
|
||||
return a;
|
||||
}
|
||||
@ -893,11 +893,11 @@ void DBQLP::xdbqlp(BQLP *a)
|
||||
}
|
||||
}
|
||||
else if (a->out != a->in)
|
||||
memcpy(a->out, a->in, a->size * sizeof(double));
|
||||
memcpy(a->out, a->in, a->size * sizeof(float));
|
||||
a->cs_update.unlock();
|
||||
}
|
||||
|
||||
void DBQLP::setBuffers_dbqlp(BQLP *a, double* in, double* out)
|
||||
void DBQLP::setBuffers_dbqlp(BQLP *a, float* in, float* out)
|
||||
{
|
||||
a->in = in;
|
||||
a->out = out;
|
||||
@ -924,7 +924,7 @@ void DBQLP::setSize_dbqlp(BQLP *a, int size)
|
||||
|
||||
void BQBP::calc_bqbp(BQBP *a)
|
||||
{
|
||||
double f0, w0, bw, q, sn, cs, c, den;
|
||||
float f0, w0, bw, q, sn, cs, c, den;
|
||||
bw = a->f_high - a->f_low;
|
||||
f0 = (a->f_high + a->f_low) / 2.0;
|
||||
q = f0 / bw;
|
||||
@ -941,7 +941,7 @@ void BQBP::calc_bqbp(BQBP *a)
|
||||
flush_bqbp(a);
|
||||
}
|
||||
|
||||
BQBP* BQBP::create_bqbp(int run, int size, double* in, double* out, double rate, double f_low, double f_high, double gain, int nstages)
|
||||
BQBP* BQBP::create_bqbp(int run, int size, float* in, float* out, float rate, float f_low, float f_high, float gain, int nstages)
|
||||
{
|
||||
BQBP *a = new BQBP;
|
||||
a->run = run;
|
||||
@ -953,12 +953,12 @@ BQBP* BQBP::create_bqbp(int run, int size, double* in, double* out, double rate,
|
||||
a->f_high = f_high;
|
||||
a->gain = gain;
|
||||
a->nstages = nstages;
|
||||
a->x0 = new double[a->nstages * 2]; // (double*)malloc0(a->nstages * sizeof(complex));
|
||||
a->x1 = new double[a->nstages * 2]; // (double*)malloc0(a->nstages * sizeof(complex));
|
||||
a->x2 = new double[a->nstages * 2]; // (double*)malloc0(a->nstages * sizeof(complex));
|
||||
a->y0 = new double[a->nstages * 2]; // (double*)malloc0(a->nstages * sizeof(complex));
|
||||
a->y1 = new double[a->nstages * 2]; // (double*)malloc0(a->nstages * sizeof(complex));
|
||||
a->y2 = new double[a->nstages * 2]; // (double*)malloc0(a->nstages * sizeof(complex));
|
||||
a->x0 = new float[a->nstages * 2]; // (float*)malloc0(a->nstages * sizeof(complex));
|
||||
a->x1 = new float[a->nstages * 2]; // (float*)malloc0(a->nstages * sizeof(complex));
|
||||
a->x2 = new float[a->nstages * 2]; // (float*)malloc0(a->nstages * sizeof(complex));
|
||||
a->y0 = new float[a->nstages * 2]; // (float*)malloc0(a->nstages * sizeof(complex));
|
||||
a->y1 = new float[a->nstages * 2]; // (float*)malloc0(a->nstages * sizeof(complex));
|
||||
a->y2 = new float[a->nstages * 2]; // (float*)malloc0(a->nstages * sizeof(complex));
|
||||
calc_bqbp(a);
|
||||
return a;
|
||||
}
|
||||
@ -1017,7 +1017,7 @@ void BQBP::xbqbp(BQBP *a)
|
||||
a->cs_update.unlock();
|
||||
}
|
||||
|
||||
void BQBP::setBuffers_bqbp(BQBP *a, double* in, double* out)
|
||||
void BQBP::setBuffers_bqbp(BQBP *a, float* in, float* out)
|
||||
{
|
||||
a->in = in;
|
||||
a->out = out;
|
||||
@ -1043,7 +1043,7 @@ void BQBP::setSize_bqbp(BQBP *a, int size)
|
||||
|
||||
void BQBP::calc_dbqbp(BQBP *a)
|
||||
{
|
||||
double f0, w0, bw, q, sn, cs, c, den;
|
||||
float f0, w0, bw, q, sn, cs, c, den;
|
||||
bw = a->f_high - a->f_low;
|
||||
f0 = (a->f_high + a->f_low) / 2.0;
|
||||
q = f0 / bw;
|
||||
@ -1060,7 +1060,7 @@ void BQBP::calc_dbqbp(BQBP *a)
|
||||
flush_dbqbp(a);
|
||||
}
|
||||
|
||||
BQBP* BQBP::create_dbqbp(int run, int size, double* in, double* out, double rate, double f_low, double f_high, double gain, int nstages)
|
||||
BQBP* BQBP::create_dbqbp(int run, int size, float* in, float* out, float rate, float f_low, float f_high, float gain, int nstages)
|
||||
{
|
||||
BQBP *a = new BQBP;
|
||||
a->run = run;
|
||||
@ -1072,12 +1072,12 @@ BQBP* BQBP::create_dbqbp(int run, int size, double* in, double* out, double rate
|
||||
a->f_high = f_high;
|
||||
a->gain = gain;
|
||||
a->nstages = nstages;
|
||||
a->x0 = new double[a->nstages]; // (double*)malloc0(a->nstages * sizeof(double));
|
||||
a->x1 = new double[a->nstages]; // (double*)malloc0(a->nstages * sizeof(double));
|
||||
a->x2 = new double[a->nstages]; // (double*)malloc0(a->nstages * sizeof(double));
|
||||
a->y0 = new double[a->nstages]; // (double*)malloc0(a->nstages * sizeof(double));
|
||||
a->y1 = new double[a->nstages]; // (double*)malloc0(a->nstages * sizeof(double));
|
||||
a->y2 = new double[a->nstages]; // (double*)malloc0(a->nstages * sizeof(double));
|
||||
a->x0 = new float[a->nstages]; // (float*)malloc0(a->nstages * sizeof(float));
|
||||
a->x1 = new float[a->nstages]; // (float*)malloc0(a->nstages * sizeof(float));
|
||||
a->x2 = new float[a->nstages]; // (float*)malloc0(a->nstages * sizeof(float));
|
||||
a->y0 = new float[a->nstages]; // (float*)malloc0(a->nstages * sizeof(float));
|
||||
a->y1 = new float[a->nstages]; // (float*)malloc0(a->nstages * sizeof(float));
|
||||
a->y2 = new float[a->nstages]; // (float*)malloc0(a->nstages * sizeof(float));
|
||||
calc_dbqbp(a);
|
||||
return a;
|
||||
}
|
||||
@ -1128,11 +1128,11 @@ void BQBP::xdbqbp(BQBP *a)
|
||||
}
|
||||
}
|
||||
else if (a->out != a->in)
|
||||
memcpy(a->out, a->in, a->size * sizeof(double));
|
||||
memcpy(a->out, a->in, a->size * sizeof(float));
|
||||
a->cs_update.unlock();
|
||||
}
|
||||
|
||||
void BQBP::setBuffers_dbqbp(BQBP *a, double* in, double* out)
|
||||
void BQBP::setBuffers_dbqbp(BQBP *a, float* in, float* out)
|
||||
{
|
||||
a->in = in;
|
||||
a->out = out;
|
||||
@ -1158,18 +1158,18 @@ void BQBP::setSize_dbqbp(BQBP *a, int size)
|
||||
|
||||
void SPHP::calc_sphp(SPHP *a)
|
||||
{
|
||||
double g;
|
||||
a->x0 = new double[a->nstages * 2]; // (double*)malloc0(a->nstages * sizeof(complex));
|
||||
a->x1 = new double[a->nstages * 2]; // (double*)malloc0(a->nstages * sizeof(complex));
|
||||
a->y0 = new double[a->nstages * 2]; // (double*)malloc0(a->nstages * sizeof(complex));
|
||||
a->y1 = new double[a->nstages * 2]; // (double*)malloc0(a->nstages * sizeof(complex));
|
||||
float g;
|
||||
a->x0 = new float[a->nstages * 2]; // (float*)malloc0(a->nstages * sizeof(complex));
|
||||
a->x1 = new float[a->nstages * 2]; // (float*)malloc0(a->nstages * sizeof(complex));
|
||||
a->y0 = new float[a->nstages * 2]; // (float*)malloc0(a->nstages * sizeof(complex));
|
||||
a->y1 = new float[a->nstages * 2]; // (float*)malloc0(a->nstages * sizeof(complex));
|
||||
g = exp(-TWOPI * a->fc / a->rate);
|
||||
a->b0 = +0.5 * (1.0 + g);
|
||||
a->b1 = -0.5 * (1.0 + g);
|
||||
a->a1 = -g;
|
||||
}
|
||||
|
||||
SPHP* SPHP::create_sphp(int run, int size, double* in, double* out, double rate, double fc, int nstages)
|
||||
SPHP* SPHP::create_sphp(int run, int size, float* in, float* out, float rate, float fc, int nstages)
|
||||
{
|
||||
SPHP *a = new SPHP;
|
||||
a->run = run;
|
||||
@ -1234,7 +1234,7 @@ void SPHP::xsphp(SPHP *a)
|
||||
a->cs_update.unlock();
|
||||
}
|
||||
|
||||
void SPHP::setBuffers_sphp(SPHP *a, double* in, double* out)
|
||||
void SPHP::setBuffers_sphp(SPHP *a, float* in, float* out)
|
||||
{
|
||||
a->in = in;
|
||||
a->out = out;
|
||||
@ -1261,18 +1261,18 @@ void SPHP::setSize_sphp(SPHP *a, int size)
|
||||
|
||||
void SPHP::calc_dsphp(SPHP *a)
|
||||
{
|
||||
double g;
|
||||
a->x0 = new double[a->nstages]; // (double*)malloc0(a->nstages * sizeof(double));
|
||||
a->x1 = new double[a->nstages]; // (double*)malloc0(a->nstages * sizeof(double));
|
||||
a->y0 = new double[a->nstages]; // (double*)malloc0(a->nstages * sizeof(double));
|
||||
a->y1 = new double[a->nstages]; // (double*)malloc0(a->nstages * sizeof(double));
|
||||
float g;
|
||||
a->x0 = new float[a->nstages]; // (float*)malloc0(a->nstages * sizeof(float));
|
||||
a->x1 = new float[a->nstages]; // (float*)malloc0(a->nstages * sizeof(float));
|
||||
a->y0 = new float[a->nstages]; // (float*)malloc0(a->nstages * sizeof(float));
|
||||
a->y1 = new float[a->nstages]; // (float*)malloc0(a->nstages * sizeof(float));
|
||||
g = exp(-TWOPI * a->fc / a->rate);
|
||||
a->b0 = +0.5 * (1.0 + g);
|
||||
a->b1 = -0.5 * (1.0 + g);
|
||||
a->a1 = -g;
|
||||
}
|
||||
|
||||
SPHP* SPHP::create_dsphp(int run, int size, double* in, double* out, double rate, double fc, int nstages)
|
||||
SPHP* SPHP::create_dsphp(int run, int size, float* in, float* out, float rate, float fc, int nstages)
|
||||
{
|
||||
SPHP *a = new SPHP;
|
||||
a->run = run;
|
||||
@ -1302,10 +1302,10 @@ void SPHP::destroy_dsphp(SPHP *a)
|
||||
|
||||
void SPHP::flush_dsphp(SPHP *a)
|
||||
{
|
||||
memset(a->x0, 0, a->nstages * sizeof(double));
|
||||
memset(a->x1, 0, a->nstages * sizeof(double));
|
||||
memset(a->y0, 0, a->nstages * sizeof(double));
|
||||
memset(a->y1, 0, a->nstages * sizeof(double));
|
||||
memset(a->x0, 0, a->nstages * sizeof(float));
|
||||
memset(a->x1, 0, a->nstages * sizeof(float));
|
||||
memset(a->y0, 0, a->nstages * sizeof(float));
|
||||
memset(a->y1, 0, a->nstages * sizeof(float));
|
||||
}
|
||||
|
||||
void SPHP::xdsphp(SPHP *a)
|
||||
@ -1330,11 +1330,11 @@ void SPHP::xdsphp(SPHP *a)
|
||||
}
|
||||
}
|
||||
else if (a->out != a->in)
|
||||
memcpy(a->out, a->in, a->size * sizeof(double));
|
||||
memcpy(a->out, a->in, a->size * sizeof(float));
|
||||
a->cs_update.unlock();
|
||||
}
|
||||
|
||||
void SPHP::setBuffers_dsphp(SPHP *a, double* in, double* out)
|
||||
void SPHP::setBuffers_dsphp(SPHP *a, float* in, float* out)
|
||||
{
|
||||
a->in = in;
|
||||
a->out = out;
|
||||
|
158
wdsp/iir.hpp
158
wdsp/iir.hpp
@ -45,23 +45,23 @@ class WDSP_API SNOTCH
|
||||
public:
|
||||
int run;
|
||||
int size;
|
||||
double* in;
|
||||
double* out;
|
||||
double rate;
|
||||
double f;
|
||||
double bw;
|
||||
double a0, a1, a2, b1, b2;
|
||||
double x0, x1, x2, y1, y2;
|
||||
float* in;
|
||||
float* out;
|
||||
float rate;
|
||||
float f;
|
||||
float bw;
|
||||
float a0, a1, a2, b1, b2;
|
||||
float x0, x1, x2, y1, y2;
|
||||
QRecursiveMutex cs_update;
|
||||
|
||||
static SNOTCH* create_snotch (int run, int size, double* in, double* out, int rate, double f, double bw);
|
||||
static SNOTCH* create_snotch (int run, int size, float* in, float* out, int rate, float f, float bw);
|
||||
static void destroy_snotch (SNOTCH *a);
|
||||
static void flush_snotch (SNOTCH *a);
|
||||
static void xsnotch (SNOTCH *a);
|
||||
static void setBuffers_snotch (SNOTCH *a, double* in, double* out);
|
||||
static void setBuffers_snotch (SNOTCH *a, float* in, float* out);
|
||||
static void setSamplerate_snotch (SNOTCH *a, int rate);
|
||||
static void setSize_snotch (SNOTCH *a, int size);
|
||||
static void SetSNCTCSSFreq (SNOTCH *a, double freq);
|
||||
static void SetSNCTCSSFreq (SNOTCH *a, float freq);
|
||||
static void SetSNCTCSSRun (SNOTCH *a, int run);
|
||||
|
||||
private:
|
||||
@ -92,32 +92,32 @@ class WDSP_API SPEAK
|
||||
public:
|
||||
int run;
|
||||
int size;
|
||||
double* in;
|
||||
double* out;
|
||||
double rate;
|
||||
double f;
|
||||
double bw;
|
||||
double cbw;
|
||||
double gain;
|
||||
double fgain;
|
||||
float* in;
|
||||
float* out;
|
||||
float rate;
|
||||
float f;
|
||||
float bw;
|
||||
float cbw;
|
||||
float gain;
|
||||
float fgain;
|
||||
int nstages;
|
||||
int design;
|
||||
double a0, a1, a2, b1, b2;
|
||||
double *x0, *x1, *x2, *y0, *y1, *y2;
|
||||
float a0, a1, a2, b1, b2;
|
||||
float *x0, *x1, *x2, *y0, *y1, *y2;
|
||||
QRecursiveMutex cs_update;
|
||||
|
||||
static SPEAK* create_speak (int run, int size, double* in, double* out, int rate, double f, double bw, double gain, int nstages, int design);
|
||||
static SPEAK* create_speak (int run, int size, float* in, float* out, int rate, float f, float bw, float gain, int nstages, int design);
|
||||
static void destroy_speak (SPEAK *a);
|
||||
static void flush_speak (SPEAK *a);
|
||||
static void xspeak (SPEAK *a);
|
||||
static void setBuffers_speak (SPEAK *a, double* in, double* out);
|
||||
static void setBuffers_speak (SPEAK *a, float* in, float* out);
|
||||
static void setSamplerate_speak (SPEAK *a, int rate);
|
||||
static void setSize_speak (SPEAK *a, int size);
|
||||
// RXA
|
||||
static void SetSPCWRun (RXA& rxa, int run);
|
||||
static void SetSPCWFreq (RXA& rxa, double freq);
|
||||
static void SetSPCWBandwidth (RXA& rxa, double bw);
|
||||
static void SetSPCWGain (RXA& rxa, double gain);
|
||||
static void SetSPCWFreq (RXA& rxa, float freq);
|
||||
static void SetSPCWBandwidth (RXA& rxa, float bw);
|
||||
static void SetSPCWGain (RXA& rxa, float gain);
|
||||
static void calc_speak (SPEAK *a);
|
||||
};
|
||||
|
||||
@ -145,34 +145,34 @@ class WDSP_API MPEAK
|
||||
public:
|
||||
int run;
|
||||
int size;
|
||||
double* in;
|
||||
double* out;
|
||||
float* in;
|
||||
float* out;
|
||||
int rate;
|
||||
int npeaks;
|
||||
int* enable;
|
||||
double* f;
|
||||
double* bw;
|
||||
double* gain;
|
||||
float* f;
|
||||
float* bw;
|
||||
float* gain;
|
||||
int nstages;
|
||||
SPEAK** pfil;
|
||||
double* tmp;
|
||||
double* mix;
|
||||
float* tmp;
|
||||
float* mix;
|
||||
QRecursiveMutex cs_update;
|
||||
|
||||
static MPEAK* create_mpeak (int run, int size, double* in, double* out, int rate, int npeaks, int* enable, double* f, double* bw, double* gain, int nstages);
|
||||
static MPEAK* create_mpeak (int run, int size, float* in, float* out, int rate, int npeaks, int* enable, float* f, float* bw, float* gain, int nstages);
|
||||
static void destroy_mpeak (MPEAK *a);
|
||||
static void flush_mpeak (MPEAK *a);
|
||||
static void xmpeak (MPEAK *a);
|
||||
static void setBuffers_mpeak (MPEAK *a, double* in, double* out);
|
||||
static void setBuffers_mpeak (MPEAK *a, float* in, float* out);
|
||||
static void setSamplerate_mpeak (MPEAK *a, int rate);
|
||||
static void setSize_mpeak (MPEAK *a, int size);
|
||||
// RXA
|
||||
static void SetmpeakRun (RXA& rxa, int run);
|
||||
static void SetmpeakNpeaks (RXA& rxa, int npeaks);
|
||||
static void SetmpeakFilEnable (RXA& rxa, int fil, int enable);
|
||||
static void SetmpeakFilFreq (RXA& rxa, int fil, double freq);
|
||||
static void SetmpeakFilBw (RXA& rxa, int fil, double bw);
|
||||
static void SetmpeakFilGain (RXA& rxa, int fil, double gain);
|
||||
static void SetmpeakFilFreq (RXA& rxa, int fil, float freq);
|
||||
static void SetmpeakFilBw (RXA& rxa, int fil, float bw);
|
||||
static void SetmpeakFilGain (RXA& rxa, int fil, float gain);
|
||||
|
||||
private:
|
||||
static void calc_mpeak (MPEAK *a);
|
||||
@ -204,26 +204,26 @@ public:
|
||||
int reverse;
|
||||
int run;
|
||||
int size;
|
||||
double* in;
|
||||
double* out;
|
||||
float* in;
|
||||
float* out;
|
||||
int rate;
|
||||
double fc;
|
||||
float fc;
|
||||
int nstages;
|
||||
// normalized such that a0 = 1
|
||||
double a1, b0, b1;
|
||||
double *x0, *x1, *y0, *y1;
|
||||
float a1, b0, b1;
|
||||
float *x0, *x1, *y0, *y1;
|
||||
QRecursiveMutex cs_update;
|
||||
|
||||
static PHROT* create_phrot (int run, int size, double* in, double* out, int rate, double fc, int nstages);
|
||||
static PHROT* create_phrot (int run, int size, float* in, float* out, int rate, float fc, int nstages);
|
||||
static void destroy_phrot (PHROT *a);
|
||||
static void flush_phrot (PHROT *a);
|
||||
static void xphrot (PHROT *a);
|
||||
static void setBuffers_phrot (PHROT *a, double* in, double* out);
|
||||
static void setBuffers_phrot (PHROT *a, float* in, float* out);
|
||||
static void setSamplerate_phrot (PHROT *a, int rate);
|
||||
static void setSize_phrot (PHROT *a, int size);
|
||||
// TXA Properties
|
||||
static void SetPHROTRun (TXA& txa, int run);
|
||||
static void SetPHROTCorner (TXA& txa, double corner);
|
||||
static void SetPHROTCorner (TXA& txa, float corner);
|
||||
static void SetPHROTNstages (TXA& txa, int nstages);
|
||||
static void SetPHROTReverse (TXA& txa, int reverse);
|
||||
|
||||
@ -254,22 +254,22 @@ class WDSP_API BQLP
|
||||
public:
|
||||
int run;
|
||||
int size;
|
||||
double* in;
|
||||
double* out;
|
||||
double rate;
|
||||
double fc;
|
||||
double Q;
|
||||
double gain;
|
||||
float* in;
|
||||
float* out;
|
||||
float rate;
|
||||
float fc;
|
||||
float Q;
|
||||
float gain;
|
||||
int nstages;
|
||||
double a0, a1, a2, b1, b2;
|
||||
double* x0, * x1, * x2, * y0, * y1, * y2;
|
||||
float a0, a1, a2, b1, b2;
|
||||
float* x0, * x1, * x2, * y0, * y1, * y2;
|
||||
QRecursiveMutex cs_update;
|
||||
|
||||
static BQLP* create_bqlp(int run, int size, double* in, double* out, double rate, double fc, double Q, double gain, int nstages);
|
||||
static BQLP* create_bqlp(int run, int size, float* in, float* out, float rate, float fc, float Q, float gain, int nstages);
|
||||
static void destroy_bqlp(BQLP *a);
|
||||
static void flush_bqlp(BQLP *a);
|
||||
static void xbqlp(BQLP *a);
|
||||
static void setBuffers_bqlp(BQLP *a, double* in, double* out);
|
||||
static void setBuffers_bqlp(BQLP *a, float* in, float* out);
|
||||
static void setSamplerate_bqlp(BQLP *a, int rate);
|
||||
static void setSize_bqlp(BQLP *a, int size);
|
||||
|
||||
@ -297,11 +297,11 @@ namespace WDSP {
|
||||
class WDSP_API DBQLP
|
||||
{
|
||||
public:
|
||||
static BQLP* create_dbqlp(int run, int size, double* in, double* out, double rate, double fc, double Q, double gain, int nstages);
|
||||
static BQLP* create_dbqlp(int run, int size, float* in, float* out, float rate, float fc, float Q, float gain, int nstages);
|
||||
static void destroy_dbqlp(BQLP *a);
|
||||
static void flush_dbqlp(BQLP *a);
|
||||
static void xdbqlp(BQLP *a);
|
||||
static void setBuffers_dbqlp(BQLP *a, double* in, double* out);
|
||||
static void setBuffers_dbqlp(BQLP *a, float* in, float* out);
|
||||
static void setSamplerate_dbqlp(BQLP *a, int rate);
|
||||
static void setSize_dbqlp(BQLP *a, int size);
|
||||
|
||||
@ -331,31 +331,31 @@ class WDSP_API BQBP
|
||||
public:
|
||||
int run;
|
||||
int size;
|
||||
double* in;
|
||||
double* out;
|
||||
double rate;
|
||||
double f_low;
|
||||
double f_high;
|
||||
double gain;
|
||||
float* in;
|
||||
float* out;
|
||||
float rate;
|
||||
float f_low;
|
||||
float f_high;
|
||||
float gain;
|
||||
int nstages;
|
||||
double a0, a1, a2, b1, b2;
|
||||
double* x0, * x1, * x2, * y0, * y1, * y2;
|
||||
float a0, a1, a2, b1, b2;
|
||||
float* x0, * x1, * x2, * y0, * y1, * y2;
|
||||
QRecursiveMutex cs_update;
|
||||
|
||||
static BQBP* create_bqbp(int run, int size, double* in, double* out, double rate, double f_low, double f_high, double gain, int nstages);
|
||||
static BQBP* create_bqbp(int run, int size, float* in, float* out, float rate, float f_low, float f_high, float gain, int nstages);
|
||||
static void destroy_bqbp(BQBP *a);
|
||||
static void flush_bqbp(BQBP *a);
|
||||
static void xbqbp(BQBP *a);
|
||||
static void setBuffers_bqbp(BQBP *a, double* in, double* out);
|
||||
static void setBuffers_bqbp(BQBP *a, float* in, float* out);
|
||||
static void setSamplerate_bqbp(BQBP *a, int rate);
|
||||
static void setSize_bqbp(BQBP *a, int size);
|
||||
|
||||
// Double Bi-Quad Band-Pass
|
||||
static BQBP* create_dbqbp(int run, int size, double* in, double* out, double rate, double f_low, double f_high, double gain, int nstages);
|
||||
static BQBP* create_dbqbp(int run, int size, float* in, float* out, float rate, float f_low, float f_high, float gain, int nstages);
|
||||
static void destroy_dbqbp(BQBP *a);
|
||||
static void flush_dbqbp(BQBP *a);
|
||||
static void xdbqbp(BQBP *a);
|
||||
static void setBuffers_dbqbp(BQBP *a, double* in, double* out);
|
||||
static void setBuffers_dbqbp(BQBP *a, float* in, float* out);
|
||||
static void setSamplerate_dbqbp(BQBP *a, int rate);
|
||||
static void setSize_dbqbp(BQBP *a, int size);
|
||||
|
||||
@ -386,29 +386,29 @@ class WDSP_API SPHP
|
||||
public:
|
||||
int run;
|
||||
int size;
|
||||
double* in;
|
||||
double* out;
|
||||
double rate;
|
||||
double fc;
|
||||
float* in;
|
||||
float* out;
|
||||
float rate;
|
||||
float fc;
|
||||
int nstages;
|
||||
double a1, b0, b1;
|
||||
double* x0, * x1, * y0, * y1;
|
||||
float a1, b0, b1;
|
||||
float* x0, * x1, * y0, * y1;
|
||||
QRecursiveMutex cs_update;
|
||||
|
||||
static SPHP* create_dsphp(int run, int size, double* in, double* out, double rate, double fc, int nstages);
|
||||
static SPHP* create_dsphp(int run, int size, float* in, float* out, float rate, float fc, int nstages);
|
||||
static void destroy_dsphp(SPHP *a);
|
||||
static void flush_dsphp(SPHP *a);
|
||||
static void xdsphp(SPHP *a);
|
||||
static void setBuffers_dsphp(SPHP *a, double* in, double* out);
|
||||
static void setBuffers_dsphp(SPHP *a, float* in, float* out);
|
||||
static void setSamplerate_dsphp(SPHP *a, int rate);
|
||||
static void setSize_dsphp(SPHP *a, int size);
|
||||
|
||||
// Complex Single-Pole High-Pass
|
||||
static SPHP* create_sphp(int run, int size, double* in, double* out, double rate, double fc, int nstages);
|
||||
static SPHP* create_sphp(int run, int size, float* in, float* out, float rate, float fc, int nstages);
|
||||
static void destroy_sphp(SPHP *a);
|
||||
static void flush_sphp(SPHP *a);
|
||||
static void xsphp(SPHP *a);
|
||||
static void setBuffers_sphp(SPHP *a, double* in, double* out);
|
||||
static void setBuffers_sphp(SPHP *a, float* in, float* out);
|
||||
static void setSamplerate_sphp(SPHP *a, int rate);
|
||||
static void setSize_sphp(SPHP *a, int size);
|
||||
|
||||
|
54
wdsp/iqc.cpp
54
wdsp/iqc.cpp
@ -37,14 +37,14 @@ namespace WDSP {
|
||||
void IQC::size_iqc (IQC *a)
|
||||
{
|
||||
int i;
|
||||
a->t = new double[a->ints + 1]; // (double *) malloc0 ((a->ints + 1) * sizeof(double));
|
||||
a->t = new float[a->ints + 1]; // (float *) malloc0 ((a->ints + 1) * sizeof(float));
|
||||
for (i = 0; i <= a->ints; i++)
|
||||
a->t[i] = (double)i / (double)a->ints;
|
||||
a->t[i] = (float)i / (float)a->ints;
|
||||
for (i = 0; i < 2; i++)
|
||||
{
|
||||
a->cm[i] = new double[a->ints * 4]; // (double *) malloc0 (a->ints * 4 * sizeof(double));
|
||||
a->cc[i] = new double[a->ints * 4]; // (double *) malloc0 (a->ints * 4 * sizeof(double));
|
||||
a->cs[i] = new double[a->ints * 4]; // (double *) malloc0 (a->ints * 4 * sizeof(double));
|
||||
a->cm[i] = new float[a->ints * 4]; // (float *) malloc0 (a->ints * 4 * sizeof(float));
|
||||
a->cc[i] = new float[a->ints * 4]; // (float *) malloc0 (a->ints * 4 * sizeof(float));
|
||||
a->cs[i] = new float[a->ints * 4]; // (float *) malloc0 (a->ints * 4 * sizeof(float));
|
||||
}
|
||||
a->dog.cpi = new int[a->ints]; // (int *) malloc0 (a->ints * sizeof (int));
|
||||
a->dog.count = 0;
|
||||
@ -67,14 +67,14 @@ void IQC::desize_iqc (IQC *a)
|
||||
void IQC::calc_iqc (IQC *a)
|
||||
{
|
||||
int i;
|
||||
double delta, theta;
|
||||
float delta, theta;
|
||||
a->cset = 0;
|
||||
a->count = 0;
|
||||
a->state = 0;
|
||||
a->busy = 0;
|
||||
a->ntup = (int)(a->tup * a->rate);
|
||||
a->cup = new double[a->ntup + 1]; // (double *) malloc0 ((a->ntup + 1) * sizeof (double));
|
||||
delta = PI / (double)a->ntup;
|
||||
a->cup = new float[a->ntup + 1]; // (float *) malloc0 ((a->ntup + 1) * sizeof (float));
|
||||
delta = PI / (float)a->ntup;
|
||||
theta = 0.0;
|
||||
for (i = 0; i <= a->ntup; i++)
|
||||
{
|
||||
@ -90,7 +90,7 @@ void IQC::decalc_iqc (IQC *a)
|
||||
delete[] (a->cup);
|
||||
}
|
||||
|
||||
IQC* IQC::create_iqc (int run, int size, double* in, double* out, double rate, int ints, double tup, int spi)
|
||||
IQC* IQC::create_iqc (int run, int size, float* in, float* out, float rate, int ints, float tup, int spi)
|
||||
{
|
||||
IQC *a = new IQC;
|
||||
a->run = run;
|
||||
@ -130,7 +130,7 @@ void IQC::xiqc (IQC *a)
|
||||
if (a->run == 1)
|
||||
{
|
||||
int i, k, cset, mset;
|
||||
double I, Q, env, dx, ym, yc, ys, PRE0, PRE1;
|
||||
float I, Q, env, dx, ym, yc, ys, PRE0, PRE1;
|
||||
for (i = 0; i < a->size; i++)
|
||||
{
|
||||
I = a->in[2 * i + 0];
|
||||
@ -208,7 +208,7 @@ void IQC::xiqc (IQC *a)
|
||||
memcpy (a->out, a->in, a->size * sizeof (wcomplex));
|
||||
}
|
||||
|
||||
void IQC::setBuffers_iqc (IQC *a, double* in, double* out)
|
||||
void IQC::setBuffers_iqc (IQC *a, float* in, float* out)
|
||||
{
|
||||
a->in = in;
|
||||
a->out = out;
|
||||
@ -232,38 +232,38 @@ void IQC::setSize_iqc (IQC *a, int size)
|
||||
* *
|
||||
********************************************************************************************************/
|
||||
|
||||
void IQC::GetiqcValues (TXA& txa, double* cm, double* cc, double* cs)
|
||||
void IQC::GetiqcValues (TXA& txa, float* cm, float* cc, float* cs)
|
||||
{
|
||||
IQC *a;
|
||||
txa.csDSP.lock();
|
||||
a = txa.iqc.p0;
|
||||
memcpy (cm, a->cm[a->cset], a->ints * 4 * sizeof (double));
|
||||
memcpy (cc, a->cc[a->cset], a->ints * 4 * sizeof (double));
|
||||
memcpy (cs, a->cs[a->cset], a->ints * 4 * sizeof (double));
|
||||
memcpy (cm, a->cm[a->cset], a->ints * 4 * sizeof (float));
|
||||
memcpy (cc, a->cc[a->cset], a->ints * 4 * sizeof (float));
|
||||
memcpy (cs, a->cs[a->cset], a->ints * 4 * sizeof (float));
|
||||
txa.csDSP.unlock();
|
||||
}
|
||||
|
||||
void IQC::SetiqcValues (TXA& txa, double* cm, double* cc, double* cs)
|
||||
void IQC::SetiqcValues (TXA& txa, float* cm, float* cc, float* cs)
|
||||
{
|
||||
IQC *a;
|
||||
txa.csDSP.lock();
|
||||
a = txa.iqc.p0;
|
||||
a->cset = 1 - a->cset;
|
||||
memcpy (a->cm[a->cset], cm, a->ints * 4 * sizeof (double));
|
||||
memcpy (a->cc[a->cset], cc, a->ints * 4 * sizeof (double));
|
||||
memcpy (a->cs[a->cset], cs, a->ints * 4 * sizeof (double));
|
||||
memcpy (a->cm[a->cset], cm, a->ints * 4 * sizeof (float));
|
||||
memcpy (a->cc[a->cset], cc, a->ints * 4 * sizeof (float));
|
||||
memcpy (a->cs[a->cset], cs, a->ints * 4 * sizeof (float));
|
||||
a->state = RUN;
|
||||
txa.csDSP.unlock();
|
||||
}
|
||||
|
||||
void IQC::SetiqcSwap (TXA& txa, double* cm, double* cc, double* cs)
|
||||
void IQC::SetiqcSwap (TXA& txa, float* cm, float* cc, float* cs)
|
||||
{
|
||||
IQC *a = txa.iqc.p1;
|
||||
txa.csDSP.lock();
|
||||
a->cset = 1 - a->cset;
|
||||
memcpy (a->cm[a->cset], cm, a->ints * 4 * sizeof (double));
|
||||
memcpy (a->cc[a->cset], cc, a->ints * 4 * sizeof (double));
|
||||
memcpy (a->cs[a->cset], cs, a->ints * 4 * sizeof (double));
|
||||
memcpy (a->cm[a->cset], cm, a->ints * 4 * sizeof (float));
|
||||
memcpy (a->cc[a->cset], cc, a->ints * 4 * sizeof (float));
|
||||
memcpy (a->cs[a->cset], cs, a->ints * 4 * sizeof (float));
|
||||
a->busy = 1; // InterlockedBitTestAndSet (&a->busy, 0);
|
||||
a->state = SWAP;
|
||||
a->count = 0;
|
||||
@ -274,14 +274,14 @@ void IQC::SetiqcSwap (TXA& txa, double* cm, double* cc, double* cs)
|
||||
}
|
||||
}
|
||||
|
||||
void IQC::SetiqcStart (TXA& txa, double* cm, double* cc, double* cs)
|
||||
void IQC::SetiqcStart (TXA& txa, float* cm, float* cc, float* cs)
|
||||
{
|
||||
IQC *a = txa.iqc.p1;
|
||||
txa.csDSP.lock();
|
||||
a->cset = 0;
|
||||
memcpy (a->cm[a->cset], cm, a->ints * 4 * sizeof (double));
|
||||
memcpy (a->cc[a->cset], cc, a->ints * 4 * sizeof (double));
|
||||
memcpy (a->cs[a->cset], cs, a->ints * 4 * sizeof (double));
|
||||
memcpy (a->cm[a->cset], cm, a->ints * 4 * sizeof (float));
|
||||
memcpy (a->cc[a->cset], cc, a->ints * 4 * sizeof (float));
|
||||
memcpy (a->cs[a->cset], cs, a->ints * 4 * sizeof (float));
|
||||
a->busy = 1; // InterlockedBitTestAndSet (&a->busy, 0);
|
||||
a->state = BEGIN;
|
||||
a->count = 0;
|
||||
|
30
wdsp/iqc.hpp
30
wdsp/iqc.hpp
@ -43,17 +43,17 @@ public:
|
||||
std::atomic<long> run;
|
||||
std::atomic<long> busy;
|
||||
int size;
|
||||
double* in;
|
||||
double* out;
|
||||
double rate;
|
||||
float* in;
|
||||
float* out;
|
||||
float rate;
|
||||
int ints;
|
||||
double* t;
|
||||
float* t;
|
||||
int cset;
|
||||
double* cm[2];
|
||||
double* cc[2];
|
||||
double* cs[2];
|
||||
double tup;
|
||||
double* cup;
|
||||
float* cm[2];
|
||||
float* cc[2];
|
||||
float* cs[2];
|
||||
float tup;
|
||||
float* cup;
|
||||
int count;
|
||||
int ntup;
|
||||
int state;
|
||||
@ -66,18 +66,18 @@ public:
|
||||
QRecursiveMutex cs;
|
||||
} dog;
|
||||
|
||||
static IQC* create_iqc (int run, int size, double* in, double* out, double rate, int ints, double tup, int spi);
|
||||
static IQC* create_iqc (int run, int size, float* in, float* out, float rate, int ints, float tup, int spi);
|
||||
static void destroy_iqc (IQC *a);
|
||||
static void flush_iqc (IQC *a);
|
||||
static void xiqc (IQC *a);
|
||||
static void setBuffers_iqc (IQC *a, double* in, double* out);
|
||||
static void setBuffers_iqc (IQC *a, float* in, float* out);
|
||||
static void setSamplerate_iqc (IQC *a, int rate);
|
||||
static void setSize_iqc (IQC *a, int size);
|
||||
// TXA Properties
|
||||
static void GetiqcValues (TXA& txa, double* cm, double* cc, double* cs);
|
||||
static void SetiqcValues (TXA& txa, double* cm, double* cc, double* cs);
|
||||
static void SetiqcSwap (TXA& txa, double* cm, double* cc, double* cs);
|
||||
static void SetiqcStart (TXA& txa, double* cm, double* cc, double* cs);
|
||||
static void GetiqcValues (TXA& txa, float* cm, float* cc, float* cs);
|
||||
static void SetiqcValues (TXA& txa, float* cm, float* cc, float* cs);
|
||||
static void SetiqcSwap (TXA& txa, float* cm, float* cc, float* cs);
|
||||
static void SetiqcStart (TXA& txa, float* cm, float* cc, float* cs);
|
||||
static void SetiqcEnd (TXA& txa);
|
||||
static void GetiqcDogCount (TXA& txa, int* count);
|
||||
static void SetiqcDogCount (TXA& txa, int count);
|
||||
|
@ -30,11 +30,11 @@ warren@wpratt.com
|
||||
|
||||
namespace WDSP {
|
||||
|
||||
void LMath::dR (int n, double* r, double* y, double* z)
|
||||
void LMath::dR (int n, float* r, float* y, float* z)
|
||||
{
|
||||
int i, j, k;
|
||||
double alpha, beta, gamma;
|
||||
memset (z, 0, (n - 1) * sizeof (double)); // work space
|
||||
float alpha, beta, gamma;
|
||||
memset (z, 0, (n - 1) * sizeof (float)); // work space
|
||||
y[0] = -r[1];
|
||||
alpha = -r[1];
|
||||
beta = 1.0;
|
||||
@ -47,24 +47,24 @@ void LMath::dR (int n, double* r, double* y, double* z)
|
||||
alpha = - (r[k + 2] + gamma) / beta;
|
||||
for (i = 0, j = k; i <= k; i++, j--)
|
||||
z[i] = y[i] + alpha * y[j];
|
||||
memcpy (y, z, (k + 1) * sizeof (double));
|
||||
memcpy (y, z, (k + 1) * sizeof (float));
|
||||
y[k + 1] = alpha;
|
||||
}
|
||||
}
|
||||
|
||||
void LMath::trI (
|
||||
int n,
|
||||
double* r,
|
||||
double* B,
|
||||
double* y,
|
||||
double* v,
|
||||
double* dR_z
|
||||
float* r,
|
||||
float* B,
|
||||
float* y,
|
||||
float* v,
|
||||
float* dR_z
|
||||
)
|
||||
{
|
||||
int i, j, ni, nj;
|
||||
double gamma, t, scale, b;
|
||||
memset (y, 0, (n - 1) * sizeof (double)); // work space
|
||||
memset (v, 0, (n - 1) * sizeof (double)); // work space
|
||||
float gamma, t, scale, b;
|
||||
memset (y, 0, (n - 1) * sizeof (float)); // work space
|
||||
memset (v, 0, (n - 1) * sizeof (float)); // work space
|
||||
scale = 1.0 / r[0];
|
||||
for (i = 0; i < n; i++)
|
||||
r[i] *= scale;
|
||||
@ -94,12 +94,12 @@ void LMath::trI (
|
||||
}
|
||||
}
|
||||
|
||||
void LMath::asolve(int xsize, int asize, double* x, double* a, double* r, double* z)
|
||||
void LMath::asolve(int xsize, int asize, float* x, float* a, float* r, float* z)
|
||||
{
|
||||
int i, j, k;
|
||||
double beta, alpha, t;
|
||||
memset(r, 0, (asize + 1) * sizeof(double)); // work space
|
||||
memset(z, 0, (asize + 1) * sizeof(double)); // work space
|
||||
float beta, alpha, t;
|
||||
memset(r, 0, (asize + 1) * sizeof(float)); // work space
|
||||
memset(z, 0, (asize + 1) * sizeof(float)); // work space
|
||||
for (i = 0; i <= asize; i++)
|
||||
{
|
||||
for (j = 0; j < xsize; j++)
|
||||
@ -128,10 +128,10 @@ void LMath::asolve(int xsize, int asize, double* x, double* a, double* r, double
|
||||
}
|
||||
}
|
||||
|
||||
void LMath::median (int n, double* a, double* med)
|
||||
void LMath::median (int n, float* a, float* med)
|
||||
{
|
||||
int S0, S1, i, j, m, k;
|
||||
double x, t;
|
||||
float x, t;
|
||||
S0 = 0;
|
||||
S1 = n - 1;
|
||||
k = n / 2;
|
||||
|
@ -34,17 +34,17 @@ namespace WDSP {
|
||||
|
||||
class WDSP_API LMath {
|
||||
public:
|
||||
static void dR (int n, double* r, double* y, double* z);
|
||||
static void dR (int n, float* r, float* y, float* z);
|
||||
static void trI (
|
||||
int n,
|
||||
double* r,
|
||||
double* B,
|
||||
double* y,
|
||||
double* v,
|
||||
double* dR_z
|
||||
float* r,
|
||||
float* B,
|
||||
float* y,
|
||||
float* v,
|
||||
float* dR_z
|
||||
);
|
||||
static void asolve(int xsize, int asize, double* x, double* a, double* r, double* z);
|
||||
static void median(int n, double* a, double* med);
|
||||
static void asolve(int xsize, int asize, float* x, float* a, float* r, float* z);
|
||||
static void median(int n, float* a, float* med);
|
||||
};
|
||||
|
||||
} // namespace WDSP
|
||||
|
@ -14,7 +14,7 @@
|
||||
* return values of main()
|
||||
*
|
||||
* 0 all OK
|
||||
* -1 sizeof(double) is not 8
|
||||
* -1 sizeof(float) is not 8
|
||||
* -2 error opening file "calculus"
|
||||
* -3 read error
|
||||
*/
|
||||
@ -26,9 +26,9 @@
|
||||
int main() {
|
||||
int fd;
|
||||
int i,j;
|
||||
double d;
|
||||
float d;
|
||||
|
||||
if (sizeof(double) != 8) {
|
||||
if (sizeof(float) != 8) {
|
||||
printf("Data type DOUBLE is not 8-byte. Please check!\n");
|
||||
return -1;
|
||||
}
|
||||
@ -41,10 +41,10 @@ int main() {
|
||||
for (j=0; j<2; j++) {
|
||||
switch (j) {
|
||||
case 0:
|
||||
printf("double GG[241*241]={\n");
|
||||
printf("float GG[241*241]={\n");
|
||||
break;
|
||||
case 1:
|
||||
printf("double GGS[241*241]={\n");
|
||||
printf("float GGS[241*241]={\n");
|
||||
break;
|
||||
}
|
||||
for (i=0; i< 241*241; i++) {
|
||||
|
@ -44,11 +44,11 @@ METER* METER::create_meter (
|
||||
int run,
|
||||
int* prun,
|
||||
int size,
|
||||
double* buff,
|
||||
float* buff,
|
||||
int rate,
|
||||
double tau_av,
|
||||
double tau_decay,
|
||||
double* result,
|
||||
float* result,
|
||||
QRecursiveMutex** pmtupdate,
|
||||
int enum_av,
|
||||
int enum_pk,
|
||||
@ -61,7 +61,7 @@ METER* METER::create_meter (
|
||||
a->prun = prun;
|
||||
a->size = size;
|
||||
a->buff = buff;
|
||||
a->rate = (double)rate;
|
||||
a->rate = (float)rate;
|
||||
a->tau_average = tau_av;
|
||||
a->tau_peak_decay = tau_decay;
|
||||
a->result = result;
|
||||
@ -126,7 +126,7 @@ void METER::xmeter (METER *a)
|
||||
a->mtupdate.unlock();
|
||||
}
|
||||
|
||||
void METER::setBuffers_meter (METER *a, double* in)
|
||||
void METER::setBuffers_meter (METER *a, float* in)
|
||||
{
|
||||
a->buff = in;
|
||||
}
|
||||
@ -149,9 +149,9 @@ void METER::setSize_meter (METER *a, int size)
|
||||
* *
|
||||
********************************************************************************************************/
|
||||
|
||||
double METER::GetMeter (RXA& rxa, int mt)
|
||||
float METER::GetMeter (RXA& rxa, int mt)
|
||||
{
|
||||
double val;
|
||||
float val;
|
||||
rxa.pmtupdate[mt]->lock();
|
||||
val = rxa.meter[mt];
|
||||
rxa.pmtupdate[mt]->unlock();
|
||||
@ -164,9 +164,9 @@ double METER::GetMeter (RXA& rxa, int mt)
|
||||
* *
|
||||
********************************************************************************************************/
|
||||
|
||||
double METER::GetMeter (TXA& txa, int mt)
|
||||
float METER::GetMeter (TXA& txa, int mt)
|
||||
{
|
||||
double val;
|
||||
float val;
|
||||
txa.pmtupdate[mt]->lock();
|
||||
val = txa.meter[mt];
|
||||
txa.pmtupdate[mt]->unlock();
|
||||
|
@ -43,13 +43,13 @@ public:
|
||||
int run;
|
||||
int* prun;
|
||||
int size;
|
||||
double* buff;
|
||||
float* buff;
|
||||
double rate;
|
||||
double tau_average;
|
||||
double tau_peak_decay;
|
||||
double mult_average;
|
||||
double mult_peak;
|
||||
double* result;
|
||||
float* result;
|
||||
int enum_av;
|
||||
int enum_pk;
|
||||
int enum_gain;
|
||||
@ -62,11 +62,11 @@ public:
|
||||
int run,
|
||||
int* prun,
|
||||
int size,
|
||||
double* buff,
|
||||
float* buff,
|
||||
int rate,
|
||||
double tau_av,
|
||||
double tau_decay,
|
||||
double* result,
|
||||
float* result,
|
||||
QRecursiveMutex** pmtupdate,
|
||||
int enum_av,
|
||||
int enum_pk,
|
||||
@ -76,13 +76,13 @@ public:
|
||||
static void destroy_meter (METER *a);
|
||||
static void flush_meter (METER *a);
|
||||
static void xmeter (METER *a);
|
||||
static void setBuffers_meter (METER *a, double* in);
|
||||
static void setBuffers_meter (METER *a, float* in);
|
||||
static void setSamplerate_meter (METER *a, int rate);
|
||||
static void setSize_meter (METER *a, int size);
|
||||
// RXA Properties
|
||||
static double GetMeter (RXA& rxa, int mt);
|
||||
static float GetMeter (RXA& rxa, int mt);
|
||||
// TXA Properties
|
||||
static double GetMeter (TXA& txa, int mt);
|
||||
static float GetMeter (TXA& txa, int mt);
|
||||
|
||||
private:
|
||||
static void calc_meter (METER *a);
|
||||
|
@ -548,7 +548,7 @@ const double MemLog::mtable[2048] = {
|
||||
9.9859042974532852e-001, 9.9894295144308476e-001, 9.9929538702341059e-001, 9.9964773652837102e-001};
|
||||
|
||||
|
||||
inline double MemLog::mlog10 (double val)
|
||||
double MemLog::mlog10 (double val)
|
||||
{
|
||||
uint64_t* pin = (uint64_t*)(&val);
|
||||
uint64_t N = *pin;
|
||||
|
84
wdsp/nbp.cpp
84
wdsp/nbp.cpp
@ -46,10 +46,10 @@ namespace WDSP {
|
||||
a->master_run = master_run;
|
||||
a->maxnotches = maxnotches;
|
||||
a->nn = 0;
|
||||
a->fcenter = new double[a->maxnotches]; // (double *) malloc0 (a->maxnotches * sizeof (double));
|
||||
a->fwidth = new double[a->maxnotches]; // (double *) malloc0 (a->maxnotches * sizeof (double));
|
||||
a->nlow = new double[a->maxnotches]; // (double *) malloc0 (a->maxnotches * sizeof (double));
|
||||
a->nhigh = new double[a->maxnotches]; // (double *) malloc0 (a->maxnotches * sizeof (double));
|
||||
a->fcenter = new float[a->maxnotches]; // (float *) malloc0 (a->maxnotches * sizeof (float));
|
||||
a->fwidth = new float[a->maxnotches]; // (float *) malloc0 (a->maxnotches * sizeof (float));
|
||||
a->nlow = new float[a->maxnotches]; // (float *) malloc0 (a->maxnotches * sizeof (float));
|
||||
a->nhigh = new float[a->maxnotches]; // (float *) malloc0 (a->maxnotches * sizeof (float));
|
||||
a->active = new int[a->maxnotches]; // (int *) malloc0 (a->maxnotches * sizeof (int ));
|
||||
return a;
|
||||
}
|
||||
@ -69,11 +69,11 @@ void NOTCHDB::destroy_notchdb (NOTCHDB *b)
|
||||
* *
|
||||
********************************************************************************************************/
|
||||
|
||||
double* NBP::fir_mbandpass (int N, int nbp, double* flow, double* fhigh, double rate, double scale, int wintype)
|
||||
float* NBP::fir_mbandpass (int N, int nbp, float* flow, float* fhigh, float rate, float scale, int wintype)
|
||||
{
|
||||
int i, k;
|
||||
double* impulse = new double[N * 2]; // (double *) malloc0 (N * sizeof (complex));
|
||||
double* imp;
|
||||
float* impulse = new float[N * 2]; // (float *) malloc0 (N * sizeof (complex));
|
||||
float* imp;
|
||||
for (k = 0; k < nbp; k++)
|
||||
{
|
||||
imp = FIR::fir_bandpass (N, flow[k], fhigh[k], rate, wintype, 1, scale);
|
||||
@ -87,9 +87,9 @@ double* NBP::fir_mbandpass (int N, int nbp, double* flow, double* fhigh, double
|
||||
return impulse;
|
||||
}
|
||||
|
||||
double NBP::min_notch_width (NBP *a)
|
||||
float NBP::min_notch_width (NBP *a)
|
||||
{
|
||||
double min_width;
|
||||
float min_width;
|
||||
switch (a->wintype)
|
||||
{
|
||||
case 0:
|
||||
@ -105,23 +105,23 @@ double NBP::min_notch_width (NBP *a)
|
||||
int NBP::make_nbp (
|
||||
int nn,
|
||||
int* active,
|
||||
double* center,
|
||||
double* width,
|
||||
double* nlow,
|
||||
double* nhigh,
|
||||
double minwidth,
|
||||
float* center,
|
||||
float* width,
|
||||
float* nlow,
|
||||
float* nhigh,
|
||||
float minwidth,
|
||||
int autoincr,
|
||||
double flow,
|
||||
double fhigh,
|
||||
double* bplow,
|
||||
double* bphigh,
|
||||
float flow,
|
||||
float fhigh,
|
||||
float* bplow,
|
||||
float* bphigh,
|
||||
int* havnotch
|
||||
)
|
||||
{
|
||||
int nbp;
|
||||
int nnbp, adds;
|
||||
int i, j, k;
|
||||
double nl, nh;
|
||||
float nl, nh;
|
||||
int* del = new int[1024]; // (int *) malloc0 (1024 * sizeof (int));
|
||||
if (fhigh > flow)
|
||||
{
|
||||
@ -202,8 +202,8 @@ int NBP::make_nbp (
|
||||
void NBP::calc_nbp_lightweight (NBP *a)
|
||||
{ // calculate and set new impulse response; used when changing tune freq or shift freq
|
||||
int i;
|
||||
double fl, fh;
|
||||
double offset;
|
||||
float fl, fh;
|
||||
float offset;
|
||||
NOTCHDB *b = a->ptraddr;
|
||||
if (a->fnfrun)
|
||||
{
|
||||
@ -234,7 +234,7 @@ void NBP::calc_nbp_lightweight (NBP *a)
|
||||
a->bphigh[i] -= offset;
|
||||
}
|
||||
a->impulse = fir_mbandpass (a->nc, a->numpb, a->bplow, a->bphigh,
|
||||
a->rate, a->gain / (double)(2 * a->size), a->wintype);
|
||||
a->rate, a->gain / (float)(2 * a->size), a->wintype);
|
||||
FIRCORE::setImpulse_fircore (a->p, a->impulse, 1);
|
||||
// print_impulse ("nbp.txt", a->size + 1, impulse, 1, 0);
|
||||
delete[](a->impulse);
|
||||
@ -248,8 +248,8 @@ void NBP::calc_nbp_lightweight (NBP *a)
|
||||
void NBP::calc_nbp_impulse (NBP *a)
|
||||
{ // calculates impulse response; for create_fircore() and parameter changes
|
||||
int i;
|
||||
double fl, fh;
|
||||
double offset;
|
||||
float fl, fh;
|
||||
float offset;
|
||||
NOTCHDB *b = a->ptraddr;
|
||||
if (a->fnfrun)
|
||||
{
|
||||
@ -282,7 +282,7 @@ void NBP::calc_nbp_impulse (NBP *a)
|
||||
a->bplow,
|
||||
a->bphigh,
|
||||
a->rate,
|
||||
a->gain / (double)(2 * a->size),
|
||||
a->gain / (float)(2 * a->size),
|
||||
a->wintype
|
||||
);
|
||||
}
|
||||
@ -295,7 +295,7 @@ void NBP::calc_nbp_impulse (NBP *a)
|
||||
a->rate,
|
||||
a->wintype,
|
||||
1,
|
||||
a->gain / (double)(2 * a->size)
|
||||
a->gain / (float)(2 * a->size)
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -307,13 +307,13 @@ NBP* NBP::create_nbp(
|
||||
int size,
|
||||
int nc,
|
||||
int mp,
|
||||
double* in,
|
||||
double* out,
|
||||
double flow,
|
||||
double fhigh,
|
||||
float* in,
|
||||
float* out,
|
||||
float flow,
|
||||
float fhigh,
|
||||
int rate,
|
||||
int wintype,
|
||||
double gain,
|
||||
float gain,
|
||||
int autoincr,
|
||||
int maxpb,
|
||||
NOTCHDB* ptraddr
|
||||
@ -326,7 +326,7 @@ NBP* NBP::create_nbp(
|
||||
a->size = size;
|
||||
a->nc = nc;
|
||||
a->mp = mp;
|
||||
a->rate = (double)rate;
|
||||
a->rate = (float)rate;
|
||||
a->wintype = wintype;
|
||||
a->gain = gain;
|
||||
a->in = in;
|
||||
@ -336,8 +336,8 @@ NBP* NBP::create_nbp(
|
||||
a->fhigh = fhigh;
|
||||
a->maxpb = maxpb;
|
||||
a->ptraddr = ptraddr;
|
||||
a->bplow = new double[a->maxpb]; // (double *) malloc0 (a->maxpb * sizeof (double));
|
||||
a->bphigh = new double[a->maxpb]; // (double *) malloc0 (a->maxpb * sizeof (double));
|
||||
a->bplow = new float[a->maxpb]; // (float *) malloc0 (a->maxpb * sizeof (float));
|
||||
a->bphigh = new float[a->maxpb]; // (float *) malloc0 (a->maxpb * sizeof (float));
|
||||
calc_nbp_impulse (a);
|
||||
a->p = FIRCORE::create_fircore (a->size, a->in, a->out, a->nc, a->mp, a->impulse);
|
||||
// print_impulse ("nbp.txt", a->size + 1, impulse, 1, 0);
|
||||
@ -366,7 +366,7 @@ void NBP::xnbp (NBP *a, int pos)
|
||||
memcpy (a->out, a->in, a->size * sizeof (wcomplex));
|
||||
}
|
||||
|
||||
void NBP::setBuffers_nbp (NBP *a, double* in, double* out)
|
||||
void NBP::setBuffers_nbp (NBP *a, float* in, float* out)
|
||||
{
|
||||
a->in = in;
|
||||
a->out = out;
|
||||
@ -433,7 +433,7 @@ void NBP::UpdateNBPFilters(RXA& rxa)
|
||||
}
|
||||
}
|
||||
|
||||
int NBP::NBPAddNotch (RXA& rxa, int notch, double fcenter, double fwidth, int active)
|
||||
int NBP::NBPAddNotch (RXA& rxa, int notch, float fcenter, float fwidth, int active)
|
||||
{
|
||||
NOTCHDB *b;
|
||||
int i, j;
|
||||
@ -463,7 +463,7 @@ int NBP::NBPAddNotch (RXA& rxa, int notch, double fcenter, double fwidth, int ac
|
||||
return rval;
|
||||
}
|
||||
|
||||
int NBP::NBPGetNotch (RXA& rxa, int notch, double* fcenter, double* fwidth, int* active)
|
||||
int NBP::NBPGetNotch (RXA& rxa, int notch, float* fcenter, float* fwidth, int* active)
|
||||
{
|
||||
NOTCHDB *a;
|
||||
int rval;
|
||||
@ -512,7 +512,7 @@ int NBP::NBPDeleteNotch (RXA& rxa, int notch)
|
||||
return rval;
|
||||
}
|
||||
|
||||
int NBP::NBPEditNotch (RXA& rxa, int notch, double fcenter, double fwidth, int active)
|
||||
int NBP::NBPEditNotch (RXA& rxa, int notch, float fcenter, float fwidth, int active)
|
||||
{
|
||||
NOTCHDB *a;
|
||||
int rval;
|
||||
@ -541,7 +541,7 @@ void NBP::NBPGetNumNotches (RXA& rxa, int* nnotches)
|
||||
rxa.csDSP.unlock();
|
||||
}
|
||||
|
||||
void NBP::NBPSetTuneFrequency (RXA& rxa, double tunefreq)
|
||||
void NBP::NBPSetTuneFrequency (RXA& rxa, float tunefreq)
|
||||
{
|
||||
NOTCHDB *a;
|
||||
a = rxa.ndb.p;
|
||||
@ -552,7 +552,7 @@ void NBP::NBPSetTuneFrequency (RXA& rxa, double tunefreq)
|
||||
}
|
||||
}
|
||||
|
||||
void NBP::NBPSetShiftFrequency (RXA& rxa, double shift)
|
||||
void NBP::NBPSetShiftFrequency (RXA& rxa, float shift)
|
||||
{
|
||||
NOTCHDB *a;
|
||||
a = rxa.ndb.p;
|
||||
@ -593,7 +593,7 @@ void NBP::NBPSetRun (RXA& rxa, int run)
|
||||
rxa.csDSP.unlock();
|
||||
}
|
||||
|
||||
void NBP::NBPSetFreqs (RXA& rxa, double flow, double fhigh)
|
||||
void NBP::NBPSetFreqs (RXA& rxa, float flow, float fhigh)
|
||||
{
|
||||
NBP *a;
|
||||
a = rxa.nbp0.p;
|
||||
@ -652,7 +652,7 @@ void NBP::NBPSetMP (RXA& rxa, int mp)
|
||||
}
|
||||
}
|
||||
|
||||
void NBP::NBPGetMinNotchWidth (RXA& rxa, double* minwidth)
|
||||
void NBP::NBPGetMinNotchWidth (RXA& rxa, float* minwidth)
|
||||
{
|
||||
NBP *a;
|
||||
rxa.csDSP.lock();
|
||||
|
78
wdsp/nbp.hpp
78
wdsp/nbp.hpp
@ -39,14 +39,14 @@ class WDSP_API NOTCHDB
|
||||
{
|
||||
public:
|
||||
int master_run;
|
||||
double tunefreq;
|
||||
double shift;
|
||||
float tunefreq;
|
||||
float shift;
|
||||
int nn;
|
||||
int* active;
|
||||
double* fcenter;
|
||||
double* fwidth;
|
||||
double* nlow;
|
||||
double* nhigh;
|
||||
float* fcenter;
|
||||
float* fwidth;
|
||||
float* nlow;
|
||||
float* nhigh;
|
||||
int maxnotches;
|
||||
|
||||
static NOTCHDB* create_notchdb (int master_run, int maxnotches);
|
||||
@ -63,19 +63,19 @@ public:
|
||||
int size; // buffer size
|
||||
int nc; // number of filter coefficients
|
||||
int mp; // minimum phase flag
|
||||
double* in; // input buffer
|
||||
double* out; // output buffer
|
||||
double flow; // low bandpass cutoff freq
|
||||
double fhigh; // high bandpass cutoff freq
|
||||
double* impulse; // filter impulse response
|
||||
double rate; // sample rate
|
||||
float* in; // input buffer
|
||||
float* out; // output buffer
|
||||
float flow; // low bandpass cutoff freq
|
||||
float fhigh; // high bandpass cutoff freq
|
||||
float* impulse; // filter impulse response
|
||||
float rate; // sample rate
|
||||
int wintype; // filter window type
|
||||
double gain; // filter gain
|
||||
float gain; // filter gain
|
||||
int autoincr; // auto-increment notch width
|
||||
int maxpb; // maximum number of passbands
|
||||
NOTCHDB* ptraddr; // ptr to addr of notch-database data structure
|
||||
double* bplow; // array of passband lows
|
||||
double* bphigh; // array of passband highs
|
||||
float* bplow; // array of passband lows
|
||||
float* bphigh; // array of passband highs
|
||||
int numpb; // number of passbands
|
||||
FIRCORE *p;
|
||||
int havnotch;
|
||||
@ -88,13 +88,13 @@ public:
|
||||
int size,
|
||||
int nc,
|
||||
int mp,
|
||||
double* in,
|
||||
double* out,
|
||||
double flow,
|
||||
double fhigh,
|
||||
float* in,
|
||||
float* out,
|
||||
float flow,
|
||||
float fhigh,
|
||||
int rate,
|
||||
int wintype,
|
||||
double gain,
|
||||
float gain,
|
||||
int autoincr,
|
||||
int maxpb,
|
||||
NOTCHDB* ptraddr
|
||||
@ -102,7 +102,7 @@ public:
|
||||
static void destroy_nbp (NBP *a);
|
||||
static void flush_nbp (NBP *a);
|
||||
static void xnbp (NBP *a, int pos);
|
||||
static void setBuffers_nbp (NBP *a, double* in, double* out);
|
||||
static void setBuffers_nbp (NBP *a, float* in, float* out);
|
||||
static void setSamplerate_nbp (NBP *a, int rate);
|
||||
static void setSize_nbp (NBP *a, int size);
|
||||
static void calc_nbp_impulse (NBP *a);
|
||||
@ -111,40 +111,40 @@ public:
|
||||
// RXA Properties
|
||||
static void UpdateNBPFiltersLightWeight (RXA& rxa);
|
||||
static void UpdateNBPFilters(RXA& rxa);
|
||||
static int NBPAddNotch (RXA& rxa, int notch, double fcenter, double fwidth, int active);
|
||||
static int NBPGetNotch (RXA& rxa, int notch, double* fcenter, double* fwidth, int* active);
|
||||
static int NBPAddNotch (RXA& rxa, int notch, float fcenter, float fwidth, int active);
|
||||
static int NBPGetNotch (RXA& rxa, int notch, float* fcenter, float* fwidth, int* active);
|
||||
static int NBPDeleteNotch (RXA& rxa, int notch);
|
||||
static int NBPEditNotch (RXA& rxa, int notch, double fcenter, double fwidth, int active);
|
||||
static int NBPEditNotch (RXA& rxa, int notch, float fcenter, float fwidth, int active);
|
||||
static void NBPGetNumNotches (RXA& rxa, int* nnotches);
|
||||
static void NBPSetTuneFrequency (RXA& rxa, double tunefreq);
|
||||
static void NBPSetShiftFrequency (RXA& rxa, double shift);
|
||||
static void NBPSetTuneFrequency (RXA& rxa, float tunefreq);
|
||||
static void NBPSetShiftFrequency (RXA& rxa, float shift);
|
||||
static void NBPSetNotchesRun (RXA& rxa, int run);
|
||||
static void NBPSetRun (RXA& rxa, int run);
|
||||
static void NBPSetFreqs (RXA& rxa, double flow, double fhigh);
|
||||
static void NBPSetFreqs (RXA& rxa, float flow, float fhigh);
|
||||
static void NBPSetWindow (RXA& rxa, int wintype);
|
||||
|
||||
static void NBPSetNC (RXA& rxa, int nc);
|
||||
static void NBPSetMP (RXA& rxa, int mp);
|
||||
|
||||
static void NBPGetMinNotchWidth (RXA& rxa, double* minwidth);
|
||||
static void NBPGetMinNotchWidth (RXA& rxa, float* minwidth);
|
||||
static void NBPSetAutoIncrease (RXA& rxa, int autoincr);
|
||||
|
||||
private:
|
||||
static double* fir_mbandpass (int N, int nbp, double* flow, double* fhigh, double rate, double scale, int wintype);
|
||||
static double min_notch_width (NBP *a);
|
||||
static float* fir_mbandpass (int N, int nbp, float* flow, float* fhigh, float rate, float scale, int wintype);
|
||||
static float min_notch_width (NBP *a);
|
||||
static int make_nbp (
|
||||
int nn,
|
||||
int* active,
|
||||
double* center,
|
||||
double* width,
|
||||
double* nlow,
|
||||
double* nhigh,
|
||||
double minwidth,
|
||||
float* center,
|
||||
float* width,
|
||||
float* nlow,
|
||||
float* nhigh,
|
||||
float minwidth,
|
||||
int autoincr,
|
||||
double flow,
|
||||
double fhigh,
|
||||
double* bplow,
|
||||
double* bphigh,
|
||||
float flow,
|
||||
float fhigh,
|
||||
float* bplow,
|
||||
float* bphigh,
|
||||
int* havnotch
|
||||
);
|
||||
static void calc_nbp_lightweight (NBP *a);
|
||||
|
@ -41,8 +41,8 @@ void OSCTRL::calc_osctrl (OSCTRL *a)
|
||||
if ((a->pn & 1) == 0) a->pn += 1;
|
||||
if (a->pn < 3) a->pn = 3;
|
||||
a->dl_len = a->pn >> 1;
|
||||
a->dl = new double[a->pn * 2]; // (double *) malloc0 (a->pn * sizeof (complex));
|
||||
a->dlenv = new double[a->pn]; // (double *) malloc0 (a->pn * sizeof (double));
|
||||
a->dl = new float[a->pn * 2]; // (float *) malloc0 (a->pn * sizeof (complex));
|
||||
a->dlenv = new float[a->pn]; // (float *) malloc0 (a->pn * sizeof (float));
|
||||
a->in_idx = 0;
|
||||
a->out_idx = a->in_idx + a->dl_len;
|
||||
a->max_env = 0.0;
|
||||
@ -57,10 +57,10 @@ void OSCTRL::decalc_osctrl (OSCTRL *a)
|
||||
OSCTRL* OSCTRL::create_osctrl (
|
||||
int run,
|
||||
int size,
|
||||
double* inbuff,
|
||||
double* outbuff,
|
||||
float* inbuff,
|
||||
float* outbuff,
|
||||
int rate,
|
||||
double osgain
|
||||
float osgain
|
||||
)
|
||||
{
|
||||
OSCTRL *a = new OSCTRL;
|
||||
@ -84,7 +84,7 @@ void OSCTRL::destroy_osctrl (OSCTRL *a)
|
||||
void OSCTRL::flush_osctrl (OSCTRL *a)
|
||||
{
|
||||
memset (a->dl, 0, a->dl_len * sizeof (wcomplex));
|
||||
memset (a->dlenv, 0, a->pn * sizeof (double));
|
||||
memset (a->dlenv, 0, a->pn * sizeof (float));
|
||||
}
|
||||
|
||||
void OSCTRL::xosctrl (OSCTRL *a)
|
||||
@ -92,7 +92,7 @@ void OSCTRL::xosctrl (OSCTRL *a)
|
||||
if (a->run)
|
||||
{
|
||||
int i, j;
|
||||
double divisor;
|
||||
float divisor;
|
||||
for (i = 0; i < a->size; i++)
|
||||
{
|
||||
a->dl[2 * a->in_idx + 0] = a->inbuff[2 * i + 0]; // put sample in delay line
|
||||
@ -119,7 +119,7 @@ void OSCTRL::xosctrl (OSCTRL *a)
|
||||
memcpy (a->outbuff, a->inbuff, a->size * sizeof (wcomplex));
|
||||
}
|
||||
|
||||
void OSCTRL::setBuffers_osctrl (OSCTRL *a, double* in, double* out)
|
||||
void OSCTRL::setBuffers_osctrl (OSCTRL *a, float* in, float* out)
|
||||
{
|
||||
a->inbuff = in;
|
||||
a->outbuff = out;
|
||||
|
@ -43,32 +43,32 @@ class WDSP_API OSCTRL
|
||||
public:
|
||||
int run; // 1 to run; 0 otherwise
|
||||
int size; // buffer size
|
||||
double *inbuff; // input buffer
|
||||
double *outbuff; // output buffer
|
||||
float *inbuff; // input buffer
|
||||
float *outbuff; // output buffer
|
||||
int rate; // sample rate
|
||||
double osgain; // gain applied to overshoot "clippings"
|
||||
double bw; // bandwidth
|
||||
float osgain; // gain applied to overshoot "clippings"
|
||||
float bw; // bandwidth
|
||||
int pn; // "peak stretcher" window, samples
|
||||
int dl_len; // delay line length, samples
|
||||
double* dl; // delay line for complex samples
|
||||
double* dlenv; // delay line for envelope values
|
||||
float* dl; // delay line for complex samples
|
||||
float* dlenv; // delay line for envelope values
|
||||
int in_idx; // input index for dl
|
||||
int out_idx; // output index for dl
|
||||
double max_env; // maximum env value in env delay line
|
||||
double env_out;
|
||||
float max_env; // maximum env value in env delay line
|
||||
float env_out;
|
||||
|
||||
static void xosctrl (OSCTRL *a);
|
||||
static OSCTRL* create_osctrl (
|
||||
int run,
|
||||
int size,
|
||||
double* inbuff,
|
||||
double* outbuff,
|
||||
float* inbuff,
|
||||
float* outbuff,
|
||||
int rate,
|
||||
double osgain
|
||||
float osgain
|
||||
);
|
||||
static void destroy_osctrl (OSCTRL *a);
|
||||
static void flush_osctrl (OSCTRL *a);
|
||||
static void setBuffers_osctrl (OSCTRL *a, double* in, double* out);
|
||||
static void setBuffers_osctrl (OSCTRL *a, float* in, float* out);
|
||||
static void setSamplerate_osctrl (OSCTRL *a, int rate);
|
||||
static void setSize_osctrl (OSCTRL *a, int size);
|
||||
// TXA Properties
|
||||
|
@ -32,7 +32,7 @@ warren@wpratt.com
|
||||
|
||||
namespace WDSP {
|
||||
|
||||
PANEL* PANEL::create_panel (int run, int size, double* in, double* out, double gain1, double gain2I, double gain2Q, int inselect, int copy)
|
||||
PANEL* PANEL::create_panel (int run, int size, float* in, float* out, float gain1, float gain2I, float gain2Q, int inselect, int copy)
|
||||
{
|
||||
PANEL* a = new PANEL;
|
||||
a->run = run;
|
||||
@ -60,9 +60,9 @@ void PANEL::flush_panel (PANEL *)
|
||||
void PANEL::xpanel (PANEL *a)
|
||||
{
|
||||
int i;
|
||||
double I, Q;
|
||||
double gainI = a->gain1 * a->gain2I;
|
||||
double gainQ = a->gain1 * a->gain2Q;
|
||||
float I, Q;
|
||||
float gainI = a->gain1 * a->gain2I;
|
||||
float gainQ = a->gain1 * a->gain2Q;
|
||||
// inselect is either 0(neither), 1(Q), 2(I), or 3(both)
|
||||
switch (a->copy)
|
||||
{
|
||||
@ -105,7 +105,7 @@ void PANEL::xpanel (PANEL *a)
|
||||
}
|
||||
}
|
||||
|
||||
void PANEL::setBuffers_panel (PANEL *a, double* in, double* out)
|
||||
void PANEL::setBuffers_panel (PANEL *a, float* in, float* out)
|
||||
{
|
||||
a->in = in;
|
||||
a->out = out;
|
||||
@ -141,14 +141,14 @@ void PANEL::SetPanelSelect (RXA& rxa, int select)
|
||||
rxa.csDSP.unlock();
|
||||
}
|
||||
|
||||
void PANEL::SetPanelGain1 (RXA& rxa, double gain)
|
||||
void PANEL::SetPanelGain1 (RXA& rxa, float gain)
|
||||
{
|
||||
rxa.csDSP.lock();
|
||||
rxa.panel.p->gain1 = gain;
|
||||
rxa.csDSP.unlock();
|
||||
}
|
||||
|
||||
void PANEL::SetPanelGain2 (RXA& rxa, double gainI, double gainQ)
|
||||
void PANEL::SetPanelGain2 (RXA& rxa, float gainI, float gainQ)
|
||||
{
|
||||
rxa.csDSP.lock();
|
||||
rxa.panel.p->gain2I = gainI;
|
||||
@ -156,9 +156,9 @@ void PANEL::SetPanelGain2 (RXA& rxa, double gainI, double gainQ)
|
||||
rxa.csDSP.unlock();
|
||||
}
|
||||
|
||||
void PANEL::SetPanelPan (RXA& rxa, double pan)
|
||||
void PANEL::SetPanelPan (RXA& rxa, float pan)
|
||||
{
|
||||
double gain1, gain2;
|
||||
float gain1, gain2;
|
||||
rxa.csDSP.lock();
|
||||
if (pan <= 0.5)
|
||||
{
|
||||
@ -202,7 +202,7 @@ void PANEL::SetPanelRun (TXA& txa, int run)
|
||||
txa.csDSP.unlock();
|
||||
}
|
||||
|
||||
void PANEL::SetPanelGain1 (TXA& txa, double gain)
|
||||
void PANEL::SetPanelGain1 (TXA& txa, float gain)
|
||||
{
|
||||
txa.csDSP.lock();
|
||||
txa.panel.p->gain1 = gain;
|
||||
|
@ -40,32 +40,32 @@ class WDSP_API PANEL
|
||||
public:
|
||||
int run;
|
||||
int size;
|
||||
double* in;
|
||||
double* out;
|
||||
double gain1;
|
||||
double gain2I;
|
||||
double gain2Q;
|
||||
float* in;
|
||||
float* out;
|
||||
float gain1;
|
||||
float gain2I;
|
||||
float gain2Q;
|
||||
int inselect;
|
||||
int copy;
|
||||
|
||||
static PANEL* create_panel (int run, int size, double* in, double* out, double gain1, double gain2I, double gain2Q, int inselect, int copy);
|
||||
static PANEL* create_panel (int run, int size, float* in, float* out, float gain1, float gain2I, float gain2Q, int inselect, int copy);
|
||||
static void destroy_panel (PANEL *a);
|
||||
static void flush_panel (PANEL *a);
|
||||
static void xpanel (PANEL *a);
|
||||
static void setBuffers_panel (PANEL *a, double* in, double* out);
|
||||
static void setBuffers_panel (PANEL *a, float* in, float* out);
|
||||
static void setSamplerate_panel (PANEL *a, int rate);
|
||||
static void setSize_panel (PANEL *a, int size);
|
||||
// RXA Properties
|
||||
static void SetPanelRun (RXA& rxa, int run);
|
||||
static void SetPanelSelect (RXA& rxa, int select);
|
||||
static void SetPanelGain1 (RXA& rxa, double gain);
|
||||
static void SetPanelGain2 (RXA& rxa, double gainI, double gainQ);
|
||||
static void SetPanelPan (RXA& rxa, double pan);
|
||||
static void SetPanelGain1 (RXA& rxa, float gain);
|
||||
static void SetPanelGain2 (RXA& rxa, float gainI, float gainQ);
|
||||
static void SetPanelPan (RXA& rxa, float pan);
|
||||
static void SetPanelCopy (RXA& rxa, int copy);
|
||||
static void SetPanelBinaural (RXA& rxa, int bin);
|
||||
// TXA Properties
|
||||
static void SetPanelRun (TXA& txa, int run);
|
||||
static void SetPanelGain1 (TXA& txa, double gain);
|
||||
static void SetPanelGain1 (TXA& txa, float gain);
|
||||
static void SetPanelSelect (TXA& txa, int select);
|
||||
};
|
||||
|
||||
|
@ -42,9 +42,9 @@ void RESAMPLE::calc_resample (RESAMPLE *a)
|
||||
int x, y, z;
|
||||
int i, j, k;
|
||||
int min_rate;
|
||||
double full_rate;
|
||||
double fc_norm_high, fc_norm_low;
|
||||
double* impulse;
|
||||
float full_rate;
|
||||
float fc_norm_high, fc_norm_low;
|
||||
float* impulse;
|
||||
a->fc = a->fcin;
|
||||
a->ncoef = a->ncoefin;
|
||||
x = a->in_rate;
|
||||
@ -59,8 +59,8 @@ void RESAMPLE::calc_resample (RESAMPLE *a)
|
||||
a->M = a->in_rate / x;
|
||||
if (a->in_rate < a->out_rate) min_rate = a->in_rate;
|
||||
else min_rate = a->out_rate;
|
||||
if (a->fc == 0.0) a->fc = 0.45 * (double)min_rate;
|
||||
full_rate = (double)(a->in_rate * a->L);
|
||||
if (a->fc == 0.0) a->fc = 0.45 * (float)min_rate;
|
||||
full_rate = (float)(a->in_rate * a->L);
|
||||
fc_norm_high = a->fc / full_rate;
|
||||
if (a->fc_low < 0.0)
|
||||
fc_norm_low = - fc_norm_high;
|
||||
@ -69,14 +69,14 @@ void RESAMPLE::calc_resample (RESAMPLE *a)
|
||||
if (a->ncoef == 0) a->ncoef = (int)(140.0 * full_rate / min_rate);
|
||||
a->ncoef = (a->ncoef / a->L + 1) * a->L;
|
||||
a->cpp = a->ncoef / a->L;
|
||||
a->h = new double[a->ncoef]; // (double *)malloc0(a->ncoef * sizeof(double));
|
||||
impulse = FIR::fir_bandpass(a->ncoef, fc_norm_low, fc_norm_high, 1.0, 1, 0, a->gain * (double)a->L);
|
||||
a->h = new float[a->ncoef]; // (float *)malloc0(a->ncoef * sizeof(float));
|
||||
impulse = FIR::fir_bandpass(a->ncoef, fc_norm_low, fc_norm_high, 1.0, 1, 0, a->gain * (float)a->L);
|
||||
i = 0;
|
||||
for (j = 0; j < a->L; j++)
|
||||
for (k = 0; k < a->ncoef; k += a->L)
|
||||
a->h[i++] = impulse[j + k];
|
||||
a->ringsize = a->cpp;
|
||||
a->ring = new double[a->ringsize]; // (double *)malloc0(a->ringsize * sizeof(complex));
|
||||
a->ring = new float[a->ringsize]; // (float *)malloc0(a->ringsize * sizeof(complex));
|
||||
a->idx_in = a->ringsize - 1;
|
||||
a->phnum = 0;
|
||||
delete[] (impulse);
|
||||
@ -88,7 +88,7 @@ void RESAMPLE::decalc_resample (RESAMPLE *a)
|
||||
delete[] (a->h);
|
||||
}
|
||||
|
||||
RESAMPLE* RESAMPLE::create_resample ( int run, int size, double* in, double* out, int in_rate, int out_rate, double fc, int ncoef, double gain)
|
||||
RESAMPLE* RESAMPLE::create_resample ( int run, int size, float* in, float* out, int in_rate, int out_rate, float fc, int ncoef, float gain)
|
||||
{
|
||||
RESAMPLE *a = new RESAMPLE;
|
||||
|
||||
@ -129,7 +129,7 @@ int RESAMPLE::xresample (RESAMPLE *a)
|
||||
{
|
||||
int i, j, n;
|
||||
int idx_out;
|
||||
double I, Q;
|
||||
float I, Q;
|
||||
|
||||
for (i = 0; i < a->size; i++)
|
||||
{
|
||||
@ -160,7 +160,7 @@ int RESAMPLE::xresample (RESAMPLE *a)
|
||||
return outsamps;
|
||||
}
|
||||
|
||||
void RESAMPLE::setBuffers_resample(RESAMPLE *a, double* in, double* out)
|
||||
void RESAMPLE::setBuffers_resample(RESAMPLE *a, float* in, float* out)
|
||||
{
|
||||
a->in = in;
|
||||
a->out = out;
|
||||
@ -186,7 +186,7 @@ void RESAMPLE::setOutRate_resample(RESAMPLE *a, int rate)
|
||||
calc_resample (a);
|
||||
}
|
||||
|
||||
void RESAMPLE::setFCLow_resample (RESAMPLE *a, double fc_low)
|
||||
void RESAMPLE::setFCLow_resample (RESAMPLE *a, float fc_low)
|
||||
{
|
||||
if (fc_low != a->fc_low)
|
||||
{
|
||||
@ -196,7 +196,7 @@ void RESAMPLE::setFCLow_resample (RESAMPLE *a, double fc_low)
|
||||
}
|
||||
}
|
||||
|
||||
void RESAMPLE::setBandwidth_resample (RESAMPLE *a, double fc_low, double fc_high)
|
||||
void RESAMPLE::setBandwidth_resample (RESAMPLE *a, float fc_low, float fc_high)
|
||||
{
|
||||
if (fc_low != a->fc_low || fc_high != a->fcin)
|
||||
{
|
||||
@ -216,7 +216,7 @@ void* RESAMPLE::create_resampleV (int in_rate, int out_rate)
|
||||
}
|
||||
|
||||
|
||||
void RESAMPLE::xresampleV (double* input, double* output, int numsamps, int* outsamps, void* ptr)
|
||||
void RESAMPLE::xresampleV (float* input, float* output, int numsamps, int* outsamps, void* ptr)
|
||||
{
|
||||
RESAMPLE *a = (RESAMPLE*) ptr;
|
||||
a->in = input;
|
||||
@ -243,10 +243,10 @@ RESAMPLEF* RESAMPLEF::create_resampleF ( int run, int size, float* in, float* ou
|
||||
int x, y, z;
|
||||
int i, j, k;
|
||||
int min_rate;
|
||||
double full_rate;
|
||||
double fc;
|
||||
double fc_norm;
|
||||
double* impulse;
|
||||
float full_rate;
|
||||
float fc;
|
||||
float fc_norm;
|
||||
float* impulse;
|
||||
a->run = run;
|
||||
a->size = size;
|
||||
a->in = in;
|
||||
@ -263,20 +263,20 @@ RESAMPLEF* RESAMPLEF::create_resampleF ( int run, int size, float* in, float* ou
|
||||
a->M = in_rate / x;
|
||||
if (in_rate < out_rate) min_rate = in_rate;
|
||||
else min_rate = out_rate;
|
||||
fc = 0.45 * (double)min_rate;
|
||||
full_rate = (double)(in_rate * a->L);
|
||||
fc = 0.45 * (float)min_rate;
|
||||
full_rate = (float)(in_rate * a->L);
|
||||
fc_norm = fc / full_rate;
|
||||
a->ncoef = (int)(60.0 / fc_norm);
|
||||
a->ncoef = (a->ncoef / a->L + 1) * a->L;
|
||||
a->cpp = a->ncoef / a->L;
|
||||
a->h = new double[a->ncoef]; // (double *) malloc0 (a->ncoef * sizeof (double));
|
||||
impulse = FIR::fir_bandpass (a->ncoef, -fc_norm, +fc_norm, 1.0, 1, 0, (double)a->L);
|
||||
a->h = new float[a->ncoef]; // (float *) malloc0 (a->ncoef * sizeof (float));
|
||||
impulse = FIR::fir_bandpass (a->ncoef, -fc_norm, +fc_norm, 1.0, 1, 0, (float)a->L);
|
||||
i = 0;
|
||||
for (j = 0; j < a->L; j ++)
|
||||
for (k = 0; k < a->ncoef; k += a->L)
|
||||
a->h[i++] = impulse[j + k];
|
||||
a->ringsize = a->cpp;
|
||||
a->ring = new double[a->ringsize]; //(double *) malloc0 (a->ringsize * sizeof (double));
|
||||
a->ring = new float[a->ringsize]; //(float *) malloc0 (a->ringsize * sizeof (float));
|
||||
a->idx_in = a->ringsize - 1;
|
||||
a->phnum = 0;
|
||||
delete[] (impulse);
|
||||
@ -292,7 +292,7 @@ void RESAMPLEF::destroy_resampleF (RESAMPLEF *a)
|
||||
|
||||
void RESAMPLEF::flush_resampleF (RESAMPLEF *a)
|
||||
{
|
||||
memset (a->ring, 0, a->ringsize * sizeof (double));
|
||||
memset (a->ring, 0, a->ringsize * sizeof (float));
|
||||
a->idx_in = a->ringsize - 1;
|
||||
a->phnum = 0;
|
||||
}
|
||||
@ -304,11 +304,11 @@ int RESAMPLEF::xresampleF (RESAMPLEF *a)
|
||||
{
|
||||
int i, j, n;
|
||||
int idx_out;
|
||||
double I;
|
||||
float I;
|
||||
|
||||
for (i = 0; i < a->size; i++)
|
||||
{
|
||||
a->ring[a->idx_in] = (double)a->in[i];
|
||||
a->ring[a->idx_in] = (float)a->in[i];
|
||||
|
||||
while (a->phnum < a->L)
|
||||
{
|
||||
|
@ -43,38 +43,38 @@ class WDSP_API RESAMPLE
|
||||
public:
|
||||
int run; // run
|
||||
int size; // number of input samples per buffer
|
||||
double* in; // input buffer for resampler
|
||||
double* out; // output buffer for resampler
|
||||
float* in; // input buffer for resampler
|
||||
float* out; // output buffer for resampler
|
||||
int in_rate;
|
||||
int out_rate;
|
||||
double fcin;
|
||||
double fc;
|
||||
double fc_low;
|
||||
double gain;
|
||||
float fcin;
|
||||
float fc;
|
||||
float fc_low;
|
||||
float gain;
|
||||
int idx_in; // index for input into ring
|
||||
int ncoefin;
|
||||
int ncoef; // number of coefficients
|
||||
int L; // interpolation factor
|
||||
int M; // decimation factor
|
||||
double* h; // coefficients
|
||||
float* h; // coefficients
|
||||
int ringsize; // number of complex pairs the ring buffer holds
|
||||
double* ring; // ring buffer
|
||||
float* ring; // ring buffer
|
||||
int cpp; // coefficients of the phase
|
||||
int phnum; // phase number
|
||||
|
||||
static RESAMPLE* create_resample (int run, int size, double* in, double* out, int in_rate, int out_rate, double fc, int ncoef, double gain);
|
||||
static RESAMPLE* create_resample (int run, int size, float* in, float* out, int in_rate, int out_rate, float fc, int ncoef, float gain);
|
||||
static void destroy_resample (RESAMPLE *a);
|
||||
static void flush_resample (RESAMPLE *a);
|
||||
static int xresample (RESAMPLE *a);
|
||||
static void setBuffers_resample (RESAMPLE *a, double* in, double* out);
|
||||
static void setBuffers_resample (RESAMPLE *a, float* in, float* out);
|
||||
static void setSize_resample(RESAMPLE *a, int size);
|
||||
static void setInRate_resample(RESAMPLE *a, int rate);
|
||||
static void setOutRate_resample(RESAMPLE *a, int rate);
|
||||
static void setFCLow_resample (RESAMPLE *a, double fc_low);
|
||||
static void setBandwidth_resample (RESAMPLE *a, double fc_low, double fc_high);
|
||||
static void setFCLow_resample (RESAMPLE *a, float fc_low);
|
||||
static void setBandwidth_resample (RESAMPLE *a, float fc_low, float fc_high);
|
||||
// Exported calls
|
||||
static void* create_resampleV (int in_rate, int out_rate);
|
||||
static void xresampleV (double* input, double* output, int numsamps, int* outsamps, void* ptr);
|
||||
static void xresampleV (float* input, float* output, int numsamps, int* outsamps, void* ptr);
|
||||
static void destroy_resampleV (void* ptr);
|
||||
|
||||
private:
|
||||
@ -106,9 +106,9 @@ public:
|
||||
int ncoef; // number of coefficients
|
||||
int L; // interpolation factor
|
||||
int M; // decimation factor
|
||||
double* h; // coefficients
|
||||
float* h; // coefficients
|
||||
int ringsize; // number of values the ring buffer holds
|
||||
double* ring; // ring buffer
|
||||
float* ring; // ring buffer
|
||||
int cpp; // coefficients of the phase
|
||||
int phnum; // phase number
|
||||
|
||||
|
@ -34,7 +34,7 @@ warren@wpratt.com
|
||||
|
||||
namespace WDSP {
|
||||
|
||||
MAV* MAV::create_mav (int ringmin, int ringmax, double nom_value)
|
||||
MAV* MAV::create_mav (int ringmin, int ringmax, float nom_value)
|
||||
{
|
||||
MAV *a = new MAV;
|
||||
a->ringmin = ringmin;
|
||||
@ -62,7 +62,7 @@ void MAV::flush_mav (MAV *a)
|
||||
a->sum = 0;
|
||||
}
|
||||
|
||||
void MAV::xmav (MAV *a, int input, double* output)
|
||||
void MAV::xmav (MAV *a, int input, float* output)
|
||||
{
|
||||
if (a->load >= a->ringmax)
|
||||
a->sum -= a->ring[a->i];
|
||||
@ -71,13 +71,13 @@ void MAV::xmav (MAV *a, int input, double* output)
|
||||
a->sum += a->ring[a->i];
|
||||
|
||||
if (a->load >= a->ringmin)
|
||||
*output = (double)a->sum / (double)a->load;
|
||||
*output = (float)a->sum / (float)a->load;
|
||||
else
|
||||
*output = a->nom_value;
|
||||
a->i = (a->i + 1) & a->mask;
|
||||
}
|
||||
|
||||
AAMAV* AAMAV::create_aamav (int ringmin, int ringmax, double nom_ratio)
|
||||
AAMAV* AAMAV::create_aamav (int ringmin, int ringmax, float nom_ratio)
|
||||
{
|
||||
AAMAV *a = new AAMAV;
|
||||
a->ringmin = ringmin;
|
||||
@ -107,7 +107,7 @@ void AAMAV::flush_aamav (AAMAV *a)
|
||||
a->neg = 0;
|
||||
}
|
||||
|
||||
void AAMAV::xaamav (AAMAV *a, int input, double* output)
|
||||
void AAMAV::xaamav (AAMAV *a, int input, float* output)
|
||||
{
|
||||
if (a->load >= a->ringmax)
|
||||
{
|
||||
@ -123,11 +123,11 @@ void AAMAV::xaamav (AAMAV *a, int input, double* output)
|
||||
else
|
||||
a->neg -= a->ring[a->i];
|
||||
if (a->load >= a->ringmin)
|
||||
*output = (double)a->neg / (double)a->pos;
|
||||
*output = (float)a->neg / (float)a->pos;
|
||||
else if (a->neg > 0 && a->pos > 0)
|
||||
{
|
||||
double frac = (double)a->load / (double)a->ringmin;
|
||||
*output = (1.0 - frac) * a->nom_ratio + frac * ((double)a->neg / (double)a->pos);
|
||||
float frac = (float)a->load / (float)a->ringmin;
|
||||
*output = (1.0 - frac) * a->nom_ratio + frac * ((float)a->neg / (float)a->pos);
|
||||
}
|
||||
else
|
||||
*output = a->nom_ratio;
|
||||
@ -137,41 +137,41 @@ void AAMAV::xaamav (AAMAV *a, int input, double* output)
|
||||
void RMATCH::calc_rmatch (RMATCH *a)
|
||||
{
|
||||
int m;
|
||||
double theta, dtheta;
|
||||
float theta, dtheta;
|
||||
int max_ring_insize;
|
||||
a->nom_ratio = (double)a->nom_outrate / (double)a->nom_inrate;
|
||||
max_ring_insize = (int)(1.0 + (double)a->insize * (1.05 * a->nom_ratio));
|
||||
a->nom_ratio = (float)a->nom_outrate / (float)a->nom_inrate;
|
||||
max_ring_insize = (int)(1.0 + (float)a->insize * (1.05 * a->nom_ratio));
|
||||
if (a->ringsize < 2 * max_ring_insize) a->ringsize = 2 * max_ring_insize;
|
||||
if (a->ringsize < 2 * a->outsize) a->ringsize = 2 * a->outsize;
|
||||
a->ring = new double[a->ringsize * 2]; // (double *) malloc0 (a->ringsize * sizeof (complex));
|
||||
a->ring = new float[a->ringsize * 2]; // (float *) malloc0 (a->ringsize * sizeof (complex));
|
||||
a->rsize = a->ringsize;
|
||||
a->n_ring = a->rsize / 2;
|
||||
a->iin = a->rsize / 2;
|
||||
a->iout = 0;
|
||||
a->resout = new double[max_ring_insize * 2]; // (double *) malloc0 (max_ring_insize * sizeof (complex));
|
||||
a->resout = new float[max_ring_insize * 2]; // (float *) malloc0 (max_ring_insize * sizeof (complex));
|
||||
a->v = VARSAMP::create_varsamp (1, a->insize, a->in, a->resout, a->nom_inrate, a->nom_outrate,
|
||||
a->fc_high, a->fc_low, a->R, a->gain, a->var, a->varmode);
|
||||
a->ffmav = AAMAV::create_aamav (a->ff_ringmin, a->ff_ringmax, a->nom_ratio);
|
||||
a->propmav = MAV::create_mav (a->prop_ringmin, a->prop_ringmax, 0.0);
|
||||
a->pr_gain = a->prop_gain * 48000.0 / (double)a->nom_outrate; // adjust gain for rate
|
||||
a->inv_nom_ratio = (double)a->nom_inrate / (double)a->nom_outrate;
|
||||
a->pr_gain = a->prop_gain * 48000.0 / (float)a->nom_outrate; // adjust gain for rate
|
||||
a->inv_nom_ratio = (float)a->nom_inrate / (float)a->nom_outrate;
|
||||
a->feed_forward = 1.0;
|
||||
a->av_deviation = 0.0;
|
||||
a->ntslew = (int)(a->tslew * a->nom_outrate);
|
||||
if (a->ntslew + 1 > a->rsize / 2) a->ntslew = a->rsize / 2 - 1;
|
||||
a->cslew = new double[a->ntslew + 1]; // (double *) malloc0 ((a->ntslew + 1) * sizeof (double));
|
||||
dtheta = PI / (double)a->ntslew;
|
||||
a->cslew = new float[a->ntslew + 1]; // (float *) malloc0 ((a->ntslew + 1) * sizeof (float));
|
||||
dtheta = PI / (float)a->ntslew;
|
||||
theta = 0.0;
|
||||
for (m = 0; m <= a->ntslew; m++)
|
||||
{
|
||||
a->cslew[m] = 0.5 * (1.0 - cos (theta));
|
||||
theta += dtheta;
|
||||
}
|
||||
a->baux = new double[a->ringsize / 2 * 2]; // (double *) malloc0 (a->ringsize / 2 * sizeof (complex));
|
||||
a->baux = new float[a->ringsize / 2 * 2]; // (float *) malloc0 (a->ringsize / 2 * sizeof (complex));
|
||||
a->readsamps = 0;
|
||||
a->writesamps = 0;
|
||||
a->read_startup = (unsigned int)((double)a->nom_outrate * a->startup_delay);
|
||||
a->write_startup = (unsigned int)((double)a->nom_inrate * a->startup_delay);
|
||||
a->read_startup = (unsigned int)((float)a->nom_outrate * a->startup_delay);
|
||||
a->write_startup = (unsigned int)((float)a->nom_inrate * a->startup_delay);
|
||||
a->control_flag = 0;
|
||||
// diagnostics
|
||||
a->underflows = 0;
|
||||
@ -191,28 +191,28 @@ void RMATCH::decalc_rmatch (RMATCH *a)
|
||||
|
||||
RMATCH* RMATCH::create_rmatch (
|
||||
int run, // 0 - input and output calls do nothing; 1 - operates normally
|
||||
double* in, // pointer to input buffer
|
||||
double* out, // pointer to output buffer
|
||||
float* in, // pointer to input buffer
|
||||
float* out, // pointer to output buffer
|
||||
int insize, // size of input buffer
|
||||
int outsize, // size of output buffer
|
||||
int nom_inrate, // nominal input samplerate
|
||||
int nom_outrate, // nominal output samplerate
|
||||
double fc_high, // high cutoff frequency if lower than max
|
||||
double fc_low, // low cutoff frequency if higher than zero
|
||||
double gain, // gain to be applied during this process
|
||||
double startup_delay, // time (seconds) to delay before beginning measurements to control variable resampler
|
||||
float fc_high, // high cutoff frequency if lower than max
|
||||
float fc_low, // low cutoff frequency if higher than zero
|
||||
float gain, // gain to be applied during this process
|
||||
float startup_delay, // time (seconds) to delay before beginning measurements to control variable resampler
|
||||
int auto_ringsize, // 0 specified ringsize is used; 1 ringsize is auto-optimized - FEATURE NOT IMPLEMENTED!!
|
||||
int ringsize, // specified ringsize; max ringsize if 'auto' is enabled
|
||||
int R, // density factor for varsamp coefficients
|
||||
double var, // initial value of variable resampler ratio (value of ~1.0)
|
||||
float var, // initial value of variable resampler ratio (value of ~1.0)
|
||||
int ffmav_min, // minimum feed-forward moving average size to put full weight on data in the ring
|
||||
int ffmav_max, // maximum feed-forward moving average size - MUST BE A POWER OF TWO!
|
||||
double ff_alpha, // feed-forward exponential averaging multiplier
|
||||
float ff_alpha, // feed-forward exponential averaging multiplier
|
||||
int prop_ringmin, // proportional feedback min moving average ringsize
|
||||
int prop_ringmax, // proportional feedback max moving average ringsize - MUST BE A POWER OF TWO!
|
||||
double prop_gain, // proportional feedback gain factor
|
||||
float prop_gain, // proportional feedback gain factor
|
||||
int varmode, // 0 - use same var for all samples of the buffer; 1 - interpolate from old_var to this var
|
||||
double tslew // slew/blend time (seconds)
|
||||
float tslew // slew/blend time (seconds)
|
||||
)
|
||||
{
|
||||
RMATCH *a = new RMATCH;
|
||||
@ -261,7 +261,7 @@ void RMATCH::reset_rmatch (RMATCH *a)
|
||||
void RMATCH::control (RMATCH *a, int change)
|
||||
{
|
||||
{
|
||||
double current_ratio;
|
||||
float current_ratio;
|
||||
AAMAV::xaamav (a->ffmav, change, ¤t_ratio);
|
||||
current_ratio *= a->inv_nom_ratio;
|
||||
a->feed_forward = a->ff_alpha * current_ratio + (1.0 - a->ff_alpha) * a->feed_forward;
|
||||
@ -302,13 +302,13 @@ void RMATCH::upslew (RMATCH *a, int newsamps)
|
||||
}
|
||||
}
|
||||
|
||||
void RMATCH::xrmatchIN (void* b, double* in)
|
||||
void RMATCH::xrmatchIN (void* b, float* in)
|
||||
{
|
||||
RMATCH *a = (RMATCH*) b;
|
||||
if (a->run == 1)
|
||||
{
|
||||
int newsamps, first, second, ovfl;
|
||||
double var;
|
||||
float var;
|
||||
a->v->in = a->in = in;
|
||||
a->cs_var.lock();
|
||||
if (!a->force)
|
||||
@ -429,7 +429,7 @@ void RMATCH::dslew (RMATCH *a)
|
||||
}
|
||||
|
||||
|
||||
void RMATCH::xrmatchOUT (void* b, double* out)
|
||||
void RMATCH::xrmatchOUT (void* b, float* out)
|
||||
{
|
||||
RMATCH *a = (RMATCH*) b;
|
||||
if (a->run == 1)
|
||||
@ -471,7 +471,7 @@ void RMATCH::xrmatchOUT (void* b, double* out)
|
||||
}
|
||||
|
||||
|
||||
void RMATCH::getRMatchDiags (void* b, int* underflows, int* overflows, double* var, int* ringsize, int* nring)
|
||||
void RMATCH::getRMatchDiags (void* b, int* underflows, int* overflows, float* var, int* ringsize, int* nring)
|
||||
{
|
||||
RMATCH *a = (RMATCH*) b;
|
||||
*underflows = a->underflows;
|
||||
@ -494,7 +494,7 @@ void RMATCH::resetRMatchDiags (void*)
|
||||
}
|
||||
|
||||
|
||||
void RMATCH::forceRMatchVar (void* b, int force, double fvar)
|
||||
void RMATCH::forceRMatchVar (void* b, int force, float fvar)
|
||||
{
|
||||
RMATCH *a = (RMATCH*) b;
|
||||
a->cs_var.lock();
|
||||
@ -504,7 +504,7 @@ void RMATCH::forceRMatchVar (void* b, int force, double fvar)
|
||||
}
|
||||
|
||||
|
||||
void* RMATCH::create_rmatchV(int in_size, int out_size, int nom_inrate, int nom_outrate, int ringsize, double var)
|
||||
void* RMATCH::create_rmatchV(int in_size, int out_size, int nom_inrate, int nom_outrate, int ringsize, float var)
|
||||
{
|
||||
return (void*)create_rmatch (
|
||||
1, // run
|
||||
@ -600,17 +600,17 @@ void RMATCH::setRMatchRingsize (void* ptr, int ringsize)
|
||||
}
|
||||
|
||||
|
||||
void RMATCH::setRMatchFeedbackGain (void* b, double feedback_gain)
|
||||
void RMATCH::setRMatchFeedbackGain (void* b, float feedback_gain)
|
||||
{
|
||||
RMATCH *a = (RMATCH*) b;
|
||||
a->cs_var.lock();
|
||||
a->prop_gain = feedback_gain;
|
||||
a->pr_gain = a->prop_gain * 48000.0 / (double)a->nom_outrate;
|
||||
a->pr_gain = a->prop_gain * 48000.0 / (float)a->nom_outrate;
|
||||
a->cs_var.unlock();
|
||||
}
|
||||
|
||||
|
||||
void RMATCH::setRMatchSlewTime (void* b, double slew_time)
|
||||
void RMATCH::setRMatchSlewTime (void* b, float slew_time)
|
||||
{
|
||||
RMATCH *a = (RMATCH*) b;
|
||||
a->run = 0; // InterlockedBitTestAndReset(&a->run, 0); // turn OFF new data coming into the rmatch
|
||||
@ -622,10 +622,10 @@ void RMATCH::setRMatchSlewTime (void* b, double slew_time)
|
||||
}
|
||||
|
||||
|
||||
void RMATCH::setRMatchSlewTime1(void* b, double slew_time)
|
||||
void RMATCH::setRMatchSlewTime1(void* b, float slew_time)
|
||||
{
|
||||
RMATCH *a = (RMATCH*) b;
|
||||
double theta, dtheta;
|
||||
float theta, dtheta;
|
||||
int m;
|
||||
a->run = 0;
|
||||
// Sleep(10);
|
||||
@ -633,8 +633,8 @@ void RMATCH::setRMatchSlewTime1(void* b, double slew_time)
|
||||
a->tslew = slew_time;
|
||||
a->ntslew = (int)(a->tslew * a->nom_outrate);
|
||||
if (a->ntslew + 1 > a->rsize / 2) a->ntslew = a->rsize / 2 - 1;
|
||||
a->cslew = new double[a->ntslew + 1]; // (double*)malloc0((a->ntslew + 1) * sizeof(double));
|
||||
dtheta = PI / (double)a->ntslew;
|
||||
a->cslew = new float[a->ntslew + 1]; // (float*)malloc0((a->ntslew + 1) * sizeof(float));
|
||||
dtheta = PI / (float)a->ntslew;
|
||||
theta = 0.0;
|
||||
for (m = 0; m <= a->ntslew; m++)
|
||||
{
|
||||
@ -693,7 +693,7 @@ void RMATCH::setRMatchFFRingMax(void* ptr, int ff_ringmax)
|
||||
}
|
||||
|
||||
|
||||
void RMATCH::setRMatchFFAlpha(void* ptr, double ff_alpha)
|
||||
void RMATCH::setRMatchFFAlpha(void* ptr, float ff_alpha)
|
||||
{
|
||||
RMATCH *a = (RMATCH*) ptr;
|
||||
a->run = 0;
|
||||
|
@ -47,12 +47,12 @@ public:
|
||||
int i;
|
||||
int load;
|
||||
int sum;
|
||||
double nom_value;
|
||||
float nom_value;
|
||||
|
||||
static MAV* create_mav (int ringmin, int ringmax, double nom_value);
|
||||
static MAV* create_mav (int ringmin, int ringmax, float nom_value);
|
||||
static void destroy_mav (MAV *a);
|
||||
static void flush_mav (MAV *a);
|
||||
static void xmav (MAV *a, int input, double* output);
|
||||
static void xmav (MAV *a, int input, float* output);
|
||||
};
|
||||
|
||||
class WDSP_API AAMAV
|
||||
@ -66,61 +66,61 @@ public:
|
||||
int load;
|
||||
int pos;
|
||||
int neg;
|
||||
double nom_ratio;
|
||||
float nom_ratio;
|
||||
|
||||
static AAMAV* create_aamav (int ringmin, int ringmax, double nom_ratio);
|
||||
static AAMAV* create_aamav (int ringmin, int ringmax, float nom_ratio);
|
||||
static void destroy_aamav (AAMAV *a);
|
||||
static void flush_aamav (AAMAV *a);
|
||||
static void xaamav (AAMAV *a, int input, double* output);
|
||||
static void xaamav (AAMAV *a, int input, float* output);
|
||||
};
|
||||
|
||||
class WDSP_API RMATCH
|
||||
{
|
||||
public:
|
||||
std::atomic<long> run;
|
||||
double* in;
|
||||
double* out;
|
||||
float* in;
|
||||
float* out;
|
||||
int insize;
|
||||
int outsize;
|
||||
double* resout;
|
||||
float* resout;
|
||||
int nom_inrate;
|
||||
int nom_outrate;
|
||||
double nom_ratio;
|
||||
double inv_nom_ratio;
|
||||
double fc_high;
|
||||
double fc_low;
|
||||
double gain;
|
||||
double startup_delay;
|
||||
float nom_ratio;
|
||||
float inv_nom_ratio;
|
||||
float fc_high;
|
||||
float fc_low;
|
||||
float gain;
|
||||
float startup_delay;
|
||||
int auto_ringsize;
|
||||
int ringsize;
|
||||
int rsize;
|
||||
double* ring;
|
||||
float* ring;
|
||||
int n_ring;
|
||||
int iin;
|
||||
int iout;
|
||||
double var;
|
||||
float var;
|
||||
int R;
|
||||
AAMAV *ffmav;
|
||||
MAV *propmav;
|
||||
int ff_ringmin;
|
||||
int ff_ringmax; // must be a power of two
|
||||
double ff_alpha;
|
||||
double feed_forward;
|
||||
float ff_alpha;
|
||||
float feed_forward;
|
||||
int prop_ringmin;
|
||||
int prop_ringmax; // must be a power of two
|
||||
double prop_gain;
|
||||
double pr_gain;
|
||||
double av_deviation;
|
||||
float prop_gain;
|
||||
float pr_gain;
|
||||
float av_deviation;
|
||||
VARSAMP *v;
|
||||
int varmode;
|
||||
QRecursiveMutex cs_ring;
|
||||
QRecursiveMutex cs_var;
|
||||
// blend / slew
|
||||
double tslew;
|
||||
float tslew;
|
||||
int ntslew;
|
||||
double* cslew;
|
||||
double* baux;
|
||||
double dlast[2];
|
||||
float* cslew;
|
||||
float* baux;
|
||||
float dlast[2];
|
||||
int ucnt;
|
||||
// variables to check start-up time for control to become active
|
||||
unsigned int readsamps;
|
||||
@ -132,57 +132,57 @@ public:
|
||||
std::atomic<long> underflows;
|
||||
std::atomic<long> overflows;
|
||||
int force;
|
||||
double fvar;
|
||||
float fvar;
|
||||
|
||||
static RMATCH* create_rmatch (
|
||||
int run, // 0 - input and output calls do nothing; 1 - operates normally
|
||||
double* in, // pointer to input buffer
|
||||
double* out, // pointer to output buffer
|
||||
float* in, // pointer to input buffer
|
||||
float* out, // pointer to output buffer
|
||||
int insize, // size of input buffer
|
||||
int outsize, // size of output buffer
|
||||
int nom_inrate, // nominal input samplerate
|
||||
int nom_outrate, // nominal output samplerate
|
||||
double fc_high, // high cutoff frequency if lower than max
|
||||
double fc_low, // low cutoff frequency if higher than zero
|
||||
double gain, // gain to be applied during this process
|
||||
double startup_delay, // time (seconds) to delay before beginning measurements to control variable resampler
|
||||
float fc_high, // high cutoff frequency if lower than max
|
||||
float fc_low, // low cutoff frequency if higher than zero
|
||||
float gain, // gain to be applied during this process
|
||||
float startup_delay, // time (seconds) to delay before beginning measurements to control variable resampler
|
||||
int auto_ringsize, // 0 specified ringsize is used; 1 ringsize is auto-optimized - FEATURE NOT IMPLEMENTED!!
|
||||
int ringsize, // specified ringsize; max ringsize if 'auto' is enabled
|
||||
int R, // density factor for varsamp coefficients
|
||||
double var, // initial value of variable resampler ratio (value of ~1.0)
|
||||
float var, // initial value of variable resampler ratio (value of ~1.0)
|
||||
int ffmav_min, // minimum feed-forward moving average size to put full weight on data in the ring
|
||||
int ffmav_max, // maximum feed-forward moving average size - MUST BE A POWER OF TWO!
|
||||
double ff_alpha, // feed-forward exponential averaging multiplier
|
||||
float ff_alpha, // feed-forward exponential averaging multiplier
|
||||
int prop_ringmin, // proportional feedback min moving average ringsize
|
||||
int prop_ringmax, // proportional feedback max moving average ringsize - MUST BE A POWER OF TWO!
|
||||
double prop_gain, // proportional feedback gain factor
|
||||
float prop_gain, // proportional feedback gain factor
|
||||
int varmode, // 0 - use same var for all samples of the buffer; 1 - interpolate from old_var to this var
|
||||
double tslew // slew/blend time (seconds)
|
||||
float tslew // slew/blend time (seconds)
|
||||
);
|
||||
static void destroy_rmatch (RMATCH *a);
|
||||
static void reset_rmatch (RMATCH *a);
|
||||
|
||||
static void* create_rmatchV(int in_size, int out_size, int nom_inrate, int nom_outrate, int ringsize, double var);
|
||||
static void* create_rmatchV(int in_size, int out_size, int nom_inrate, int nom_outrate, int ringsize, float var);
|
||||
static void* create_rmatchLegacyV(int in_size, int out_size, int nom_inrate, int nom_outrate, int ringsize);
|
||||
static void destroy_rmatchV (void* ptr);
|
||||
static void xrmatchOUT (void* b, double* out);
|
||||
static void xrmatchIN (void* b, double* in);
|
||||
static void xrmatchOUT (void* b, float* out);
|
||||
static void xrmatchIN (void* b, float* in);
|
||||
static void setRMatchInsize (void* ptr, int insize);
|
||||
static void setRMatchOutsize (void* ptr, int outsize);
|
||||
static void setRMatchNomInrate (void* ptr, int nom_inrate);
|
||||
static void setRMatchNomOutrate (void* ptr, int nom_outrate);
|
||||
static void setRMatchRingsize (void* ptr, int ringsize);
|
||||
static void getRMatchDiags (void* b, int* underflows, int* overflows, double* var, int* ringsize, int* nring);
|
||||
static void getRMatchDiags (void* b, int* underflows, int* overflows, float* var, int* ringsize, int* nring);
|
||||
static void resetRMatchDiags (void* b);
|
||||
static void forceRMatchVar (void* b, int force, double fvar);
|
||||
static void setRMatchFeedbackGain(void* b, double feedback_gain);
|
||||
static void setRMatchSlewTime(void* b, double slew_time);
|
||||
static void setRMatchSlewTime1(void* b, double slew_time);
|
||||
static void forceRMatchVar (void* b, int force, float fvar);
|
||||
static void setRMatchFeedbackGain(void* b, float feedback_gain);
|
||||
static void setRMatchSlewTime(void* b, float slew_time);
|
||||
static void setRMatchSlewTime1(void* b, float slew_time);
|
||||
static void setRMatchPropRingMin(void* ptr, int prop_min);
|
||||
static void setRMatchPropRingMax(void* ptr, int prop_max);
|
||||
static void setRMatchFFRingMin(void* ptr, int ff_ringmin);
|
||||
static void setRMatchFFRingMax(void* ptr, int ff_ringmax);
|
||||
static void setRMatchFFAlpha(void* ptr, double ff_alpha);
|
||||
static void setRMatchFFAlpha(void* ptr, float ff_alpha);
|
||||
static void getControlFlag(void* ptr, int* control_flag);
|
||||
|
||||
private:
|
||||
|
@ -32,7 +32,7 @@ warren@wpratt.com
|
||||
|
||||
namespace WDSP {
|
||||
|
||||
SENDER* SENDER::create_sender (int run, int flag, int mode, int size, double* in)
|
||||
SENDER* SENDER::create_sender (int run, int flag, int mode, int size, float* in)
|
||||
{
|
||||
SENDER *a = new SENDER;
|
||||
a->run = run;
|
||||
@ -70,7 +70,7 @@ void SENDER::xsender (SENDER *a)
|
||||
}
|
||||
}
|
||||
|
||||
void SENDER::setBuffers_sender (SENDER *a, double* in)
|
||||
void SENDER::setBuffers_sender (SENDER *a, float* in)
|
||||
{
|
||||
a->in = in;
|
||||
}
|
||||
|
@ -47,14 +47,14 @@ public:
|
||||
int flag; // secondary 'run'; AND'd with 'run'
|
||||
int mode; // selects the specific processing and function call
|
||||
int size; // size of the data buffer (complex samples)
|
||||
double* in; // buffer from which to take the data
|
||||
float* in; // buffer from which to take the data
|
||||
BufferProbe *spectrumProbe; // this is the data handler actually
|
||||
|
||||
static SENDER* create_sender (int run, int flag, int mode, int size, double* in);
|
||||
static SENDER* create_sender (int run, int flag, int mode, int size, float* in);
|
||||
static void destroy_sender (SENDER *a);
|
||||
static void flush_sender (SENDER *a);
|
||||
static void xsender (SENDER *a);
|
||||
static void setBuffers_sender (SENDER *a, double* in);
|
||||
static void setBuffers_sender (SENDER *a, float* in);
|
||||
static void setSamplerate_sender (SENDER *a, int rate);
|
||||
static void setSize_sender (SENDER *a, int size);
|
||||
// RXA Properties
|
||||
|
@ -38,14 +38,14 @@ void SHIFT::calc_shift (SHIFT *a)
|
||||
a->sin_delta = sin (a->delta);
|
||||
}
|
||||
|
||||
SHIFT* SHIFT::create_shift (int run, int size, double* in, double* out, int rate, double fshift)
|
||||
SHIFT* SHIFT::create_shift (int run, int size, float* in, float* out, int rate, float fshift)
|
||||
{
|
||||
SHIFT *a = new SHIFT;
|
||||
a->run = run;
|
||||
a->size = size;
|
||||
a->in = in;
|
||||
a->out = out;
|
||||
a->rate = (double)rate;
|
||||
a->rate = (float)rate;
|
||||
a->shift = fshift;
|
||||
a->phase = 0.0;
|
||||
calc_shift (a);
|
||||
@ -67,9 +67,9 @@ void SHIFT::xshift (SHIFT *a)
|
||||
if (a->run)
|
||||
{
|
||||
int i;
|
||||
double I1, Q1, t1, t2;
|
||||
double cos_phase = cos (a->phase);
|
||||
double sin_phase = sin (a->phase);
|
||||
float I1, Q1, t1, t2;
|
||||
float cos_phase = cos (a->phase);
|
||||
float sin_phase = sin (a->phase);
|
||||
for (i = 0; i < a->size; i++)
|
||||
{
|
||||
I1 = a->in[2 * i + 0];
|
||||
@ -89,7 +89,7 @@ void SHIFT::xshift (SHIFT *a)
|
||||
memcpy (a->out, a->in, a->size * sizeof (wcomplex));
|
||||
}
|
||||
|
||||
void SHIFT::setBuffers_shift(SHIFT *a, double* in, double* out)
|
||||
void SHIFT::setBuffers_shift(SHIFT *a, float* in, float* out)
|
||||
{
|
||||
a->in = in;
|
||||
a->out = out;
|
||||
@ -121,7 +121,7 @@ void SHIFT::SetShiftRun (RXA& rxa, int run)
|
||||
rxa.csDSP.unlock();
|
||||
}
|
||||
|
||||
void SHIFT::SetShiftFreq (RXA& rxa, double fshift)
|
||||
void SHIFT::SetShiftFreq (RXA& rxa, float fshift)
|
||||
{
|
||||
rxa.csDSP.lock();
|
||||
rxa.shift.p->shift = fshift;
|
||||
|
@ -39,25 +39,25 @@ class WDSP_API SHIFT
|
||||
public:
|
||||
int run;
|
||||
int size;
|
||||
double* in;
|
||||
double* out;
|
||||
double rate;
|
||||
double shift;
|
||||
double phase;
|
||||
double delta;
|
||||
double cos_delta;
|
||||
double sin_delta;
|
||||
float* in;
|
||||
float* out;
|
||||
float rate;
|
||||
float shift;
|
||||
float phase;
|
||||
float delta;
|
||||
float cos_delta;
|
||||
float sin_delta;
|
||||
|
||||
static SHIFT* create_shift (int run, int size, double* in, double* out, int rate, double fshift);
|
||||
static SHIFT* create_shift (int run, int size, float* in, float* out, int rate, float fshift);
|
||||
static void destroy_shift (SHIFT *a);
|
||||
static void flush_shift (SHIFT *a);
|
||||
static void xshift (SHIFT *a);
|
||||
static void setBuffers_shift (SHIFT *a, double* in, double* out);
|
||||
static void setBuffers_shift (SHIFT *a, float* in, float* out);
|
||||
static void setSamplerate_shift (SHIFT *a, int rate);
|
||||
static void setSize_shift (SHIFT *a, int size);
|
||||
// RXA Properties
|
||||
static void SetShiftRun (RXA& rxa, int run);
|
||||
static void SetShiftFreq (RXA& rxa, double fshift);
|
||||
static void SetShiftFreq (RXA& rxa, float fshift);
|
||||
|
||||
private:
|
||||
static void calc_shift (SHIFT *a);
|
||||
|
@ -36,13 +36,13 @@ namespace WDSP {
|
||||
void SIPHON::build_window (SIPHON *a)
|
||||
{
|
||||
int i;
|
||||
double arg0, cosphi;
|
||||
double sum, scale;
|
||||
arg0 = 2.0 * PI / ((double)a->fftsize - 1.0);
|
||||
float arg0, cosphi;
|
||||
float sum, scale;
|
||||
arg0 = 2.0 * PI / ((float)a->fftsize - 1.0);
|
||||
sum = 0.0;
|
||||
for (i = 0; i < a->fftsize; i++)
|
||||
{
|
||||
cosphi = cos (arg0 * (double)i);
|
||||
cosphi = cos (arg0 * (float)i);
|
||||
a->window[i] = + 6.3964424114390378e-02
|
||||
+ cosphi * ( - 2.3993864599352804e-01
|
||||
+ cosphi * ( + 3.5015956323820469e-01
|
||||
@ -63,7 +63,7 @@ SIPHON* SIPHON::create_siphon (
|
||||
int mode,
|
||||
int disp,
|
||||
int insize,
|
||||
double* in,
|
||||
float* in,
|
||||
int sipsize,
|
||||
int fftsize,
|
||||
int specmode
|
||||
@ -79,19 +79,19 @@ SIPHON* SIPHON::create_siphon (
|
||||
a->sipsize = sipsize; // NOTE: sipsize MUST BE A POWER OF TWO!!
|
||||
a->fftsize = fftsize;
|
||||
a->specmode = specmode;
|
||||
a->sipbuff = new double[a->sipsize * 2]; // (double *) malloc0 (a->sipsize * sizeof (complex));
|
||||
a->sipbuff = new float[a->sipsize * 2]; // (float *) malloc0 (a->sipsize * sizeof (complex));
|
||||
a->idx = 0;
|
||||
a->sipout = new double[a->sipsize * 2]; // (double *) malloc0 (a->sipsize * sizeof (complex));
|
||||
a->specout = new double[a->fftsize * 2]; // (double *) malloc0 (a->fftsize * sizeof (complex));
|
||||
a->sipplan = fftw_plan_dft_1d (a->fftsize, (fftw_complex *)a->sipout, (fftw_complex *)a->specout, FFTW_FORWARD, FFTW_PATIENT);
|
||||
a->window = new double[a->fftsize * 2]; // (double *) malloc0 (a->fftsize * sizeof (complex));
|
||||
a->sipout = new float[a->sipsize * 2]; // (float *) malloc0 (a->sipsize * sizeof (complex));
|
||||
a->specout = new float[a->fftsize * 2]; // (float *) malloc0 (a->fftsize * sizeof (complex));
|
||||
a->sipplan = fftwf_plan_dft_1d (a->fftsize, (fftwf_complex *)a->sipout, (fftwf_complex *)a->specout, FFTW_FORWARD, FFTW_PATIENT);
|
||||
a->window = new float[a->fftsize * 2]; // (float *) malloc0 (a->fftsize * sizeof (complex));
|
||||
build_window (a);
|
||||
return a;
|
||||
}
|
||||
|
||||
void SIPHON::destroy_siphon (SIPHON *a)
|
||||
{
|
||||
fftw_destroy_plan (a->sipplan);
|
||||
fftwf_destroy_plan (a->sipplan);
|
||||
delete[] (a->window);
|
||||
delete[] (a->specout);
|
||||
delete[] (a->sipout);
|
||||
@ -143,7 +143,7 @@ void SIPHON::xsiphon (SIPHON *a, int pos)
|
||||
a->update.unlock();
|
||||
}
|
||||
|
||||
void SIPHON::setBuffers_siphon (SIPHON *a, double* in)
|
||||
void SIPHON::setBuffers_siphon (SIPHON *a, float* in)
|
||||
{
|
||||
a->in = in;
|
||||
}
|
||||
@ -184,7 +184,7 @@ void SIPHON::sip_spectrum (SIPHON *a)
|
||||
a->sipout[2 * i + 0] *= a->window[i];
|
||||
a->sipout[2 * i + 1] *= a->window[i];
|
||||
}
|
||||
fftw_execute (a->sipplan);
|
||||
fftwf_execute (a->sipplan);
|
||||
}
|
||||
|
||||
/********************************************************************************************************
|
||||
@ -346,7 +346,7 @@ void flush_siphonEXT (int id)
|
||||
}
|
||||
|
||||
PORT
|
||||
void xsiphonEXT (int id, double* buff)
|
||||
void xsiphonEXT (int id, float* buff)
|
||||
{
|
||||
SIPHON a = psiphon[id];
|
||||
a->in = buff;
|
||||
|
@ -50,17 +50,17 @@ public:
|
||||
int mode;
|
||||
int disp;
|
||||
int insize;
|
||||
double* in;
|
||||
float* in;
|
||||
int sipsize; // NOTE: sipsize MUST BE A POWER OF TWO!!
|
||||
double* sipbuff;
|
||||
float* sipbuff;
|
||||
int outsize;
|
||||
int idx;
|
||||
double* sipout;
|
||||
float* sipout;
|
||||
int fftsize;
|
||||
double* specout;
|
||||
float* specout;
|
||||
std::atomic<long> specmode;
|
||||
fftw_plan sipplan;
|
||||
double* window;
|
||||
fftwf_plan sipplan;
|
||||
float* window;
|
||||
QRecursiveMutex update;
|
||||
|
||||
static SIPHON* create_siphon (
|
||||
@ -69,7 +69,7 @@ public:
|
||||
int mode,
|
||||
int disp,
|
||||
int insize,
|
||||
double* in,
|
||||
float* in,
|
||||
int sipsize,
|
||||
int fftsize,
|
||||
int specmode
|
||||
@ -77,7 +77,7 @@ public:
|
||||
static void destroy_siphon (SIPHON *a);
|
||||
static void flush_siphon (SIPHON *a);
|
||||
static void xsiphon (SIPHON *a, int pos);
|
||||
static void setBuffers_siphon (SIPHON *a, double* in);
|
||||
static void setBuffers_siphon (SIPHON *a, float* in);
|
||||
static void setSamplerate_siphon (SIPHON *a, int rate);
|
||||
static void setSize_siphon (SIPHON *a, int size);
|
||||
// RXA Properties
|
||||
@ -94,7 +94,7 @@ public:
|
||||
// Calls for External Use
|
||||
// static void create_siphonEXT (int id, int run, int insize, int sipsize, int fftsize, int specmode);
|
||||
// static void destroy_siphonEXT (int id);
|
||||
// static void xsiphonEXT (int id, double* buff);
|
||||
// static void xsiphonEXT (int id, float* buff);
|
||||
// static void SetSiphonInsize (int id, int size);
|
||||
|
||||
private:
|
||||
|
@ -42,14 +42,14 @@ enum _USLEW
|
||||
void USLEW::calc_uslew (USLEW *a)
|
||||
{
|
||||
int i;
|
||||
double delta, theta;
|
||||
float delta, theta;
|
||||
a->runmode = 0;
|
||||
a->state = BEGIN;
|
||||
a->count = 0;
|
||||
a->ndelup = (int)(a->tdelay * a->rate);
|
||||
a->ntup = (int)(a->tupslew * a->rate);
|
||||
a->cup = new double[a->ntup + 1]; // (double *) malloc0 ((a->ntup + 1) * sizeof (double));
|
||||
delta = PI / (double)a->ntup;
|
||||
a->cup = new float[a->ntup + 1]; // (float *) malloc0 ((a->ntup + 1) * sizeof (float));
|
||||
delta = PI / (float)a->ntup;
|
||||
theta = 0.0;
|
||||
for (i = 0; i <= a->ntup; i++)
|
||||
{
|
||||
@ -64,7 +64,7 @@ void USLEW::decalc_uslew (USLEW *a)
|
||||
delete[] (a->cup);
|
||||
}
|
||||
|
||||
USLEW* USLEW::create_uslew (TXA *txa, std::atomic<long> *ch_upslew, int size, double* in, double* out, double rate, double tdelay, double tupslew)
|
||||
USLEW* USLEW::create_uslew (TXA *txa, std::atomic<long> *ch_upslew, int size, float* in, float* out, float rate, float tdelay, float tupslew)
|
||||
{
|
||||
USLEW *a = new USLEW;
|
||||
a->txa = txa;
|
||||
@ -102,7 +102,7 @@ void USLEW::xuslew (USLEW *a)
|
||||
if (a->runmode && upslew) //_InterlockedAnd (a->ch_upslew, 1))
|
||||
{
|
||||
int i;
|
||||
double I, Q;
|
||||
float I, Q;
|
||||
for (i = 0; i < a->size; i++)
|
||||
{
|
||||
I = a->in[2 * i + 0];
|
||||
@ -161,7 +161,7 @@ void USLEW::xuslew (USLEW *a)
|
||||
memcpy (a->out, a->in, a->size * sizeof (wcomplex));
|
||||
}
|
||||
|
||||
void USLEW::setBuffers_uslew (USLEW *a, double* in, double* out)
|
||||
void USLEW::setBuffers_uslew (USLEW *a, float* in, float* out)
|
||||
{
|
||||
a->in = in;
|
||||
a->out = out;
|
||||
@ -186,7 +186,7 @@ void USLEW::setSize_uslew (USLEW *a, int size)
|
||||
* *
|
||||
********************************************************************************************************/
|
||||
|
||||
void USLEW::SetuSlewTime (TXA& txa, double time)
|
||||
void USLEW::SetuSlewTime (TXA& txa, float time)
|
||||
{
|
||||
// NOTE: 'time' is in seconds
|
||||
txa.csDSP.lock();
|
||||
|
@ -42,27 +42,27 @@ public:
|
||||
TXA *txa;
|
||||
std::atomic<long> *ch_upslew;
|
||||
int size;
|
||||
double* in;
|
||||
double* out;
|
||||
double rate;
|
||||
double tdelay;
|
||||
double tupslew;
|
||||
float* in;
|
||||
float* out;
|
||||
float rate;
|
||||
float tdelay;
|
||||
float tupslew;
|
||||
int runmode;
|
||||
int state;
|
||||
int count;
|
||||
int ndelup;
|
||||
int ntup;
|
||||
double* cup;
|
||||
float* cup;
|
||||
|
||||
static USLEW* create_uslew (TXA *txa, std::atomic<long> *ch_upslew, int size, double* in, double* out, double rate, double tdelay, double tupslew);
|
||||
static USLEW* create_uslew (TXA *txa, std::atomic<long> *ch_upslew, int size, float* in, float* out, float rate, float tdelay, float tupslew);
|
||||
static void destroy_uslew (USLEW *a);
|
||||
static void flush_uslew (USLEW *a);
|
||||
static void xuslew (USLEW *a);
|
||||
static void setBuffers_uslew (USLEW *a, double* in, double* out);
|
||||
static void setBuffers_uslew (USLEW *a, float* in, float* out);
|
||||
static void setSamplerate_uslew (USLEW *a, int rate);
|
||||
static void setSize_uslew (USLEW *a, int size);
|
||||
// TXA Properties
|
||||
static void SetuSlewTime (TXA& txa, double time);
|
||||
static void SetuSlewTime (TXA& txa, float time);
|
||||
|
||||
private:
|
||||
static void calc_uslew (USLEW *a);
|
||||
|
192
wdsp/snb.cpp
192
wdsp/snb.cpp
@ -48,8 +48,8 @@ void SNBA::calc_snba (SNBA *d)
|
||||
d->isize = d->bsize / (d->inrate / d->internalrate);
|
||||
else
|
||||
d->isize = d->bsize * (d->internalrate / d->inrate);
|
||||
d->inbuff = new double[d->isize * 2]; // (double *) malloc0 (d->isize * sizeof (complex));
|
||||
d->outbuff = new double[d->isize * 2]; // (double *) malloc0 (d->isize * sizeof (complex));
|
||||
d->inbuff = new float[d->isize * 2]; // (float *) malloc0 (d->isize * sizeof (complex));
|
||||
d->outbuff = new float[d->isize * 2]; // (float *) malloc0 (d->isize * sizeof (complex));
|
||||
if (d->inrate != d->internalrate)
|
||||
d->resamprun = 1;
|
||||
else
|
||||
@ -65,7 +65,7 @@ void SNBA::calc_snba (SNBA *d)
|
||||
d->iasize = d->isize;
|
||||
d->iainidx = 0;
|
||||
d->iaoutidx = 0;
|
||||
d->inaccum = new double[d->isize]; // (double *) malloc0 (d->iasize * sizeof (double));
|
||||
d->inaccum = new float[d->isize]; // (float *) malloc0 (d->iasize * sizeof (float));
|
||||
d->nsamps = 0;
|
||||
if (d->incr > d->isize)
|
||||
{
|
||||
@ -80,13 +80,13 @@ void SNBA::calc_snba (SNBA *d)
|
||||
d->oaoutidx = 0;
|
||||
}
|
||||
d->init_oaoutidx = d->oaoutidx;
|
||||
d->outaccum = new double[d->oasize]; // (double *) malloc0 (d->oasize * sizeof (double));
|
||||
d->outaccum = new float[d->oasize]; // (float *) malloc0 (d->oasize * sizeof (float));
|
||||
}
|
||||
|
||||
SNBA* SNBA::create_snba (
|
||||
int run,
|
||||
double* in,
|
||||
double* out,
|
||||
float* in,
|
||||
float* out,
|
||||
int inrate,
|
||||
int internalrate,
|
||||
int bsize,
|
||||
@ -94,14 +94,14 @@ SNBA* SNBA::create_snba (
|
||||
int xsize,
|
||||
int asize,
|
||||
int npasses,
|
||||
double k1,
|
||||
double k2,
|
||||
float k1,
|
||||
float k2,
|
||||
int b,
|
||||
int pre,
|
||||
int post,
|
||||
double pmultmin,
|
||||
double out_low_cut,
|
||||
double out_high_cut
|
||||
float pmultmin,
|
||||
float out_low_cut,
|
||||
float out_high_cut
|
||||
)
|
||||
{
|
||||
SNBA *d = new SNBA;
|
||||
@ -126,30 +126,30 @@ SNBA* SNBA::create_snba (
|
||||
|
||||
calc_snba (d);
|
||||
|
||||
d->xbase = new double[2 * d->xsize]; // (double *) malloc0 (2 * d->xsize * sizeof (double));
|
||||
d->xbase = new float[2 * d->xsize]; // (float *) malloc0 (2 * d->xsize * sizeof (float));
|
||||
d->xaux = d->xbase + d->xsize;
|
||||
d->exec.a = new double[d->xsize]; // (double *) malloc0 (d->xsize * sizeof (double));
|
||||
d->exec.v = new double[d->xsize]; // (double *) malloc0 (d->xsize * sizeof (double));
|
||||
d->exec.a = new float[d->xsize]; // (float *) malloc0 (d->xsize * sizeof (float));
|
||||
d->exec.v = new float[d->xsize]; // (float *) malloc0 (d->xsize * sizeof (float));
|
||||
d->exec.detout = new int[d->xsize]; // (int *) malloc0 (d->xsize * sizeof (int));
|
||||
d->exec.savex = new double[d->xsize]; // (double *) malloc0 (d->xsize * sizeof (double));
|
||||
d->exec.xHout = new double[d->xsize]; // (double *) malloc0 (d->xsize * sizeof (double));
|
||||
d->exec.savex = new float[d->xsize]; // (float *) malloc0 (d->xsize * sizeof (float));
|
||||
d->exec.xHout = new float[d->xsize]; // (float *) malloc0 (d->xsize * sizeof (float));
|
||||
d->exec.unfixed = new int32_t[d->xsize]; // (int *) malloc0 (d->xsize * sizeof (int));
|
||||
d->sdet.vp = new double[d->xsize]; // (double *) malloc0 (d->xsize * sizeof (double));
|
||||
d->sdet.vpwr = new double[d->xsize]; // (double *) malloc0 (d->xsize * sizeof (double));
|
||||
d->sdet.vp = new float[d->xsize]; // (float *) malloc0 (d->xsize * sizeof (float));
|
||||
d->sdet.vpwr = new float[d->xsize]; // (float *) malloc0 (d->xsize * sizeof (float));
|
||||
|
||||
d->wrk.xHat_a1rows_max = d->xsize + d->exec.asize;
|
||||
d->wrk.xHat_a2cols_max = d->xsize + 2 * d->exec.asize;
|
||||
d->wrk.xHat_r = new double[d->xsize]; // (double *) malloc0 (d->xsize * sizeof(double));
|
||||
d->wrk.xHat_ATAI = new double[d->xsize * d->xsize]; // (double *) malloc0 (d->xsize * d->xsize * sizeof(double));
|
||||
d->wrk.xHat_A1 = new double[d->wrk.xHat_a1rows_max * d->xsize]; // (double *) malloc0 (d->wrk.xHat_a1rows_max * d->xsize * sizeof(double));
|
||||
d->wrk.xHat_A2 = new double[d->wrk.xHat_a1rows_max * d->wrk.xHat_a2cols_max]; // (double *) malloc0 (d->wrk.xHat_a1rows_max * d->wrk.xHat_a2cols_max * sizeof(double));
|
||||
d->wrk.xHat_P1 = new double[d->xsize * d->wrk.xHat_a2cols_max]; // (double *) malloc0 (d->xsize * d->wrk.xHat_a2cols_max * sizeof(double));
|
||||
d->wrk.xHat_P2 = new double[d->xsize]; // (double *) malloc0 (d->xsize * sizeof(double));
|
||||
d->wrk.trI_y = new double[d->xsize - 1]; // (double *) malloc0 ((d->xsize - 1) * sizeof(double));
|
||||
d->wrk.trI_v = new double[d->xsize - 1]; // (double *) malloc0 ((d->xsize - 1) * sizeof(double));
|
||||
d->wrk.dR_z = new double[d->xsize - 2]; // (double *) malloc0 ((d->xsize - 2) * sizeof(double));
|
||||
d->wrk.asolve_r = new double[d->exec.asize + 1]; // (double *) malloc0 ((d->exec.asize + 1) * sizeof(double));
|
||||
d->wrk.asolve_z = new double[d->exec.asize + 1]; // (double *) malloc0 ((d->exec.asize + 1) * sizeof(double));
|
||||
d->wrk.xHat_r = new float[d->xsize]; // (float *) malloc0 (d->xsize * sizeof(float));
|
||||
d->wrk.xHat_ATAI = new float[d->xsize * d->xsize]; // (float *) malloc0 (d->xsize * d->xsize * sizeof(float));
|
||||
d->wrk.xHat_A1 = new float[d->wrk.xHat_a1rows_max * d->xsize]; // (float *) malloc0 (d->wrk.xHat_a1rows_max * d->xsize * sizeof(float));
|
||||
d->wrk.xHat_A2 = new float[d->wrk.xHat_a1rows_max * d->wrk.xHat_a2cols_max]; // (float *) malloc0 (d->wrk.xHat_a1rows_max * d->wrk.xHat_a2cols_max * sizeof(float));
|
||||
d->wrk.xHat_P1 = new float[d->xsize * d->wrk.xHat_a2cols_max]; // (float *) malloc0 (d->xsize * d->wrk.xHat_a2cols_max * sizeof(float));
|
||||
d->wrk.xHat_P2 = new float[d->xsize]; // (float *) malloc0 (d->xsize * sizeof(float));
|
||||
d->wrk.trI_y = new float[d->xsize - 1]; // (float *) malloc0 ((d->xsize - 1) * sizeof(float));
|
||||
d->wrk.trI_v = new float[d->xsize - 1]; // (float *) malloc0 ((d->xsize - 1) * sizeof(float));
|
||||
d->wrk.dR_z = new float[d->xsize - 2]; // (float *) malloc0 ((d->xsize - 2) * sizeof(float));
|
||||
d->wrk.asolve_r = new float[d->exec.asize + 1]; // (float *) malloc0 ((d->exec.asize + 1) * sizeof(float));
|
||||
d->wrk.asolve_z = new float[d->exec.asize + 1]; // (float *) malloc0 ((d->exec.asize + 1) * sizeof(float));
|
||||
|
||||
return d;
|
||||
}
|
||||
@ -202,17 +202,17 @@ void SNBA::flush_snba (SNBA *d)
|
||||
d->oainidx = 0;
|
||||
d->oaoutidx = d->init_oaoutidx;
|
||||
|
||||
memset (d->inaccum, 0, d->iasize * sizeof (double));
|
||||
memset (d->outaccum, 0, d->oasize * sizeof (double));
|
||||
memset (d->xaux, 0, d->xsize * sizeof (double));
|
||||
memset (d->exec.a, 0, d->xsize * sizeof (double));
|
||||
memset (d->exec.v, 0, d->xsize * sizeof (double));
|
||||
memset (d->inaccum, 0, d->iasize * sizeof (float));
|
||||
memset (d->outaccum, 0, d->oasize * sizeof (float));
|
||||
memset (d->xaux, 0, d->xsize * sizeof (float));
|
||||
memset (d->exec.a, 0, d->xsize * sizeof (float));
|
||||
memset (d->exec.v, 0, d->xsize * sizeof (float));
|
||||
memset (d->exec.detout, 0, d->xsize * sizeof (int));
|
||||
memset (d->exec.savex, 0, d->xsize * sizeof (double));
|
||||
memset (d->exec.xHout, 0, d->xsize * sizeof (double));
|
||||
memset (d->exec.savex, 0, d->xsize * sizeof (float));
|
||||
memset (d->exec.xHout, 0, d->xsize * sizeof (float));
|
||||
memset (d->exec.unfixed, 0, d->xsize * sizeof (int));
|
||||
memset (d->sdet.vp, 0, d->xsize * sizeof (double));
|
||||
memset (d->sdet.vpwr, 0, d->xsize * sizeof (double));
|
||||
memset (d->sdet.vp, 0, d->xsize * sizeof (float));
|
||||
memset (d->sdet.vpwr, 0, d->xsize * sizeof (float));
|
||||
|
||||
memset (d->inbuff, 0, d->isize * sizeof (wcomplex));
|
||||
memset (d->outbuff, 0, d->isize * sizeof (wcomplex));
|
||||
@ -220,7 +220,7 @@ void SNBA::flush_snba (SNBA *d)
|
||||
RESAMPLE::flush_resample (d->outresamp);
|
||||
}
|
||||
|
||||
void SNBA::setBuffers_snba (SNBA *a, double* in, double* out)
|
||||
void SNBA::setBuffers_snba (SNBA *a, float* in, float* out)
|
||||
{
|
||||
decalc_snba (a);
|
||||
a->in = in;
|
||||
@ -242,20 +242,20 @@ void SNBA::setSize_snba (SNBA *a, int size)
|
||||
calc_snba (a);
|
||||
}
|
||||
|
||||
void SNBA::ATAc0 (int n, int nr, double* A, double* r)
|
||||
void SNBA::ATAc0 (int n, int nr, float* A, float* r)
|
||||
{
|
||||
int i, j;
|
||||
memset(r, 0, n * sizeof (double));
|
||||
memset(r, 0, n * sizeof (float));
|
||||
for (i = 0; i < n; i++)
|
||||
for (j = 0; j < nr; j++)
|
||||
r[i] += A[j * n + i] * A[j * n + 0];
|
||||
}
|
||||
|
||||
void SNBA::multA1TA2(double* a1, double* a2, int m, int n, int q, double* c)
|
||||
void SNBA::multA1TA2(float* a1, float* a2, int m, int n, int q, float* c)
|
||||
{
|
||||
int i, j, k;
|
||||
int p = q - m;
|
||||
memset (c, 0, m * n * sizeof (double));
|
||||
memset (c, 0, m * n * sizeof (float));
|
||||
for (i = 0; i < m; i++)
|
||||
{
|
||||
for (j = 0; j < n; j++)
|
||||
@ -274,10 +274,10 @@ void SNBA::multA1TA2(double* a1, double* a2, int m, int n, int q, double* c)
|
||||
}
|
||||
}
|
||||
|
||||
void SNBA::multXKE(double* a, double* xk, int m, int q, int p, double* vout)
|
||||
void SNBA::multXKE(float* a, float* xk, int m, int q, int p, float* vout)
|
||||
{
|
||||
int i, k;
|
||||
memset (vout, 0, m * sizeof (double));
|
||||
memset (vout, 0, m * sizeof (float));
|
||||
for (i = 0; i < m; i++)
|
||||
{
|
||||
for (k = i; k < p; k++)
|
||||
@ -287,10 +287,10 @@ void SNBA::multXKE(double* a, double* xk, int m, int q, int p, double* vout)
|
||||
}
|
||||
}
|
||||
|
||||
void SNBA::multAv(double* a, double* v, int m, int q, double* vout)
|
||||
void SNBA::multAv(float* a, float* v, int m, int q, float* vout)
|
||||
{
|
||||
int i, k;
|
||||
memset (vout, 0, m * sizeof (double));
|
||||
memset (vout, 0, m * sizeof (float));
|
||||
for (i = 0; i < m; i++)
|
||||
{
|
||||
for (k = 0; k < q; k++)
|
||||
@ -301,29 +301,29 @@ void SNBA::multAv(double* a, double* v, int m, int q, double* vout)
|
||||
void SNBA::xHat(
|
||||
int xusize,
|
||||
int asize,
|
||||
double* xk,
|
||||
double* a,
|
||||
double* xout,
|
||||
double* r,
|
||||
double* ATAI,
|
||||
double* A1,
|
||||
double* A2,
|
||||
double* P1,
|
||||
double* P2,
|
||||
double* trI_y,
|
||||
double* trI_v,
|
||||
double* dR_z
|
||||
float* xk,
|
||||
float* a,
|
||||
float* xout,
|
||||
float* r,
|
||||
float* ATAI,
|
||||
float* A1,
|
||||
float* A2,
|
||||
float* P1,
|
||||
float* P2,
|
||||
float* trI_y,
|
||||
float* trI_v,
|
||||
float* dR_z
|
||||
)
|
||||
{
|
||||
int i, j, k;
|
||||
int a1rows = xusize + asize;
|
||||
int a2cols = xusize + 2 * asize;
|
||||
memset (r, 0, xusize * sizeof(double)); // work space
|
||||
memset (ATAI, 0, xusize * xusize * sizeof(double)); // work space
|
||||
memset (A1, 0, a1rows * xusize * sizeof(double)); // work space
|
||||
memset (A2, 0, a1rows * a2cols * sizeof(double)); // work space
|
||||
memset (P1, 0, xusize * a2cols * sizeof(double)); // work space
|
||||
memset (P2, 0, xusize * sizeof(double)); // work space
|
||||
memset (r, 0, xusize * sizeof(float)); // work space
|
||||
memset (ATAI, 0, xusize * xusize * sizeof(float)); // work space
|
||||
memset (A1, 0, a1rows * xusize * sizeof(float)); // work space
|
||||
memset (A2, 0, a1rows * a2cols * sizeof(float)); // work space
|
||||
memset (P1, 0, xusize * a2cols * sizeof(float)); // work space
|
||||
memset (P2, 0, xusize * sizeof(float)); // work space
|
||||
|
||||
for (i = 0; i < xusize; i++)
|
||||
{
|
||||
@ -352,10 +352,10 @@ void SNBA::xHat(
|
||||
multAv(ATAI, P2, xusize, xusize, xout);
|
||||
}
|
||||
|
||||
void SNBA::invf(int xsize, int asize, double* a, double* x, double* v)
|
||||
void SNBA::invf(int xsize, int asize, float* a, float* x, float* v)
|
||||
{
|
||||
int i, j;
|
||||
memset (v, 0, xsize * sizeof (double));
|
||||
memset (v, 0, xsize * sizeof (float));
|
||||
for (i = asize; i < xsize - asize; i++)
|
||||
{
|
||||
for (j = 0; j < asize; j++)
|
||||
@ -370,10 +370,10 @@ void SNBA::invf(int xsize, int asize, double* a, double* x, double* v)
|
||||
}
|
||||
}
|
||||
|
||||
void SNBA::det(SNBA *d, int asize, double* v, int* detout)
|
||||
void SNBA::det(SNBA *d, int asize, float* v, int* detout)
|
||||
{
|
||||
int i, j;
|
||||
double medpwr, t1, t2;
|
||||
float medpwr, t1, t2;
|
||||
int bstate, bcount, bsamp;
|
||||
for (i = asize, j = 0; i < d->xsize; i++, j++)
|
||||
{
|
||||
@ -390,7 +390,7 @@ void SNBA::det(SNBA *d, int asize, double* v, int* detout)
|
||||
else if (d->sdet.vpwr[i] <= 2.0 * t1)
|
||||
t2 += 2.0 * t1 - d->sdet.vpwr[i];
|
||||
}
|
||||
t2 *= d->sdet.k2 / (double)(d->xsize - asize);
|
||||
t2 *= d->sdet.k2 / (float)(d->xsize - asize);
|
||||
for (i = asize; i < d->xsize; i++)
|
||||
{
|
||||
if (d->sdet.vpwr[i] > t2)
|
||||
@ -453,7 +453,7 @@ void SNBA::det(SNBA *d, int asize, double* v, int* detout)
|
||||
int SNBA::scanFrame(
|
||||
int xsize,
|
||||
int pval,
|
||||
double pmultmin,
|
||||
float pmultmin,
|
||||
int* det,
|
||||
int* bimp,
|
||||
int* limp,
|
||||
@ -466,9 +466,9 @@ int SNBA::scanFrame(
|
||||
int inflag = 0;
|
||||
int i = 0, j = 0, k = 0;
|
||||
int nimp = 0;
|
||||
double td;
|
||||
float td;
|
||||
int ti;
|
||||
double merit[MAXIMP] = { 0 };
|
||||
float merit[MAXIMP] = { 0 };
|
||||
int nextlist[MAXIMP];
|
||||
memset (befimp, 0, MAXIMP * sizeof (int));
|
||||
memset (aftimp, 0, MAXIMP * sizeof (int));
|
||||
@ -508,7 +508,7 @@ int SNBA::scanFrame(
|
||||
|
||||
for (i = 0; i < nimp; i++)
|
||||
{
|
||||
merit[i] = (double)p_opt[i] / (double)limp[i];
|
||||
merit[i] = (float)p_opt[i] / (float)limp[i];
|
||||
nextlist[i] = i;
|
||||
}
|
||||
for (j = 0; j < nimp - 1; j++)
|
||||
@ -548,7 +548,7 @@ int SNBA::scanFrame(
|
||||
return nimp;
|
||||
}
|
||||
|
||||
void SNBA::execFrame(SNBA *d, double* x)
|
||||
void SNBA::execFrame(SNBA *d, float* x)
|
||||
{
|
||||
int i, k;
|
||||
int pass;
|
||||
@ -560,7 +560,7 @@ void SNBA::execFrame(SNBA *d, double* x)
|
||||
int p_opt[MAXIMP];
|
||||
int next = 0;
|
||||
int p;
|
||||
memcpy (d->exec.savex, x, d->xsize * sizeof (double));
|
||||
memcpy (d->exec.savex, x, d->xsize * sizeof (float));
|
||||
LMath::asolve(d->xsize, d->exec.asize, x, d->exec.a, d->wrk.asolve_r, d->wrk.asolve_z);
|
||||
invf(d->xsize, d->exec.asize, d->exec.a, x, d->exec.v);
|
||||
det(d, d->exec.asize, d->exec.v, d->exec.detout);
|
||||
@ -584,12 +584,12 @@ void SNBA::execFrame(SNBA *d, double* x)
|
||||
xHat(limp[next], p, &x[bimp[next] - p], d->exec.a, d->exec.xHout,
|
||||
d->wrk.xHat_r, d->wrk.xHat_ATAI, d->wrk.xHat_A1, d->wrk.xHat_A2,
|
||||
d->wrk.xHat_P1, d->wrk.xHat_P2, d->wrk.trI_y, d->wrk.trI_v, d->wrk.dR_z);
|
||||
memcpy (&x[bimp[next]], d->exec.xHout, limp[next] * sizeof (double));
|
||||
memcpy (&x[bimp[next]], d->exec.xHout, limp[next] * sizeof (float));
|
||||
memset (&d->exec.unfixed[bimp[next]], 0, limp[next] * sizeof (int));
|
||||
}
|
||||
else
|
||||
{
|
||||
memcpy (&x[bimp[next]], &d->exec.savex[bimp[next]], limp[next] * sizeof (double));
|
||||
memcpy (&x[bimp[next]], &d->exec.savex[bimp[next]], limp[next] * sizeof (float));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -609,13 +609,13 @@ void SNBA::xsnba (SNBA *d)
|
||||
d->nsamps += d->isize;
|
||||
while (d->nsamps >= d->incr)
|
||||
{
|
||||
memcpy (&d->xaux[d->xsize - d->incr], &d->inaccum[d->iaoutidx], d->incr * sizeof (double));
|
||||
memcpy (&d->xaux[d->xsize - d->incr], &d->inaccum[d->iaoutidx], d->incr * sizeof (float));
|
||||
execFrame (d, d->xaux);
|
||||
d->iaoutidx = (d->iaoutidx + d->incr) % d->iasize;
|
||||
d->nsamps -= d->incr;
|
||||
memcpy (&d->outaccum[d->oainidx], d->xaux, d->incr * sizeof (double));
|
||||
memcpy (&d->outaccum[d->oainidx], d->xaux, d->incr * sizeof (float));
|
||||
d->oainidx = (d->oainidx + d->incr) % d->oasize;
|
||||
memmove (d->xbase, &d->xbase[d->incr], (2 * d->xsize - d->incr) * sizeof (double));
|
||||
memmove (d->xbase, &d->xbase[d->incr], (2 * d->xsize - d->incr) * sizeof (float));
|
||||
}
|
||||
for (i = 0; i < d->isize; i++)
|
||||
{
|
||||
@ -674,14 +674,14 @@ void SNBA::SetSNBAnpasses (RXA& rxa, int npasses)
|
||||
rxa.csDSP.unlock();
|
||||
}
|
||||
|
||||
void SNBA::SetSNBAk1 (RXA& rxa, double k1)
|
||||
void SNBA::SetSNBAk1 (RXA& rxa, float k1)
|
||||
{
|
||||
rxa.csDSP.lock();
|
||||
rxa.snba.p->sdet.k1 = k1;
|
||||
rxa.csDSP.unlock();
|
||||
}
|
||||
|
||||
void SNBA::SetSNBAk2 (RXA& rxa, double k2)
|
||||
void SNBA::SetSNBAk2 (RXA& rxa, float k2)
|
||||
{
|
||||
rxa.csDSP.lock();
|
||||
rxa.snba.p->sdet.k2 = k2;
|
||||
@ -709,18 +709,18 @@ void SNBA::SetSNBApostsamps (RXA& rxa, int postsamps)
|
||||
rxa.csDSP.unlock();
|
||||
}
|
||||
|
||||
void SNBA::SetSNBApmultmin (RXA& rxa, double pmultmin)
|
||||
void SNBA::SetSNBApmultmin (RXA& rxa, float pmultmin)
|
||||
{
|
||||
rxa.csDSP.lock();
|
||||
rxa.snba.p->scan.pmultmin = pmultmin;
|
||||
rxa.csDSP.unlock();
|
||||
}
|
||||
|
||||
void SNBA::SetSNBAOutputBandwidth (RXA& rxa, double flow, double fhigh)
|
||||
void SNBA::SetSNBAOutputBandwidth (RXA& rxa, float flow, float fhigh)
|
||||
{
|
||||
SNBA *a;
|
||||
RESAMPLE *d;
|
||||
double f_low, f_high;
|
||||
float f_low, f_high;
|
||||
rxa.csDSP.lock();
|
||||
a = rxa.snba.p;
|
||||
d = a->outresamp;
|
||||
@ -741,7 +741,7 @@ void SNBA::SetSNBAOutputBandwidth (RXA& rxa, double flow, double fhigh)
|
||||
}
|
||||
else if (flow < 0 && fhigh > 0)
|
||||
{
|
||||
double absmax = std::max (-flow, fhigh);
|
||||
float absmax = std::max (-flow, fhigh);
|
||||
if (absmax < a->out_low_cut) absmax = a->out_low_cut;
|
||||
f_low = a->out_low_cut;
|
||||
f_high = std::min (a->out_high_cut, absmax);
|
||||
@ -764,7 +764,7 @@ void SNBA::SetSNBAOutputBandwidth (RXA& rxa, double flow, double fhigh)
|
||||
|
||||
void BPSNBA::calc_bpsnba (BPSNBA *a)
|
||||
{
|
||||
a->buff = new double[a->size * 2]; // (double *) malloc0 (a->size * sizeof (complex));
|
||||
a->buff = new float[a->size * 2]; // (float *) malloc0 (a->size * sizeof (complex));
|
||||
a->bpsnba = NBP::create_nbp (
|
||||
1, // run, always runs (use bpsnba 'run')
|
||||
a->run_notches, // run the notches
|
||||
@ -791,15 +791,15 @@ BPSNBA* BPSNBA::create_bpsnba (
|
||||
int size,
|
||||
int nc,
|
||||
int mp,
|
||||
double* in,
|
||||
double* out,
|
||||
float* in,
|
||||
float* out,
|
||||
int rate,
|
||||
double abs_low_freq,
|
||||
double abs_high_freq,
|
||||
double f_low,
|
||||
double f_high,
|
||||
float abs_low_freq,
|
||||
float abs_high_freq,
|
||||
float f_low,
|
||||
float f_high,
|
||||
int wintype,
|
||||
double gain,
|
||||
float gain,
|
||||
int autoincr,
|
||||
int maxpb,
|
||||
NOTCHDB* ptraddr
|
||||
@ -846,7 +846,7 @@ void BPSNBA::flush_bpsnba (BPSNBA *a)
|
||||
NBP::flush_nbp (a->bpsnba);
|
||||
}
|
||||
|
||||
void BPSNBA::setBuffers_bpsnba (BPSNBA *a, double* in, double* out)
|
||||
void BPSNBA::setBuffers_bpsnba (BPSNBA *a, float* in, float* out)
|
||||
{
|
||||
decalc_bpsnba (a);
|
||||
a->in = in;
|
||||
|
156
wdsp/snb.hpp
156
wdsp/snb.hpp
@ -39,8 +39,8 @@ class WDSP_API SNBA
|
||||
{
|
||||
public:
|
||||
int run;
|
||||
double* in;
|
||||
double* out;
|
||||
float* in;
|
||||
float* out;
|
||||
int inrate;
|
||||
int internalrate;
|
||||
int bsize;
|
||||
@ -50,70 +50,70 @@ public:
|
||||
int iasize;
|
||||
int iainidx;
|
||||
int iaoutidx;
|
||||
double* inaccum;
|
||||
double* xbase;
|
||||
double* xaux;
|
||||
float* inaccum;
|
||||
float* xbase;
|
||||
float* xaux;
|
||||
int nsamps;
|
||||
int oasize;
|
||||
int oainidx;
|
||||
int oaoutidx;
|
||||
int init_oaoutidx;
|
||||
double* outaccum;
|
||||
float* outaccum;
|
||||
|
||||
int resamprun;
|
||||
int isize;
|
||||
RESAMPLE *inresamp;
|
||||
RESAMPLE *outresamp;
|
||||
double* inbuff;
|
||||
double* outbuff;
|
||||
float* inbuff;
|
||||
float* outbuff;
|
||||
struct _exec
|
||||
{
|
||||
int asize;
|
||||
double* a;
|
||||
double* v;
|
||||
float* a;
|
||||
float* v;
|
||||
int* detout;
|
||||
double* savex;
|
||||
double* xHout;
|
||||
float* savex;
|
||||
float* xHout;
|
||||
int* unfixed;
|
||||
int npasses;
|
||||
} exec;
|
||||
struct _det
|
||||
{
|
||||
double k1;
|
||||
double k2;
|
||||
float k1;
|
||||
float k2;
|
||||
int b;
|
||||
int pre;
|
||||
int post;
|
||||
double* vp;
|
||||
double* vpwr;
|
||||
float* vp;
|
||||
float* vpwr;
|
||||
} sdet;
|
||||
struct _scan
|
||||
{
|
||||
double pmultmin;
|
||||
float pmultmin;
|
||||
} scan;
|
||||
struct _wrk
|
||||
{
|
||||
int xHat_a1rows_max;
|
||||
int xHat_a2cols_max;
|
||||
double* xHat_r;
|
||||
double* xHat_ATAI;
|
||||
double* xHat_A1;
|
||||
double* xHat_A2;
|
||||
double* xHat_P1;
|
||||
double* xHat_P2;
|
||||
double* trI_y;
|
||||
double* trI_v;
|
||||
double* dR_z;
|
||||
double* asolve_r;
|
||||
double* asolve_z;
|
||||
float* xHat_r;
|
||||
float* xHat_ATAI;
|
||||
float* xHat_A1;
|
||||
float* xHat_A2;
|
||||
float* xHat_P1;
|
||||
float* xHat_P2;
|
||||
float* trI_y;
|
||||
float* trI_v;
|
||||
float* dR_z;
|
||||
float* asolve_r;
|
||||
float* asolve_z;
|
||||
} wrk;
|
||||
double out_low_cut;
|
||||
double out_high_cut;
|
||||
float out_low_cut;
|
||||
float out_high_cut;
|
||||
|
||||
static SNBA* create_snba (
|
||||
int run,
|
||||
double* in,
|
||||
double* out,
|
||||
float* in,
|
||||
float* out,
|
||||
int inrate,
|
||||
int internalrate,
|
||||
int bsize,
|
||||
@ -121,63 +121,63 @@ public:
|
||||
int xsize,
|
||||
int asize,
|
||||
int npasses,
|
||||
double k1,
|
||||
double k2,
|
||||
float k1,
|
||||
float k2,
|
||||
int b,
|
||||
int pre,
|
||||
int post,
|
||||
double pmultmin,
|
||||
double out_low_cut,
|
||||
double out_high_cut
|
||||
float pmultmin,
|
||||
float out_low_cut,
|
||||
float out_high_cut
|
||||
);
|
||||
static void destroy_snba (SNBA *d);
|
||||
static void flush_snba (SNBA *d);
|
||||
static void xsnba (SNBA *d);
|
||||
static void setBuffers_snba (SNBA *a, double* in, double* out);
|
||||
static void setBuffers_snba (SNBA *a, float* in, float* out);
|
||||
static void setSamplerate_snba (SNBA *a, int rate);
|
||||
static void setSize_snba (SNBA *a, int size);
|
||||
// RXA
|
||||
static void SetSNBAOutputBandwidth (RXA& rxa, double flow, double fhigh);
|
||||
static void SetSNBAOutputBandwidth (RXA& rxa, float flow, float fhigh);
|
||||
static void SetSNBARun (RXA& rxa, int run);
|
||||
static void SetSNBAovrlp (RXA& rxa, int ovrlp);
|
||||
static void SetSNBAasize (RXA& rxa, int size);
|
||||
static void SetSNBAnpasses (RXA& rxa, int npasses);
|
||||
static void SetSNBAk1 (RXA& rxa, double k1);
|
||||
static void SetSNBAk2 (RXA& rxa, double k2);
|
||||
static void SetSNBAk1 (RXA& rxa, float k1);
|
||||
static void SetSNBAk2 (RXA& rxa, float k2);
|
||||
static void SetSNBAbridge (RXA& rxa, int bridge);
|
||||
static void SetSNBApresamps (RXA& rxa, int presamps);
|
||||
static void SetSNBApostsamps (RXA& rxa, int postsamps);
|
||||
static void SetSNBApmultmin (RXA& rxa, double pmultmin);
|
||||
static void SetSNBApmultmin (RXA& rxa, float pmultmin);
|
||||
|
||||
private:
|
||||
static void calc_snba (SNBA *d);
|
||||
static void decalc_snba (SNBA *d);
|
||||
static void ATAc0 (int n, int nr, double* A, double* r);
|
||||
static void multA1TA2(double* a1, double* a2, int m, int n, int q, double* c);
|
||||
static void multXKE(double* a, double* xk, int m, int q, int p, double* vout);
|
||||
static void multAv(double* a, double* v, int m, int q, double* vout);
|
||||
static void ATAc0 (int n, int nr, float* A, float* r);
|
||||
static void multA1TA2(float* a1, float* a2, int m, int n, int q, float* c);
|
||||
static void multXKE(float* a, float* xk, int m, int q, int p, float* vout);
|
||||
static void multAv(float* a, float* v, int m, int q, float* vout);
|
||||
static void xHat(
|
||||
int xusize,
|
||||
int asize,
|
||||
double* xk,
|
||||
double* a,
|
||||
double* xout,
|
||||
double* r,
|
||||
double* ATAI,
|
||||
double* A1,
|
||||
double* A2,
|
||||
double* P1,
|
||||
double* P2,
|
||||
double* trI_y,
|
||||
double* trI_v,
|
||||
double* dR_z
|
||||
float* xk,
|
||||
float* a,
|
||||
float* xout,
|
||||
float* r,
|
||||
float* ATAI,
|
||||
float* A1,
|
||||
float* A2,
|
||||
float* P1,
|
||||
float* P2,
|
||||
float* trI_y,
|
||||
float* trI_v,
|
||||
float* dR_z
|
||||
);
|
||||
static void invf(int xsize, int asize, double* a, double* x, double* v);
|
||||
static void det(SNBA *d, int asize, double* v, int* detout);
|
||||
static void invf(int xsize, int asize, float* a, float* x, float* v);
|
||||
static void det(SNBA *d, int asize, float* v, int* detout);
|
||||
static int scanFrame(
|
||||
int xsize,
|
||||
int pval,
|
||||
double pmultmin,
|
||||
float pmultmin,
|
||||
int* det,
|
||||
int* bimp,
|
||||
int* limp,
|
||||
@ -186,7 +186,7 @@ private:
|
||||
int* p_opt,
|
||||
int* next
|
||||
);
|
||||
static void execFrame(SNBA *d, double* x);
|
||||
static void execFrame(SNBA *d, float* x);
|
||||
};
|
||||
|
||||
|
||||
@ -202,17 +202,17 @@ public:
|
||||
int size; // buffer size
|
||||
int nc; // number of filter coefficients
|
||||
int mp; // minimum phase flag
|
||||
double* in; // input buffer
|
||||
double* out; // output buffer
|
||||
float* in; // input buffer
|
||||
float* out; // output buffer
|
||||
int rate; // sample rate
|
||||
double* buff; // internal buffer
|
||||
float* buff; // internal buffer
|
||||
NBP *bpsnba; // pointer to the notched bandpass filter, nbp
|
||||
double f_low; // low cutoff frequency
|
||||
double f_high; // high cutoff frequency
|
||||
double abs_low_freq; // lowest positive freq supported by SNB
|
||||
double abs_high_freq; // highest positive freq supported by SNG
|
||||
float f_low; // low cutoff frequency
|
||||
float f_high; // high cutoff frequency
|
||||
float abs_low_freq; // lowest positive freq supported by SNB
|
||||
float abs_high_freq; // highest positive freq supported by SNG
|
||||
int wintype; // filter window type
|
||||
double gain; // filter gain
|
||||
float gain; // filter gain
|
||||
int autoincr; // use auto increment for notch width
|
||||
int maxpb; // maximum passband segments supported
|
||||
NOTCHDB* ptraddr; // pointer to address of NOTCH DATABASE
|
||||
@ -224,22 +224,22 @@ public:
|
||||
int size,
|
||||
int nc,
|
||||
int mp,
|
||||
double* in,
|
||||
double* out,
|
||||
float* in,
|
||||
float* out,
|
||||
int rate,
|
||||
double abs_low_freq,
|
||||
double abs_high_freq,
|
||||
double f_low,
|
||||
double f_high,
|
||||
float abs_low_freq,
|
||||
float abs_high_freq,
|
||||
float f_low,
|
||||
float f_high,
|
||||
int wintype,
|
||||
double gain,
|
||||
float gain,
|
||||
int autoincr,
|
||||
int maxpb,
|
||||
NOTCHDB* ptraddr
|
||||
);
|
||||
static void destroy_bpsnba (BPSNBA *a);
|
||||
static void flush_bpsnba (BPSNBA *a);
|
||||
static void setBuffers_bpsnba (BPSNBA *a, double* in, double* out);
|
||||
static void setBuffers_bpsnba (BPSNBA *a, float* in, float* out);
|
||||
static void setSamplerate_bpsnba (BPSNBA *a, int rate);
|
||||
static void setSize_bpsnba (BPSNBA *a, int size);
|
||||
static void xbpsnbain (BPSNBA *a, int position);
|
||||
|
@ -39,7 +39,7 @@ namespace WDSP {
|
||||
* *
|
||||
********************************************************************************************************/
|
||||
|
||||
FTOV* FTOV::create_ftov (int run, int size, int rate, int rsize, double fmax, double* in, double* out)
|
||||
FTOV* FTOV::create_ftov (int run, int size, int rate, int rsize, float fmax, float* in, float* out)
|
||||
{
|
||||
FTOV *a = new FTOV;
|
||||
a->run = run;
|
||||
@ -92,7 +92,7 @@ void FTOV::xftov (FTOV *a)
|
||||
a->rcount++; // increment the count
|
||||
}
|
||||
if (++a->rptr == a->rsize) a->rptr = 0; // increment and wrap the pointer as needed
|
||||
a->out[0] = std::min (1.0, (double)a->rcount / a->div); // calculate the output sample
|
||||
a->out[0] = std::min (1.0f, (float)a->rcount / a->div); // calculate the output sample
|
||||
a->inlast = a->in[a->size - 1]; // save the last input sample for next buffer
|
||||
for (int i = 1; i < a->size; i++)
|
||||
{
|
||||
@ -108,7 +108,7 @@ void FTOV::xftov (FTOV *a)
|
||||
a->rcount++; // increment the count
|
||||
}
|
||||
if (++a->rptr == a->rsize) a->rptr = 0; // increment and wrap the pointer as needed
|
||||
a->out[i] = std::min(1.0, (double)a->rcount / a->div); // calculate the output sample
|
||||
a->out[i] = std::min(1.0f, (float)a->rcount / a->div); // calculate the output sample
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -120,15 +120,15 @@ void FTOV::xftov (FTOV *a)
|
||||
void SSQL::compute_ssql_slews(SSQL *a)
|
||||
{
|
||||
int i;
|
||||
double delta, theta;
|
||||
delta = PI / (double)a->ntup;
|
||||
float delta, theta;
|
||||
delta = PI / (float)a->ntup;
|
||||
theta = 0.0;
|
||||
for (i = 0; i <= a->ntup; i++)
|
||||
{
|
||||
a->cup[i] = a->muted_gain + (1.0 - a->muted_gain) * 0.5 * (1.0 - cos(theta));
|
||||
theta += delta;
|
||||
}
|
||||
delta = PI / (double)a->ntdown;
|
||||
delta = PI / (float)a->ntdown;
|
||||
theta = 0.0;
|
||||
for (i = 0; i <= a->ntdown; i++)
|
||||
{
|
||||
@ -139,12 +139,12 @@ void SSQL::compute_ssql_slews(SSQL *a)
|
||||
|
||||
void SSQL::calc_ssql (SSQL *a)
|
||||
{
|
||||
a->b1 = new double[a->size * 2]; // (double*) malloc0 (a->size * sizeof (complex));
|
||||
a->b1 = new float[a->size * 2]; // (float*) malloc0 (a->size * sizeof (complex));
|
||||
a->dcbl = CBL::create_cbl (1, a->size, a->in, a->b1, 0, a->rate, 0.02);
|
||||
a->ibuff = new double[a->size]; // (double*) malloc0 (a->size * sizeof (double));
|
||||
a->ftovbuff = new double[a->size]; // (double*) malloc0(a->size * sizeof (double));
|
||||
a->ibuff = new float[a->size]; // (float*) malloc0 (a->size * sizeof (float));
|
||||
a->ftovbuff = new float[a->size]; // (float*) malloc0(a->size * sizeof (float));
|
||||
a->cvtr = FTOV::create_ftov (1, a->size, a->rate, a->ftov_rsize, a->ftov_fmax, a->ibuff, a->ftovbuff);
|
||||
a->lpbuff = new double[a->size]; // (double*) malloc0 (a->size * sizeof (double));
|
||||
a->lpbuff = new float[a->size]; // (float*) malloc0 (a->size * sizeof (float));
|
||||
a->filt = DBQLP::create_dbqlp (1, a->size, a->ftovbuff, a->lpbuff, a->rate, 11.3, 1.0, 1.0, 1);
|
||||
a->wdbuff = new int[a->size]; // (int*) malloc0 (a->size * sizeof (int));
|
||||
a->tr_signal = new int[a->size]; // (int*) malloc0 (a->size * sizeof (int));
|
||||
@ -158,8 +158,8 @@ void SSQL::calc_ssql (SSQL *a)
|
||||
// level change
|
||||
a->ntup = (int)(a->tup * a->rate);
|
||||
a->ntdown = (int)(a->tdown * a->rate);
|
||||
a->cup = new double[a->ntup + 1]; // (double*) malloc0 ((a->ntup + 1) * sizeof (double));
|
||||
a->cdown = new double[a->ntdown + 1]; // (double*) malloc0 ((a->ntdown + 1) * sizeof (double));
|
||||
a->cup = new float[a->ntup + 1]; // (float*) malloc0 ((a->ntup + 1) * sizeof (float));
|
||||
a->cdown = new float[a->ntdown + 1]; // (float*) malloc0 ((a->ntdown + 1) * sizeof (float));
|
||||
compute_ssql_slews (a);
|
||||
// control
|
||||
a->state = 0;
|
||||
@ -184,18 +184,18 @@ void SSQL::decalc_ssql (SSQL *a)
|
||||
SSQL* SSQL::create_ssql (
|
||||
int run,
|
||||
int size,
|
||||
double* in,
|
||||
double* out,
|
||||
float* in,
|
||||
float* out,
|
||||
int rate,
|
||||
double tup,
|
||||
double tdown,
|
||||
double muted_gain,
|
||||
double tau_mute,
|
||||
double tau_unmute,
|
||||
double wthresh,
|
||||
double tr_thresh,
|
||||
float tup,
|
||||
float tdown,
|
||||
float muted_gain,
|
||||
float tau_mute,
|
||||
float tau_unmute,
|
||||
float wthresh,
|
||||
float tr_thresh,
|
||||
int rsize,
|
||||
double fmax
|
||||
float fmax
|
||||
)
|
||||
{
|
||||
SSQL *a = new SSQL;
|
||||
@ -231,10 +231,10 @@ void SSQL::flush_ssql (SSQL *a)
|
||||
|
||||
memset (a->b1, 0, a->size * sizeof (wcomplex));
|
||||
CBL::flush_cbl (a->dcbl);
|
||||
memset (a->ibuff, 0, a->size * sizeof (double));
|
||||
memset (a->ftovbuff, 0, a->size * sizeof (double));
|
||||
memset (a->ibuff, 0, a->size * sizeof (float));
|
||||
memset (a->ftovbuff, 0, a->size * sizeof (float));
|
||||
FTOV::flush_ftov (a->cvtr);
|
||||
memset (a->lpbuff, 0, a->size * sizeof (double));
|
||||
memset (a->lpbuff, 0, a->size * sizeof (float));
|
||||
DBQLP::flush_dbqlp (a->filt);
|
||||
memset (a->wdbuff, 0, a->size * sizeof (int));
|
||||
memset (a->tr_signal, 0, a->size * sizeof (int));
|
||||
@ -320,7 +320,7 @@ void SSQL::xssql (SSQL *a)
|
||||
memcpy (a->out, a->in, a->size * sizeof(wcomplex));
|
||||
}
|
||||
|
||||
void SSQL::setBuffers_ssql (SSQL *a, double* in, double* out)
|
||||
void SSQL::setBuffers_ssql (SSQL *a, float* in, float* out)
|
||||
{
|
||||
decalc_ssql (a);
|
||||
a->in = in;
|
||||
@ -355,7 +355,7 @@ void SSQL::SetSSQLRun (RXA& rxa, int run)
|
||||
rxa.csDSP.unlock();
|
||||
}
|
||||
|
||||
void SSQL::SetSSQLThreshold (RXA& rxa, double threshold)
|
||||
void SSQL::SetSSQLThreshold (RXA& rxa, float threshold)
|
||||
{
|
||||
// 'threshold' should be between 0.0 and 1.0
|
||||
// WU2O testing: 0.16 is a good default for 'threshold'; => 0.08 for 'wthresh'
|
||||
@ -364,7 +364,7 @@ void SSQL::SetSSQLThreshold (RXA& rxa, double threshold)
|
||||
rxa.csDSP.unlock();
|
||||
}
|
||||
|
||||
void SSQL::SetSSQLTauMute (RXA& rxa, double tau_mute)
|
||||
void SSQL::SetSSQLTauMute (RXA& rxa, float tau_mute)
|
||||
{
|
||||
// reasonable (wide) range is 0.1 to 2.0
|
||||
// WU2O testing: 0.1 is good default value
|
||||
@ -375,7 +375,7 @@ void SSQL::SetSSQLTauMute (RXA& rxa, double tau_mute)
|
||||
rxa.csDSP.unlock();
|
||||
}
|
||||
|
||||
void SSQL::SetSSQLTauUnMute (RXA& rxa, double tau_unmute)
|
||||
void SSQL::SetSSQLTauUnMute (RXA& rxa, float tau_unmute)
|
||||
{
|
||||
// reasonable (wide) range is 0.1 to 1.0
|
||||
// WU2O testing: 0.1 is good default value
|
||||
|
@ -39,17 +39,17 @@ public:
|
||||
int size; // buffer size
|
||||
int rate; // sample-rate
|
||||
int rsize; // rate * time_to_fill_ring, e.g., 48K/s * 50ms = 2400
|
||||
double fmax; // frequency (Hz) for full output, e.g., 2000 (Hz)
|
||||
double* in; // pointer to the intput buffer for ftov
|
||||
double* out; // pointer to the output buffer for ftov
|
||||
float fmax; // frequency (Hz) for full output, e.g., 2000 (Hz)
|
||||
float* in; // pointer to the intput buffer for ftov
|
||||
float* out; // pointer to the output buffer for ftov
|
||||
int* ring; // pointer to the base of the ring
|
||||
int rptr; // index into the ring
|
||||
double inlast; // holds last sample from previous buffer
|
||||
float inlast; // holds last sample from previous buffer
|
||||
int rcount; // count of zero-crossings currently in the ring
|
||||
double div; // divisor for 'rcount' to produce output of 1.0 at 'fmax'
|
||||
double eps; // minimum input change to count as a signal edge transition
|
||||
float div; // divisor for 'rcount' to produce output of 1.0 at 'fmax'
|
||||
float eps; // minimum input change to count as a signal edge transition
|
||||
|
||||
static FTOV* create_ftov (int run, int size, int rate, int rsize, double fmax, double* in, double* out);
|
||||
static FTOV* create_ftov (int run, int size, int rate, int rsize, float fmax, float* in, float* out);
|
||||
static void destroy_ftov (FTOV *a);
|
||||
static void flush_ftov (FTOV *a);
|
||||
static void xftov (FTOV *a);
|
||||
@ -65,72 +65,72 @@ class WDSP_API SSQL // Syllabic Squelch
|
||||
public:
|
||||
int run; // 0 if squelch system is OFF; 1 if it's ON
|
||||
int size; // size of input/output buffers
|
||||
double* in; // squelch input signal buffer
|
||||
double* out; // squelch output signal buffer
|
||||
float* in; // squelch input signal buffer
|
||||
float* out; // squelch output signal buffer
|
||||
int rate; // sample rate
|
||||
int state; // state machine control
|
||||
int count; // count variable for raised cosine transitions
|
||||
double tup; // time for turn-on transition
|
||||
double tdown; // time for turn-off transition
|
||||
float tup; // time for turn-on transition
|
||||
float tdown; // time for turn-off transition
|
||||
int ntup; // number of samples for turn-on transition
|
||||
int ntdown; // number of samples for turn-off transition
|
||||
double* cup; // coefficients for up-slew
|
||||
double* cdown; // coefficients for down-slew
|
||||
double muted_gain; // audio gain while muted; 0.0 for complete silence
|
||||
float* cup; // coefficients for up-slew
|
||||
float* cdown; // coefficients for down-slew
|
||||
float muted_gain; // audio gain while muted; 0.0 for complete silence
|
||||
|
||||
double* b1; // buffer to hold output of dc-block function
|
||||
double* ibuff; // buffer containing only 'I' component
|
||||
double* ftovbuff; // buffer containing output of f to v converter
|
||||
double* lpbuff; // buffer containing output of low-pass filter
|
||||
float* b1; // buffer to hold output of dc-block function
|
||||
float* ibuff; // buffer containing only 'I' component
|
||||
float* ftovbuff; // buffer containing output of f to v converter
|
||||
float* lpbuff; // buffer containing output of low-pass filter
|
||||
int* wdbuff; // buffer containing output of window detector
|
||||
CBL *dcbl; // pointer to DC Blocker data structure
|
||||
FTOV *cvtr; // pointer to F to V Converter data structure
|
||||
BQLP *filt; // pointer to Bi-Quad Low-Pass Filter data structure
|
||||
int ftov_rsize; // ring size for f_to_v converter
|
||||
double ftov_fmax; // fmax for f_to_v converter
|
||||
float ftov_fmax; // fmax for f_to_v converter
|
||||
// window detector
|
||||
double wdtau; // window detector time constant
|
||||
double wdmult; // window detector time constant multiplier
|
||||
double wdaverage; // average signal value
|
||||
double wthresh; // window threshold above/below average
|
||||
float wdtau; // window detector time constant
|
||||
float wdmult; // window detector time constant multiplier
|
||||
float wdaverage; // average signal value
|
||||
float wthresh; // window threshold above/below average
|
||||
// trigger
|
||||
double tr_thresh; // trigger threshold: 100K/(100K+22K)=0.8197
|
||||
double tr_tau_unmute; // trigger unmute time-constant: (100K||220K)*10uF = 0.6875
|
||||
double tr_ss_unmute; // trigger steady-state level for unmute: 100K/(100K+220K)=0.3125
|
||||
double tr_tau_mute; // trigger mute time-constant: 220K*10uF = 2.2
|
||||
double tr_ss_mute; // trigger steady-state level for mute: 1.0
|
||||
double tr_voltage; // trigger voltage
|
||||
double mute_mult; // multiplier for successive voltage calcs when muted
|
||||
double unmute_mult; // multiplier for successive voltage calcs when unmuted
|
||||
float tr_thresh; // trigger threshold: 100K/(100K+22K)=0.8197
|
||||
float tr_tau_unmute; // trigger unmute time-constant: (100K||220K)*10uF = 0.6875
|
||||
float tr_ss_unmute; // trigger steady-state level for unmute: 100K/(100K+220K)=0.3125
|
||||
float tr_tau_mute; // trigger mute time-constant: 220K*10uF = 2.2
|
||||
float tr_ss_mute; // trigger steady-state level for mute: 1.0
|
||||
float tr_voltage; // trigger voltage
|
||||
float mute_mult; // multiplier for successive voltage calcs when muted
|
||||
float unmute_mult; // multiplier for successive voltage calcs when unmuted
|
||||
int* tr_signal; // trigger signal, 0 or 1
|
||||
|
||||
static SSQL* create_ssql (
|
||||
int run,
|
||||
int size,
|
||||
double* in,
|
||||
double* out,
|
||||
float* in,
|
||||
float* out,
|
||||
int rate,
|
||||
double tup,
|
||||
double tdown,
|
||||
double muted_gain,
|
||||
double tau_mute,
|
||||
double tau_unmute,
|
||||
double wthresh,
|
||||
double tr_thresh,
|
||||
float tup,
|
||||
float tdown,
|
||||
float muted_gain,
|
||||
float tau_mute,
|
||||
float tau_unmute,
|
||||
float wthresh,
|
||||
float tr_thresh,
|
||||
int rsize,
|
||||
double fmax
|
||||
float fmax
|
||||
);
|
||||
static void destroy_ssql (SSQL *a);
|
||||
static void flush_ssql (SSQL *a);
|
||||
static void xssql (SSQL *a);
|
||||
static void setBuffers_ssql (SSQL *a, double* in, double* out);
|
||||
static void setBuffers_ssql (SSQL *a, float* in, float* out);
|
||||
static void setSamplerate_ssql (SSQL *a, int rate);
|
||||
static void setSize_ssql (SSQL *a, int size);
|
||||
// RXA Properties
|
||||
static void SetSSQLRun (RXA& rxa, int run);
|
||||
static void SetSSQLThreshold (RXA& rxa, double threshold);
|
||||
static void SetSSQLTauMute (RXA& rxa, double tau_mute);
|
||||
static void SetSSQLTauUnMute (RXA& rxa, double tau_unmute);
|
||||
static void SetSSQLThreshold (RXA& rxa, float threshold);
|
||||
static void SetSSQLTauMute (RXA& rxa, float tau_mute);
|
||||
static void SetSSQLTauUnMute (RXA& rxa, float tau_unmute);
|
||||
|
||||
private:
|
||||
static void compute_ssql_slews(SSQL *a);
|
||||
|
@ -33,9 +33,9 @@ namespace WDSP {
|
||||
|
||||
void VARSAMP::calc_varsamp (VARSAMP *a)
|
||||
{
|
||||
double min_rate, max_rate, norm_rate;
|
||||
double fc_norm_high, fc_norm_low;
|
||||
a->nom_ratio = (double)a->out_rate / (double)a->in_rate;
|
||||
float min_rate, max_rate, norm_rate;
|
||||
float fc_norm_high, fc_norm_low;
|
||||
a->nom_ratio = (float)a->out_rate / (float)a->in_rate;
|
||||
a->cvar = a->var * a->nom_ratio;
|
||||
a->inv_cvar = 1.0 / a->cvar;
|
||||
a->old_inv_cvar = a->inv_cvar;
|
||||
@ -44,14 +44,14 @@ void VARSAMP::calc_varsamp (VARSAMP *a)
|
||||
a->fc = a->fcin;
|
||||
if (a->out_rate >= a->in_rate)
|
||||
{
|
||||
min_rate = (double)a->in_rate;
|
||||
max_rate = (double)a->out_rate;
|
||||
min_rate = (float)a->in_rate;
|
||||
max_rate = (float)a->out_rate;
|
||||
norm_rate = min_rate;
|
||||
}
|
||||
else
|
||||
{
|
||||
min_rate = (double)a->out_rate;
|
||||
max_rate = (double)a->in_rate;
|
||||
min_rate = (float)a->out_rate;
|
||||
max_rate = (float)a->in_rate;
|
||||
norm_rate = max_rate;
|
||||
}
|
||||
if (a->fc == 0.0) a->fc = 0.95 * 0.45 * min_rate;
|
||||
@ -63,12 +63,12 @@ void VARSAMP::calc_varsamp (VARSAMP *a)
|
||||
a->rsize = (int)(140.0 * norm_rate / min_rate);
|
||||
a->ncoef = a->rsize + 1;
|
||||
a->ncoef += (a->R - 1) * (a->ncoef - 1);
|
||||
a->h = FIR::fir_bandpass(a->ncoef, fc_norm_low, fc_norm_high, (double)a->R, 1, 0, (double)a->R * a->gain);
|
||||
a->h = FIR::fir_bandpass(a->ncoef, fc_norm_low, fc_norm_high, (float)a->R, 1, 0, (float)a->R * a->gain);
|
||||
// print_impulse ("imp.txt", a->ncoef, a->h, 0, 0);
|
||||
a->ring = new double[a->rsize * 2]; // (double *)malloc0(a->rsize * sizeof(complex));
|
||||
a->ring = new float[a->rsize * 2]; // (float *)malloc0(a->rsize * sizeof(complex));
|
||||
a->idx_in = a->rsize - 1;
|
||||
a->h_offset = 0.0;
|
||||
a->hs = new double[a->rsize]; // (double *)malloc0 (a->rsize * sizeof (double));
|
||||
a->hs = new float[a->rsize]; // (float *)malloc0 (a->rsize * sizeof (float));
|
||||
a->isamps = 0.0;
|
||||
}
|
||||
|
||||
@ -82,15 +82,15 @@ void VARSAMP::decalc_varsamp (VARSAMP *a)
|
||||
VARSAMP* VARSAMP::create_varsamp (
|
||||
int run,
|
||||
int size,
|
||||
double* in,
|
||||
double* out,
|
||||
float* in,
|
||||
float* out,
|
||||
int in_rate,
|
||||
int out_rate,
|
||||
double fc,
|
||||
double fc_low,
|
||||
float fc,
|
||||
float fc_low,
|
||||
int R,
|
||||
double gain,
|
||||
double var,
|
||||
float gain,
|
||||
float var,
|
||||
int varmode
|
||||
)
|
||||
{
|
||||
@ -130,15 +130,15 @@ void VARSAMP::hshift (VARSAMP *a)
|
||||
{
|
||||
int i, j, k;
|
||||
int hidx;
|
||||
double frac, pos;
|
||||
pos = (double)a->R * a->h_offset;
|
||||
float frac, pos;
|
||||
pos = (float)a->R * a->h_offset;
|
||||
hidx = (int)(pos);
|
||||
frac = pos - (double)hidx;
|
||||
frac = pos - (float)hidx;
|
||||
for (i = a->rsize - 1, j = hidx, k = hidx + 1; i >= 0; i--, j += a->R, k += a->R)
|
||||
a->hs[i] = a->h[j] + frac * (a->h[k] - a->h[j]);
|
||||
}
|
||||
|
||||
int VARSAMP::xvarsamp (VARSAMP *a, double var)
|
||||
int VARSAMP::xvarsamp (VARSAMP *a, float var)
|
||||
{
|
||||
int outsamps = 0;
|
||||
uint64_t* picvar;
|
||||
@ -149,7 +149,7 @@ int VARSAMP::xvarsamp (VARSAMP *a, double var)
|
||||
a->inv_cvar = 1.0 / a->cvar;
|
||||
if (a->varmode)
|
||||
{
|
||||
a->dicvar = (a->inv_cvar - a->old_inv_cvar) / (double)a->size;
|
||||
a->dicvar = (a->inv_cvar - a->old_inv_cvar) / (float)a->size;
|
||||
a->inv_cvar = a->old_inv_cvar;
|
||||
}
|
||||
else a->dicvar = 0.0;
|
||||
@ -157,7 +157,7 @@ int VARSAMP::xvarsamp (VARSAMP *a, double var)
|
||||
{
|
||||
int i, j;
|
||||
int idx_out;
|
||||
double I, Q;
|
||||
float I, Q;
|
||||
for (i = 0; i < a->size; i++)
|
||||
{
|
||||
a->ring[2 * a->idx_in + 0] = a->in[2 * i + 0];
|
||||
@ -165,7 +165,7 @@ int VARSAMP::xvarsamp (VARSAMP *a, double var)
|
||||
a->inv_cvar += a->dicvar;
|
||||
picvar = (uint64_t*)(&a->inv_cvar);
|
||||
N = *picvar & 0xffffffffffff0000;
|
||||
a->inv_cvar = static_cast<double>(N);
|
||||
a->inv_cvar = static_cast<float>(N);
|
||||
a->delta = 1.0 - a->inv_cvar;
|
||||
while (a->isamps < 1.0)
|
||||
{
|
||||
@ -195,7 +195,7 @@ int VARSAMP::xvarsamp (VARSAMP *a, double var)
|
||||
return outsamps;
|
||||
}
|
||||
|
||||
void VARSAMP::setBuffers_varsamp (VARSAMP *a, double* in, double* out)
|
||||
void VARSAMP::setBuffers_varsamp (VARSAMP *a, float* in, float* out)
|
||||
{
|
||||
a->in = in;
|
||||
a->out = out;
|
||||
@ -221,7 +221,7 @@ void VARSAMP::setOutRate_varsamp (VARSAMP *a, int rate)
|
||||
calc_varsamp (a);
|
||||
}
|
||||
|
||||
void VARSAMP::setFCLow_varsamp (VARSAMP *a, double fc_low)
|
||||
void VARSAMP::setFCLow_varsamp (VARSAMP *a, float fc_low)
|
||||
{
|
||||
if (fc_low != a->fc_low)
|
||||
{
|
||||
@ -231,7 +231,7 @@ void VARSAMP::setFCLow_varsamp (VARSAMP *a, double fc_low)
|
||||
}
|
||||
}
|
||||
|
||||
void VARSAMP::setBandwidth_varsamp (VARSAMP *a, double fc_low, double fc_high)
|
||||
void VARSAMP::setBandwidth_varsamp (VARSAMP *a, float fc_low, float fc_high)
|
||||
{
|
||||
if (fc_low != a->fc_low || fc_high != a->fcin)
|
||||
{
|
||||
@ -249,7 +249,7 @@ void* VARSAMP::create_varsampV (int in_rate, int out_rate, int R)
|
||||
return (void *)create_varsamp (1, 0, 0, 0, in_rate, out_rate, 0.0, -1.0, R, 1.0, 1.0, 1);
|
||||
}
|
||||
|
||||
void VARSAMP::xvarsampV (double* input, double* output, int numsamps, double var, int* outsamps, void* ptr)
|
||||
void VARSAMP::xvarsampV (float* input, float* output, int numsamps, float var, int* outsamps, void* ptr)
|
||||
{
|
||||
VARSAMP *a = (VARSAMP*) ptr;
|
||||
a->in = input;
|
||||
|
@ -37,58 +37,58 @@ class WDSP_API VARSAMP
|
||||
public:
|
||||
int run;
|
||||
int size;
|
||||
double* in;
|
||||
double* out;
|
||||
float* in;
|
||||
float* out;
|
||||
int in_rate;
|
||||
int out_rate;
|
||||
double fcin;
|
||||
double fc;
|
||||
double fc_low;
|
||||
double gain;
|
||||
float fcin;
|
||||
float fc;
|
||||
float fc_low;
|
||||
float gain;
|
||||
int idx_in;
|
||||
int ncoef;
|
||||
double* h;
|
||||
float* h;
|
||||
int rsize;
|
||||
double* ring;
|
||||
double var;
|
||||
float* ring;
|
||||
float var;
|
||||
int varmode;
|
||||
double cvar;
|
||||
double inv_cvar;
|
||||
double old_inv_cvar;
|
||||
double dicvar;
|
||||
double delta;
|
||||
double* hs;
|
||||
float cvar;
|
||||
float inv_cvar;
|
||||
float old_inv_cvar;
|
||||
float dicvar;
|
||||
float delta;
|
||||
float* hs;
|
||||
int R;
|
||||
double h_offset;
|
||||
double isamps;
|
||||
double nom_ratio;
|
||||
float h_offset;
|
||||
float isamps;
|
||||
float nom_ratio;
|
||||
|
||||
static VARSAMP* create_varsamp (
|
||||
int run,
|
||||
int size,
|
||||
double* in,
|
||||
double* out,
|
||||
float* in,
|
||||
float* out,
|
||||
int in_rate,
|
||||
int out_rate,
|
||||
double fc,
|
||||
double fc_low,
|
||||
float fc,
|
||||
float fc_low,
|
||||
int R,
|
||||
double gain,
|
||||
double var,
|
||||
float gain,
|
||||
float var,
|
||||
int varmode
|
||||
);
|
||||
static void destroy_varsamp (VARSAMP *a);
|
||||
static void flush_varsamp (VARSAMP *a);
|
||||
static int xvarsamp (VARSAMP *a, double var);
|
||||
static void setBuffers_varsamp (VARSAMP *a, double* in, double* out);
|
||||
static int xvarsamp (VARSAMP *a, float var);
|
||||
static void setBuffers_varsamp (VARSAMP *a, float* in, float* out);
|
||||
static void setSize_varsamp (VARSAMP *a, int size);
|
||||
static void setInRate_varsamp (VARSAMP *a, int rate);
|
||||
static void setOutRate_varsamp (VARSAMP *a, int rate);
|
||||
static void setFCLow_varsamp (VARSAMP *a, double fc_low);
|
||||
static void setBandwidth_varsamp (VARSAMP *a, double fc_low, double fc_high);
|
||||
static void setFCLow_varsamp (VARSAMP *a, float fc_low);
|
||||
static void setBandwidth_varsamp (VARSAMP *a, float fc_low, float fc_high);
|
||||
// Exported calls
|
||||
static void* create_varsampV (int in_rate, int out_rate, int R);
|
||||
static void xvarsampV (double* input, double* output, int numsamps, double var, int* outsamps, void* ptr);
|
||||
static void xvarsampV (float* input, float* output, int numsamps, float var, int* outsamps, void* ptr);
|
||||
static void destroy_varsampV (void* ptr);
|
||||
|
||||
private:
|
||||
|
@ -53,8 +53,8 @@ void WCPAGC::calc_wcpagc (WCPAGC *a)
|
||||
a->hang_counter = 0;
|
||||
a->decay_type = 0;
|
||||
a->state = 0;
|
||||
a->ring = new double[RB_SIZE * 2]; // (double *)malloc0(RB_SIZE * sizeof(complex));
|
||||
a->abs_ring = new double[RB_SIZE]; //(double *)malloc0(RB_SIZE * sizeof(double));
|
||||
a->ring = new double[RB_SIZE * 2]; // (float *)malloc0(RB_SIZE * sizeof(complex));
|
||||
a->abs_ring = new double[RB_SIZE]; //(float *)malloc0(RB_SIZE * sizeof(float));
|
||||
loadWcpAGC(a);
|
||||
}
|
||||
|
||||
@ -68,8 +68,8 @@ WCPAGC* WCPAGC::create_wcpagc (
|
||||
int run,
|
||||
int mode,
|
||||
int pmode,
|
||||
double* in,
|
||||
double* out,
|
||||
float* in,
|
||||
float* out,
|
||||
int io_buffsize,
|
||||
int sample_rate,
|
||||
double tau_attack,
|
||||
@ -98,7 +98,7 @@ WCPAGC* WCPAGC::create_wcpagc (
|
||||
a->in = in;
|
||||
a->out = out;
|
||||
a->io_buffsize = io_buffsize;
|
||||
a->sample_rate = (double)sample_rate;
|
||||
a->sample_rate = (float)sample_rate;
|
||||
a->tau_attack = tau_attack;
|
||||
a->tau_decay = tau_decay;
|
||||
a->n_tau = n_tau;
|
||||
@ -121,7 +121,7 @@ WCPAGC* WCPAGC::create_wcpagc (
|
||||
|
||||
void WCPAGC::loadWcpAGC (WCPAGC *a)
|
||||
{
|
||||
double tmp;
|
||||
float tmp;
|
||||
//calculate internal parameters
|
||||
a->attack_buffsize = (int)ceil(a->sample_rate * a->n_tau * a->tau_attack);
|
||||
a->in_index = a->attack_buffsize + a->out_index;
|
||||
@ -131,7 +131,7 @@ void WCPAGC::loadWcpAGC (WCPAGC *a)
|
||||
a->fast_backmult = 1.0 - exp(-1.0 / (a->sample_rate * a->tau_fast_backaverage));
|
||||
a->onemfast_backmult = 1.0 - a->fast_backmult;
|
||||
|
||||
a->out_target = a->out_targ * (1.0 - exp(-(double)a->n_tau)) * 0.9999;
|
||||
a->out_target = a->out_targ * (1.0 - exp(-(float)a->n_tau)) * 0.9999;
|
||||
a->min_volts = a->out_target / (a->var_gain * a->max_gain);
|
||||
a->inv_out_target = 1.0 / a->out_target;
|
||||
|
||||
@ -160,15 +160,15 @@ void WCPAGC::destroy_wcpagc (WCPAGC *a)
|
||||
|
||||
void WCPAGC::flush_wcpagc (WCPAGC *a)
|
||||
{
|
||||
memset ((void *)a->ring, 0, sizeof(double) * RB_SIZE * 2);
|
||||
memset ((void *)a->ring, 0, sizeof(float) * RB_SIZE * 2);
|
||||
a->ring_max = 0.0;
|
||||
memset ((void *)a->abs_ring, 0, sizeof(double)* RB_SIZE);
|
||||
memset ((void *)a->abs_ring, 0, sizeof(float)* RB_SIZE);
|
||||
}
|
||||
|
||||
void WCPAGC::xwcpagc (WCPAGC *a)
|
||||
{
|
||||
int i, j, k;
|
||||
double mult;
|
||||
float mult;
|
||||
if (a->run)
|
||||
{
|
||||
if (a->mode == 0)
|
||||
@ -348,7 +348,7 @@ void WCPAGC::xwcpagc (WCPAGC *a)
|
||||
memcpy(a->out, a->in, a->io_buffsize * sizeof (wcomplex));
|
||||
}
|
||||
|
||||
void WCPAGC::setBuffers_wcpagc (WCPAGC *a, double* in, double* out)
|
||||
void WCPAGC::setBuffers_wcpagc (WCPAGC *a, float* in, float* out)
|
||||
{
|
||||
a->in = in;
|
||||
a->out = out;
|
||||
@ -419,7 +419,7 @@ void WCPAGC::SetAGCMode (RXA& rxa, int mode)
|
||||
void WCPAGC::SetAGCAttack (RXA& rxa, int attack)
|
||||
{
|
||||
rxa.csDSP.lock();
|
||||
rxa.agc.p->tau_attack = (double)attack / 1000.0;
|
||||
rxa.agc.p->tau_attack = (float)attack / 1000.0;
|
||||
loadWcpAGC ( rxa.agc.p );
|
||||
rxa.csDSP.unlock();
|
||||
}
|
||||
@ -427,7 +427,7 @@ void WCPAGC::SetAGCAttack (RXA& rxa, int attack)
|
||||
void WCPAGC::SetAGCDecay (RXA& rxa, int decay)
|
||||
{
|
||||
rxa.csDSP.lock();
|
||||
rxa.agc.p->tau_decay = (double)decay / 1000.0;
|
||||
rxa.agc.p->tau_decay = (float)decay / 1000.0;
|
||||
loadWcpAGC ( rxa.agc.p );
|
||||
rxa.csDSP.unlock();
|
||||
}
|
||||
@ -435,12 +435,12 @@ void WCPAGC::SetAGCDecay (RXA& rxa, int decay)
|
||||
void WCPAGC::SetAGCHang (RXA& rxa, int hang)
|
||||
{
|
||||
rxa.csDSP.lock();
|
||||
rxa.agc.p->hangtime = (double)hang / 1000.0;
|
||||
rxa.agc.p->hangtime = (float)hang / 1000.0;
|
||||
loadWcpAGC ( rxa.agc.p );
|
||||
rxa.csDSP.unlock();
|
||||
}
|
||||
|
||||
void WCPAGC::GetAGCHangLevel(RXA& rxa, double *hangLevel)
|
||||
void WCPAGC::GetAGCHangLevel(RXA& rxa, float *hangLevel)
|
||||
//for line on bandscope
|
||||
{
|
||||
rxa.csDSP.lock();
|
||||
@ -448,10 +448,10 @@ void WCPAGC::GetAGCHangLevel(RXA& rxa, double *hangLevel)
|
||||
rxa.csDSP.unlock();
|
||||
}
|
||||
|
||||
void WCPAGC::SetAGCHangLevel(RXA& rxa, double hangLevel)
|
||||
void WCPAGC::SetAGCHangLevel(RXA& rxa, float hangLevel)
|
||||
//for line on bandscope
|
||||
{
|
||||
double convert, tmp;
|
||||
float convert, tmp;
|
||||
rxa.csDSP.lock();
|
||||
if (rxa.agc.p->max_input > rxa.agc.p->min_volts)
|
||||
{
|
||||
@ -478,15 +478,15 @@ void WCPAGC::SetAGCHangThreshold (RXA& rxa, int hangthreshold)
|
||||
//For slider in setup
|
||||
{
|
||||
rxa.csDSP.lock();
|
||||
rxa.agc.p->hang_thresh = (double)hangthreshold / 100.0;
|
||||
rxa.agc.p->hang_thresh = (float)hangthreshold / 100.0;
|
||||
loadWcpAGC ( rxa.agc.p );
|
||||
rxa.csDSP.unlock();
|
||||
}
|
||||
|
||||
void WCPAGC::GetAGCThresh(RXA& rxa, double *thresh, double size, double rate)
|
||||
void WCPAGC::GetAGCThresh(RXA& rxa, float *thresh, float size, float rate)
|
||||
//for line on bandscope.
|
||||
{
|
||||
double noise_offset;
|
||||
float noise_offset;
|
||||
rxa.csDSP.lock();
|
||||
noise_offset = 10.0 * log10((rxa.nbp0.p->fhigh - rxa.nbp0.p->flow)
|
||||
* size / rate);
|
||||
@ -494,10 +494,10 @@ void WCPAGC::GetAGCThresh(RXA& rxa, double *thresh, double size, double rate)
|
||||
rxa.csDSP.unlock();
|
||||
}
|
||||
|
||||
void WCPAGC::SetAGCThresh(RXA& rxa, double thresh, double size, double rate)
|
||||
void WCPAGC::SetAGCThresh(RXA& rxa, float thresh, float size, float rate)
|
||||
//for line on bandscope
|
||||
{
|
||||
double noise_offset;
|
||||
float noise_offset;
|
||||
rxa.csDSP.lock();
|
||||
noise_offset = 10.0 * log10((rxa.nbp0.p->fhigh - rxa.nbp0.p->flow)
|
||||
* size / rate);
|
||||
@ -507,7 +507,7 @@ void WCPAGC::SetAGCThresh(RXA& rxa, double thresh, double size, double rate)
|
||||
rxa.csDSP.unlock();
|
||||
}
|
||||
|
||||
void WCPAGC::GetAGCTop(RXA& rxa, double *max_agc)
|
||||
void WCPAGC::GetAGCTop(RXA& rxa, float *max_agc)
|
||||
//for AGC Max Gain in setup
|
||||
{
|
||||
rxa.csDSP.lock();
|
||||
@ -515,11 +515,11 @@ void WCPAGC::GetAGCTop(RXA& rxa, double *max_agc)
|
||||
rxa.csDSP.unlock();
|
||||
}
|
||||
|
||||
void WCPAGC::SetAGCTop (RXA& rxa, double max_agc)
|
||||
void WCPAGC::SetAGCTop (RXA& rxa, float max_agc)
|
||||
//for AGC Max Gain in setup
|
||||
{
|
||||
rxa.csDSP.lock();
|
||||
rxa.agc.p->max_gain = pow (10.0, (double)max_agc / 20.0);
|
||||
rxa.agc.p->max_gain = pow (10.0, (float)max_agc / 20.0);
|
||||
loadWcpAGC ( rxa.agc.p );
|
||||
rxa.csDSP.unlock();
|
||||
}
|
||||
@ -527,20 +527,20 @@ void WCPAGC::SetAGCTop (RXA& rxa, double max_agc)
|
||||
void WCPAGC::SetAGCSlope (RXA& rxa, int slope)
|
||||
{
|
||||
rxa.csDSP.lock();
|
||||
rxa.agc.p->var_gain = pow (10.0, (double)slope / 20.0 / 10.0);
|
||||
rxa.agc.p->var_gain = pow (10.0, (float)slope / 20.0 / 10.0);
|
||||
loadWcpAGC ( rxa.agc.p );
|
||||
rxa.csDSP.unlock();
|
||||
}
|
||||
|
||||
void WCPAGC::SetAGCFixed (RXA& rxa, double fixed_agc)
|
||||
void WCPAGC::SetAGCFixed (RXA& rxa, float fixed_agc)
|
||||
{
|
||||
rxa.csDSP.lock();
|
||||
rxa.agc.p->fixed_gain = pow (10.0, (double)fixed_agc / 20.0);
|
||||
rxa.agc.p->fixed_gain = pow (10.0, (float)fixed_agc / 20.0);
|
||||
loadWcpAGC ( rxa.agc.p );
|
||||
rxa.csDSP.unlock();
|
||||
}
|
||||
|
||||
void WCPAGC::SetAGCMaxInputLevel (RXA& rxa, double level)
|
||||
void WCPAGC::SetAGCMaxInputLevel (RXA& rxa, float level)
|
||||
{
|
||||
rxa.csDSP.lock();
|
||||
rxa.agc.p->max_input = level;
|
||||
@ -564,7 +564,7 @@ void WCPAGC::SetALCSt (TXA& txa, int state)
|
||||
void WCPAGC::SetALCAttack (TXA& txa, int attack)
|
||||
{
|
||||
txa.csDSP.lock();
|
||||
txa.alc.p->tau_attack = (double)attack / 1000.0;
|
||||
txa.alc.p->tau_attack = (float)attack / 1000.0;
|
||||
loadWcpAGC(txa.alc.p);
|
||||
txa.csDSP.unlock();
|
||||
}
|
||||
@ -572,7 +572,7 @@ void WCPAGC::SetALCAttack (TXA& txa, int attack)
|
||||
void WCPAGC::SetALCDecay (TXA& txa, int decay)
|
||||
{
|
||||
txa.csDSP.lock();
|
||||
txa.alc.p->tau_decay = (double)decay / 1000.0;
|
||||
txa.alc.p->tau_decay = (float)decay / 1000.0;
|
||||
loadWcpAGC(txa.alc.p);
|
||||
txa.csDSP.unlock();
|
||||
}
|
||||
@ -580,15 +580,15 @@ void WCPAGC::SetALCDecay (TXA& txa, int decay)
|
||||
void WCPAGC::SetALCHang (TXA& txa, int hang)
|
||||
{
|
||||
txa.csDSP.lock();
|
||||
txa.alc.p->hangtime = (double)hang / 1000.0;
|
||||
txa.alc.p->hangtime = (float)hang / 1000.0;
|
||||
loadWcpAGC(txa.alc.p);
|
||||
txa.csDSP.unlock();
|
||||
}
|
||||
|
||||
void WCPAGC::SetALCMaxGain (TXA& txa, double maxgain)
|
||||
void WCPAGC::SetALCMaxGain (TXA& txa, float maxgain)
|
||||
{
|
||||
txa.csDSP.lock();
|
||||
txa.alc.p->max_gain = pow (10.0,(double)maxgain / 20.0);
|
||||
txa.alc.p->max_gain = pow (10.0,(float)maxgain / 20.0);
|
||||
loadWcpAGC(txa.alc.p);
|
||||
txa.csDSP.unlock();
|
||||
}
|
||||
@ -603,7 +603,7 @@ void WCPAGC::SetLevelerSt (TXA& txa, int state)
|
||||
void WCPAGC::SetLevelerAttack (TXA& txa, int attack)
|
||||
{
|
||||
txa.csDSP.lock();
|
||||
txa.leveler.p->tau_attack = (double)attack / 1000.0;
|
||||
txa.leveler.p->tau_attack = (float)attack / 1000.0;
|
||||
loadWcpAGC(txa.leveler.p);
|
||||
txa.csDSP.unlock();
|
||||
}
|
||||
@ -611,7 +611,7 @@ void WCPAGC::SetLevelerAttack (TXA& txa, int attack)
|
||||
void WCPAGC::SetLevelerDecay (TXA& txa, int decay)
|
||||
{
|
||||
txa.csDSP.lock();
|
||||
txa.leveler.p->tau_decay = (double)decay / 1000.0;
|
||||
txa.leveler.p->tau_decay = (float)decay / 1000.0;
|
||||
loadWcpAGC(txa.leveler.p);
|
||||
txa.csDSP.unlock();
|
||||
}
|
||||
@ -619,15 +619,15 @@ void WCPAGC::SetLevelerDecay (TXA& txa, int decay)
|
||||
void WCPAGC::SetLevelerHang (TXA& txa, int hang)
|
||||
{
|
||||
txa.csDSP.lock();
|
||||
txa.leveler.p->hangtime = (double)hang / 1000.0;
|
||||
txa.leveler.p->hangtime = (float)hang / 1000.0;
|
||||
loadWcpAGC(txa.leveler.p);
|
||||
txa.csDSP.unlock();
|
||||
}
|
||||
|
||||
void WCPAGC::SetLevelerTop (TXA& txa, double maxgain)
|
||||
void WCPAGC::SetLevelerTop (TXA& txa, float maxgain)
|
||||
{
|
||||
txa.csDSP.lock();
|
||||
txa.leveler.p->max_gain = pow (10.0,(double)maxgain / 20.0);
|
||||
txa.leveler.p->max_gain = pow (10.0,(float)maxgain / 20.0);
|
||||
loadWcpAGC(txa.leveler.p);
|
||||
txa.csDSP.unlock();
|
||||
}
|
||||
|
@ -46,10 +46,10 @@ public:
|
||||
int run;
|
||||
int mode;
|
||||
int pmode;
|
||||
double* in;
|
||||
double* out;
|
||||
float* in;
|
||||
float* out;
|
||||
int io_buffsize;
|
||||
double sample_rate;
|
||||
float sample_rate;
|
||||
|
||||
double tau_attack;
|
||||
double tau_decay;
|
||||
@ -112,8 +112,8 @@ public:
|
||||
int run,
|
||||
int mode,
|
||||
int pmode,
|
||||
double* in,
|
||||
double* out,
|
||||
float* in,
|
||||
float* out,
|
||||
int io_buffsize,
|
||||
int sample_rate,
|
||||
double tau_attack,
|
||||
@ -135,25 +135,25 @@ public:
|
||||
);
|
||||
static void destroy_wcpagc (WCPAGC *a);
|
||||
static void flush_wcpagc (WCPAGC *a);
|
||||
static void setBuffers_wcpagc (WCPAGC *a, double* in, double* out);
|
||||
static void setBuffers_wcpagc (WCPAGC *a, float* in, float* out);
|
||||
static void setSamplerate_wcpagc (WCPAGC *a, int rate);
|
||||
static void setSize_wcpagc (WCPAGC *a, int size);
|
||||
// RXA Properties
|
||||
static void SetAGCMode (RXA& rxa, int mode);
|
||||
static void SetAGCFixed (RXA& rxa, double fixed_agc);
|
||||
static void SetAGCFixed (RXA& rxa, float fixed_agc);
|
||||
static void SetAGCAttack (RXA& rxa, int attack);
|
||||
static void SetAGCDecay (RXA& rxa, int decay);
|
||||
static void SetAGCHang (RXA& rxa, int hang);
|
||||
static void GetAGCHangLevel(RXA& rxa, double *hangLevel);
|
||||
static void SetAGCHangLevel(RXA& rxa, double hangLevel);
|
||||
static void GetAGCHangLevel(RXA& rxa, float *hangLevel);
|
||||
static void SetAGCHangLevel(RXA& rxa, float hangLevel);
|
||||
static void GetAGCHangThreshold(RXA& rxa, int *hangthreshold);
|
||||
static void SetAGCHangThreshold (RXA& rxa, int hangthreshold);
|
||||
static void GetAGCTop(RXA& rxa, double *max_agc);
|
||||
static void SetAGCTop (RXA& rxa, double max_agc);
|
||||
static void GetAGCTop(RXA& rxa, float *max_agc);
|
||||
static void SetAGCTop (RXA& rxa, float max_agc);
|
||||
static void SetAGCSlope (RXA& rxa, int slope);
|
||||
static void SetAGCThresh(RXA& rxa, double thresh, double size, double rate);
|
||||
static void GetAGCThresh(RXA& rxa, double *thresh, double size, double rate);
|
||||
static void SetAGCMaxInputLevel (RXA& rxa, double level);
|
||||
static void SetAGCThresh(RXA& rxa, float thresh, float size, float rate);
|
||||
static void GetAGCThresh(RXA& rxa, float *thresh, float size, float rate);
|
||||
static void SetAGCMaxInputLevel (RXA& rxa, float level);
|
||||
// TXA Properties
|
||||
static void SetALCSt (TXA& txa, int state);
|
||||
static void SetALCAttack (TXA& txa, int attack);
|
||||
@ -163,8 +163,8 @@ public:
|
||||
static void SetLevelerAttack (TXA& txa, int attack);
|
||||
static void SetLevelerDecay (TXA& txa, int decay);
|
||||
static void SetLevelerHang (TXA& txa, int hang);
|
||||
static void SetLevelerTop (TXA& txa, double maxgain);
|
||||
static void SetALCMaxGain (TXA& txa, double maxgain);
|
||||
static void SetLevelerTop (TXA& txa, float maxgain);
|
||||
static void SetALCMaxGain (TXA& txa, float maxgain);
|
||||
|
||||
private:
|
||||
static void calc_wcpagc (WCPAGC *a);
|
||||
|
Loading…
x
Reference in New Issue
Block a user