id: low_pass_filter
label: Low Pass Filter
flags: [ python, cpp ]

parameters:
-   id: type
    label: FIR Type
    dtype: enum
    options: [fir_filter_ccf, interp_fir_filter_ccf, fir_filter_fff, interp_fir_filter_fff]
    option_labels: [Complex->Complex (Decimating), Complex->Complex (Interpolating),
        Float->Float (Decimating), Float->Float (Interpolating)]
    option_attributes:
        input: [complex, complex, float, float]
        output: [complex, complex, float, float]
    hide: part
-   id: decim
    label: Decimation
    dtype: int
    default: '1'
    hide: ${ ('all' if str(type).startswith('interp') else 'none') }
-   id: interp
    label: Interpolation
    dtype: int
    default: '1'
    hide: ${ ('none' if str(type).startswith('interp') else 'all') }
-   id: gain
    label: Gain
    dtype: real
    default: '1'
-   id: samp_rate
    label: Sample Rate
    dtype: real
    default: samp_rate
-   id: cutoff_freq
    label: Cutoff Freq
    dtype: real
-   id: width
    label: Transition Width
    dtype: real
-   id: win
    label: Window
    dtype: raw
    default: window.WIN_HAMMING
    options: [window.WIN_HAMMING, window.WIN_HANN, window.WIN_BLACKMAN, window.WIN_RECTANGULAR,
        window.WIN_KAISER]
    option_labels: [Hamming, Hann, Blackman, Rectangular, Kaiser]
-   id: beta
    label: Beta
    dtype: real
    default: '6.76'

inputs:
-   domain: stream
    dtype: ${ type.input }

outputs:
-   domain: stream
    dtype: ${ type.output }

templates:
    imports: |-
        from gnuradio import filter
        from gnuradio.filter import firdes
    make: |-
        filter.${type}(
            ${ interp if str(type).startswith('interp') else decim },
            firdes.low_pass(
                ${gain},
                ${samp_rate},
                ${cutoff_freq},
                ${width},
                ${win},
                ${beta}))
    callbacks:
    - set_taps(firdes.low_pass(${gain}, ${samp_rate}, ${cutoff_freq}, ${width}, ${win},
        ${beta}))

cpp_templates:
    includes: ['#include <gnuradio/filter/firdes.h>', '#include <gnuradio/filter/interp_fir_filter.h>', '#include <gnuradio/filter/fir_filter_blk.h>']
    declarations: 'gr::filter::${type}::sptr ${id};'
    make: |-
        this->${id} = filter::${type}::make(
            ${ interp if str(type).startswith('interp') else decim },
            gr::filter::firdes::low_pass(
                ${gain},
                ${samp_rate},
                ${cutoff_freq},
                ${width},
                ${win.replace('firdes.', 'gr::filter::firdes::')},
                ${beta}));
    link: ['gnuradio::gnuradio-filter']
    callbacks:
    - set_taps(gr::filter::firdes::low_pass(${gain}, ${samp_rate}, ${cutoff_freq}, ${width}, ${win.replace('firdes.', 'gr::filter::firdes::')},
        ${beta}))

documentation: |-
    This filter is a convenience wrapper for an fir filter and a firdes taps generating function.

    Sample rate, cutoff frequency, and transition width are in Hertz.

    The beta parameter only applies to the Kaiser window.

file_format: 1
