User-Defined Opcode Database

Statevar

A digital version of the analogue state variable filter.

Download UDO File

Description

This filter implements the state variable filter
design, with individual controls for centre/cutoff
frequency and resonance. It outputs four filter signals simultaneously: high-pass, low-pass, band-pass and band-reject.

This is version 2 of this UDO (revised 25/nov/04). In order to make this an all-frequency stable filter, there is a damping limiter, which will impose a limit on the resonance factor of the filter, usually at high frequencies.

Syntax

ahp,alp,abp,abr Statevar asig, kcf, kres

Performance

asig - input signal
kcf - filter cutoff/centre frequency
kres - filter resonance

Code

opcode Statevar, aaaa, akk

    setksmps 1

abpd init 0
alpd init 0
alp  init 0
ipi = 4.*taninv(1);

asig,kcf,kres   xin

kf = 2*sin(ipi*kcf/(3*sr))
kq = 1/kres
klim = ((2-kf)/2)*0.33

if kq < klim then
kq = klim
endif

ahp = asig - kq*abpd - alp 
abp = ahp*kf + abpd
alp = abpd*kf + alpd
abr = alp + ahp
abpd = abp
alpd = alp 

ahp = asig - kq*abpd - alp 
abp = ahp*kf + abpd
alp = abpd*kf + alpd
abr = alp + ahp
abpd = abp
alpd = alp  

ahp = asig - kq*abpd - alp 
abp = ahp*kf + abpd
alp = abpd*kf + alpd
abr = alp + ahp
abpd = abp
alpd = alp 
  
      xout  ahp,alp,abp,abr
	
endop

Examples

instr 1
kenv               linseg 0,0.1,1, p3-0.2,1, 0.1, 0
asig               buzz 16000*kenv, 100, 100, 1;  
kf                 expseg 100, p3/2, 5000, p3/2, 1000
ahp,alp,abp,abr    statevar  asig, kf, 200
                   outs alp,ahp
	
endin

Credits

Author: Victor Lazzarini


Previous Home Next
findPowerOfTwo   sampleSlicer