clfilt — Implements low-pass and high-pass filters of different styles.
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.
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.
asig -- The input audio signal.
kfreq -- The corner frequency for low-pass or high-pass.
Here is an example of the clfilt opcode as a low-pass filter. It uses the file clfilt_lowpass.csd.
Example 70. 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 ; Audio out Audio in No messages -odac -iadc -d ;;;RT audio I/O ; For Non-realtime ouput leave only the line below: ; -o clfilt_lowpass.wav -W ;;; for file output any platform </CsOptions> <CsInstruments> ; 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 </CsInstruments> <CsScore> ; Play Instrument #1 for two seconds. i 1 0 2 ; Play Instrument #2 for two seconds. 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 71. 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 ; Audio out Audio in No messages -odac -iadc -d ;;;RT audio I/O ; For Non-realtime ouput leave only the line below: ; -o clfilt_highpass.wav -W ;;; for file output any platform </CsOptions> <CsInstruments> ; 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 </CsInstruments> <CsScore> ; Play Instrument #1 for two seconds. i 1 0 2 ; Play Instrument #2 for two seconds. i 2 2 2 e </CsScore> </CsoundSynthesizer>