Engee documentation

EngeeDSP.NotchPeakFilter

Configurable notch and narrow-band second-order IIR filter.

Library

EngeeDSP

Block

Notch-Peak Filter

Description

To implement a second-order notch or narrow-band IIR filter, follow these steps:

  1. Create an object EngeeDSP.NotchPeakFilter and set its properties.

  2. Call the object with arguments as if it were a function.

To learn more about how to work with system objects, see Engee System Objects.

Syntax

Creation

  • npFilter = EngeeDSP.NotchPeakFilter() returns a second-order notch and narrow-band IIR filter, which independently filters each channel of the input signal in time using a given center frequency and bandwidth. 3 dB.

  • npFilter = EngeeDSP.NotchPeakFilter(Specification="Quality factor and center frequency") the quality factor (Q-factor) of the notch or narrowband filter is indicated instead of the bandwidth 3 dB.

  • npFilter = EngeeDSP.NotchPeakFilter(Specification="Coefficients") The values of the coefficients that directly affect the bandwidth and center frequency are indicated, rather than the design parameters in Hz. This eliminates the need for trigonometric calculations when setting up the characteristics.

  • npFilter = EngeeDSP.NotchPeakFilter(Name=Value) returns a notch or narrow-band IIR filter with the specified property Name, set to the specified value Value. You can specify additional arguments as a name-value pair in any order (Name1=Value1,…​,NameN=ValueN). Unspecified properties have default values.

    Example:

    npFilter = EngeeDSP.NotchPeakFilter(CenterFrequency=5000,Bandwidth=500)

Using

  • Yn = npFilter(x) filters each channel (column) of the input signal x, creating the output signal of the notch filter Yn.

  • Yn, Yp = npFilter(x) filters each channel (column) of the input signal x, creating the output signal of the notch filter Yn and the output signal of the narrowband filter Yp.

Arguments

Input arguments

x — input signal

+ vector | the matrix

Details

The input signal is specified as a vector or matrix.

Типы данных

Float32, Float64

Support for complex numbers

Yes

Output arguments

Yn is the output signal of the notch filter

+ vector | the matrix

Details

The output signal of the notch filter, returned as a vector or matrix.

Типы данных

Float32, Float64

Support for complex numbers

Yes

Yp is the output signal of the narrowband filter

+ vector | the matrix

Details

The output signal of a narrowband filter, returned as a vector or matrix.

Типы данных

Float32, Float64

Support for complex numbers

Yes

Features

# Specification — filter characteristics

+ "Bandwidth and center frequency" (by default) | "Quality factor and center frequency" | "Coefficients"

Details

Specify the properties that the block uses to design the filter.:

# Bandwidth — bandwidth 3 dB, in Hz

+ 2205 (default) | positive scalar

Details

Bandwidth 3 The dB of the filter, set as a positive scalar in Hz.

Dependencies

To use this property, set the Specification value "Bandwidth and center frequency", and for the property NormalizedFrequency the value false.

# NormalizedBandwidth — bandwidth 3 dB, in normalized units

+ 0.1 (by default) | a positive scalar is less than 1.0

Details

Bandwidth 3 The dB of the filter, set as a positive scalar, is less than 1.0 in normalized units.

If, when creating an object, the NormalizedFrequency property is set to true if no bandwidth is set, then the object will automatically set the default bandwidth in normalized frequency units using the default sampling rate. 44100 Hz.

npFilter = EngeeDSP.NotchPeakFilter(NormalizedFrequency = true)
NotchPeakFilter:
    Specification=Bandwidth and center frequency
    NormalizedBandwidth=0.1
    NormalizedCenterFrequency=0.5
    SampleRate=44100
    NormalizedFrequency=true
    FilterOutput=NotchAndPeak

If the property NormalizedFrequency is set to true After creating the object, you must specify the bandwidth in normalized units before running the object algorithm.

npFilter = EngeeDSP.NotchPeakFilter()
NotchPeakFilter:
    Specification=Bandwidth and center frequency
    Bandwidth=2205
    CenterFrequency=11025
    SampleRate=44100
    NormalizedFrequency=false
    FilterOutput=NotchAndPeak

To specify a normalized frequency value, set the NormalizedFrequency property to true and manually convert the frequency value in Hz to a normalized value using half the sampling frequency of the input signal in Hz. For example, if the input sampling rate is compose 44100 Hz, then the corresponding bandwidth value in normalized units is .

npFilter.NormalizedFrequency = true
npFilter.NormalizedBandwidth = 2205/(44100/2)
npFilter
NotchPeakFilter:
    Specification=Bandwidth and center frequency
    NormalizedBandwidth=0.1
    NormalizedCenterFrequency=0.5
    SampleRate=44100
    NormalizedFrequency=true
    FilterOutput=NotchAndPeak

Dependencies

To use this property, set the Specification value "Bandwidth and center frequency", and for the property NormalizedFrequency the value true.

# CenterFrequency — the center frequency of a notch or narrowband filter, in Hz

+ 11025 (by default) | positive scalar

Details

The center frequency of the filter, set as a positive scalar in Hz.

Dependencies

To use this property, set the Specification value "Bandwidth and center frequency", and for the property NormalizedFrequency the value false.

