I need to use a bunch of small audio samples throughout my app and would like some kind of mechanism (class) to keep it efficient. I started thinking that it would be great if there was something similar to the way JUCE works with image data…

Image logo = ImageCache::getFromMemory(BinaryData::logo_png, BinaryData::logo_pngSize);

Something like:
AudioSample beep = SampleCache::getFromMemory(BinaryData::beep_wav, BinaryData::beep_wavSize);

Is there any way to do something like that?



The MemoryMappedAudioFormatReader would be something similar. However, it is only implemented for not compressing audio formats, i.e. wav and aiff.
If you want to stream, BufferingAudioReader is the other option, where a background thread reads a fixed amount of audio into memory.



I was hoping to encode the wav files directly into the project just images. It looks like Projucer will encode a wav file, but of course, it looks like it’s with all the wav header info, not just the samples. I’ll have to look into this.