[Top][All Lists]

## [Discuss-gnuradio] Setting FIR Taps to None in C++

 From: Luke B Subject: [Discuss-gnuradio] Setting FIR Taps to None in C++ Date: Fri, 23 Aug 2013 07:28:50 -0400

I am writing a GR C++ program I would like to do a simple rate resampling and I don't need to use any FIR filters. Is there a Null Tap or a pass through filter I could use? Would some form of this work?

upsample_audio = gr_make_rational_resampler_base_fff(44100, 8000, std::vector<float>(1,0));

In python you can simply fill in None for the taps:

self.blks2_rational_resampler_xxx_1 = blks2.rational_resampler_ccc(
interpolation=channel_rate,
decimation=pre_channel_rate,
taps=None,
fractional_bw=None,
)

Which uses the following code in block2 - I can't figure out what grc.gcd is though or how to call it from C++:

def design_filter(interpolation, decimation, fractional_bw):

if fractional_bw >= 0.5 or fractional_bw <= 0:
raise ValueError, "Invalid fractional_bandwidth, must be in (0, 0.5)"

beta = 5.0
trans_width = 0.5 - fractional_bw
mid_transition_band = 0.5 - trans_width/2

taps = gr.firdes.low_pass(interpolation,                     # gain
1,                                 # Fs
mid_transition_band/interpolation, # trans mid point
trans_width/interpolation,         # transition width
gr.firdes.WIN_KAISER,
beta                               # beta
)

return taps

and is called this way:

if taps is None and fractional_bw is None:
fractional_bw = 0.4

d = gru.gcd(interpolation, decimation)
interpolation = interpolation // d
decimation = decimation // d

if taps is None:
taps = design_filter(interpolation, decimation, fractional_bw)