X-Git-Url: https://adrianiainlam.tk/git/?p=4yp.git;a=blobdiff_plain;f=rxFilter.m;h=e8e572af85f43b60f586be8dc2694fbe9525fdcb;hp=eb25a32d2ca52449e03f19e43ae864cde0de8454;hb=5fae00773184080617ac022c07495d365975e0e1;hpb=427465905320390cebf3d247b8beace19387c70f diff --git a/rxFilter.m b/rxFilter.m index eb25a32..e8e572a 100644 --- a/rxFilter.m +++ b/rxFilter.m @@ -8,13 +8,23 @@ function r = rxFilter(y, rolloff, span, sps) %% Output: %% - r: filtered signal (energy not normalized), %% normalize and then sample. - filter = comm.RaisedCosineReceiveFilter... + rxfilter = comm.RaisedCosineReceiveFilter... ('Shape', 'Square root', ... 'RolloffFactor', rolloff, ... 'FilterSpanInSymbols', span, ... 'InputSamplesPerSymbol', sps, ... - 'DecimationFactor', 1); + 'DecimationFactor', 4, ... + 'DecimationOffset', mod(span+1, 4)); - r = filter([y; zeros(span * sps, 1)]); - r = r(span * sps / 2 + 1 : end); % truncate filter transients + coef = coeffs(rxfilter); + filter_fft = fft(coef.Numerator, length(y)); + y_fft = fft(y); + + rs = ifft(y_fft .* filter_fft.'); + + %% re-order signal due to circular conv + l = (length(coef.Numerator) - 1) / 2; + rr = [rs(l:end); rs(1:l-1)]; + + r = downsample(rr, 4, 3); end