# Analog Devices Wiki

This version (18 May 2021 09:09) was approved by Nikhin Shetty.

# General First Order Filter

## Description

The General 1st-Order block allows you to design 1st-order lowpass and highpass filters.

Drag the block into the workspace and it's ready to use. As with other blocks, there's the option to increase the stage count to this algorithm. Observe, however, that with this module adding another stage the algorithm will add another frequency band to the block, which is equivalent to having two filters in series.

To switch among highpass, lowpass, and flat, click the filter type icon. This can be done in real time, without needing to recompile the project. Enter your desired values in the text fields to set the cutoff frequency and overall gain (sometimes called scale gain) of the filter. Or click the arrows to increment values for these parameters. To increment them very quickly, click and hold.

### Calculating Filter Coefficients

Use the following formulas to calculate the coefficients for first order filters.

Variables:

• frequency = Cutoff frequency
• gain = Linear Gain
• fs = Sample Rate
• PI = π

For lowpass filters,

• A1 = 2.7^(-2 * PI * frequency/fs))
• B0 = gain * (1.0 - A1)
• B1 = 0

For highpass filters,

• A1 = e^(-2 * PI * frequency/fs)) where e = 2.718…..
• B1 = (1.0 + A1) * 0.5 * gain
• B0 = -B1

For allpass filters,

• A1 = 2.7^(-2 * PI * frequency/fs))
• B0 = -gain * A1
• B1 = gain

## Targets Supported

—————————— ——————-- ——————————-- —————————-
General First Order NA NA S

## Pins

### Input

NameTypeDescription
————————————— —————————— ————————————————
Input Audio Input channel

### Output

NameTypeDescription
————————————— —————————— ————————————————
Output AudioFilter Output

## Configurable Parameters

GUI Parameter NameDefault ValueRangeFunction Description
———————————————- —————————- ————————————- —————————————————————-
NumStages11 to 8Number of filter stages
Gain_StageX0-12 to 12 dBGain for individual filter stage
Frequency_StageX1000 1 to 96000Filter cutoff frequency of individual filter stage
FilterType_StageX0 0 to 2LowPass/HighPass/BandPass filter type of individual filter stage
Phase_StageXtrue true/falseIn phase/out of phase for individual filter stage
Enabled_StageXtrue true/falseFilter Enabled/Bypassed for individual filter stage

Note : _StageX - Refers to parameters of each stage. X represents the stage index.