adsr
adsr copied to clipboard
Gain jump at start of release phase
When the sustain value is low, the gain seems to jump at the start of the release phase. I used the included tests with the following values:
attack: 0.5892
decay: 0.6596
sustain: 0.1108
release: 1.7864
startValue: 0
endValue: 0
It's audible with trigger 1s
and trigger hold
(when held long enough).
Yeah it does sound a bit off. Not sure if this is a bug or just how linear ramps sound. You're welcome to tinker with the code and see if you can fix it (PRs accepted). I have found (more recently since writing this) that using setTargetAtTime for everything in an envelope sounds much better.
You may also want to check out https://github.com/itsjoesullivan/envelope-generator which was was inspired by this module, but has more control over the curves 😸
I am new to web audio, but I will take a look and see what I can do.
I will definitely check out envelope-generator. Thanks for suggesting it.