This takes a tone sung or played around 440hz and shifts the pitch down by a semitone two seconds after tone onset. Instr 2 is mostly from the harmon2 manpage.
It works ok except for a noticeable click at the pitch shift. Any suggestions for smoothing it out would be much appreciated.
; Audio out Audio in
-odac -iadc -+rtaudio=alsa
afol follow2 a1, .01, .1 ;amplitude following signal
kfol downsamp afol ;
kgate = (kfol<200?0:1);gate input until it crosses amplitude threshold
schedkwhen kgate,0,1,2,0,2,0 ;initial tone - starts when gate opens
schedkwhen kgate,0,1,2,2,1,-100 ;perturbation
krms rms a1, 20
kvar = 0.6 + krms/8000
wsig spectrum a1, .01, 7, 24, 15, 0, 3
koct,kamp specptrk wsig, kvar, 6.75, 9.75, 8.75, 20, 4, .7, 1, 5, 1, .2
k3 linen kamp, .1,1,.1; doesn't reduce the click - why not?
kfrq1 = 0
kcents = p4
kfrq2 = cent(kcents)
a2 delay a1, 0.01
a3 harmon2 a2, koct, kfrq1, kfrq2, 0, 6.9
i1 0 5