Skip to content

Constant 2nd Order (Bandpass) Filter

Description

Filters its input (potentially multi-dimensional) by a second order IIR filter with a constant center frequency, amplitude and bandwidth.

Syntax and Default Values

The 'constant-second-order-filter controller can be created using the following Lisp, mlys.lua or mlys (Max) syntax:

(make-controller 'constant-second-order-filter
                  dimension
                  period
                  input_controller
                  (list a1 a2 ... aN)
                  (list cf1 cf2 ... cfN)
                  (list bw1 bw2 ... bwN))
create_controller{kind="constant-second-order-filter",
                  period=-1,  -- optional
                  input=<input controller>, -- dim=2 here
                  amps={1,2},
                  freqs={220,393},
                  bandwidths={10,15},
                  name="MyConstant2ndOrderFilter"}

In Modalys for Max, this object is named mlys.constant-second-order-filter:

An 1-dimensional input controller must be connected to the first inlet.
Beside dimension, name and period, the essential parameters are called amplitude, frequency and bandwidth.
💡If you change the dimension parameter, the related lists (amplitude etc.) will be adapted in size. Likewise, if you change the size of one list, the others (and the dimension parameter) will adapt accordingly.

Parameters

The 'constant-second-order-filter controller takes the following arguments:

  • dimension: number of dimensions of the input and output controllers.
  • period: the time between the updates of the controller. If zero is given then it updates every sample.
  • input_controller: filter input (a controller of dimension N).
  • {aN}: linear amplitude (N real numbers, with N = dimension).
  • {cfN}: center frequency in Hertz (N real numbers).
  • {bwN}: bandwidth in Hertz (N real numbers).

The number of dimensions of the output controller should be the same as that of the input controller.

The amplitude, center frequency and bandwidth parameters cannot vary over time.

Discussion

The constant second order (bandpass) filter can be used for a variety of purposes, but generally is used either to smooth out envelopes or create resonances from impulses. Using a low frequency and fairly wide bandwidth, it can smooth out envelopes:

(setq my-env (make-controller 'envelope 1 '((0 0.0) (0.1 1.0) (1.4 1) (1.5 0)) ))
(setq my-filtered-env (make-controller 'constant-second-order-filter
                                        1
                                        0
                                        my-env
                                        (list 1)
                                        (list 1)
                                        (list 5)))
Or it can be used to add a resonance to an impulse or other noisy sound, by using a specific frequency and a very narrow bandwidth:

(setq my-noise (make-controller 'noise 1 0 (list (const 44100) (const 0.25) (const 0.25) (const 1) (const 1)) 10))
(setq my-filtered-noise (make-controller 'constant-second-order-filter
                                          1
                                          0
                                          my-noise
                                          (list 1)
                                          (list 440)
                                          (list 1)))
You may want to use the more general-purpose biquadratic-filter instead of this filter. However, to do so you will need to generate your own filter coefficients (whereas this filter lets you use higher-level parameters like frequency, amplitude and bandwidth).


★     ★
★