Strategies for plugin data

I’m trying to figure out a reasonable strategy for storing & editing some data structures. My data structure has a couple of float arrays and a few other float variables. My plugin will end up with a few dozen of these.

While I’m developing this plugin, it makes sense for me to store/load/edit these as XML files so I can use other tools to edit them, but at some point I want them to be internal to the plugin without loading them from disk.

What’s the best way to deal with this?

I do something similar for my graphics artist… I have a Layout class which reads from comma delimited files… You should put the external files in your Resources folder – on macOS that’s inside the plug-in’s bundle… and on Windows it’s in the AppData Roaming path for the plug-in… next to the settings. (On Windows your installer will have to put the Resources in the correct location).

If you no longer wish to use the external files you can embed them in the code as Binary Data.

Rail

1 Like

That’s how my QT-style layouts work:

but to be honest, I haven’t used it myself in a while, since the layouts I had recently were too simple.
The editor is kind of unfinished, but the layout works stable… it predates Grid and FlexBox in JUCE…

And by “embedding them as Binary Data”, you mean adding the file(s) with Projucer as we would with an image file?

Yep.

Rail

Could you please suggest:

I am building a .vst plugin on MAC. If I am adding the data bin files in projucer as resource file,

  1. Do I need to manually copy these files to resource folder?
  2. Assuming that I am reading from data.bin file, and if the file is present in resource folder, what path to file should I give in my CPP file which reads from data.bin file?
  1. No, the Xcode project has a copy step that copies the resources to the bundle (independent from the Projucer setting “Enable plugin build step”)
  2. You can use juce::File::getSpecialLocation (juce::File::currentApplicationFile)
    auto resources = juce::File::getSpecialLocation (juce::File::currentApplicationFile)
        .getChildFile ("Contents")
        .getChildFile ("Resources");

This will give you the Resources folder in the bundle and you can find from there the files.

Hope that helps

1 Like

Thanks Daniel this will definitely help, a follow-up question,

In my application, I am generating this code from software like MATLAB, and then I am using JUCE to build it and I am not allowed to write my own code, I am allowed to just edit Projucer fields and options.

This generated code takes the path from a c++ macro PATH_TO_BIN_FILES, I was puzzled what value of this MACRO should be set in order to read these files successfully. I wanted to know the relative path to resource folder.

Thanks in advance