diff --git a/plugins/channelrx/demoddatv/leansdr/filtergen.h b/plugins/channelrx/demoddatv/leansdr/filtergen.h index 8d6494e70..75d6de142 100644 --- a/plugins/channelrx/demoddatv/leansdr/filtergen.h +++ b/plugins/channelrx/demoddatv/leansdr/filtergen.h @@ -88,7 +88,7 @@ int lowpass(int order, float Fcut, T **coeffs, float gain = 1) // https://en.wikipedia.org/wiki/Root-raised-cosine_filter template -int root_raised_cosine(int order, float Fs, float rolloff, T **coeffs) +int root_raised_cosine(int order, float Fs, float rolloff, T **coeffs, float gain=1) { float B = rolloff, pi = M_PI; int ncoeffs = (order + 1) | 1; @@ -98,19 +98,18 @@ int root_raised_cosine(int order, float Fs, float rolloff, T **coeffs) int t = i - ncoeffs / 2; float c; if (t == 0) - c = sqrt(Fs) * (1 - B + 4 * B / pi); + c = (1 - B + 4*B/pi); else { float tT = t * Fs; float den = pi * tT * (1 - (4 * B * tT) * (4 * B * tT)); if (!den) - c = B * sqrt(Fs / 2) * ((1 + 2 / pi) * sin(pi / (4 * B)) + (1 - 2 / pi) * cos(pi / (4 * B))); + c = B/sqrtf(2) * ( (1+2/pi)*sinf(pi/(4*B)) + (1-2/pi)*cosf(pi/(4*B)) ); else - c = sqrt(Fs) * (sin(pi * tT * (1 - B)) + 4 * B * tT * cos(pi * tT * (1 + B))) / den; + c = ( sinf(pi*tT*(1-B)) + 4*B*tT*cosf(pi*tT*(1+B)) ) / den; } - (*coeffs)[i] = c; + (*coeffs)[i] = Fs * c * gain; } - normalize_dcgain(ncoeffs, *coeffs); return ncoeffs; }