svfilter
Prev | Orchestra Opcodes and Operators | Next

## svfilter

svfilter — A resonant second order filter, with simultaneous lowpass, highpass and bandpass outputs.

## Description

Implementation of a resonant second order filter, with simultaneous lowpass, highpass and bandpass outputs.

## Syntax

    alow, ahigh, aband svfilter  asig, kcf, kq [, iscl]

## Initialization

iscl -- coded scaling factor, similar to that in reson. A non-zero value signifies a peak response factor of 1, i.e. all frequencies other than kcf are attenuated in accordance with the (normalized) response curve. A zero value signifies no scaling of the signal, leaving that to some later adjustment (see balance). The default value is 0.

## Performance

svfilter is a second order state-variable filter, with k-rate controls for cutoff frequency and Q. As Q is increased, a resonant peak forms around the cutoff frequency. svfilter has simultaneous lowpass, highpass, and bandpass filter outputs; by mixing the outputs together, a variety of frequency responses can be generated. The state-variable filter, or "multimode" filter was a common feature in early analog synthesizers, due to the wide variety of sounds available from the interaction between cutoff, resonance, and output mix ratios. svfilter is well suited to the emulation of "analog" sounds, as well as other applications where resonant filters are called for.

asig -- Input signal to be filtered.

kcf -- Cutoff or resonant frequency of the filter, measured in Hz.

kq -- Q of the filter, which is defined (for bandpass filters) as bandwidth/cutoff. kq should be in a range between 1 and 500. As kq is increased, the resonance of the filter increases, which corresponds to an increase in the magnitude and "sharpness" of the resonant peak. When using svfilter without any scaling of the signal (where iscl is either absent or 0), the volume of the resonant peak increases as Q increases. For high values of Q, it is recommended that iscl be set to a non-zero value, or that an external scaling function such as balance is used.

svfilter is based upon an algorithm in Hal Chamberlin's Musical Applications of Microprocessors (Hayden Books, 1985).

## Examples

Here is an example of the svfilter opcode. It uses the file svfilter.csd.

Example 840. Example of the svfilter opcode.

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 svfilter.wav -W ;;; for file output any platform
    </CsOptions>
    <CsInstruments>

    ; Orchestra file for resonant filter sweep of a sawtooth-like waveform.
    ; The seperate outputs of the filter are scaled by values from the score,
    ; and are mixed together.
    sr = 44100
    kr = 2205
    ksmps = 20
    nchnls = 1

    instr 1

      idur     = p3
      ifreq    = p4
      iamp     = p5
      ilowamp  = p6              ; determines amount of lowpass output in signal
      ihighamp = p7              ; determines amount of highpass output in signal
      ibandamp = p8              ; determines amount of bandpass output in signal
      iq       = p9              ; value of q

      iharms   =        (sr*.4) / ifreq

      asig    gbuzz 1, ifreq, iharms, 1, .9, 1             ; Sawtooth-like waveform
      kfreq   linseg 1, idur * 0.5, 4000, idur * 0.5, 1     ; Envelope to control filter cutoff

      alow, ahigh, aband   svfilter asig, kfreq, iq

      aout1   =         alow * ilowamp
      aout2   =         ahigh * ihighamp
      aout3   =         aband * ibandamp
      asum    =         aout1 + aout2 + aout3
      kenv    linseg 0, .1, iamp, idur -.2, iamp, .1, 0     ; Simple amplitude envelope
              out asum * kenv

    endin

    </CsInstruments>
    <CsScore>

    f1 0 8192 9 1 1 .25

    i1  0 5 100 1000 1 0 0  5  ; lowpass sweep
    i1  5 5 200 1000 1 0 0 30  ; lowpass sweep, octave higher, higher q
    i1 10 5 100 1000 0 1 0  5  ; highpass sweep
    i1 15 5 200 1000 0 1 0 30  ; highpass sweep, octave higher, higher q
    i1 20 5 100 1000 0 0 1  5  ; bandpass sweep
    i1 25 5 200 1000 0 0 1 30  ; bandpass sweep, octave higher, higher q
    i1 30 5 200 2000 .4 .6  0  ; notch sweep - notch formed by combining highpass and lowpass outputs
    e

    </CsScore>
    </CsoundSynthesizer>

## Credits

Author: Sean Costello
Seattle, Washington
1999

New in Csound version 3.55

Prev | Up | Next
sumtab | Home | syncgrain