| Hi this is and old code which implements manually a KarplusStrong pluck with a
"passive nonlinear filter" in series with a tanh compression to avoid overflow.
If can generate nice inharmonicities even with a sine input.
sr = 44100
kr = 44100
ksmps = 1
zakinit 2,2
instr 1
idur = 1/150
timout 0,idur,noise
turnoff
noise:
kamp linen 1,idur/5,idur,idur/5
;anoise rand kamp
anoise oscili kamp,150,1; see how a PNF corrupts
; an innocent sine wave ;-)
zaw anoise,0
endin
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
instr 2; Passive nonlinear filter + soft compression
;after J.Pierce & Scott V. Duyne / US Patent 5,703,313
;coded by Josep M Comajuncosas /NovĀ“98
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
iatt1 = .998; attenuation
ifco1 = -.058; freq dependent decay
aback init 0
afdbk init 0
anoise zar 0
ainput1 = anoise + aback
aout1 delay ainput1,1/150
alpf filter2 aout1*iatt1, 1, 1, 1+ifco1, ifco1
;Passive nonlinear filter : a variable allpass filter
;requires sr = kr to run the conditional
;compute some parameters
au = alpf - afdbk
;au = adcrem - afdbk;??????sona millor!!!
ku downsamp au
if ku < 0 goto or
kstiff = p4
goto next
or:
kstiff = p5
next:
afdbk delay1 kstiff*au
;the filter itself
alpf2 biquad alpf,kstiff,1,0,1,kstiff,0
ainput2 = alpf2
aback delay tanh(ainput2),1/150
out aout1*10000
zacl 0,2
endin
f1 0 8193 10 1
i1 0 1
i2 0 5.5 -.3 -.2
s
i1 0 1
i2 0 5.5 -.75 .32
s
i1 0 1
i2 0 5.5 -.85 -.55
s
i1 0 1
i2 0 5.5 -.75 -.62
s
i1 0 1
i2 0 5.5 -.9 -.65
s
i1 0 1
i2 0 5.5 -.95 -.45
s
e
--
Josep M Comajuncosas
C/ Circumval.lacio 75 08790 Gelida - Penedes
Catalunya - SPAIN tel. 93 7792243
e-mail: gelida@intercom.es
ET Informatica de Sistemes
e-mail: jcomajuncosas@campus.uoc.es
http://members.tripod.com/csound/
|