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

ADSRNode issues #194

Open
Avataren opened this issue Sep 7, 2023 · 7 comments
Open

ADSRNode issues #194

Avataren opened this issue Sep 7, 2023 · 7 comments

Comments

@Avataren
Copy link
Contributor

Avataren commented Sep 7, 2023

Hi,
I'm trying to implement a syntesizer with polyphony, and clean up each voice once the release section of the ADSRNode for that voice has "finished", so that I may free up the resources used by this part of the graph.

I have not found any good way to determine that the envelope is really done, there is a finished method, but this returns true the instant the release part of the envelope begins.

    bool ADSRNode::finished(ContextRenderLock& r)
    {
        if (!r.context())
            return true;

        double now = r.context()->currentTime();
        return adsr_impl->_lerp.size() > 0;
    }

I added another method that seems to work, but if there's already a way to detect this without forking the project I would appreciate some pointers to it :)

the way I tried to fix it was like this:

        bool isReleaseCompleted() const
        {
            return _currentGate == 0 && _lerp.empty();
        }

Also there seems to be no way to have exponential ramps, only linear interpolation between the amplitudes. It is my understanding that ADSR envelopes usually are exponential, and not linear. Is this a feature that is planned for the future?

@Avataren
Copy link
Contributor Author

Avataren commented Sep 7, 2023

The approach I used sometimes didn't work, but I managed to set a boolean flag at the end of the release interpolation and use that instead.

@meshula
Copy link
Member

meshula commented Sep 10, 2023

Hi, I'm currently rewriting ADSR and scheduling in order to be able to exactly know the status of a sound versus where it is in its schedule.

@Avataren
Copy link
Contributor Author

I found a pretty good article on implementing "analogue" adsr filters in c++, is this similar to how you are rewriting the adsr node?

He also has a javascript widget that plots the envelope and lets you play with the parameters, and a video on it.

@Avataren
Copy link
Contributor Author

I did a quick and dirty test of the algorithm from that article and put it into a new adsr node, it sounds pretty good.

@meshula
Copy link
Member

meshula commented Sep 12, 2023

No, that's not the approach I was taking, but I like it :)

The aim in a rewrite is to have better behavior in a performance context ~ if you hit a note rapidly, it should gracefully switch into A mode no matter where it was already in the ADSR sequence.

So if your new node is "playable" from an instrument, I'm very happy to take it as a PR in preference to my work in progress as I'm not yet satisfied with mine.

@Avataren
Copy link
Contributor Author

Sure, I just need to clean it up a little.. Do you want me to make a PR with a new node for it, or replace the existing ADSRNode?

@meshula
Copy link
Member

meshula commented Sep 14, 2023

I'm fine with a replacement, thanks!

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

No branches or pull requests

2 participants