Working Kerr effect; PDM; speedups; removed unused files
[4yp.git] / rxFilter.m
index eb25a32..e8e572a 100644 (file)
@@ -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