Saving short audio clips in state information

I am building a plugin that records short (1-3 second) audio clips, and uses that audio data for further processing. I would like for that audio to still be accessible in the plugin even after the DAW is restarted and the plugin is reopened. I have successfully saved the state of parameters using the getStateInformation() functions in the AudioProcessor and am considering trying to keep the audio data in this state as well. Does this sound like a bad idea?

The most reasonable alternative is to write the recordings to wav files, but I don’t love the idea of having external file dependencies. I also don’t want the user to have to worry about setting up these audio files. Any particular audio recording does not need to be used across different projects (to me, that would mean that saving them as WAVs would be the right thing to do). Has anyone faced this decision before?

really interesting question.

my first reaction was, “yeah, that sounds like a really bad idea”, but then when i thought about it, i can see why it would be quite handy to have the host store that audio data for each instance of the plugin.

i’m currently doing a midi sequence effect, and i certainly want to save my midi sequence as state data, but of course that’s a couple of orders of magnitude smaller than audio data…but yeah, it does pose a nice question.

Is there a limit (imposed, practical, or otherwise) on how much data can be saved in the setStateInformation method?

Storing large blocks of data is unattractive, and I’m not sure of what a practical size limit is for these. Another alternative is storing them in the project directory and having the plugin manage the files (and store just the filenames). That seems like it’s as convenient as getting the directory structure for the project, which I haven’t yet looked into.