I don’t want to go through the trouble of creating bindings for the whole library (which I probably couldn’t figure out how to do anyway), but I want to control JUCE with Python.
The docs say that DynamicObject is for use with scripting languages, but I don’t see how to use it to access JUCE library commands. For the Javascript engine there’s RegisterNativeObject, and it seems I’d need something equivalent for DynamicObject to use JUCE with Python, but I don’t see anything.
Actually, looking at the docs again, I see that setMethod might be the key. I could set a method to point to a native function, I guess? Though I’m a bit lost on the big picture of what it would look like to use NativeObject to interact with Python. For one thing, I don’t understand how to use var. It seems to support various types of variables, but I don’t get how you select a particular subtype of var and how it works with C++'s strict typeness..
Also, I don’t know how I would translate a general DynamicObject object to a Python object..
Thanks. By the way the documentation was worded, I thought DynamicObject could be used for scripting languages in general (not just Javascript).
I could use PyBind11 with JUCE to interface with the Python API, but I was hoping I could use it to make a Python function in my JUCE project that accesses all JUCE functions using DynamicObject rather than having to make bindings for every JUCE function individually.
Basically what I want to do with Python is provide an efficient way to make music programmatically, loading VSTs or whatever other instrument/effect format, connecting them together and disconnecting them at certain times, passing the right parameters to them at the right times, etc. I may also eventually want to programmatically allow for midi input to fulfill certain spaces for parameters/notes while the song is playing and save the data alongside the song program.
DynamicObject wouldn’t solve having to do lots of manual work on the C++ side anyway, even if it worked easily with Python. PyBind11 is IMHO the way to go, I am using it myself for a similar project to yours. I have not yet decided if I will ultimately be using Juce in mine or not, though.
Are you aware of the popsicle project?
They have done the hard work of wrapping much of Juce functionality for PyBind11. It may be that isn’t very actively maintained, though. (They seem to be officially supporting only up to Python 3.12 now, while Python 3.14 will already be out later this year.)
Another option could be to use interprocess communication between Python and a Juce application instead of explicit language bindings. Obviously that would have its own challenges too, 2-way interprocess communication isn’t exactly fun to deal with.
Thanks, popsicle seems perfect for my purpose. It seems the last update was about 9 months ago, so maybe that’s good enough (for a while).
If your similar project will be able load VST3’s and such, I’m curious about how you’re doing it? VST3 is very complicated, and JUCE is the only way I know of to easily work with it.. if you know of another way, maybe it will be useful to me?
Oh, I have another question. It seems that most VST3’s have some kind of digital rights in them because you have to buy them, usually with a subscription. Is that what juce_product_unlocking is for? Because no support for that is planned in popsicle. Or can you just load any VST3, even ones paid for with a subscription, using the normal loading functions?
My project is based around the Clap plugin format. There is not a huge selection of Clap plugins available yet…VST3 plugins hosting support indeed could be the main reason I might ultimately have to have the project use Juce too, since hosting VST3 plugins indeed is quite a hassle to code from scratch.
juce_product_unlocking is for Juce using developers who want to use that for their product authorization, the actual plugin host doesn’t need to care about that.
Dang, audio processors is listed as “in progress” for popsicle, as are a few other crucial sections, and I couldn’t find “PluginFormatManager” or “scanAndAddFile” anywhere in the popsicle source, so I assume they’re not supported, so I assume there’s no way yet to load plugins. Unless they’re not in the source because pybind11 just adds them automatically? idk. But I have no idea how I’d use them if they are, because scanAndAddFile requries an OwnedArray, which is a template that you pass a type to, so I have no idea how I’d do that in Python/popsicle. And the docs don’t cover much. I hope they’re still working on popsicle.
Yeah, unfortunately it looks like the Juce AudioProcessors module doesn’t actually have any bindings code added yet in Popsicle…It is indeed a manual process, since C++ doesn’t really have much in terms of reflection, these things have to be manually written out for things like PyBind11.
By the way, I just remembered there’s another project of interest that bridges Python and Juce, Spotify Pedalboard :
It’s specifically written to allow using audio plugins from Python code. (And uses Juce for that stuff.) Unfortunately, that also has its own quirks and limitations and might not be what you are looking for. They started implementing support for instrument plugins quite late and I suspect the support might not be that advanced yet.
If you are looking at just using python to script audio applications i would suggest you try pedalboard, which is a bit more advanced in term of supported audio functionality than popsicle at the moment, you could eventually pair the two together if you will also need to expose some UI.
It’s not currently very active as i’m working on a much more ambitious project but i always welcome patches and fixes.