Setting FIR Taps to None in C++

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(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)

On Fri, Aug 23, 2013 at 07:28:50AM -0400, Luke B wrote:

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?

Luke,

when you’re resampling, you always need FIR filters. Can you confirm
your application really doesn’t need them and that you have fully
understood the theory behind resampling?

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

The filter equivalent of a neutral element would be a Dirac impulse,
i.e. std::vector(1, 1) (In Python notation: (1,) ).

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

As you’ve figured out, it calculates filter taps which work most of the
time. So ‘None’ means ‘choose suitable default values for me’.

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

gcd == greatest common denominator

I recommend you calculate suitable taps a-priori (say, using
gr_filter_design) and import them as a static vector into your code.

MB


Karlsruhe Institute of Technology (KIT)
Communications Engineering Lab (CEL)

Dipl.-Ing. Martin B.
Research Associate

Kaiserstraße 12
Building 05.01
76131 Karlsruhe

Phone: +49 721 608-43790
Fax: +49 721 608-46071
www.cel.kit.edu

KIT – University of the State of Baden-Württemberg and
National Laboratory of the Helmholtz Association

On Fri, Aug 23, 2013 at 11:09 AM, Luke B [email protected] wrote:


I definitely don’t really understand what I am doing. I am more of a
software guy.
It looks like Amazon has a good selection of books on the subject
(including recent titles using GNU gear):
http://www.amazon.com/s/ref=nb_sb_noss_2?url=search-alias%3Dstripbooks&field-keywords=software+defined+radio.

(Sorry to drift OT a bit).

Jeff

On Fri, Aug 23, 2013 at 11:09:46AM -0400, Luke B wrote:

I definitely don’t really understand what I am doing. I am more of a software
guy. Prior to resampling I already used a low-pass filter to get the section of
signal I need. The GRC file I am basing my program off of simply has “[]” for
the taps, so I am assuming a neutral element is needed.

You might be able to fold that filter into the resampler. Makes the
whole thing more efficient.

MB


Karlsruhe Institute of Technology (KIT)
Communications Engineering Lab (CEL)

Dipl.-Ing. Martin B.
Research Associate

Kaiserstraße 12
Building 05.01
76131 Karlsruhe

Phone: +49 721 608-43790
Fax: +49 721 608-46071
www.cel.kit.edu

KIT – University of the State of Baden-Württemberg and
National Laboratory of the Helmholtz Association

when you’re resampling, you always need FIR filters. Can you confirm
your application really doesn’t need them and that you have fully
understood the theory behind resampling?

I definitely don’t really understand what I am doing. I am more of a
software guy. Prior to resampling I already used a low-pass filter to
get
the section of signal I need. The GRC file I am basing my program off of
simply has “[]” for the taps, so I am assuming a neutral element is
needed.

The filter equivalent of a neutral element would be a Dirac impulse,
i.e. std::vector(1, 1) (In Python notation: (1,) ).

I will give this a try and see how it works.

I recommend you calculate suitable taps a-priori (say, using
gr_filter_design) and import them as a static vector into your code.

MB

This sounds like a better option. Thanks! Clearly I have a lot to learn
about RF.

-Luke