# Envelope clic on each note (linen opcode)

**URL:** <https://forum.csound.com/t/envelope-clic-on-each-note-linen-opcode/1883>\
**Category:** Newbies\
**Created:** [November 4, 2024, 9:52am UTC](https://forum.csound.com/t/envelope-clic-on-each-note-linen-opcode/1883 "2024-11-04T09:52:10Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jstoro](https://forum.csound.com/letter_avatar_proxy/v4/letter/j/91b2a8/32.png) [@Jstoro](https://forum.csound.com/u/Jstoro)\
**Post date:** [November 4, 2024, 9:52am UTC](https://forum.csound.com/t/envelope-clic-on-each-note-linen-opcode/1883/1 "2024-11-04T09:52:10Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![tarmo](https://forum.csound.com/letter_avatar_proxy/v4/letter/t/c37758/32.png) [@tarmo](https://forum.csound.com/u/tarmo)\
**Post date:** [November 4, 2024, 10:15am UTC](https://forum.csound.com/t/envelope-clic-on-each-note-linen-opcode/1883/2 "2024-11-04T10:15:09Z")

</div>

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](mailto:noreply@forum.csound.com)\> kirjutas:

---

<div class="post-metadata">

**Author:** ![Jstoro](https://forum.csound.com/letter_avatar_proxy/v4/letter/j/91b2a8/32.png) [@Jstoro](https://forum.csound.com/u/Jstoro)\
**Post date:** [November 4, 2024, 10:34am UTC](https://forum.csound.com/t/envelope-clic-on-each-note-linen-opcode/1883/3 "2024-11-04T10:34:44Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![tarmo](https://forum.csound.com/letter_avatar_proxy/v4/letter/t/c37758/32.png) [@tarmo](https://forum.csound.com/u/tarmo)\
**Post date:** [November 4, 2024, 11:06am UTC](https://forum.csound.com/t/envelope-clic-on-each-note-linen-opcode/1883/4 "2024-11-04T11:06:45Z")

</div>

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](mailto:noreply@forum.csound.com)\>) kirjutas kuupäeval E, 4. november 2024 kell 12:44:

---

<div class="post-metadata">

**Author:** ![rory](https://forum.csound.com/user_avatar/forum.csound.com/rory/32/7_2.png) [@rory](https://forum.csound.com/u/rory)\
**Post date:** [November 4, 2024, 11:09am UTC](https://forum.csound.com/t/envelope-clic-on-each-note-linen-opcode/1883/5 "2024-11-04T11:09:54Z")

</div>

> [@Jstoro](#):
>
> I thought I did, by defining the kenv as the afm amplitude

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:

```csound
; 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 🤣

---

<div class="post-metadata">

**Author:** ![Jstoro](https://forum.csound.com/letter_avatar_proxy/v4/letter/j/91b2a8/32.png) [@Jstoro](https://forum.csound.com/u/Jstoro)\
**Post date:** [November 4, 2024, 11:28am UTC](https://forum.csound.com/t/envelope-clic-on-each-note-linen-opcode/1883/6 "2024-11-04T11:28:51Z")

</div>

Great! Thanks Rory and Tarmo,

It worked by wrapping the division with .

> [@rory](#):
>
> blowing the ears off themselves when they copy and paste your code with an amp of 1500 🤣

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

Thank you!
