Envelope clic on each note (linen opcode)

Hello!

I’m currently learning my first steps in Csound. While I’m trying to do is to get the generator (foscil) to be multiplied by a linen opcode. I think I’m in the right way, but I cannot eliminate the final clic on each note (the duration of the linen parameters is relative to the total duration of the note, I think…). I would like to know what I am doing wrong. Here’s the code for the instrument and the code for one note.

instr 101

iamp = p4
ifreq = p5
icar = p6
imod = p7
indx = p8
irise = p9
idec = p10

kenv linen iamp, p3[times]irise, p3, p3[times]idec
afm foscil kenv, ifreq, icar, imod, indx, 1
out afm
endin

––Score ––
f 1 0 1024 10 10

t 0 60 5 120
; instr strt dur amp freq car mod ndx rise decay
i 101 0 .5 1500 110 1 2 10 1/10 1/2

You create the envelope but do not apply it. Try

out afm*kenv

It is better to have also the amplitude envelope in a-rate, sounds better, so use rather aenv for the enevlope.

Tarmo

E, 4. november 2024 12:02 Juan via The Csound Community <noreply@forum.csound.com> kirjutas:

Hi Tarmo,

I thought I did, by defining the kenv as the afm amplitude. I also tried doing what you say but it multiplied the two amplitudes almost blowing up my ears, do you know why that happended?

I tried using the envelope in audio rate but it is still making that clic in each note.

Thank you,

Juan

Hi,

Right, sorry, I read you email too quickly.
Your code looks right, there might be some mistake in the p-fields that come in I suggest to set once the enelope by numeric constants and print out you p-fields, like:

print irise, idec

kenv linen iamp, 0.1, p3, 0.1
afm foscil kenv, ifreq, icar, imod, indx, 1

hope it helps you further. Otherwise please attach the whole csd.

tarmo

Kontakt Juan via The Csound Community (<noreply@forum.csound.com>) kirjutas kuupäeval E, 4. november 2024 kell 12:44:

You’re right. Applying it there is fine. The issue is more likely down to the fact that you can’t use / in the score without wrapping within [ ]. Change to:

; instr strt dur amp freq car mod ndx rise decay
i 101 0 .5 1500 110 1 2 10 [1/10] [1/2]

and it should work better. Finally, you might consider using 0dbfs=1 in your header section. Then scale everything between 0 and 1. It’s the norm these days and reduces the likelihood of people, like me, blowing the ears off themselves when they copy and paste your code with an amp of 1500 :rofl:

Great! Thanks Rory and Tarmo,

It worked by wrapping the division with [ ].

Oops! Sorry for that, I will do it next time.

Thank you!