**diff options**

author | Thomas Tsou <tom@tsou.cc> | 2013-08-20 20:54:54 -0400 |
---|---|---|

committer | Thomas Tsou <tom@tsou.cc> | 2013-10-18 13:10:17 -0400 |

commit | 03e6ecf9771ea029e69fd4cdc2f2e289e93d3978 (patch) | |

tree | 9bd4abdc74ba979a051386b1d730378ae254bdab /Transceiver52M/Resampler.h | |

parent | 3eaae80c90752abe3173c43a5dae5cdf17493764 (diff) |

Transceiver52M: Replace resampler with SSE enabled implementation

Replace the polyphase filter and resampler with a separate
implementation using SSE enabled convolution. The USRP2 (including
derived devices N200, N210) are the only supported devices that
require sample rate conversion, so set the default resampling
parameters for the 100 MHz FPGA clock. This changes the previous
resampling ratios.
270.833 kHz -> 400 kHz (65 / 96)
270.833 kHz -> 390.625 kHz (52 / 75)
The new resampling factor uses a USRP resampling factor of 256
instead of 250. On the device, this allows two halfband filters to
be used rather than one. The end result is reduced distortial and
aliasing effecits from CIC filter rolloff.
B100 and USRP1 will no be supported at 400 ksps with these changes.
Signed-off-by: Thomas Tsou <tom@tsou.cc>

Diffstat (limited to 'Transceiver52M/Resampler.h')

-rw-r--r-- | Transceiver52M/Resampler.h | 77 |

1 files changed, 77 insertions, 0 deletions

diff --git a/Transceiver52M/Resampler.h b/Transceiver52M/Resampler.h new file mode 100644 index 0000000..cf2defd --- /dev/null +++ b/Transceiver52M/Resampler.h @@ -0,0 +1,77 @@ +/* + * Rational Sample Rate Conversion + * Copyright (C) 2012, 2013 Thomas Tsou <tom@tsou.cc> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef _RESAMPLER_H_ +#define _RESAMPLER_H_ + +class Resampler { +public: + /* Constructor for rational sample rate conversion + * @param p numerator of resampling ratio + * @param q denominator of resampling ratio + * @param filt_len length of each polyphase subfilter + */ + Resampler(size_t p, size_t q, size_t filt_len = 16); + ~Resampler(); + + /* Initilize resampler filterbank. + * @param bw bandwidth factor on filter generation (pre-window) + * @return false on error, zero otherwise + * + * Automatic setting is to compute the filter to prevent aliasing with + * a Blackman-Harris window. Adjustment is made through a bandwith + * factor to shift the cutoff and/or the constituent filter lengths. + * Calculation of specific rolloff factors or 3-dB cutoff points is + * left as an excersize for the reader. + */ + bool init(float bw = 1.0f); + + /* Rotate "commutator" and drive samples through filterbank + * @param in continuous buffer of input complex float values + * @param in_len input buffer length + * @param out continuous buffer of output complex float values + * @param out_len output buffer length + * @return number of samples outputted, negative on error + * + * Input and output vector lengths must of be equal multiples of the + * rational conversion rate denominator and numerator respectively. + */ + int rotate(float *in, size_t in_len, float *out, size_t out_len); + + /* Get filter length + * @return number of taps in each filter partition + */ + size_t len(); + +private: + size_t p; + size_t q; + size_t filt_len; + size_t *in_index; + size_t *out_path; + + float **partitions; + float *history; + + bool initFilters(float bw); + void releaseFilters(); + void computePath(); +}; + +#endif /* _RESAMPLER_H_ */ |