Loading sample/files

Hello

Let’s say I would like to build a VST3 plugin that has a bunch of pads. Each pad is a different sample. When the user press a pad it plays the sample/sound associated with that pad for as long as the pad is being held.

Questions:

  1. how would I let the user load/assign their own sample (wav, mp3, etc…) with each pad? Is there any classes in the SDK that facilitate this loading?
  2. the samples would have to be saved with the VST. Shall they be saved with the regular state (Processor::getState) or differently?
  3. I would like the ability for the user to drag and drop their own file on a pad. Is there any classes in the SDK that facilitate this?

Thank you
Yan

I found the class CNewFileSelector (<vstgui4/vstgui/lib/cfileselector.h>) in the SDK which opens the a file dialog to select one file which answers my question #1.

So now that I have loaded a sample and I assume there is no help in the SDK to turn the file into an array of samples, but I suppose you can use libsndfile, or similar to do the job… Is that correct?

Once the sample is loaded, it becomes part of the “state” of the plugin since it needs to be restored when the plugin is loaded again later on. Should it be just saved part of the state like any other parameter (getState(IBStream* state))? Or is there a different mechanism that should be used for larger amount of data (sample could be big…)

Any help appreciated.

Thanks
Yan

Hi

if this is small data (1 or 2 mega) and you want to be sure the user will move between different computer then you could save it in the plugin state,
but i will recommend to save only a path to this file, and reload it when setState is called…