Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strange envelope behaviour #7

Closed
SpotlightKid opened this issue Jul 17, 2019 · 21 comments
Closed

Strange envelope behaviour #7

SpotlightKid opened this issue Jul 17, 2019 · 21 comments

Comments

@SpotlightKid
Copy link

I'm not sure, whether this is intentional, but I'm experiencing strange behaviour of the ADSR envelope:

  • The attack is still very slow at the lowest settings.
  • If the sustain is 0 and decay > 0 and attack is 0, there is no sound, even when the decay is increased.
  • Generally the envelope settings react in unexpected ways, which I haven't fully grasped yet.

Is this supposed to behave like a standard ADSR? I had a short look at the source code and AFAICS it doesn't mention any intended special behaviour.

@jpcima
Copy link
Owner

jpcima commented Jul 17, 2019

It's the Exponential ADSR function of faust, known as en.adsre. (as opposed to linear ADSR en.adsr)
It has the Faust source in the file comment at the bottom of ADSREnvelope source.
(implemented in not the cleanest copy-paste fashion, admittedly)

ADR are expressed in seconds, S in decible.

By manipulating, I didn't experience problems as you describe.
I use the jalv host, but there were some parameter sync problems reported on Carla, so I've to see if this might be related.

@SpotlightKid
Copy link
Author

When using the plugin via jalv, I see some other strange behaviour,:

  • If the attack, decay and sustain are at the minimum, the sound goes directly to a low sustain level (but apparently not -40dB). So far, so good, even though the graphical representation shows a descending ramp. For a standard ADSR envelope (with a sustain level below the hearing threshold) I'd expect to only hear a short click, though.
  • As soon as I raise the attack > 0, the sound sustains at maximum after the attack. It should drop to -40 dB after the attack phase.
  • If attack and sustain are at minimum and decay is raised > 0, the sound has a slow attack. It should start at full level and drop to 40dB at the decay rate and not have any attack at all.
  • If the attack is then raised > 0, the envelope behaves as expected, i.e. the sound fades in to max level, then falls back to -40 dB at the decay rate.

I suggest to set the min sustain level to -60dB or lower, with -40dB you can't seem to get non-sustaining sounds.

@jpcima
Copy link
Owner

jpcima commented Jul 18, 2019

While having not examinated the ADSRE function of faust in the greatest detail, I think that:
contrary to linear envelope, time deltas are not to imagine as absolutes, more as time delta of a RC circuit.

In faust, the function will be indicated as

adsre(attT60,decT60,susLvl,relT60,gate)

T60 stands for time constants, which are about the 60% of the exponential "charge/discharge" if you will.

I can provide a switch for Linear/Exponential envelope mode.

Ok for setting a lower bound on the sustain.

@SpotlightKid
Copy link
Author

Thanks for the explanation. I think I understand how the faust exponential envelopes technically work, but I think they are not producing very musically useful behaviour. Also, the behaviour I described in my previous comment seems just plain wrong to me.

If you haven't already read it, I recommend reading this blog article series, which IMO describes the traditional behaviour of analog envelopes very well:

http://www.earlevel.com/main/2013/06/01/envelope-generators/

Part 3 links to a C++ implementation, which AFAICS has liberal license. I use this envelope in a simple example plugin, and it works rather well, though the envelope parameter ranges could probably be scaled better to allow for finer control of small values.

Taking a step back though, string machines usually didn't have full-fledged ADSR envelopes, so if you are aiming to faithfully re-create their features, all of the above might not apply anyway.

@jpcima
Copy link
Owner

jpcima commented Jul 18, 2019

  • For as far as I can tell, the current ADSR uses identical principles as this article describes. will compare in detail.
  • I do not observe the bad behavior which you have described; (to begin, for the 2 points listed in the top post)
  • It's correct that the string machine used a simpler form for envelope. (which may behave different regarding the bass section to-do, will have to check that)
    The model I based it on has used a generic ADSR module, I did similar.
  • I picked an exponential because I think it makes sense; perceptually, and also for matching usual analog (cf. article you posted)

For me, envelope behavior is not surprising, but it's evident we have some contradicting experiences for some reason.

Not necessarily related, it's some thoughts on this:

  • in my experience, analog synths usually control ADR times in logarithmic scale; UI is in linear (is this a problem?).
  • I think the display is awful, I should find a way to make it better scaled and readable. it's maybe the better idea to plot in linear instead of decibel.

@SpotlightKid
Copy link
Author

I do not observe the bad behavior which you have described; (to begin, for the 2 points listed in the top post)

