Last active
May 15, 2021 11:00
-
-
Save jpcima/8fa21a6bd8cf9fc425795e43167609da to your computer and use it in GitHub Desktop.
Filters 1-pole with faked resonance
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import("stdfaust.lib"); | |
/// | |
lp1Reson(cutoff, dbGain, cfSmooth) = lp : peak with { | |
lp = fi.iir((1-p),(0-p)) with { | |
p = exp(-2.*ma.PI*cutoff/ma.SR) : cfSmooth; | |
}; | |
peak = fi.tf22t(b0/a0,b1/a0,b2/a0,a1/a0,a2/a0) with { | |
w = max(0,cutoff)*(2*ma.PI/ma.SR); | |
A = 10^(dbGain/40); | |
S = sin(w) : cfSmooth; C = cos(w) : cfSmooth; | |
b0 = 1+S*A; b1 =-2*C; b2 = 1-S*A; | |
a0 = 1+S/A; a1 =-2*C; a2 = 1-S/A; | |
}; | |
}; | |
hp1Reson(cutoff, dbGain, cfSmooth) = lp : peak with { | |
lp = fi.iir((0.5*(1.+p),-0.5*(1+p)),(0.-p)) with { | |
p = exp(-2.*ma.PI*cutoff/ma.SR) : cfSmooth; | |
}; | |
peak = fi.tf22t(b0/a0,b1/a0,b2/a0,a1/a0,a2/a0) with { | |
w = max(0,cutoff)*(2*ma.PI/ma.SR); | |
A = 10^(dbGain/40); | |
S = sin(w) : cfSmooth; C = cos(w) : cfSmooth; | |
b0 = 1+S*A; b1 =-2*C; b2 = 1-S*A; | |
a0 = 1+S/A; a1 =-2*C; a2 = 1-S/A; | |
}; | |
}; | |
/// | |
process = | |
//par(i, 2, lp1Reson(cutoff, pkShGain, cfSmooth)) | |
par(i, 2, hp1Reson(cutoff, pkShGain, cfSmooth)) | |
with { | |
cfSmooth = si.smooth(ba.tau2pole(50e-3)); | |
cutoff = hslider("[01] Cutoff [unit:Hz] [scale:log]", 440.0, 50.0, 10000.0, 1.0) : max(1.0) : min(20000.0); | |
pkShGain = hslider("[02] Peak/shelf gain [unit:dB]", 0.0, 0.0, 40.0, 0.1) : max(-120.0) : min(60.0); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment