form size(500, 260), caption("Baroque Clarinet"), pluginId("BaroqueClarinet")
keyboard bounds(12, 150, 480, 100)
rslider bounds(22, 10, 72, 75) range(0, 10000, 1000, 1, 0.001), channel("cutoff"), text("Filer Cutoff")
rslider bounds(104, 10, 75, 73) range(0, .3, 0.01, 1, 0.001), channel("emboff"), text("Emb Off")
-n -d -+rtmidi=NULL -M0 --midi-key=4 --midi-velocity-amp=5
;sr is set by the host
ksmps = 32
nchnls = 2
0dbfs=1
;instr 1
;a1 oscili p5, p4, 1
;outs a1, a1
;endin
instr 1
areedbell init 0
ifqc = cpsmidinn(p4)
kfco = chnget:k("cutoff")
ibore = 1/ifqc-15/sr
kenvl madsr 0.01, 0, 1, .1
kenvibr linsegr 0, 0.1, 0, 0.9, 1, 1, .1 ; Vibrato envelope
kemboff = chnget:k("emboff") ; Adjust reed stiffness.
avibr oscil 0.1*kenvibr, 5, 3 ; Breath pressure
apressm = kenvl + avibr ; Lowpass reflection filter at bell
arefilt tone areedbell, kfco
abellreed delay arefilt, ibore ; the delay from bell to reed
; Back pressure and reed table lookup
asum2 = -apressm - 0.95 * arefilt - kemboff
areedtab tablei asum2/4 + 0.34, 4, 1, 0.5
amult1 = asum2*areedtab
; Forward pressure
asum1 = apressm + amult1
areedbell delay asum1, ibore
aofilt atone areedbell, kfco
out aofilt * p5
endin
f3 0 1024 10 1
f4 0 1024 7 0 512 1 512 0
f0 z