8 #ifndef INCLUDED_UHD_TYPES_FILTERS_HPP 9 #define INCLUDED_UHD_TYPES_FILTERS_HPP 15 #include <boost/shared_ptr.hpp> 16 #include <boost/scoped_array.hpp> 28 typedef boost::shared_ptr<filter_info_base>
sptr;
42 _type(type), _bypass(bypass),
43 _position_index(position_index)
63 virtual std::string to_pp_string();
76 std::string _analog_type;
78 typedef boost::shared_ptr<analog_filter_base>
sptr;
82 size_t position_index,
83 const std::string& analog_type
86 _analog_type(analog_type)
96 virtual std::string to_pp_string();
105 typedef boost::shared_ptr<analog_filter_lp>
sptr;
109 size_t position_index,
110 const std::string& analog_type,
136 virtual std::string to_pp_string();
139 template<
typename tap_t>
151 typedef boost::shared_ptr<digital_filter_base>
sptr;
155 size_t position_index,
157 size_t interpolation,
159 double tap_full_scale,
161 const std::vector<tap_t>& taps
165 _interpolation(interpolation),
166 _decimation(decimation),
167 _tap_full_scale(tap_full_scale),
168 _max_num_taps(max_num_taps),
176 return (_bypass ? _rate : (_rate / _decimation * _interpolation));
186 return _interpolation;
196 return _tap_full_scale;
206 std::ostringstream os;
208 "\t[digital_filter_base]"<<std::endl<<
209 "\tinput rate: "<<_rate<<std::endl<<
210 "\tinterpolation: "<<_interpolation<<std::endl<<
211 "\tdecimation: "<<_decimation<<std::endl<<
212 "\tfull-scale: "<<_tap_full_scale<<std::endl<<
213 "\tmax num taps: "<<_max_num_taps<<std::endl<<
214 "\ttaps: "<<std::endl;
217 for(
size_t i = 0; i < _taps.size(); i++)
219 os<<
"(tap "<<i<<
": "<<_taps[i]<<
")";
220 if( ((i%10) == 0) && (i != 0))
222 os<<std::endl<<
"\t\t";
226 return std::string(os.str());
231 template<
typename tap_t>
235 typedef boost::shared_ptr<digital_filter_fir<tap_t> >
sptr;
239 bool bypass,
size_t position_index,
241 size_t interpolation,
243 size_t tap_bit_width,
245 const std::vector<tap_t>& taps
247 digital_filter_base<tap_t>(type, bypass, position_index, rate, interpolation, decimation, tap_bit_width, max_num_taps, taps)
254 std::size_t num_taps = taps.size();
255 if(num_taps < this->_max_num_taps){
256 UHD_LOGGER_WARNING(
"FILTERS") <<
"digital_filter_fir::set_taps not enough coefficients. Appending zeros";
257 std::vector<tap_t> coeffs;
258 for (
size_t i = 0; i < this->_max_num_taps; i++)
262 coeffs.push_back(taps[i]);
267 this->_taps = coeffs;
virtual std::string to_pp_string()
boost::shared_ptr< digital_filter_fir< tap_t > > sptr
Definition: filters.hpp:235
filter_type _type
Definition: filters.hpp:66
Definition: filters.hpp:232
UHD_INLINE std::vector< tap_t > & get_taps()
Definition: filters.hpp:199
std::vector< tap_t > _taps
Definition: filters.hpp:148
boost::shared_ptr< analog_filter_base > sptr
Definition: filters.hpp:78
virtual std::string to_pp_string()
Definition: filters.hpp:204
UHD_INLINE const std::string & get_analog_type()
Definition: filters.hpp:91
UHD_INLINE double get_decimation()
Definition: filters.hpp:189
UHD_INLINE double get_interpolation()
Definition: filters.hpp:184
uint32_t _decimation
Definition: filters.hpp:145
virtual UHD_INLINE bool is_bypassed()
Definition: filters.hpp:48
tap_t _tap_full_scale
Definition: filters.hpp:146
Definition: filters.hpp:140
bool _bypass
Definition: filters.hpp:67
Definition: filters.hpp:74
UHD_INLINE void set_cutoff(const double cutoff)
Definition: filters.hpp:131
Definition: build_info.hpp:14
void set_taps(const std::vector< tap_t > &taps)
Definition: filters.hpp:252
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:152
Definition: filters.hpp:25
UHD_INLINE double get_rolloff()
Definition: filters.hpp:126
boost::shared_ptr< filter_info_base > sptr
Definition: filters.hpp:28
UHD_INLINE double get_input_rate()
Definition: filters.hpp:179
Definition: filters.hpp:99
UHD_INLINE double get_tap_full_scale()
Definition: filters.hpp:194
analog_filter_base(filter_type type, bool bypass, size_t position_index, const std::string &analog_type)
Definition: filters.hpp:79
virtual ~filter_info_base()
Definition: filters.hpp:58
Definition: filters.hpp:31
#define UHD_INLINE
Definition: config.h:53
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:237
analog_filter_lp(filter_type type, bool bypass, size_t position_index, const std::string &analog_type, double cutoff, double rolloff)
Definition: filters.hpp:106
size_t _position_index
Definition: filters.hpp:68
#define UHD_API
Definition: config.h:63
filter_type
Definition: filters.hpp:29
filter_info_base(filter_type type, bool bypass, size_t position_index)
Definition: filters.hpp:37
boost::shared_ptr< analog_filter_lp > sptr
Definition: filters.hpp:105
UHD_API std::ostream & operator<<(std::ostream &os, filter_info_base &f)
uint32_t _interpolation
Definition: filters.hpp:144
UHD_INLINE double get_cutoff()
Definition: filters.hpp:121
boost::shared_ptr< digital_filter_base > sptr
Definition: filters.hpp:151
UHD_INLINE double get_output_rate()
Definition: filters.hpp:174
Definition: filters.hpp:32
uint32_t _max_num_taps
Definition: filters.hpp:147
double _rate
Definition: filters.hpp:143
#define UHD_LOGGER_WARNING(component)
Definition: log.hpp:241
UHD_INLINE filter_type get_type()
Definition: filters.hpp:53
Definition: filters.hpp:33