Hey all,
I’m working on a sampler that saves the audio data for each preset in one FLAC file. Each sound instance then reads its portion of the file into memory when the plugin loads.
However, I’m finding that lots of the sound instances end up with empty buffers.
Here’s the code that does the reading:
auto reader = audioFormatManager.createReaderFor(monolithFile);
data.reset(new juce::AudioBuffer<float>(reader->numChannels, length));
reader->read(data->getArrayOfWritePointers(), reader->numChannels, monolithStartSample, length);
this->maxSample = data->getMagnitude(0, length);
if (maxSample == 0)
DBG("empty buffer");
the FLAC file in question absolutely contains audio data between monoStart
and monoStart + length
.
Also, it seems like it’s always the same sections of the file which end up with empty buffers. This file, for example,
fails 720000 - 1440000
fails 1440000 - 2160000
fails 2160000 - 2501808
succeeds 2501808 - 2669328
fails 2669328 - 3389328
There are no problems if I read the entire file into memory first and then copy the various sections into each instance’s buffer. Do I need to reset the FLAC reader’s state or something?