Below is an excerpt from the SamplerPluginDemo demo.
//==============================================================================
inline std::unique_ptr<AudioFormatReader> makeAudioFormatReader (AudioFormatManager& manager,
const void* sampleData,
size_t dataSize)
{
return std::unique_ptr<AudioFormatReader> (manager.createReaderFor (std::make_unique<MemoryInputStream> (sampleData, dataSize, false)));
}
You can find this (plugin example) here -