Fix RRC amplitude.

work
pabr 2020-01-09 11:38:12 +01:00
rodzic 2ac274f77e
commit dd2d9b9702
1 zmienionych plików z 7 dodań i 8 usunięć

Wyświetl plik

@ -73,7 +73,8 @@ namespace leansdr {
// https://en.wikipedia.org/wiki/Root-raised-cosine_filter
template<typename T>
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;
*coeffs = new T[ncoeffs];
@ -81,20 +82,18 @@ namespace leansdr {
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;
}