8 #ifndef INCLUDED_UHD_TYPES_FILTERS_HPP 9 #define INCLUDED_UHD_TYPES_FILTERS_HPP 14 #include <boost/scoped_array.hpp> 15 #include <boost/shared_ptr.hpp> 27 typedef boost::shared_ptr<filter_info_base>
sptr;
28 enum filter_type { ANALOG_LOW_PASS, ANALOG_BAND_PASS, DIGITAL_I16, DIGITAL_FIR_I16 };
31 : _type(type), _bypass(bypass), _position_index(position_index)
51 virtual std::string to_pp_string();
63 std::string _analog_type;
66 typedef boost::shared_ptr<analog_filter_base>
sptr;
69 size_t position_index,
70 const std::string& analog_type)
81 virtual std::string to_pp_string();
90 typedef boost::shared_ptr<analog_filter_lp>
sptr;
93 size_t position_index,
94 const std::string& analog_type,
119 virtual std::string to_pp_string();
133 typedef boost::shared_ptr<digital_filter_base>
sptr;
136 size_t position_index,
138 size_t interpolation,
140 double tap_full_scale,
142 const std::vector<tap_t>& taps)
145 , _interpolation(interpolation)
146 , _decimation(decimation)
147 , _tap_full_scale(tap_full_scale)
148 , _max_num_taps(max_num_taps)
156 return (_bypass ? _rate : (_rate / _decimation * _interpolation));
166 return _interpolation;
176 return _tap_full_scale;
186 std::ostringstream os;
188 <<
"\tinput rate: " << _rate << std::endl
189 <<
"\tinterpolation: " << _interpolation << std::endl
190 <<
"\tdecimation: " << _decimation << std::endl
191 <<
"\tfull-scale: " << _tap_full_scale << std::endl
192 <<
"\tmax num taps: " << _max_num_taps << std::endl
193 <<
"\ttaps: " << std::endl;
196 for (
size_t i = 0; i < _taps.size(); i++) {
197 os <<
"(tap " << i <<
": " << _taps[i] <<
")";
198 if (((i % 10) == 0) && (i != 0)) {
199 os << std::endl <<
"\t\t";
203 return std::string(os.str());
207 template <
typename tap_t>
211 typedef boost::shared_ptr<digital_filter_fir<tap_t> >
sptr;
215 size_t position_index,
217 size_t interpolation,
219 size_t tap_bit_width,
221 const std::vector<tap_t>& taps)
237 std::size_t num_taps = taps.size();
238 if (num_taps < this->_max_num_taps) {
240 "coefficients. Appending zeros";
241 std::vector<tap_t> coeffs;
242 for (
size_t i = 0; i < this->_max_num_taps; i++) {
244 coeffs.push_back(taps[i]);
249 this->_taps = coeffs;
virtual std::string to_pp_string()
boost::shared_ptr< digital_filter_fir< tap_t > > sptr
Definition: filters.hpp:211
filter_type _type
Definition: filters.hpp:54
Definition: filters.hpp:208
UHD_INLINE std::vector< tap_t > & get_taps()
Definition: filters.hpp:179
std::vector< tap_t > _taps
Definition: filters.hpp:130
boost::shared_ptr< analog_filter_base > sptr
Definition: filters.hpp:66
virtual std::string to_pp_string()
Definition: filters.hpp:184
UHD_INLINE const std::string & get_analog_type()
Definition: filters.hpp:76
UHD_INLINE double get_decimation()
Definition: filters.hpp:169
UHD_INLINE double get_interpolation()
Definition: filters.hpp:164
uint32_t _decimation
Definition: filters.hpp:127
virtual UHD_INLINE bool is_bypassed()
Definition: filters.hpp:36
tap_t _tap_full_scale
Definition: filters.hpp:128
Definition: filters.hpp:122
bool _bypass
Definition: filters.hpp:55
Definition: filters.hpp:61
UHD_INLINE void set_cutoff(const double cutoff)
Definition: filters.hpp:114
Definition: build_info.hpp:13
void set_taps(const std::vector< tap_t > &taps)
Definition: filters.hpp:235
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:134
Definition: filters.hpp:24
UHD_INLINE double get_rolloff()
Definition: filters.hpp:109
boost::shared_ptr< filter_info_base > sptr
Definition: filters.hpp:27
UHD_INLINE double get_input_rate()
Definition: filters.hpp:159
Definition: filters.hpp:84
UHD_INLINE double get_tap_full_scale()
Definition: filters.hpp:174
analog_filter_base(filter_type type, bool bypass, size_t position_index, const std::string &analog_type)
Definition: filters.hpp:67
virtual ~filter_info_base()
Definition: filters.hpp:46
#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:213
analog_filter_lp(filter_type type, bool bypass, size_t position_index, const std::string &analog_type, double cutoff, double rolloff)
Definition: filters.hpp:91
size_t _position_index
Definition: filters.hpp:56
#define UHD_API
Definition: config.h:68
filter_type
Definition: filters.hpp:28
filter_info_base(filter_type type, bool bypass, size_t position_index)
Definition: filters.hpp:30
boost::shared_ptr< analog_filter_lp > sptr
Definition: filters.hpp:90
UHD_API std::ostream & operator<<(std::ostream &os, filter_info_base &f)
uint32_t _interpolation
Definition: filters.hpp:126
UHD_INLINE double get_cutoff()
Definition: filters.hpp:104
boost::shared_ptr< digital_filter_base > sptr
Definition: filters.hpp:133
UHD_INLINE double get_output_rate()
Definition: filters.hpp:154
uint32_t _max_num_taps
Definition: filters.hpp:129
double _rate
Definition: filters.hpp:125
#define UHD_LOGGER_WARNING(component)
Definition: log.hpp:239
UHD_INLINE filter_type get_type()
Definition: filters.hpp:41