Skip to content

Instantly share code, notes, and snippets.

@paniq
Created April 5, 2019 23:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save paniq/e69abff3e51338c5d119e77e9e103364 to your computer and use it in GitHub Desktop.
Save paniq/e69abff3e51338c5d119e77e9e103364 to your computer and use it in GitHub Desktop.
inline svf~ (srate)
let srate = (srate as f32)
let invsrate = (/ (2.0 * srate))
stateful-map
inline "svf~" (src state...)
# signal 523.0 0.0 0.0
let in cutoff res drive = (src)
drive := (drive * 0.1)
freq := 2.0 * (sin (pi * (min 0.25 (cutoff * invsrate))))
damp := (min 2.0
(2.0 * (1.0 - (pow res 0.25))) (2.0 / freq - freq * 0.5))
inline step (notch low high band)
notch := (in - damp * band)
low := (low + freq * band)
high := (notch - low)
band := (freq * high + band - drive * band * band * band)
_ notch low high band
let notch1 low1 high1 band1 = (step state...)
let notch2 low2 high2 band2 = (step notch1 low1 high1 band1)
_
inline ()
let a = (vec4 notch1 low1 high1 band1)
let b = (vec4 notch2 low2 high2 band2)
a * 0.5 + b * 0.5
\ notch2 low2 high2 band2
# notch low high band
\ 0.0 0.0 0.0 0.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment