diff --git a/wdsp/resample.cpp b/wdsp/resample.cpp index 7eb94cd7b..6cc1b845a 100644 --- a/wdsp/resample.cpp +++ b/wdsp/resample.cpp @@ -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 float[a->ncoef]; // (float *)malloc0(a->ncoef * sizeof(float)); + a->h = new double[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 float[a->ringsize]; // (float *)malloc0(a->ringsize * sizeof(complex)); + a->ring = new double[a->ringsize]; // (float *)malloc0(a->ringsize * sizeof(complex)); a->idx_in = a->ringsize - 1; a->phnum = 0; delete[] (impulse); @@ -88,7 +88,17 @@ void RESAMPLE::decalc_resample (RESAMPLE *a) delete[] (a->h); } -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* RESAMPLE::create_resample ( + int run, + int size, + float* in, + float* out, + int in_rate, + int out_rate, + double fc, + int ncoef, + double gain +) { RESAMPLE *a = new RESAMPLE; @@ -116,7 +126,7 @@ void RESAMPLE::destroy_resample (RESAMPLE *a) void RESAMPLE::flush_resample (RESAMPLE *a) { - memset (a->ring, 0, a->ringsize * sizeof (wcomplex)); + std::fill(a->ring, a->ring + 2 * a->ringsize, 0); a->idx_in = a->ringsize - 1; a->phnum = 0; } @@ -129,7 +139,7 @@ int RESAMPLE::xresample (RESAMPLE *a) { int i, j, n; int idx_out; - float I, Q; + double I, Q; for (i = 0; i < a->size; i++) { diff --git a/wdsp/resample.hpp b/wdsp/resample.hpp index 47b2fb44d..5933ec1ef 100644 --- a/wdsp/resample.hpp +++ b/wdsp/resample.hpp @@ -47,22 +47,32 @@ public: float* out; // output buffer for resampler int in_rate; int out_rate; - float fcin; - float fc; - float fc_low; - float gain; + double fcin; + double fc; + double fc_low; + double gain; int idx_in; // index for input into ring int ncoefin; int ncoef; // number of coefficients int L; // interpolation factor int M; // decimation factor - float* h; // coefficients + double* h; // coefficients int ringsize; // number of complex pairs the ring buffer holds - float* ring; // ring buffer + double* ring; // ring buffer int cpp; // coefficients of the phase int phnum; // phase number - 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 RESAMPLE* create_resample ( + int run, + int size, + float* in, + float* out, + int in_rate, + int out_rate, + double fc, + int ncoef, + double gain + ); static void destroy_resample (RESAMPLE *a); static void flush_resample (RESAMPLE *a); static int xresample (RESAMPLE *a); diff --git a/wdsp/snba.cpp b/wdsp/snba.cpp index 76fbb15a7..b1bc61a7d 100644 --- a/wdsp/snba.cpp +++ b/wdsp/snba.cpp @@ -58,7 +58,8 @@ void SNBA::calc_snba (SNBA *d) d->inresamp = RESAMPLE::create_resample ( d->resamprun, - d->bsize, d->in, + d->bsize, + d->in, d->inbuff, d->inrate, d->internalrate,