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

Current state of Plugin::updateStateValue() #410

Open
lucianoiam opened this issue Feb 2, 2023 · 2 comments
Open

Current state of Plugin::updateStateValue() #410

lucianoiam opened this issue Feb 2, 2023 · 2 comments

Comments

@lucianoiam
Copy link
Contributor

lucianoiam commented Feb 2, 2023

Given

    void ExamplePluginStates::activate() override
    {
        d_stderr("activate");
        updateStateValue("top-left", "hello");
    }

    ExampleUIStates::ExampleUIStates()
    {
    ...
        d_stderr("open ui");
    }

    void ExampleUIStates::stateChanged(const char* key, const char* value) override
    {
    ...
        d_stderr("state changed %s = %s", key, value);
    }

Loading the plugins prints the following:

VST

activate
updateStateValueCallback 0x0
open ui
open ui
open ui
state changed bottom-center = false
state changed bottom-left = false
state changed bottom-right = false
state changed middle-center = false
state changed middle-left = false
state changed middle-right = false
state changed top-center = false
state changed top-left = false
state changed top-right = false

VST3

activate
updateStateValueCallback 0x0
activate
updateStateValueCallback 0x0
open ui
open ui
state changed bottom-center = false
state changed bottom-left = false
state changed bottom-right = false
state changed middle-center = false
state changed middle-left = false
state changed middle-right = false
state changed top-center = false
state changed top-left = false
state changed top-right = false

CLAP

activate
updateStateValueCallback 0x11c59ca20
open ui
open ui
state changed bottom-center = false
state changed bottom-left = false
state changed bottom-right = false
state changed middle-center = false
state changed middle-left = false
state changed middle-right = false
state changed top-center = false
state changed top-left = false
state changed top-right = false

LV2
(Plugin builds but REAPER/Mac is not picking it up, no errors shown)

I was expecting the UI to get top-left="hello" instead of the default value "false".

Cardinal calls updateStateValue() from a OSC handler
https://github.com/DISTRHO/Cardinal/blob/a238f10eec777f2b0704d3299e226bf5129c022c/src/CardinalCommon.cpp#L331

That piece of code could be interpreted as, timing is important, ie. if updateStateValue() only works after the UI opens, but it seems not:

    void activate() override
    {
        t = new std::thread([this](){
            d_msleep(1000);
            d_stderr("thread");
            updateStateValue("top-left", "hello");
        });
    }
open ui
open ui
state changed bottom-center = false
state changed bottom-left = false
state changed bottom-right = false
state changed middle-center = false
state changed middle-left = false
state changed middle-right = false
state changed top-center = false
state changed top-left = false
state changed top-right = false
thread
updateStateValueCallback 0x1382728d0

Are these tests valid at all?

updateStateValueCallback 0x0 means some formats still do not support this right?

@falkTX
Copy link
Contributor

falkTX commented Feb 2, 2023

I would need to check back on this, but this was done initially for LV2 so that is the one that should be working.
It does not require UI to be open, but if it is the UI should get a state value notification.

@lucianoiam
Copy link
Contributor Author

Thanks for the clarification, I confirm LV2 works as expected. It was an unfortunate coincidence that yesterday only that format failed to load on the Mac.

So the call not only works but it is pretty straightforward, it can be done from activate() and the UI will get the updated state immediately upon being opened:

activate
updateStateValueCallback 0x7f90a5f52260
open ui
state changed top-left = hello   <-- not the default value anymore
state changed top-center = false
state changed top-right = false
state changed middle-left = false
state changed middle-center = false
state changed middle-right = false
state changed bottom-left = false
state changed bottom-center = false
state changed bottom-right = false

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

2 participants