CabbageRack
CabbageRack copied to clipboard
How to allow multiple modules in CabbageRack project?
When exporting for VCV Rack, CabbageRack prepares a directory structure that contains a single module:
- module.csd
- LICENSE
- plugin.json
- plugin.so
- README
It is conventional for Rack modules to be distributed in "packs" of multiple modules, as can be seen in plugin.json
:
...
"modules": [ ... ]
...
When modifying the modules
array in plugin.json
, the CabbageRack module fails to register with VCV Rack.
Steps to reproduce
- export a module for VCV Rack (e.g.
cabbage_test
) - open Rack and verify that the plugin loads
- duplicate the
cabbage_test.csd
ascabbage_test_two.csd
- modify the
modules
array inplugin.json
to include the newcabbage_test_two
- open Rack and look for the plugins which are now missing
plugin.json
{
"slug": "cabbage_test",
"name": "Cabbage Test",
"version": "1.0.0",
"license": "GPL",
"brand": "Cabbage Test",
"author": "Rory Walsh",
"authorEmail": "",
"authorUrl": "cabbageaudio.com",
"pluginUrl": "",
"manualUrl": "",
"sourceUrl": "",
"donateUrl": "",
"modules": [
{
"slug": "cabbage_test",
"name": "cabbage_test",
"description": "VCV Rack interface for Cabbage",
"tags": [
"Csound",
"Cabbage"
]
},
{
"slug": "cabbage_test_two",
"name": "cabbage_test_two",
"description": "VCV Rack interface for Cabbage",
"tags": [
"Csound",
"Cabbage"
]
}
]
}
I'm happy to take a pull request on this..
Understandable. I just don't know where to begin, hence the question in the issue title.
What prevents the module from loading the second cabage_test_two.csd
file? Is the plugin.so
unique only to the initial cabbage_test.csd
?
Yes, each 'module' currently deals with a single .csd file. But I think it's probably something here that needs changing: https://github.com/rorywalsh/CabbageRack/blob/master/src/plugin.cpp#L15 When I wrote this interface I don't think it was possible to define multiple modules. The problem is getting the the correct .csd file to be loaded..
One possible solution might be:
- parse the
plugin.json
modules array - for each module object,
- look for a corresponding
.csd
file based on theslug
field<slug>.csd
- initialize the module
- look for a corresponding
Then, we would just need to update:
- the exporter UX so it somehow allows a developer to export just the
.csd
file without the other package files - the documentation to clarify the importance of the
<slug>.csd
naming convention
Do you have any recommendations for a C++ JSON parser? Is there one in the C++ standard library? I've searched but only seem to find recommendations on Stack Overflow for third-party libraries.
Hmm, it looks like there is at least one proposal for JSON parsing support in the C++ standard library. The lack of JSON support in the C++ standard library is somewhat surprising given the ubiquity of JSON.
There is no in-built support for parsing JSON files in C++ afaik. You can write your own parser or use a 3rd party one. https://github.com/nlohmann/json is definitely one of the better ones. I've used quite a bit before and never had an issues, although I'm by no means an expert. If you can hack together something that works on the CabbageRack side I can update the Cabbage stuff. Aporpos, the idea would be that users export all .csd file to a single CabbageRack folder? That sounds like a nice solution. In fact, it would be trivial to place a CabbageRack folder into the VCV Plugins dir when installing Cabbage. And each time a user exports, it automatically get places into that very folder.
it would be trivial to place a CabbageRack folder into the VCV Plugins dir when installing Cabbage. And each time a user exports, it automatically get places into that very folder.
Consider the use case of a module developer who wants to package multiple modules potentially under separate packages. In their case, the folder should be flexible, within reason, and not make too many hard-coded assumptions.
Perhaps, the "Export as VCV Rack module" workflow could be something like:
- prompt user to select a directory (and possibly create an empty directory in the selection process)
- if the directory is empty, scaffold a boilerplate plugin with the
.csd
file - if the folder contains an existing CabbageRack export, place only the
.csd
file into an existing project
The plugin.so
would dynamically register all local .csd
files at runtime, perhaps by parsing the contents of plugin.json
for the module slugs (as described above).
Yes, this sounds good. :+1: