My intent, as a JUCE newbie, is to load an entire audio file to memory and then do some operations on it. During my experiments with the library I’ve come up with basically two ways:
MemoryMappedAudioFormatReader. This is how my code looks like, so far:
AudioFormatManager formatManager; formatManager.registerBasicFormats(); AudioFormat *audioFormat = formatManager.getDefaultFormat(); #if MEMORY_MAPPED MemoryMappedAudioFormatReader *reader = audioFormat->createMemoryMappedReader(File("/path/to/my/file.wav")); reader->mapEntireFile(); #else AudioFormatReader *reader = formatManager.createReaderFor(File("/path/to/my/file.wav")); #endif AudioSampleBuffer buffer; reader->read(buffer, 0, reader->lengthInSamples, 0, true, true); delete reader;
Now my questions:
- I just want to grab the file from disk and drop it into memory: is the MemoryMapped version the best choice?
- Why do I need to fill an AudioSampleBuffer in case of the MemoryMapped version? Can I just read data straight from memory, instead?
Thanks in advance!