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

Further Envelope improvements #868

Merged
merged 43 commits into from Jan 14, 2024
Merged

Conversation

daslyfe
Copy link
Collaborator

@daslyfe daslyfe commented Dec 16, 2023

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)
`

@Bubobubobubobubo
Copy link
Contributor

This is super nice!

@daslyfe
Copy link
Collaborator Author

daslyfe commented Dec 31, 2023

@felixroos There were quite a few edge cases caused by different behaviors between Firefox and chromium, but this should be ready to go now :)

@daslyfe
Copy link
Collaborator Author

daslyfe commented Dec 31, 2023

not sure why it is flagging prettier, it is passing locally

@felixroos
Copy link
Collaborator

felixroos commented Jan 3, 2024

finally came around to look at this one!

I love the idea to change the envelope type based on which controls are set.
I've added 2 more functions ad + ar to more quickly use those types, so only one control is enough in these cases.
These functions allow both single values (value is used for both) or lists with 2 elements (set individual values):

// 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.
The problem was something like this would have produced a crack before above mentioned PR:

note("c a f e").decay(1)

In the currently deployed version, the crack is gone, and instead, the decay plays till the end.
When I do the same on this branch (envelope_improvements), I get cracks again.

I suspect the problem is somewhere here.
iirc canceling a previously scheduled envelope is not really possible on firefox (as mentioned in #522 )

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

@felixroos
Copy link
Collaborator

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 setTimeout workaround is not really working

@daslyfe
Copy link
Collaborator Author

daslyfe commented Jan 8, 2024

This should be ready to go again

@daslyfe daslyfe merged commit 6d0ecb9 into tidalcycles:main Jan 14, 2024
1 check passed
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

Successfully merging this pull request may close these issues.

None yet

3 participants