18 #ifndef INCLUDED_UHD_TYPES_FILTERS_HPP 19 #define INCLUDED_UHD_TYPES_FILTERS_HPP 24 #include <boost/cstdint.hpp> 25 #include <boost/shared_ptr.hpp> 26 #include <boost/scoped_array.hpp> 38 typedef boost::shared_ptr<filter_info_base>
sptr;
52 _type(type), _bypass(bypass),
53 _position_index(position_index)
73 virtual std::string to_pp_string();
86 std::string _analog_type;
88 typedef boost::shared_ptr<analog_filter_base>
sptr;
92 size_t position_index,
93 const std::string& analog_type
96 _analog_type(analog_type)
106 virtual std::string to_pp_string();
115 typedef boost::shared_ptr<analog_filter_lp>
sptr;
119 size_t position_index,
120 const std::string& analog_type,
146 virtual std::string to_pp_string();
149 template<
typename tap_t>
161 typedef boost::shared_ptr<digital_filter_base>
sptr;
165 size_t position_index,
167 size_t interpolation,
169 double tap_full_scale,
171 const std::vector<tap_t>& taps
175 _interpolation(interpolation),
176 _decimation(decimation),
177 _tap_full_scale(tap_full_scale),
178 _max_num_taps(max_num_taps),
186 return (_bypass ? _rate : (_rate / _decimation * _interpolation));
196 return _interpolation;
206 return _tap_full_scale;
216 std::ostringstream os;
218 "\t[digital_filter_base]"<<std::endl<<
219 "\tinput rate: "<<_rate<<std::endl<<
220 "\tinterpolation: "<<_interpolation<<std::endl<<
221 "\tdecimation: "<<_decimation<<std::endl<<
222 "\tfull-scale: "<<_tap_full_scale<<std::endl<<
223 "\tmax num taps: "<<_max_num_taps<<std::endl<<
224 "\ttaps: "<<std::endl;
227 for(
size_t i = 0; i < _taps.size(); i++)
229 os<<
"(tap "<<i<<
": "<<_taps[i]<<
")";
230 if( ((i%10) == 0) && (i != 0))
232 os<<std::endl<<
"\t\t";
236 return std::string(os.str());
241 template<
typename tap_t>
245 typedef boost::shared_ptr<digital_filter_fir<tap_t> >
sptr;
249 bool bypass,
size_t position_index,
251 size_t interpolation,
253 size_t tap_bit_width,
255 const std::vector<tap_t>& taps
257 digital_filter_base<tap_t>(type, bypass, position_index, rate, interpolation, decimation, tap_bit_width, max_num_taps, taps)
264 std::size_t num_taps = taps.size();
265 if(num_taps < this->_max_num_taps){
266 UHD_MSG(
warning) <<
"digital_filter_fir::set_taps not enough coefficients. Appending zeros";
267 std::vector<tap_t> coeffs;
268 for (
size_t i = 0; i < this->_max_num_taps; i++)
272 coeffs.push_back(taps[i]);
277 this->_taps = coeffs;
virtual std::string to_pp_string()
boost::shared_ptr< digital_filter_fir< tap_t > > sptr
Definition: filters.hpp:245
filter_type _type
Definition: filters.hpp:76
Definition: filters.hpp:242
UHD_INLINE std::vector< tap_t > & get_taps()
Definition: filters.hpp:209
std::vector< tap_t > _taps
Definition: filters.hpp:158
boost::shared_ptr< analog_filter_base > sptr
Definition: filters.hpp:88
virtual std::string to_pp_string()
Definition: filters.hpp:214
UHD_INLINE const std::string & get_analog_type()
Definition: filters.hpp:101
UHD_INLINE double get_decimation()
Definition: filters.hpp:199
UHD_INLINE double get_interpolation()
Definition: filters.hpp:194
virtual UHD_INLINE bool is_bypassed()
Definition: filters.hpp:58
tap_t _tap_full_scale
Definition: filters.hpp:156
Definition: filters.hpp:150
bool _bypass
Definition: filters.hpp:77
Definition: filters.hpp:84
UHD_INLINE void set_cutoff(const double cutoff)
Definition: filters.hpp:141
Definition: build_info.hpp:25
void set_taps(const std::vector< tap_t > &taps)
Definition: filters.hpp:262
digital_filter_base(filter_type type, bool bypass, size_t position_index, double rate, size_t interpolation, size_t decimation, double tap_full_scale, size_t max_num_taps, const std::vector< tap_t > &taps)
Definition: filters.hpp:162
Definition: filters.hpp:35
UHD_INLINE double get_rolloff()
Definition: filters.hpp:136
boost::shared_ptr< filter_info_base > sptr
Definition: filters.hpp:38
#define UHD_MSG(type)
Definition: msg.hpp:31
UHD_INLINE double get_input_rate()
Definition: filters.hpp:189
Definition: filters.hpp:109
UHD_INLINE double get_tap_full_scale()
Definition: filters.hpp:204
analog_filter_base(filter_type type, bool bypass, size_t position_index, const std::string &analog_type)
Definition: filters.hpp:89
virtual ~filter_info_base()
Definition: filters.hpp:68
Definition: filters.hpp:41
#define UHD_INLINE
Definition: config.h:63
digital_filter_fir(filter_info_base::filter_type type, bool bypass, size_t position_index, double rate, size_t interpolation, size_t decimation, size_t tap_bit_width, size_t max_num_taps, const std::vector< tap_t > &taps)
Definition: filters.hpp:247
analog_filter_lp(filter_type type, bool bypass, size_t position_index, const std::string &analog_type, double cutoff, double rolloff)
Definition: filters.hpp:116
size_t _position_index
Definition: filters.hpp:78
#define UHD_API
Definition: config.h:73
filter_type
Definition: filters.hpp:39
filter_info_base(filter_type type, bool bypass, size_t position_index)
Definition: filters.hpp:47
boost::shared_ptr< analog_filter_lp > sptr
Definition: filters.hpp:115
UHD_API std::ostream & operator<<(std::ostream &os, filter_info_base &f)
UHD_INLINE double get_cutoff()
Definition: filters.hpp:131
boost::shared_ptr< digital_filter_base > sptr
Definition: filters.hpp:161
UHD_INLINE double get_output_rate()
Definition: filters.hpp:184
Definition: filters.hpp:42
double _rate
Definition: filters.hpp:153
boost::uint32_t _decimation
Definition: filters.hpp:155
UHD_INLINE filter_type get_type()
Definition: filters.hpp:63
boost::uint32_t _interpolation
Definition: filters.hpp:154
Definition: filters.hpp:43
boost::uint32_t _max_num_taps
Definition: filters.hpp:157