Yes, I only observed those in Carla. But the first 3 points in my first comment (after the issue description) I definitely experience in Jalv. Are you saying, you can't confirm those? Or are you saying that these are expected behaviour?

@jpcima
Copy link
Owner

jpcima commented Jul 18, 2019

I have used Jalv as host.
About Carla, it had a problem with UI reading parameters, which existed in 0.1.0 and was fixed in 97919f0. It is supposed to affect display, but not sound.

It's surprising that there exist sound differences from host to host.

Under Jalv, I could not verify your first 2 statements.
It makes me feel sort of dumb, but I was unable.

  • "The attack is still very slow at the lowest settings." → it's fast
  • "If the sustain is 0 and decay > 0 and attack is 0, there is no sound, even when the decay is increased." → there is sound

At a later time, I can record some samples for checking.

@SpotlightKid
Copy link
Author

SpotlightKid commented Jul 18, 2019

Ok, let's go through these one by one.

The attack is still very slow at the lowest settings." → it's fast

  1. Try setting A: 0,00005 D: >=0.1, S: 0.0, R: 0.0. This gives an immediate attack and a sustained sound as it should.
  2. Now lower the attack to <=0,00004. The attack becomes slow.
  3. Lower the decay to something near 0 and the attack becomes fast again.

Tested with Git commit g31af50c with jalv.gtk (compiled from its git commit 57b35f6) with the generic UI (option -g).

@jpcima
Copy link
Owner

jpcima commented Jul 18, 2019

I have recorded this result. Tried at multiple sample rates and latencies.
I have jalv-git at 1.6.2.r450.57b35f6.

@jpcima
Copy link
Owner

jpcima commented Jul 19, 2019

I've pushed a new branch activate.
In this variant, the initialization which depends on sample rate has been moved.
It goes inside the activate() call, which is probably the best practice.

Maybe it does a thing regarding the problem at hand, or maybe not.

@jpcima
Copy link
Owner

jpcima commented Jul 22, 2019

Hi @SpotlightKid. ping regarding the envelope generator
Did you experience identical results as what I sent 2 posts above? following your experimental steps

ps. yesterday I finalized an implementation of the virtual analog bbd line of a dafx-2018 paper at https://github.com/jpcima/bbd-delay-experimental.
I've implemented in the string machine's chorus, in the branch analog-delay, you're welcome to try if you want before I'll merge it.

@SpotlightKid
Copy link
Author

I wanted to make recordings on my system as well and compare. I haven't found the time yet, but i will soon, I hope.

@YruamaLairba
Copy link

As we discussed with jpcima on irc, the problem is more noticeable with a great envelope decay. Worst and weird, when the envelope attack is set to something short, the actual attack seems controlled by the envelope decay.

It work as expected with this parameters (test1.ogg)
Capture du 2019-08-04 02-38-34

It acts weird with this parameters(test2.ogg)
Capture du 2019-08-04 02-41-07

@jpcima
Copy link
Owner

jpcima commented Aug 4, 2019

Yeah definitely a problem going on here, I'm digging into this and will make an alternative implementation.
At faust there is an open report on the ADSRE, not sure if related grame-cncm/faustlibraries#6

@jpcima
Copy link
Owner

jpcima commented Aug 4, 2019

Done, I've reimplemented the ADSR in pushed in master.

@SpotlightKid
Copy link
Author

Thanks! Works much better, except minimum sustain is only -20 dB, which is not low enough to get non-sustained sounds. Should be at least -60 dB, IMO.

@jpcima
Copy link
Owner

jpcima commented Aug 5, 2019

It's ok I changed it.
(I've adjusted other controls prior as well, to make them more useful, like Osc shape filters and detune)

@SpotlightKid
Copy link
Author

I can confirm that the new envelopes work well and the new "hold" stage is nice to have too.

I only have one minor complaint left: with the tiny label font it is hard to distinguish between "A" (Attack) and "R" (Release) and even the "H" (Hold). It's a bit confusing.

@jpcima
Copy link
Owner

jpcima commented Aug 7, 2019

The UI is a rather low-quality imitation of a reaktor patch.
I didn't try to make anything better than this.
Capture du 2019-08-07 16-37-34

Feel free to contribute some design if you want. I don't prioritize it.
The UI is planned to be extended after adding other parts to the instrument. (see #2)

@SpotlightKid
Copy link
Author

I see. I guess it's better to defer this until a UI redesign is done.

@jpcima
Copy link
Owner

jpcima commented Aug 8, 2019

@SpotlightKid font rendering is reworked in the latest, and the bitmaps display perfect instead of blurry.
Since EG is resolved, I close the issue. Lets' discuss UI in different issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants