nlfilt2
Prev | Orchestra Opcodes and Operators | Next

## nlfilt2

nlfilt2 — A filter with a non-linear effect and blowup protection.

## Description

Implements the filter:

Y{n} =tanh(a Y{n-1} + b Y{n-2} + d Y^2{n-L} + X{n} - C)

described in Dobson and Fitch (ICMC'96) as modified by Risto Holopainen.

## Syntax

    ares nlfilt2 ain, ka, kb, kd, kC, kL

## Performance

1. Non-linear effect. The range of parameters are:

   a = b = 0
   d = 0.8, 0.9, 0.7
   C = 0.4, 0.5, 0.6
   L = 20

   This affects the lower register most but there are audible effects over the whole range. We suggest that it may be useful for coloring drums, and for adding arbitrary highlights to notes.

2. Low Pass with non-linear. The range of parameters are:

   a = 0.4
   b = 0.2
   d = 0.7
   C = 0.11
   L = 20, ... 200

   There are instability problems with this variant but the effect is more pronounced of the lower register, but is otherwise much like the pure comb. Short values of L can add attack to a sound.

3. High Pass with non-linear. The range of parameters are:

   a = 0.35
   b = -0.3
   d = 0.95
   C = 0,2, ... 0.4
   L = 200

4. High Pass with non-linear. The range of parameters are:

   a = 0.7
   b = -0.2, ... 0.5
   d = 0.9
   C = 0.12, ... 0.24
   L = 500, 10

   The high pass version is less likely to oscillate. It adds scintillation to medium-high registers. With a large delay L it is a little like a reverberation, while with small values there appear to be formant-like regions. There are arbitrary color changes and resonances as the pitch changes. Works well with individual notes.

| Warning
The "useful" ranges of parameters are not yet mapped.

## Examples

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

Example 507. Example of the nlfilt2 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
    -odac  ;;;realtime audio out
    ;-iadc    ;;;uncomment -iadc if realtime audio input is needed too
    ; For Non-realtime ouput leave only the line below:
    ; -o nlfilt.wav -W ;;; for file output any platform
    </CsOptions>
    <CsInstruments>

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

    instr 1	;unfiltered noise

    asig rand .7
         outs asig, asig

    endin

    instr 2	;filtered noise

    ka = p4
    kb = p5
    kd = p6
    kC = p7
    kL = p8
    asig  rand .3
    afilt nlfilt2 asig, ka, kb, kd, kC, kL
          outs    afilt, afilt
    endin
    </CsInstruments>
    <CsScore>

    i 1 0 2				; unfiltered

    ;        a    b    d    C    L
    i 2 2 2  0    0   0.8  0.5  20	; non-linear effect
    i 2 + 2 .4   0.2  0.7  0.11 200	; low=pass with non-linear
    i 2 + 2 0.35 -0.3 0.95 0.1  200	; high-pass with non-linear
    i 2 + 2 0.7 -0.2  0.9  0.2  20 	; high-pass with non-linear

    e
    </CsScore>
    </CsoundSynthesizer>

## Credits

Author: John ffitch
University of Bath/Codemist Ltd.
Bath, UK
2012

New in version 5.19

Prev | Up | Next
nlfilt | Home | noise