13 #include <boost/scoped_array.hpp> 26 typedef std::shared_ptr<filter_info_base>
sptr;
27 enum filter_type { ANALOG_LOW_PASS, ANALOG_BAND_PASS, DIGITAL_I16, DIGITAL_FIR_I16 };
30 : _type(type), _bypass(bypass), _position_index(position_index)
50 virtual std::string to_pp_string();
62 std::string _analog_type;
65 typedef std::shared_ptr<analog_filter_base>
sptr;
68 size_t position_index,
69 const std::string& analog_type)
80 std::string to_pp_string()
override;
89 typedef std::shared_ptr<analog_filter_lp>
sptr;
92 size_t position_index,
93 const std::string& analog_type,
118 std::string to_pp_string()
override;
121 template <
typename tap_t>
133 typedef std::shared_ptr<digital_filter_base>
sptr;
136 size_t position_index,
138 uint32_t interpolation,
140 tap_t tap_full_scale,
141 uint32_t max_num_taps,
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 std::shared_ptr<digital_filter_fir<tap_t>>
sptr;
215 size_t position_index,
217 uint32_t interpolation,
220 uint32_t max_num_taps,
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()
filter_type _type
Definition: filters.hpp:53
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
UHD_INLINE uint32_t get_interpolation()
Definition: filters.hpp:164
UHD_INLINE const std::string & get_analog_type()
Definition: filters.hpp:75
uint32_t _decimation
Definition: filters.hpp:127
virtual UHD_INLINE bool is_bypassed()
Definition: filters.hpp:35
UHD_INLINE uint32_t get_decimation()
Definition: filters.hpp:169
#define UHD_API_HEADER
Definition: config.h:88
digital_filter_fir(filter_info_base::filter_type type, bool bypass, size_t position_index, double rate, uint32_t interpolation, uint32_t decimation, tap_t tap_bit_width, uint32_t max_num_taps, const std::vector< tap_t > &taps)
Definition: filters.hpp:213
tap_t _tap_full_scale
Definition: filters.hpp:128
Definition: filters.hpp:122
bool _bypass
Definition: filters.hpp:54
Definition: filters.hpp:60
UHD_INLINE void set_cutoff(const double cutoff)
Definition: filters.hpp:113
std::shared_ptr< analog_filter_lp > sptr
Definition: filters.hpp:89
Definition: build_info.hpp:12
void set_taps(const std::vector< tap_t > &taps)
Definition: filters.hpp:235
Definition: filters.hpp:23
UHD_INLINE double get_rolloff()
Definition: filters.hpp:108
UHD_INLINE double get_input_rate()
Definition: filters.hpp:159
Definition: filters.hpp:83
UHD_API_HEADER std::ostream & operator<<(std::ostream &os, filter_info_base &f)
analog_filter_base(filter_type type, bool bypass, size_t position_index, const std::string &analog_type)
Definition: filters.hpp:66
virtual ~filter_info_base()
Definition: filters.hpp:45
UHD_INLINE uint32_t get_tap_full_scale()
Definition: filters.hpp:174
#define UHD_INLINE
Definition: config.h:65
analog_filter_lp(filter_type type, bool bypass, size_t position_index, const std::string &analog_type, double cutoff, double rolloff)
Definition: filters.hpp:90
std::shared_ptr< analog_filter_base > sptr
Definition: filters.hpp:65
size_t _position_index
Definition: filters.hpp:55
std::shared_ptr< filter_info_base > sptr
Definition: filters.hpp:26
#define UHD_API
Definition: config.h:87
filter_type
Definition: filters.hpp:27
filter_info_base(filter_type type, bool bypass, size_t position_index)
Definition: filters.hpp:29
std::shared_ptr< digital_filter_fir< tap_t > > sptr
Definition: filters.hpp:211
digital_filter_base(filter_type type, bool bypass, size_t position_index, double rate, uint32_t interpolation, uint32_t decimation, tap_t tap_full_scale, uint32_t max_num_taps, const std::vector< tap_t > &taps)
Definition: filters.hpp:134
uint32_t _interpolation
Definition: filters.hpp:126
std::string to_pp_string() override
Definition: filters.hpp:184
UHD_INLINE double get_cutoff()
Definition: filters.hpp:103
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:272
UHD_INLINE filter_type get_type()
Definition: filters.hpp:40
std::shared_ptr< digital_filter_base > sptr
Definition: filters.hpp:133