# NormalizedCenterFrequency — the center frequency of a notch or narrowband filter, in normalized units

+ 0.5 (by default) | a positive scalar is less than 1.0

Details

The center frequency of a notch or narrowband filter, set as a positive scalar, is less than 1.0 in normalized units.

If, when creating an object, the NormalizedFrequency property is set to true if the center frequency is not set, then the object will automatically set the default center frequency in normalized frequency units using the default sampling rate. 44100 Hz.

npFilter = EngeeDSP.NotchPeakFilter(NormalizedFrequency = true)
NotchPeakFilter:
    Specification=Bandwidth and center frequency
    NormalizedBandwidth=0.1
    NormalizedCenterFrequency=0.5
    SampleRate=44100
    NormalizedFrequency=true
    FilterOutput=NotchAndPeak

If the property NormalizedFrequency is set to true After creating the object, it is necessary to specify the center frequency in normalized units before running the object algorithm.

npFilter = EngeeDSP.NotchPeakFilter()
NotchPeakFilter:
    Specification=Bandwidth and center frequency
    Bandwidth=2205
    CenterFrequency=11025
    SampleRate=44100
    NormalizedFrequency=false
    FilterOutput=NotchAndPeak

To specify a normalized frequency value, set the NormalizedFrequency property to true and manually convert the frequency value in Hz to a normalized value using half the sampling frequency of the input signal in Hz. For example, if the input sampling rate is compose 44100 Hz, then the corresponding value of the central frequency in normalized units is .

npFilter.NormalizedFrequency = true
npFilter.NormalizedCenterFrequency = 11025/(44100/2)
npFilter
NotchPeakFilter:
    Specification=Bandwidth and center frequency
    NormalizedBandwidth=0.1
    NormalizedCenterFrequency=0.5
    SampleRate=44100
    NormalizedFrequency=true
    FilterOutput=NotchAndPeak

Dependencies

To use this property, set the Specification value "Bandwidth and center frequency" or "Quality factor and center frequency", and for the property NormalizedFrequency the value true.

# QualityFactor — the quality of a notch or narrowband filter

+ 5 (by default) | positive scalar

Details

The Q-factor of a notch or narrowband filter, specified as a real positive scalar. Q factor is defined as the ratio of the center frequency to the bandwidth. The higher the Q factor, the narrower the suppression or transmission band.

Dependencies

To use this property, set the Specification value "Quality factor and center frequency".

# SampleRate is the sampling frequency of the input signal, in Hz

+ 44100 (by default) | positive scalar

Details

The sampling frequency of the input signal, set as a scalar in Hz.

Dependencies

To use this property, set the Specification value "Bandwidth and center frequency" or "Quality factor and center frequency", and for the property NormalizedFrequency the value false.

# BandwidthCoefficient — bandwidth factor

+ 0.726554 (by default) | a real scalar in the range [-1, 1]

Details

The coefficient determining the bandwidth 3 dB, set as a scalar in the range from −1 before 1:

  • −1 corresponds to the maximum bandwidth 3 dB (one-fourth of the sampling rate of the input signal);

  • 1 corresponds to the minimum bandwidth (0 Hz, i.e. frequency-independent filter).

Dependencies

To use this property, set the Specification value "Coefficients".

# CenterFrequencyCoefficient — bandwidth factor

+ 0.0 (by default) | a real scalar in the range [-1, 1]

Details

The coefficient that determines the center frequency of the filter, set as a scalar in the range from −1 before 1:

  • −1 corresponds to the minimum central frequency (0 Hz);

  • 1 corresponds to the maximum center frequency (half of the sampling frequency of the input signal).

Dependencies

To use this property, set the Specification value "Coefficients".

# NormalizedFrequency — option to set frequencies in normalized units

+ false (by default) | true

Details

Option to set frequencies in normalized units:

  • false — the values of the bandwidth and center frequency are specified in Hz and must be less than half the value SampleRate;

  • true — The bandwidth and center frequency values are specified in normalized frequency units. The values must be positive scalars less than 1.0.

Dependencies

To use this property, set the Specification value "Bandwidth and center frequency" or "Quality factor and center frequency".

# FilterOutput — select a filter for data output

+ "NotchAndPeak" (by default) | "Notch" | "Peak"

Details

Selecting the output data:

  • "NotchAndPeak" — the output signal after passing the notch and narrowband filter;

  • "Notch" — output signal after passing through the notch filter;

  • "Peak" — the output signal after passing the narrowband filter.

Methods

Common to all system objects

step!

Run the system object operation algorithm

release!

Allow changing the value of a system object property

reset!

Resetting the internal states of a system object

Algorithms

The equation for a narrowband filter design is as follows:

The equation for the notch filter design is as follows:

In these equations

where

  • — the central frequency in Hz;

  • — sampling rate in Hz;

  • — bandwidth 3 dB in Hz.

Please note that these two filters complement each other.:

They can be rewritten as

where — frequency-independent second-order filter:

The filter is implemented as follows:

notch peak filter 1

In the picture:

Please note that depends only on the central frequency, and — only from bandwidth 3 dB.

Literature

  1. Orfanidis, Sophocles J. Introduction to Signal Processing. Upper Saddle River, NJ: Prentice-Hall, 1996.