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
Further Envelope improvements #868
Conversation
This is super nice! |
@felixroos There were quite a few edge cases caused by different behaviors between Firefox and chromium, but this should be ready to go now :) |
not sure why it is flagging prettier, it is passing locally |
finally came around to look at this one! I love the idea to change the envelope type based on which controls are set. // AD
note("c a f e").ad(.1) // = .attack(.1).decay(.1)
note("c a f e").ad(".1:.2") // = .attack(.1).decay(.2)
// AR
note("c a f e").ar(.1) // = .attack(.1).release(.1)
note("c a f e").ar(".1:.2") // = .attack(.1).release(.2) one regression i've noticed is that the fix from #861 seems to have vanished. note("c a f e").decay(1) In the currently deployed version, the crack is gone, and instead, the decay plays till the end. I suspect the problem is somewhere here. as of my knowledge, the only 2 ways to avoid cracking envelopes on firefox is to either let it play till it's finished (as in #861 ) or to implement a custom envelope using an AudioWorklet. Letting it play till the end is not what a normal synth would do but I don't find it very unintuitive either.. What do you think? edit: i have yet to check out the filter envelope logic |
regarding envelope canceling: one idea i haven't tested yet is to not cancel the param but just use another gain node for the release.. this would mean the envelope would continue during the release but it would probably sound more or less the same. don't know why it shouldn't work.. I think the |
This should be ready to go again |
I wanted to improve the envelope behavior to make them more intuitive and musically useful.
current value is held at the end of the event time, and the release ramp begins at that value (like you would expect if you held down a note, and let it go, the release would begin at that time from the current value)
fixes glitchy envelope behavior for filters
changes filter envelopes to use exponential curve (behavior is now more musically useful/ in line with most synthesizers due to how the ear perceives frequency)
Default ADSR values are set based on which parameters are used to be more intuitive/less verbose for achieving desired effect. for example: sound(val).decay(val) will behave like a decay envelope
Test examples:
`
// D
note("f a e c3").sound("gm_synth_strings_2:3").decay(0.1)
// A
note("f a e c3").sound("gm_synth_strings_2:3").attack(0.1)
// AD
note("f a e c3").sound("gm_synth_strings_2:3").attack(0.2).decay(0.1)
// AR
note("f a e c3").sound("gm_synth_strings_2:3").attack(0.2).release(.7)
// ADSR
note("f a e c3").sound("gm_synth_strings_2:3").attack(0.1).decay(0.1).sustain(.5).release(.3)
// filter example
note("c d d g f a".add(12)).sound("sawtooth").lpf(100).lpenv(18).lpattack(0.1).lpdecay(.2).lprelease(2).release(2)
`