Skip to content

resony

A bank of second-order bandpass filters, connected in parallel.

Syntax

ares = resony(asig, kbf, kbw, inum, ksep [, isepmode] [, iscl] [, iskip] [, icorrect])
ares resony asig, kbf, kbw, inum, ksep [, isepmode] [, iscl] [, iskip] [, icorrect]

Initialization

inum -- number of filters, rounded to the nearest integer. Values below 0.5 select four filters. The formulas below use this effective count.

isepmode (optional, default=0) -- selects octave spacing when zero and linear spacing when nonzero. With the default icorrect=0, this value is first truncated to an integer, so values between -1 and 1 select octave spacing. With icorrect=1, every nonzero value selects corrected linear spacing.

iscl (optional, default=0) -- coded scaling factor for resonators. A value of 1 signifies a peak response factor of 1, i.e. all frequencies other than kcf are attenuated in accordance with the (normalized) response curve. A value of 2 raises the response factor so that its overall RMS value equals 1. (This intended equalization of input and output power assumes all frequencies are physically present; hence it is most applicable to white noise.) A zero value signifies no scaling of the signal, leaving that to some later adjustment (e.g. balance). The default value is 0.

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.

icorrect (optional, default=0) -- selects the spacing calculation. Use 0 to preserve the original result for existing scores, or 1 to enable corrected linear spacing in hertz, starting at the base frequency. Only 0 and 1 are accepted. Added in Csound 7.0.

Performance

asig -- audio input signal

kbf -- base frequency in Hz. This is the first filter's center frequency for octave spacing and corrected linear spacing. It must be nonzero when icorrect=1.

kbw -- bandwidth in Hz at the base frequency. Each filter's bandwidth is scaled by its center frequency divided by kbf.

ksep -- total spacing parameter, divided by inum to obtain the step between filters. Its unit is octaves for octave spacing, hertz for corrected linear spacing, and a multiplier for the original linear calculation.

For filter index j = 0, 1, ..., inum - 1, the center frequency is:

Spacing Center frequency
Octave kbf * 2^(ksep * j / inum)
Original linear (icorrect = 0) kbf * (ksep / inum) * j
Corrected linear (icorrect = 1) kbf + (ksep / inum) * j

The original linear formula starts at 0 Hz and multiplies the spacing by the base frequency. This behavior remains the default for compatibility, including its silent first filter when normalization is enabled. Corrected linear spacing can change the sound of an existing score, so it must be selected explicitly.

For example, kbf = 700, inum = 3, ksep = 900, isepmode = 1, and icorrect = 1 produce filter centers at 700, 1000, and 1300 Hz.

Examples

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

Example of the resony 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

ksep    = p4                            ;vary seperation of center frequency of filters in octaves
kenv    linseg  0, p3*.5, 1, p3*.5, 0   ;envelope
asig    rand    0.7
kbf     line    300, p3, 2000           ;vary base frequency
afilt   resony  asig, kbf, 300, 4, ksep
asig    balance afilt, asig
        outs    asig*kenv, asig*kenv

endin
</CsInstruments>
<CsScore>

i 1 0 2
i 2 3 2 1
i 2 6 2 3

e
</CsScore>
</CsoundSynthesizer>

Here is another example of the metro2 Opcode. It uses the file resony_corrected.csd. It selects corrected linear spacing with the final argument:

<CsoundSynthesizer>
<CsOptions>
-odac -d -m0
</CsOptions>
<CsInstruments>
sr = 48000
ksmps = 32
nchnls = 1
0dbfs = 1

instr 1
  aInput rand 0.05
  ; Three centers: 700, 1000, and 1300 Hz.
  ; The last argument opts into corrected linear spacing.
  aBank resony aInput, 700, 100, 3, 900, 1, 1, 0, 1
  out aBank
endin
</CsInstruments>
<CsScore>
i 1 0 2
e
</CsScore>
</CsoundSynthesizer>

See also

Standard Filters: Resonant Low-pass filters

Credits

Author: Gabriel Maldonado
Italy
1999

New in Csound version 3.56