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 file clfilt_lowpass.csd.

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

See the sections Real-time Audio and Command Line Flags for more information on using command line flags.

    <CsoundSynthesizer>
    <CsOptions>
    ; Select audio/midi flags here according to platform
    -odac     ;;;RT audio out
    ;-iadc    ;;;uncomment -iadc if RT audio input is needed too
    ; For Non-realtime ouput leave only the line below:
    ; -o clfilt_lowpass.wav -W ;;; for file output any platform
    </CsOptions>
    <CsInstruments>

    sr = 44100
    ksmps = 32
    nchnls = 2
    0dbfs = 1

    instr 1	; white noise

    asig rand 0.5
    outs asig, asig

    endin

    instr 2	; filtered noise

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

    endin

    </CsInstruments>
    <CsScore>

    i 1 0 2
    i 2 2 2
    e

    </CsScore>
    </CsoundSynthesizer>

Here is an example of the clfilt opcode as a high-pass filter. It uses the file clfilt_highpass.csd.

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

See the sections Real-time Audio and Command Line Flags for more information on using command line flags.

    <CsoundSynthesizer>
    <CsOptions>
    ; Select audio/midi flags here according to platform
    -odac     ;;;RT audio out
    ;-iadc    ;;;uncomment -iadc if RT audio input is needed too
    ; For Non-realtime ouput leave only the line below:
    ; -o clfilt_highpass.wav -W ;;; for file output any platform
    </CsOptions>
    <CsInstruments>

    sr = 44100
    ksmps = 32
    nchnls = 2
    0dbfs = 1

    instr 1	; white noise

    asig rand 0.6
         outs asig, asig

    endin

    instr 2	;filtered noise

    asig rand 0.7
    ; 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
       outs a1, a1

    endin

    </CsInstruments>
    <CsScore>

    i 1 0 2
    i 2 2 2
    e

    </CsScore>
    </CsoundSynthesizer>

## Credits

Author: Erik Spjut

New in version 4.20

Prev | Up | Next
clear | Home | clip