GNU Radio 3.6.4.2 C++ API
gr::filter::pfb_arb_resampler_ccf Class Referenceabstract

Polyphase filterbank arbitrary resampler with gr_complex input, gr_complex output and float taps. More...

#include <pfb_arb_resampler_ccf.h>

Inheritance diagram for gr::filter::pfb_arb_resampler_ccf:
gr_block gr::filter::pfb_arb_resampler_ccf_impl

Public Types

typedef boost::shared_ptr
< pfb_arb_resampler_ccf
sptr
 
- Public Types inherited from gr_block
enum  { WORK_CALLED_PRODUCE = -2, WORK_DONE = -1 }
 Return options for the work call. More...
 
enum  tag_propagation_policy_t { TPP_DONT = 0, TPP_ALL_TO_ALL = 1, TPP_ONE_TO_ONE = 2 }
 
typedef std::deque< pmt::pmt_tmsg_queue_t
 
typedef std::map< pmt::pmt_t,
msg_queue_t,
pmt::pmt_comperator
msg_queue_map_t
 
typedef std::map< pmt::pmt_t,
msg_queue_t,
pmt::pmt_comperator >
::iterator 
msg_queue_map_itr
 
typedef boost::function< void(pmt::pmt_t)> msg_handler_t
 
typedef std::map< pmt::pmt_t,
msg_handler_t,
pmt::pmt_comperator
d_msg_handlers_t
 

Public Member Functions

virtual void set_taps (const std::vector< float > &taps)=0
 
virtual std::vector
< std::vector< float > > 
taps () const =0
 
virtual void print_taps ()=0
 
virtual void set_rate (float rate)=0
 
virtual void set_phase (float ph)=0
 
virtual float phase () const =0
 
- Public Member Functions inherited from gr_block
 gr_block (void)
 
 gr_block (const std::string &name, gr_io_signature_sptr input_signature, gr_io_signature_sptr output_signature)
 
long unique_id (void) const
 
std::string name (void) const
 
virtual ~gr_block (void)
 
gr_io_signature_sptr input_signature (void) const
 
gr_io_signature_sptr output_signature (void) const
 
void set_input_signature (gr_io_signature_sptr sig)
 
void set_output_signature (gr_io_signature_sptr sig)
 
virtual bool check_topology (int ninputs, int noutputs)
 
virtual void forecast (int, std::vector< int > &)
 Overload me! I am the forecast. More...
 
virtual int general_work (int noutput_items, gr_vector_int &ninput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items)
 compute output items from input items More...
 
virtual bool start (void)
 
virtual bool stop (void)
 
void consume_each (const int how_many_items)
 Call during work to consume items. More...
 
void consume (const size_t i, const int how_many_items)
 
void produce (const size_t o, const int how_many_items)
 
uint64_t nitems_read (const size_t which_input=0)
 Get absolute count of all items consumed on the given input port. More...
 
uint64_t nitems_written (const size_t which_output=0)
 Get absolute count of all items produced on the given output port. More...
 
void add_item_tag (const size_t which_output, const gr_tag_t &tag)
 
void add_item_tag (const size_t which_output, uint64_t abs_offset, const pmt::pmt_t &key, const pmt::pmt_t &value, const pmt::pmt_t &srcid=pmt::PMT_F)
 
void get_tags_in_range (std::vector< gr_tag_t > &tags, const size_t which_input, uint64_t abs_start, uint64_t abs_end, const pmt::pmt_t &key=pmt::pmt_t())
 
void set_alignment (const size_t alignment)
 
bool is_unaligned (void)
 
size_t fixed_rate_noutput_to_ninput (const size_t noutput_items)
 
size_t interpolation (void) const
 
void set_interpolation (const size_t)
 
size_t decimation (void) const
 
void set_decimation (const size_t)
 
int max_noutput_items (void) const
 
void set_max_noutput_items (int)
 
void unset_max_noutput_items (void)
 
bool is_set_max_noutput_items (void) const
 
unsigned history (void) const
 
void set_history (unsigned history)
 
void set_fixed_rate (const bool fixed_rate)
 
bool fixed_rate (void) const
 Get the fixed rate setting. More...
 
void set_relative_rate (const double relative_rate)
 
double relative_rate (void) const
 Get the relative rate setting. More...
 
