Presets, Files and Folders

Hello,

I have three short question (I hope). So ask them here.

  1. I’ve made presets to my plugin. I use AudioProcessorValueTreeState for buttons, sliders and comboboxes. All other parameters I store like a string. And save it all as xml. One of these parameters is a folder path to wav samples. And I’m not sure that it’s a good idea to store samples (files) like this. Maybe any other options?

  2. Is it better to store presets params in different xml files or in a single preset file?

  3. Is it possible to rename xml to custom format (like .plugingpreset) and use it in juce?

And I’m sure somebody knows the answers:)
Thank you:)

I don’t understand your questions.

  1. Given that you “save it all as xml”, what do you mean with “I store like a string”? All in a single string attribute? That doesn’t sound like the best idea -I’d save each parameter in a different attribute. I guess you’ve checked this tutorial. What would be “to store sample (files) like this”? As wav files in a folder as opposed to something else? Wavs in a folder sounds right to me.
  2. I guess you mean different presets in different files as opposed to a single file with all presets. I’d go with the former.
  3. Check the docs on XmlElement and File. XmlElement has a writeTo method that saves to a File. File doesn’t care what you’re saving to it -you can choose whatever filename you want. To read from a File you can use parseXML.

Thank you for your answer.

  1. I save each parameter in a different attribute. But for the samples it’s just a path to wav files. Yes. The question was “As wav files in a folder as opposed to something else”

  2. Thanks

  3. I have a preset file “empty.xml” and everything works fine. but I want to change it to “empty.preset”, but in that case my code doesn’t work.

    File preset("…/empty.preset");
    if (auto xml = parseXML(preset))

It works here. You must have some other issue.
btw, in the real case you may want to place your files in a common location (see SpecialLocationType), with a reasonable folder structure.

it’s really strange.
Just one line of code. With empty.xml everything is good. With empty.preset is null.
And, of course, both files are identical and exist in a folder.

The File class in JUCE doesn’t expect the path to be relative, as far as I remember.
It should also trigger an assertion if you try to do so.
Also, in your code above you have three … instead of just two in “…/empty.preset”. Perhaps that was just autocorrect, but better to check that

The site turns all double dots into triple dots, for some reason. The File docs say “If the path supplied is a relative path, it is taken to be relative to the current working directory” (then advises against it).

Thank you.
For sure, I don’t use relative path. I’ve just pasted the last part of it.
The full line of code is
auto files = File{ "/Users/name/Programming/pluging/presets" }.findChildFiles(File::findFiles, true , "empty.preset");

And it doesn't work, but with xml it works:
auto files = File{ "/Users/name/Programming/pluging/presets" }.findChildFiles(File::findFiles, true, "empty.xml");