Sharing plugin state with external python application

Hi everyone,

I have a JUCE plugin and I have all my state stored in a ValueTree object. I want to write a UI which will run in a python script. The way I have it working now is that my python script exposes an HTTP endpoint and every X ms the plugin makes a post to that endpoint with an XML version of the whole plugin state. Then the python script parses the XML and does whatever it needs to update the UI. So far it works more or less well, but my state updates can’t be very frequent because parsing the XML takes some time. Also, sending the whole state every time when only some small bits change seems like a waste of resources.

I was wondering how to do that better. I could add some custom logic to send the state by bits and only send those that change or stuff like that, but I was thinking that maybe there’s a better way to have the value tree synced automagically. I had a look at the ValueTreeSynchroniser, but because I need to sync the state to a python script and not another juce app, I would need some sort of implementation of applyChange in python and I guess this is difficult.

What do you think would be the best way to transmit the changes in the ValueTree in a machine readable way that then my python script could understand?

Thanks in advance for your time!

You can provide a ValueTree::Listener object to record changes and send them over whatever IPC method you’re using. You add it to the value tree using addListener

1 Like

thanks for the suggestion, I’ll check that out!

Could you have a 2-way communication and have your python script send a message back to say it’s ready for more data? Just a thought.

Hi, yeah, that is a good idea to make sure the script is not flooded with messages it can’t handle. In fact, at some point I had it implemented like that. However, I still want to optimize the amount of information sent as sending the whole state every time sounds like a waste of resources (as 90% or more is the same). I’ll test several options, thanks for the suggestion!