# Envelope chnset widget

**URL:** <https://forum.cabbageaudio.com/t/envelope-chnset-widget/1713>\
**Category:** Csound Noobs\
**Created:** [17 December 2019 15:24 UTC](https://forum.cabbageaudio.com/t/envelope-chnset-widget/1713 "2019-12-17T15:24:44Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![gerardotrance](https://forum.cabbageaudio.com/user_avatar/forum.cabbageaudio.com/gerardotrance/32/1537_2.png) [@gerardotrance](https://forum.cabbageaudio.com/u/gerardotrance)\
**Post date:** [17 December 2019 15:24 UTC](https://forum.cabbageaudio.com/t/envelope-chnset-widget/1713/1 "2019-12-17T15:24:44Z")

</div>

Can I use the chnset opcode to implement an envelope on a widget  
So far I have a moogladder with a widget control on the cutoff frequency can I use the chnset opcode to apply an envelope to that widget to control the amount of time that widget is set so with a high decay on the envelope the widget will bounce from 0 to 2000 for example

---

<div class="post-metadata">

**Author:** ![rorywalsh](https://forum.cabbageaudio.com/user_avatar/forum.cabbageaudio.com/rorywalsh/32/165_2.png) [@rorywalsh](https://forum.cabbageaudio.com/u/rorywalsh)\
**Post date:** [17 December 2019 17:25 UTC](https://forum.cabbageaudio.com/t/envelope-chnset-widget/1713/2 "2019-12-17T17:25:40Z")

</div>

I’m a little confused, are you asking if you can control a widget from data in Csound, like say an envelop? If so the answer is yes. Check out the following code:

```
<Cabbage>
form caption("Untitled") size(400, 300), colour(58, 110, 182), pluginid("def1")
keyboard bounds(8, 158, 381, 95)
rslider bounds(20, 14, 104, 108) channel("slider"), range(0, 1, 0, 1, 0.001)
</Cabbage>
<CsoundSynthesizer>
<CsOptions>
-n -d -+rtmidi=NULL -M0 -m0d --midi-key-cps=4 --midi-velocity-amp=5
</CsOptions>
<CsInstruments>
; Initialize the global variables. 
ksmps = 32
nchnls = 2
0dbfs = 1

;instrument will be triggered by keyboard widget
instr 1
kEnv madsr .1, .2, .6, .4
chnset kEnv, "slider"
aOut vco2 p5, p4
outs aOut*kEnv, aOut*kEnv
endin

</CsInstruments>
<CsScore>
;causes Csound to run for about 7000 years...
f0 z
</CsScore>
</CsoundSynthesizer>

```

[envControl.csd](https://forum.cabbageaudio.com/uploads/short-url/89XibDJL47p6i0NvOFuV20DHsYV.csd) (703 Bytes)

---

<div class="post-metadata">

**Author:** ![gerardotrance](https://forum.cabbageaudio.com/user_avatar/forum.cabbageaudio.com/gerardotrance/32/1537_2.png) [@gerardotrance](https://forum.cabbageaudio.com/u/gerardotrance)\
**Post date:** [17 December 2019 18:31 UTC](https://forum.cabbageaudio.com/t/envelope-chnset-widget/1713/3 "2019-12-17T18:31:16Z")

</div>

I was more interested if the chnset opcode could be used to modulate the widget if so how would you go about doing this

---

<div class="post-metadata">

**Author:** ![rorywalsh](https://forum.cabbageaudio.com/user_avatar/forum.cabbageaudio.com/rorywalsh/32/165_2.png) [@rorywalsh](https://forum.cabbageaudio.com/u/rorywalsh)\
**Post date:** [17 December 2019 19:43 UTC](https://forum.cabbageaudio.com/t/envelope-chnset-widget/1713/4 "2019-12-17T19:43:52Z")

</div>

Continuously? Just use an oscillator? I’m still not following exactly what you are trying to do.

![ModWidget](https://forum.cabbageaudio.com/uploads/default/original/2X/e/e22e3197f8d82dd9c798cf20aff000329582301e.gif)

---

<div class="post-metadata">

**Author:** ![gerardotrance](https://forum.cabbageaudio.com/user_avatar/forum.cabbageaudio.com/gerardotrance/32/1537_2.png) [@gerardotrance](https://forum.cabbageaudio.com/u/gerardotrance)\
**Post date:** [17 December 2019 20:02 UTC](https://forum.cabbageaudio.com/t/envelope-chnset-widget/1713/5 "2019-12-17T20:02:07Z")

</div>

Sorry for my explanation very much like in the explanation above but only once with varying levels of in intensity so aswell as having a filter cutoff slider you can control in the GUI you could set the cutoff slider to move independent of the GUI control or could leave it at 0 and have no independent movement

---

<div class="post-metadata">

**Author:** ![gerardotrance](https://forum.cabbageaudio.com/user_avatar/forum.cabbageaudio.com/gerardotrance/32/1537_2.png) [@gerardotrance](https://forum.cabbageaudio.com/u/gerardotrance)\
**Post date:** [17 December 2019 20:03 UTC](https://forum.cabbageaudio.com/t/envelope-chnset-widget/1713/6 "2019-12-17T20:03:58Z")

</div>

I suppose with an oscillator that only has one cycle might be what I need or maybe another solution 🤔

---

<div class="post-metadata">

**Author:** ![gerardotrance](https://forum.cabbageaudio.com/user_avatar/forum.cabbageaudio.com/gerardotrance/32/1537_2.png) [@gerardotrance](https://forum.cabbageaudio.com/u/gerardotrance)\
**Post date:** [17 December 2019 20:47 UTC](https://forum.cabbageaudio.com/t/envelope-chnset-widget/1713/7 "2019-12-17T20:47:27Z")

</div>

I suppose one way to describe what I mean is an envelope on top of a filter so on the GUI there’s a slider controlling the filter cutoff but then also something maybe a adsr envelope modulating the filter cutoff also

---

<div class="post-metadata">

**Author:** ![rorywalsh](https://forum.cabbageaudio.com/user_avatar/forum.cabbageaudio.com/rorywalsh/32/165_2.png) [@rorywalsh](https://forum.cabbageaudio.com/u/rorywalsh)\
**Post date:** [17 December 2019 23:59 UTC](https://forum.cabbageaudio.com/t/envelope-chnset-widget/1713/8 "2019-12-17T23:59:26Z")

</div>

My first example showed a slider being controller by an ADSR, that could easily be connected to a filter, and any other control signal can easily be connected to a widget. There is two way communication.
