7 #ifndef INCLUDED_UHD_TYPES_FILTERS_HPP 8 #define INCLUDED_UHD_TYPES_FILTERS_HPP 14 #include <boost/shared_ptr.hpp> 15 #include <boost/scoped_array.hpp> 27 typedef boost::shared_ptr<filter_info_base>
sptr;
41 _type(type), _bypass(bypass),
42 _position_index(position_index)
62 virtual std::string to_pp_string();
75 std::string _analog_type;
77 typedef boost::shared_ptr<analog_filter_base>
sptr;
81 size_t position_index,
82 const std::string& analog_type
85 _analog_type(analog_type)
95 virtual std::string to_pp_string();
104 typedef boost::shared_ptr<analog_filter_lp>
sptr;
108 size_t position_index,
109 const std::string& analog_type,
135 virtual std::string to_pp_string();
138 template<
typename tap_t>
150 typedef boost::shared_ptr<digital_filter_base>
sptr;
154 size_t position_index,
156 size_t interpolation,
158 double tap_full_scale,
160 const std::vector<tap_t>& taps
164 _interpolation(interpolation),
165 _decimation(decimation),
166 _tap_full_scale(tap_full_scale),
167 _max_num_taps(max_num_taps),
175 return (_bypass ? _rate : (_rate / _decimation * _interpolation));
185 return _interpolation;
195 return _tap_full_scale;
205 std::ostringstream os;
207 "\t[digital_filter_base]"<<std::endl<<
208 "\tinput rate: "<<_rate<<std::endl<<
209 "\tinterpolation: "<<_interpolation<<std::endl<<
210 "\tdecimation: "<<_decimation<<std::endl<<
211 "\tfull-scale: "<<_tap_full_scale<<std::endl<<
212 "\tmax num taps: "<<_max_num_taps<<std::endl<<
213 "\ttaps: "<<std::endl;
216 for(
size_t i = 0; i < _taps.size(); i++)
218 os<<
"(tap "<<i<<
": "<<_taps[i]<<
")";
219 if( ((i%10) == 0) && (i != 0))
221 os<<std::endl<<
"\t\t";
225 return std::string(os.str());
230 template<
typename tap_t>
234 typedef boost::shared_ptr<digital_filter_fir<tap_t> >
sptr;
238 bool bypass,
size_t position_index,
240 size_t interpolation,
242 size_t tap_bit_width,
244 const std::vector<tap_t>& taps
246 digital_filter_base<tap_t>(type, bypass, position_index, rate, interpolation, decimation, tap_bit_width, max_num_taps, taps)
253 std::size_t num_taps = taps.size();
254 if(num_taps < this->_max_num_taps){
255 UHD_LOGGER_WARNING(
"FILTERS") <<
"digital_filter_fir::set_taps not enough coefficients. Appending zeros";
256 std::vector<tap_t> coeffs;
257 for (
size_t i = 0; i < this->_max_num_taps; i++)
261 coeffs.push_back(taps[i]);
266 this->_taps = coeffs;
virtual std::string to_pp_string()
boost::shared_ptr< digital_filter_fir< tap_t > > sptr
Definition: filters.hpp:234
filter_type _type
Definition: filters.hpp:65
Definition: filters.hpp:231
UHD_INLINE std::vector< tap_t > & get_taps()
Definition: filters.hpp:198
std::vector< tap_t > _taps
Definition: filters.hpp:147
boost::shared_ptr< analog_filter_base > sptr
Definition: filters.hpp:77
virtual std::string to_pp_string()
Definition: filters.hpp:203
UHD_INLINE const std::string & get_analog_type()
Definition: filters.hpp:90
UHD_INLINE double get_decimation()
Definition: filters.hpp:188
UHD_INLINE double get_interpolation()
Definition: filters.hpp:183
uint32_t _decimation
Definition: filters.hpp:144
virtual UHD_INLINE bool is_bypassed()
Definition: filters.hpp:47
tap_t _tap_full_scale
Definition: filters.hpp:145
Definition: filters.hpp:139
bool _bypass
Definition: filters.hpp:66
Definition: filters.hpp:73
UHD_INLINE void set_cutoff(const double cutoff)
Definition: filters.hpp:130
Definition: build_info.hpp:14
void set_taps(const std::vector< tap_t > &taps)
Definition: filters.hpp:251
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:151
Definition: filters.hpp:24
UHD_INLINE double get_rolloff()
Definition: filters.hpp:125
boost::shared_ptr< filter_info_base > sptr
Definition: filters.hpp:27
UHD_INLINE double get_input_rate()
Definition: filters.hpp:178
Definition: filters.hpp:98
UHD_INLINE double get_tap_full_scale()
Definition: filters.hpp:193
analog_filter_base(filter_type type, bool bypass, size_t position_index, const std::string &analog_type)
Definition: filters.hpp:78
virtual ~filter_info_base()
Definition: filters.hpp:57
Definition: filters.hpp:30
#define UHD_INLINE
Definition: config.h:52
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:236
analog_filter_lp(filter_type type, bool bypass, size_t position_index, const std::string &analog_type, double cutoff, double rolloff)
Definition: filters.hpp:105
size_t _position_index
Definition: filters.hpp:67
#define UHD_API
Definition: config.h:62
filter_type
Definition: filters.hpp:28
filter_info_base(filter_type type, bool bypass, size_t position_index)
Definition: filters.hpp:36
boost::shared_ptr< analog_filter_lp > sptr
Definition: filters.hpp:104
UHD_API std::ostream & operator<<(std::ostream &os, filter_info_base &f)
uint32_t _interpolation
Definition: filters.hpp:143
UHD_INLINE double get_cutoff()
Definition: filters.hpp:120
boost::shared_ptr< digital_filter_base > sptr
Definition: filters.hpp:150
UHD_INLINE double get_output_rate()
Definition: filters.hpp:173
Definition: filters.hpp:31
uint32_t _max_num_taps
Definition: filters.hpp:146
double _rate
Definition: filters.hpp:142
#define UHD_LOGGER_WARNING(component)
Definition: log.hpp:240
UHD_INLINE filter_type get_type()
Definition: filters.hpp:52
Definition: filters.hpp:32