id: band_reject_filter
label: Band Reject 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,
        fir_filter_ccc, interp_fir_filter_ccc, fir_filter_fcc, interp_fir_filter_fcc]
    option_labels: [Complex->Complex (Real Taps) (Decim), Complex->Complex (Real Taps)
            (Interp), Float->Float (Real Taps) (Decim), Float->Float (Real Taps) (Interp),
        Complex->Complex (Complex Taps) (Decim), Complex->Complex (Complex Taps) (Interp),
        Float->Complex (Complex Taps) (Decim), Float->Complex (Complex Taps) (Interp)]
    option_attributes:
        fcn: [band_reject, band_reject, band_reject, band_reject, complex_band_reject,
              complex_band_reject, complex_band_reject, complex_band_reject]
        input: [complex, complex, float, float, complex, complex, float, float]
        output: [complex, complex, float, float, complex, complex, complex, complex]
    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: low_cutoff_freq
    label: Low Cutoff Freq
    dtype: real
-   id: high_cutoff_freq
    label: High 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'

asserts:
-   ${ low_cutoff_freq <= high_cutoff_freq }
-   ${ width > 0 }

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.${type.fcn}(
                ${gain},
                ${samp_rate},
                ${low_cutoff_freq},
                ${high_cutoff_freq},
                ${width},
                ${win},
                ${beta}))
    callbacks:
    - set_taps(firdes.${type.fcn}(${gain}, ${samp_rate}, ${low_cutoff_freq}, ${high_cutoff_freq},
        ${width}, ${win}, ${beta}))

cpp_templates:
    includes: ['#include <gnuradio/filter/firdes.h>']
    declarations: 'filter::firdes::sptr ${id};'
    make: |-
        this->${id} = filter::${type}::make(
            ${ interp if str(type).startswith('interp') else decim },
            firdes.${type.fcn}(
                ${gain},
                ${samp_rate},
                ${low_cutoff_freq},
                ${high_cutoff_freq},
                ${width},
                ${win},
                ${beta}));
    link: ['gnuradio::gnuradio-filter']
    callbacks:
    - set_taps(firdes::${type.fcn}(${gain}, ${samp_rate}, ${low_cutoff_freq}, ${high_cutoff_freq},
        ${width}, ${win}, ${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
