Hi @rorywalsh are there plans for adding support for exporting Cabbage instruments to WAMs?
Exporting Cabbage instruments as Web Audio Modules
Short answer: yes. Long answer is I’m not sure what the best way to do it is. Clap has a web audio wrapper project which would be perfect, but development has been slow. Fwiw, I know @Andy.Fillebrown is keen on exploring this too. It would be great to have it.
Hi @rorywalsh ! I don’t know if using Clap would give some extra benefits here but I’ve played a bit with your cabbage js code that is exported and I’ve managed (together with my AI agent ) to ‘export’ cabbage3 instrument directly to WAM.
I’ve done some changes to the original code to make it work and for sure not all changes are good ones. Here is the repo if you want to have a look: https://gitlab.gwdg.de/lovre.bogdanic/cabbage32wam
Here is a link to the WAM host, called WANE, where WAMs can be uploaded and tested: https://wane-3508d7.pages-pe.gwdguser.de/ . I’ve put one Cabbage32WAM example in Generators group so you can add it easlly.
Alternately here is a .json WANE project file (I needed to put txt extension to it because otherwise i couldn’t upload it, so just remove it after you download the file) with cabbage32wam example in it so you can load it and check it out. Don’t forget to press ‘Run audio’ button
WANE_with_cabbage32WAM.json.txt (8.1 KB)
Let me know what you think
Very nice! When you first mentioned WAMs I assumed you were talking about some kind of web assembly build of the actual plugin binaries. This is a much simpler approach and works very well. So your WANE file defines the audio graph. But where/how do you define the UI for the various parts of the synth? I couldn’t see this info in the .json file. We should try to tie this in the main project, if you’re up for it? How do you think it would best work? Maybe an export to WAM command?
I’m not sure if you’re aware of this, but I’ve created HTML elements for each Cabbage widget to make them easier to use across various contexts. They can be found here.
A WANE .json file is basically a project file where name, position and parameters of active nodes are stored. It says nothing about how exactly WAM looks like. That is completely defined in WAM itself.
So in this case, Cabbage section of .csd file defines how GUI looks like. The cabbage32wam takes that part of the code and calls your .js code to construct a HTML element (it’s using of course your HTML elements for that) and then wraps it as defined in WAM specifications so a WAM host can use it. I hope this clarifies it a bit.
Yes, export to WAM command seems self explanatory enough . If you look in the dist folder, there I’ve bundled WAM class together with all dependencies (including Cabbage code) into one index.js file and this is what WAM host is looking for (together with descriptor.json). (Now when I think about it, I could also bundle cabbage.css file in it.) Since this whole bundle (except .csd code of course) won’t change as long as the Cabbage src .js code doesn’t change, you could automatically generate a new bundle on each release and then when user clicks on export to WAM command, Cabbage exports that bundle and just changes the code inside cabbage_instrument.csd with users code. Maybe there is also a better way but this is seems pretty straight forward to me.
We can gladly try to tie it to the main project but I need to warn you that I’m really not an expert when it comes to JavaScript.
That makes 2 of us
Seems perfectly straightforward to me too. I’ve a few other things ot nail down first, but I will try to get around to this shortly. Feel free to make a PR in the meantime
I will try to get around to this shortly.
No rush since there are still several things/features to implement, clean up and optimize in cabbage32wam. That will take a moment but once I do that I will make a PR.