```
d2 $ note ((scaleP scalePattern $ (rotR 3.5) -- $ inversion \n $ (+ slow 8 "x" <~> ((0.5 ~>) generateMelodicSeed)) -- $ slow 2 \n $ generateMelodicSeed ) - 12)#s "[pe-gtr:9,midi]" #gain 1.2 #orbit 1 #midichan 2
```

```
let melody = slow 6 $ "0 2 [4 8 .] [3 4 3] 8 4 9"
```

```
d9 $ midicmd "start" # s "midi"
```

```
scalePattern = slow 16 "
```"

# Digital Filter

A digital filter is a process that takes some input signal and produces some (possibly modified) output signal. In that way almost everything that interacts with an audio signal inside the computer is a digital filter.

Filters can be used to subtract or add frequency components of input signals, as well as manipulate the phase of those frequency components.

## common types of filters

Common types of filters are names based on their effect on incoming frequencies.

### lowpass

It lets through the low frequencies and attenuates the high frequencies.

### highpass

It lets through the high frequencies and attenuates the low frequencies.

### bandpass

Both high and low frequencies are attenuated and some set of middle frequencies are allowed to pass.

### notch

Both high and low frequencies are allowed to pass and some middle band of frequencies is attenuated.

### allpass

No frequencies are attenuated but the phase relationships are changed.

### comb

The signal is combined with a delayed version of itself to create phase cancellation. This mimics the effect created when a sound bounces off of a surface.

## filter design

Most filters can be thought of as dynamical systems and discrete versions mathematical techniques for analyzing differential equations can be applied to analyze the behavior of the filter system to input. Typically, it is interesting to know the following about a filter:

- How the system will respond to a unit impulse
- Under what conditions its output is stable, semi-stable, and unstable
- How incoming frequencies will be affected (ie. its frequency response)
- How the phase of incoming signals will be affected
- How to calculate parameters or coefficients for the filter from more intuitive quantities (such as cutoff frequency and resonance)

Answering the above typically involves designing a filter in state space and deriving its difference equation by taking the inverse Z transform. For Linear Time Invariant filters this operation is easy as $Z_{-1}(\sum_{i=0}^p a_{i}Y_{n-i}) = \sum_{i=0}^p a_{i}y[n-i]$ If the filter is not a Linear Time Invariant Filter the power series must be solved or referenced from a lookup table.

## digital filter implementation

- Convolution with an recorded impulse response
- A difference equation with a Finite Impulse Response (FIR filter)
- A difference equation with a Infinite Impulse Response (IIR filter)
- A difference equation with lookahead ( [[ non-causal filter ]])

### Notes mentioning this note

There are no notes linking to this note.

This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.