void set_output_multiple (const size_t multiple)
 
size_t output_multiple (void) const
 Get the output multiple setting. More...
 
tag_propagation_policy_t tag_propagation_policy (void)
 
void set_tag_propagation_policy (tag_propagation_policy_t p)
 
void set_max_output_buffer (long)
 
void set_max_output_buffer (int, long)
 
long max_output_buffer (size_t)
 
void set_min_output_buffer (long)
 
void set_min_output_buffer (int, long)
 
long min_output_buffer (size_t)
 
std::string symbol_name () const
 
bool alias_set ()
 
std::string alias ()
 
pmt::pmt_t alias_pmt ()
 
void set_block_alias (std::string name)
 
template<typename T >
void set_msg_handler (pmt::pmt_t which_port, T msg_handler)
 
void message_port_register_in (pmt::pmt_t)
 
void message_port_register_out (pmt::pmt_t)
 
void message_port_pub (pmt::pmt_t, pmt::pmt_t)
 
void message_port_sub (pmt::pmt_t, pmt::pmt_t)
 
void message_port_unsub (pmt::pmt_t, pmt::pmt_t)
 
virtual bool message_port_is_hier (pmt::pmt_t port_id)
 
virtual bool message_port_is_hier_in (pmt::pmt_t port_id)
 
virtual bool message_port_is_hier_out (pmt::pmt_t port_id)
 
pmt::pmt_t message_ports_in ()
 Get input message port names. More...
 
pmt::pmt_t message_ports_out ()
 Get output message port names. More...
 
bool empty_p (pmt::pmt_t which_port)
 is the queue empty? More...
 
bool empty_p ()
 
void insert_tail (pmt::pmt_t, pmt::pmt_t)
 
pmt::pmt_t delete_head_nowait (pmt::pmt_t)
 
pmt::pmt_t delete_head_blocking (pmt::pmt_t)
 
msg_queue_t::iterator get_iterator (pmt::pmt_t which_port)
 
void erase_msg (pmt::pmt_t which_port, msg_queue_t::iterator it)
 
virtual bool has_msg_port (pmt::pmt_t which_port)
 
bool has_msg_handler (pmt::pmt_t which_port)
 Tests if there is a handler attached to port which_port. More...
 
virtual void dispatch_msg (pmt::pmt_t which_port, pmt::pmt_t msg)
 
void set_processor_affinity (const std::vector< int > &mask)
 Set the thread's affinity to processor core n. More...
 
void unset_processor_affinity ()
 Remove processor affinity to a specific core. More...
 
std::vector< int > processor_affinity ()
 Get the current processor affinity. More...
 
void work (const InputItems &, const OutputItems &)
 implements work -> calls general work More...
 
void notify_topology (const size_t, const size_t)
 notifications of new topological commits More...
 
void notify_active (void)
 start notification More...
 
void notify_inactive (void)
 stop notification More...
 
virtual void propagate_tags (const size_t, const gras::TagIter &)
 implements tag_propagation_policy() More...
 
void _update_input_reserve (void)
 
gras::BufferQueueSptr input_buffer_allocator (const size_t, const gras::SBufferConfig &)
 
gras::BufferQueueSptr output_buffer_allocator (const size_t, const gras::SBufferConfig &)
 

Static Public Member Functions

static sptr make (float rate, const std::vector< float > &taps, unsigned int filter_size=32)
 

Additional Inherited Members

- Public Attributes inherited from gr_block
long _unique_id
 
std::string _name
 
std::string d_symbol_alias
 
std::string d_symbol_name
 
msg_queue_map_t msg_queue
 
pmt::pmt_t message_subscribers
 
d_msg_handlers_t d_msg_handlers
 
gruel::mutex d_setlock
 
std::vector< int > d_affinity
 
gr_vector_int _work_ninput_items
 
gr_vector_int _fcast_ninput_items
 
size_t _num_outputs
 
ptrdiff_t _work_io_ptr_mask
 
size_t _output_multiple_items
 
double _relative_rate
 
bool _enable_fixed_rate
 
size_t _input_history_items
 
tag_propagation_policy_t _tag_prop_policy
 
size_t _interp
 
size_t _decim
 
gr_io_signature_sptr _in_sig
 
