getting rid of clicks

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.

<CsoundSynthesizer>

<CsOptions>

; Audio out Audio in
-odac -iadc -+rtaudio=alsa

</CsOptions>

<CsInstruments>

sr=48000
kr=4800
ksmps=10
nchnls=1

instr 1

a1 in

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

endin

instr 2

a1 in

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

out a3
endin

</CsInstruments>

<CsScore>

i1 0 5

e
</CsScore>
</CsoundSynthesizer>

On a rainy Sunday...

... I took some time to look at your code. (Always interested to play with opcodes I didn't know about before!)

First, you ask why "k3 linen..." doesn't affect anything. Well, umm, you don't actually use it! (:-)) However, I tried modifying a2 with the value, and it didn't have much if any effect.

Your main problem I think is that you're using the "schedkwhen" statement to restart Instr 2, so you get a great glitch as it picks up the incoming audio again.

I made a simple change, turning 'kcents' into a global 'gkcents' (initialized to 0), and added an Instr 3 to set that:

instr 3
prints "Instr 3 with p4=%f\\n", p4 ; so we can see it happen
gkcents = p4
endin

You can either run that at the appropriate time from a score statement, or change the schedkwhen statements to run it. Start Instr 2 at time 0, and leave it running.

Seems to work with a 440-Hz sine wave. (But somehow using a sung note creates something like a Tarzan yell...! (:-))

Works great - thanks a lot!

Works great - thanks a lot!

pharmacy uk generic cialis buy viagra uk viagra uk kamagra uk z pack avanafil z-pak z-pack zpak viagra online ed drugs z pak ed pills cheap generic viagra staxyn Canadian pharmacy zpack generic viagra cialis uk Canadian pharmacy viagra cialis online buy zithromax