Skip to content

resonx

Emulates a stack of filters using the reson opcode.

resonx passes the input through a series of reson filters. All layers use the same center frequency, bandwidth, and scaling mode. More layers give a sharper combined response.

Syntax

ares = resonx(asig, xcf, xbw [, inumlayer] [, iscl] [, iskip])
ares resonx asig, xcf, xbw [, inumlayer] [, iscl] [, iskip]

Initialization

inumlayer (optional) -- number of elements in the filter stack. Default value is 4.

iscl (optional, default=0) -- scaling mode for each layer, as in reson. A value of 1 gives each layer a peak gain of 1. A value of 2 gives each layer an RMS gain of 1 for white-noise input; this does not make the combined filter's RMS gain equal to 1. A value of 0 applies no scaling. Use balance if you need to adjust the final output level.

iskip (optional, default=0) -- initial disposition of internal data space. Since filtering incorporates a feedback loop of previous output, the initial status of the storage space used is significant. A zero value will clear the space; a non-zero value will allow previous information to remain. The default value is 0.

Performance

asig -- input signal.

xcf -- center frequency of each layer in Hz, at control or audio rate.

xbw -- bandwidth of each layer in Hz, at control or audio rate. This is the difference between that layer's upper and lower half-power frequencies. The combined filter has a narrower bandwidth when it contains more than one layer.

At each sample, every layer uses the same current xcf and xbw values. Either parameter can be audio-rate while the other is control-rate.

Examples

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

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

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

instr 1 ; unfiltered noise

kenv    linseg  0, p3*.5, 1, p3*.5, 0   ;envelope
asig    rand    0.7                     ;white noise
        outs    asig*kenv, asig*kenv

endin

instr 2 ; filtered noise

kenv    linseg  0, p3*.5, 1, p3*.5, 0   ;envelope
asig    rand    0.7
kcf     line    300, p3, 2000
afilt   resonx  asig, kcf, 300, 4
asig    balance afilt, asig
        outs    asig*kenv, asig*kenv

endin
</CsInstruments>
<CsScore>

i 1 0 2
i 2 3 2

e
</CsScore>
</CsoundSynthesizer>

See also

Standard Filters: Resonant Low-pass filters

Credits

Author: Gabriel Maldonado (adapted by John ffitch)
Italy

New in Csound version 3.49

Audio rate parameters introduced in version 6.02

November 2013.