# New ADSR envelope widget

**URL:** <https://discourse.zynthian.org/t/new-adsr-envelope-widget/10269>\
**Category:** Software\
**Tags:** new-feature\
**Created:** [October 7, 2024, 11:17am UTC](https://discourse.zynthian.org/t/new-adsr-envelope-widget/10269 "2024-10-07T11:17:31Z")\
**Posts on this page:** 8\
**Page:** 3

<div class="post-metadata">

**Author:** ![riban](https://discourse.zynthian.org/user_avatar/discourse.zynthian.org/riban/32/2331_2.png) [@riban](https://discourse.zynthian.org/u/riban)\
**Post date:** [October 20, 2024, 7:05am UTC](https://discourse.zynthian.org/t/new-adsr-envelope-widget/10269/41 "2024-10-20T07:05:42Z")

</div>

> [@ricard](#):
>
> two parameters (decay and sustain time) which have similar behavior are rendered very differently in the graphic.

This happens because we have a known amplitude difference (from max to sustain level) in the decay but the fade is less obvious. We don’t want to drop the curve to zero during fade because we need to indicate the release phase. Also, we split the y-axis into segments with a maximum width representing a fraction (based on the quantity of phases) of the total width. Both appoaches are simplistic and could be improved. Please raise a feature request describing the issue and propose some possible curve representations. (If one mind is considering the problem you don’t always get the best implementation!)

> [@ricard](#):
>
> some form of at least semi exponential mapping of parameter values to slope times

Probably true. Raise a feature request and we can consider how this best works. Controls can be flagged as logarithmic (which probably covers all the non-linear curves you describe). This _may_ provide a hint to how to render the curve. We need something that makes sense for each synth’s envelope and may not be a true representation but if something is very obviously wrong, we should improve it.

> [@ricard](#):
>
> the usefulness of graphic envelope representation is rises sharply with more complex envelopes

We can add this to the editor. It is only really plotting level and duration points so not too tricky. (I did this for my VZ-1 editor software and abstracted the [envelope editor](https://github.com/riban-bw/wxEnvelopeGraph).) Please add a feature request. (I know - but I already have reported 44% of the open issues!!!)

> [@ricard](#):
>
> graphic rendering of an ADSR can even add more complexity

I like the option. A MiniMoog had just knobs that you twiddled but they were all there in front of you. Zynthian also has knobs you can twiddle but only 4 at a time. I immediately enjoyed and benefited from @jofemodo’s initial implementation of the envelope editor and with more complex envelopes added in more engines and with touch drag, I love how easy it is to control the whole envelope from one place. It helps to suspend your logical alignment of time and space and use it as a tool to make relative rather than absolute adjustments (as you would when knob twiddling) - “I want a little longer on the attack”, not “I want 1.254s attack”. 😉 I think this (and possible other, future widgets) does provide benefit and is not just a pretty gimick, but we can all chose which features we want to use in the quantiful provision of the zynthian.

> [@ricard](#):
>
> advantageous if the key on period could be indicated in the graph,

😄 Absolutely! This is implemented but commented out in the code. Slightly different to your suggestion, I put a vertical line where the release occurs, i.e. indicating a trigger point in the curve. I too saw the benefit of indicating the key held/released phases of the curve but my implementation was a bit “ugly”, so we removed it and awaited user comment. And now we have one. 😄 @jofemodo what do you think of @ricard’s cool suggestion of indicating the key held period with a bar along the bottom of the display? We would want to avoid using too much vertical space but it could overlay the curve if necessary. Alternatively we could indicate the release point with an icon of line of change of shading. (Avoid colours as they are less accessible and can make the display less attractive (to some).)

> [@ricard](#):
>
> not given that all synths will operate that way

Indeed, each synth may implement each phase in very different ways. Some may invert values (rate rather than time), some may have offsets / bipolar values, etc. We will try to accomodate as many in a common, automatic implementation but if necessary we may need to flag some behaviour. The most urgent example is the couple of synths that have bipolar fade phase. I have reported this as [issue 1247](https://github.com/zynthian/zynthian-issue-tracking/issues/1247).

> [@ricard](#):
>
> synth plugin itself could generate a rendering of its envelope shape

I feel we are wandering into the realms of full plugin editor GUI which is not our aim in the zynthian UI. Simple sound crafting is possible from the limited UI. Complex sound crafting should be done with the native GUI which may provide much better control and visualisation of the plugin’s parameters. I would prefer to work on exposing the native GUI more easily to users, e.g. via a HDMI output. (It is more complex than this but that is the subject of a different discussion.)

---

<div class="post-metadata">

**Author:** ![wyleu](https://discourse.zynthian.org/user_avatar/discourse.zynthian.org/wyleu/32/514_2.png) [@wyleu](https://discourse.zynthian.org/u/wyleu)\
**Post date:** [October 20, 2024, 7:16am UTC](https://discourse.zynthian.org/t/new-adsr-envelope-widget/10269/42 "2024-10-20T07:16:02Z")

</div>

A Picture paints a thousand words.

Drawing envelopes might provide a suitable list of edge cases?

Ironically there isn’t an obvious tool to do this. . .

![Envelope-EPS](https://discourse.zynthian.org/uploads/default/original/2X/2/209e00ed9b07a0ed52e163ecd05c4f8d74727242.gif)

![G2-envelope](https://discourse.zynthian.org/uploads/default/original/2X/6/6bdb2b7c32afcd328cad452fa65f91839e64751d.png)

Two examples from my collection.

Personally I think the Maplin 5600S transient generator has a lot to answer for . . .

[Page 25 . . .](https://worldradiohistory.com/UK/Mapelin/Electronics-Today-and-Maplin-5600S-Owner's-Manual.pdf)

---

<div class="post-metadata">

**Author:** ![riban](https://discourse.zynthian.org/user_avatar/discourse.zynthian.org/riban/32/2331_2.png) [@riban](https://discourse.zynthian.org/u/riban)\
**Post date:** [October 20, 2024, 8:06am UTC](https://discourse.zynthian.org/t/new-adsr-envelope-widget/10269/43 "2024-10-20T08:06:43Z")

</div>

> [@riban](#):
>
> The most urgent example is the couple of synths that have bipolar fade phase. I have reported this as [issue 1247](https://github.com/zynthian/zynthian-issue-tracking/issues/1247).

Fixed in Vangelis. I just needed to make 1=1 and -1=2. I didn’t revert to quadratic equations.

---

<div class="post-metadata">

**Author:** ![jofemodo](https://discourse.zynthian.org/user_avatar/discourse.zynthian.org/jofemodo/32/2_2.png) [@jofemodo](https://discourse.zynthian.org/u/jofemodo)\
**Post date:** [October 21, 2024, 12:16pm UTC](https://discourse.zynthian.org/t/new-adsr-envelope-widget/10269/44 "2024-10-21T12:16:47Z")

</div>

I just added parameter groups and envelope marking to 2 synth engines:

- **Calf Monosynth** =\> It has a “sloped sustain” phase, so it’s good for testing the envelope widget
- **Vex** =\> It naturally fits quite nicely the 4 parameters/page zynthian design, so i decided to make it was worth the effort. On the way i got hugely pleased by some VEX “hidden” features that i was not aware. I prefer to describe the details in this thread:

> [@Arpeggiators](https://discourse.zynthian.org/t/arpeggiators/10315/28):
>
> Did you know about the “arpeggiator features” that our venerable Vex engine hides in its native GUI? note the 3 “black” circles on each part header … Yessss! There is a “hidden” pattern-based arpeggiator for each part, and you can adjust the velocity and more!! It’s also synced to host tempo … I’ve been playing a few minutes only, but it’s super fun!! The pity is that these amazing arpeggiator fe…

Regards,

---

<div class="post-metadata">

**Author:** ![riban](https://discourse.zynthian.org/user_avatar/discourse.zynthian.org/riban/32/2331_2.png) [@riban](https://discourse.zynthian.org/u/riban)\
**Post date:** [October 21, 2024, 2:54pm UTC](https://discourse.zynthian.org/t/new-adsr-envelope-widget/10269/45 "2024-10-21T14:54:09Z")

</div>

There is a problem with bipolar fade. I am working on a solution but have been offline today. I will continue later this week.

---

<div class="post-metadata">

**Author:** ![ricard](https://discourse.zynthian.org/user_avatar/discourse.zynthian.org/ricard/32/6775_2.png) [@ricard](https://discourse.zynthian.org/u/ricard)\
**Post date:** [October 22, 2024, 8:35pm UTC](https://discourse.zynthian.org/t/new-adsr-envelope-widget/10269/46 "2024-10-22T20:35:22Z")

</div>

> [@riban](#):
>
> > [@ricard](#):
> >
> > two parameters (decay and sustain time) which have similar behavior are rendered very differently in the graphic.
> 
> This happens because we have a known amplitude difference (from max to sustain level) in the decay but the fade is less obvious. We don’t want to drop the curve to zero during fade because we need to indicate the release phase.

I understand, but you essentially have the same problem already when the sustain level is set to zero - let’s say the decay time is 1 second and the release is 3 seconds. If you release the key before the decay is up it will continue at the release rate, but the graphic assumes the note is held for the duration of the decay phase and will show the curve dropping to zero before the release.

I don’t have any good ideas on how to solve this though, I think it’s a question of playing around with ideas in small increments. It is problematic, because depending on how long the note is held you will or will not notice the release phase, which is difficult to combine in one graphic.

> [@](#):
>
> Also, we split the y-axis into segments with a maximum width representing a fraction (based on the quantity of phases) of the total width. Both approaches are simplistic and could be improved. Please raise a feature request describing the issue and propose some possible curve representations.

Again, I’m not sure I have any good ideas, but is issues regarding the touch envelope to be repoerted in [GitHub - riban-bw/wxEnvelopeGraph: A wxWidget control that displays draggable nodes connected by straight lines on a scrollable window](https://github.com/riban-bw/wxEnvelopeGraph) or in the general Zynthian issue tracker?

> [@](#):
>
> > [@ricard](#):
> >
> > some form of at least semi exponential mapping of parameter values to slope times
> 
> …  
> Controls can be flagged as logarithmic (which probably covers all the non-linear curves you describe). This _may_ provide a hint to how to render the curve. We need something that makes sense for each synth’s envelope and may not be a true representation but if something is very obviously wrong, we should improve it.

I agree that one ‘exponential-like’ (or ‘logarithmic-like’ depending on you look at it) alternative should be enough, given that the exact mapping is not known anyway.

But quite frankly, are there any envelope generators that have linear controls for envelope times? Certainly it’s not something a hardware synth designer would ever consider, but plugins tend to vary wildly in their attention to detail so perhaps it’s more prevailant there.

> [@](#):
>
> > [@ricard](#):
> >
> > advantageous if the key on period could be indicated in the graph,
> 
> 😄 Absolutely! This is implemented but commented out in the code. Slightly different to your suggestion, I put a vertical line where the release occurs, i.e. indicating a trigger point in the curve.

I don’t really have much of an opinion on the layout of such a function, except that given that the x axis represents time, to me it makes sense to draw the ‘gate’ or ‘note on’ time in the same manner, rather than think of note on and note off events, which is a MIDI-centric way of thinking of it, but I don’t think that’s how most humans intuitively think.

BTW, I initially didn’t realize even from the name that one could edit the envelope right in the graph using the touch screen. I really like the way the segment is highlighted when touched, making it very clear which segment is being affected. I’m not a big fan of touch displays as synth UIs because they require much more concentration on the UI (especially if one has to pick up a stylus) which takes concentration away from playing, compared to knobs. But when the display is there of course it should be put to good use.

---

<div class="post-metadata">

**Author:** ![riban](https://discourse.zynthian.org/user_avatar/discourse.zynthian.org/riban/32/2331_2.png) [@riban](https://discourse.zynthian.org/u/riban)\
**Post date:** [October 23, 2024, 6:36am UTC](https://discourse.zynthian.org/t/new-adsr-envelope-widget/10269/47 "2024-10-23T06:36:07Z")

</div>

> [@ricard](#):
>
> Again, I’m not sure I have any good ideas, but is issues regarding the touch envelope to be repoerted in [GitHub - riban-bw/wxEnvelopeGraph: A wxWidget control that displays draggable nodes connected by straight lines on a scrollable window](https://github.com/riban-bw/wxEnvelopeGraph) or in the general Zynthian issue tracker?

[Zynthian issue tracker.](https://github.com/zynthian/zynthian-issue-tracking/issues)

> [@ricard](#):
>
> not a big fan of touch displays as synth UIs

Knobs are good but we have designed zynthian to be used with knobs and/or switches and/or touch/mouse so we try to make it fully operational in all UIs.

---

<div class="post-metadata">

**Author:** ![ricard](https://discourse.zynthian.org/user_avatar/discourse.zynthian.org/ricard/32/6775_2.png) [@ricard](https://discourse.zynthian.org/u/ricard)\
**Post date:** [October 23, 2024, 7:54am UTC](https://discourse.zynthian.org/t/new-adsr-envelope-widget/10269/48 "2024-10-23T07:54:42Z")

</div>

Yes, and it’s an amazing feat to get the system to work more or less seamlessly in all these environments. I recently loaded up Zynthian on an bare RPi3 to test the CPU loading on that platform, and I was pleased that everything worked more or less out of the box with some minor (and rather obvious) configuration done via the webconf. I fairly effortlessly ran the UI using a mouse and pointer via VNC.

[Previous page](https://discourse.zynthian.org/t/new-adsr-envelope-widget/10269.md?page=2)