gr_io_signature_sptr _out_sig
 

Detailed Description

Polyphase filterbank arbitrary resampler with gr_complex input, gr_complex output and float taps.

This block takes in a signal stream and performs arbitrary resampling. The resampling rate can be any real number r. The resampling is done by constructing N filters where N is the interpolation rate. We then calculate D where D = floor(N/r).

Using N and D, we can perform rational resampling where N/D is a rational number close to the input rate r where we have N filters and we cycle through them as a polyphase filterbank with a stride of D so that i+1 = (i + D) % N.

To get the arbitrary rate, we want to interpolate between two points. For each value out, we take an output from the current filter, i, and the next filter i+1 and then linearly interpolate between the two based on the real resampling rate we want.

The linear interpolation only provides us with an approximation to the real sampling rate specified. The error is a quantization error between the two filters we used as our interpolation points. To this end, the number of filters, N, used determines the quantization error; the larger N, the smaller the noise. You can design for a specified noise floor by setting the filter size (parameters filter_size). The size defaults to 32 filters, which is about as good as most implementations need.

The trick with designing this filter is in how to specify the taps of the prototype filter. Like the PFB interpolator, the taps are specified using the interpolated filter rate. In this case, that rate is the input sample rate multiplied by the number of filters in the filterbank, which is also the interpolation rate. All other values should be relative to this rate.

For example, for a 32-filter arbitrary resampler and using the GNU Radio's firdes utility to build the filter, we build a low-pass filter with a sampling rate of fs, a 3-dB bandwidth of BW and a transition bandwidth of TB. We can also specify the out-of-band attenuation to use, ATT, and the filter window function (a Blackman-harris window in this case). The first input is the gain of the filter, which we specify here as the interpolation rate (32).

self._taps = filter.firdes.low_pass_2(32, 32*fs, BW, TB, attenuation_dB=ATT, window=filter.firdes.WIN_BLACKMAN_hARRIS)

The theory behind this block can be found in Chapter 7.5 of the following book.

f. harris, "Multirate Signal Processing for Communication Systems", Upper Saddle River, NJ: Prentice Hall, Inc. 2004.

Member Typedef Documentation

Member Function Documentation

static sptr gr::filter::pfb_arb_resampler_ccf::make ( float  rate,
const std::vector< float > &  taps,
unsigned int  filter_size = 32 
)
static

Build the polyphase filterbank arbitray resampler.

Parameters
rate(float) Specifies the resampling rate to use
taps(vector/list of floats) The prototype filter to populate the filterbank. The taps should be generated at the filter_size sampling rate.
filter_size(unsigned int) The number of filters in the filter bank. This is directly related to quantization noise introduced during the resampling. Defaults to 32 filters.
virtual float gr::filter::pfb_arb_resampler_ccf::phase ( ) const
pure virtual

Gets the current phase of the resampler in radians (2 to 2pi).

Implemented in gr::filter::pfb_arb_resampler_ccf_impl.

virtual void gr::filter::pfb_arb_resampler_ccf::print_taps ( )
pure virtual

Print all of the filterbank taps to screen.

Implemented in gr::filter::pfb_arb_resampler_ccf_impl.

virtual void gr::filter::pfb_arb_resampler_ccf::set_phase ( float  ph)
pure virtual

Sets the current phase offset in radians (0 to 2pi).

Implemented in gr::filter::pfb_arb_resampler_ccf_impl.

virtual void gr::filter::pfb_arb_resampler_ccf::set_rate ( float  rate)
pure virtual

Sets the resampling rate of the block.

Implemented in gr::filter::pfb_arb_resampler_ccf_impl.

virtual void gr::filter::pfb_arb_resampler_ccf::set_taps ( const std::vector< float > &  taps)
pure virtual

Resets the filterbank's filter taps with the new prototype filter

Parameters
taps(vector/list of floats) The prototype filter to populate the filterbank.

Implemented in gr::filter::pfb_arb_resampler_ccf_impl.

virtual std::vector<std::vector<float> > gr::filter::pfb_arb_resampler_ccf::taps ( ) const
pure virtual

Return a vector<vector<>> of the filterbank taps

Implemented in gr::filter::pfb_arb_resampler_ccf_impl.


The documentation for this class was generated from the following file: