clfilt
Prev | Orchestra Opcodes and Operators | Next

## clfilt

clfilt — Implements low-pass and high-pass filters of different styles.

## Description

Implements the classical standard analog filter types: low-pass and high-pass. They are implemented with the four classical kinds of filters: Butterworth, Chebyshev Type I, Chebyshev Type II, and Elliptical. The number of poles may be any even number from 2 to 80.

## Syntax

    ares clfilt asig, kfreq, itype, inpol [, ikind] [, ipbr] [, isba] [, iskip]

## Initialization

itype -- 0 for low-pass, 1 for high-pass.

inpol -- The number of poles in the filter. It must be an even number from 2 to 80.

ikind (optional) -- 0 for Butterworth, 1 for Chebyshev Type I, 2 for Chebyshev Type II, 3 for Elliptical. Defaults to 0 (Butterworth)

ipbr (optional) -- The pass-band ripple in dB. Must be greater than 0. It is ignored by Butterworth and Chebyshev Type II. The default is 1 dB.

isba (optional) -- The stop-band attenuation in dB. Must be less than 0. It is ignored by Butterworth and Chebyshev Type I. The default is -60 dB.

iskip (optional) -- 0 initializes all filter internal states to 0. 1 skips initialization. The default is 0.

## Performance

asig -- The input audio signal.

kfreq -- The corner frequency for low-pass or high-pass.

## Examples

Here is an example of the clfilt opcode as a low-pass filter. It uses the files clfilt_lowpass.orc and clfilt_lowpass.sco.

Example 63. Example of the clfilt opcode as a low-pass filter.

    /* clfilt_lowpass.orc */
    ; Initialize the global variables.
    sr = 22050
    kr = 2205
    ksmps = 10
    nchnls = 1

    ; Instrument #1 - an unfiltered noise waveform.
    instr 1
      ; White noise signal
      asig rand 22050

      out asig
    endin

    ; Instrument #2 - a filtered noise waveform.
    instr 2
      ; White noise signal
      asig rand 22050

      ; Lowpass filter signal asig with a
      ; 10-pole Butterworth at 500 Hz.
      a1 clfilt asig, 500, 0, 10

      out a1
    endin
    /* clfilt_lowpass.orc */

    /* clfilt_lowpass.sco */
    ; Play Instrument #1 for two seconds.
    i 1 0 2
    ; Play Instrument #2 for two seconds.
    i 2 2 2
    e
    /* clfilt_lowpass.sco */

Here is an example of the clfilt opcode as a high-pass filter. It uses the files clfilt_highpass.orc and clfilt_highpass.sco.

Example 64. Example of the clfilt opcode as a high-pass filter.

    /* clfilt_highpass.orc */
    ; Initialize the global variables.
    sr = 22050
    kr = 2205
    ksmps = 10
    nchnls = 1

    ; Instrument #1 - an unfiltered noise waveform.
    instr 1
      ; White noise signal
      asig rand 22050

      out asig
    endin

    ; Instrument #2 - a filtered noise waveform.
    instr 2
      ; White noise signal
      asig rand 22050

      ; Highpass filter signal asig with a 6-pole Chebyshev
      ; Type I at 20 Hz with 3 dB of passband ripple.
      a1 clfilt asig, 20, 1, 6, 1, 3

      out a1
    endin
    /* clfilt_highpass.orc */

    /* clfilt_highpass.sco */
    ; Play Instrument #1 for two seconds.
    i 1 0 2
    ; Play Instrument #2 for two seconds.
    i 2 2 2
    e
    /* clfilt_highpass.sco */

## Credits

Author: Erik Spjut

New in version 4.20

Prev | Up | Next
clear | Home | clip