I’m trying to access a wav file on a server and create the appropriate
AudioFormatReader from it. The reader is stored as a
std::unique_ptr and it gets set up like so:
reader.reset (manager.createReaderFor (resourceUrl.createInputStream (juce::URL::InputStreamOptions (juce::URL::ParameterHandling::inAddress) .withConnectionTimeoutMs (1000) .withNumRedirectsToFollow (1))));
Checking the data members of the reader object confirms that the sample rate, channel layout, and number of samples all match the file as expected. But, calling
read() to fill a buffer from the reader returns all zeroes, and calling
readMaxLevels() shows that the max and min sample values are both zero.
Trying to locate the issue, I loaded the same file from a local disk into the reader like this:
reader.reset (manager.createReaderFor (localFile));
The reader’s metadata is again all correct, but with this the actual sample data can be read into a buffer without issue. Based on that I’m guessing that the issue is something to do with the
InputStream being created from the URL. I’ve tried changing the arguments in
withNumRedirectsToFollow to no avail. Is there some other detail in the
InputStreamOptions object that could be causing this? Otherwise, are there special considerations for accessing server audio files that I’ve overlooked? Any experience/insight much appreciated!