Envelope Help

Hi, I’m totally new to csound. I have no musical background, but some programming knowledge.

My goal is to be able to use linseg to interpolate between arbitrary frequencies, then loop that as many times as I want. It seems like the way to avoid the click/pop between repetitions is to use an envelope, however when I do it just replaces the click with a buzz when it loops. I assume I’m just using envelopes wrong.

Here’s my code. Any help would be wonderful.


sr = 44100
ksmps = 64
nchnls = 2
0dbfs = 1

instr bc
kenv linen .5, .1, 1, .1
aBCline linseg 164.81,.5,100,.5, 164.81
aBCwave poscil kenv, aBCline,-1
outs aBCwave, aBCwave

i "bc" 0 1

It looks like it only happens when I use headphones. When I play the sound through external speakers it sounds fine. This kind of solves the problem, but I’d still love to know what’s going on. I’ve tried different pairs of headphones of different types, so it’s not just tied to that one pair.

hi -

i think looping should be done in the instrument, not via score.

there are different options; perhaps you would like to have a look at
the loopseg opcode.

from programming point of view, using a table with your frequency line
might be a good choice, like:


sr = 44100
ksmps = 64
nchnls = 2
0dbfs = 1

giFreqLine = ftgen(0,0,8192,-5,164.81,4096,100,4096,164.81)

instr bc
kenv = linen:k(.5,.1,p3,.1)
kFreq = poscil:k(1,1,giFreqLine)
aBCwave = poscil:a(kenv,kFreq)

i "bc" 0 10

i used an exponential table, as this should be more appropriate for raw
frequencies. you can adjust the speed of the frequency loops in the
kfreq line.

best -