mirror of
https://github.com/f4exb/sdrangel.git
synced 2026-08-14 15:33:34 -04:00
WDSP: nigrate to float mostly
This commit is contained in:
+26
-26
@@ -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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user