Is BufferingAudioReader working correctly? (solved, yes it's working...)


#1

Hi again,
I was trying to read from a wav file with a buffer, however if I try the code below, strangely only the first 2s or so of the sound are read (I’m using getNextAudioBlock after prepareToPlay). However if I use directly the AudioFormatReader everything works fine. Am I doing something wrong? Is there something else I should know to make BufferingAudioReader work or this is a bug? I’m running the last JUCE offered by projucer in windows 7 64bit.
Thanks!

AudioFormatReader* reader = formatManager.createReaderFor(playerFile);

if (reader != nullptr)
{
  BufferingAudioReader * bufferedReader = new BufferingAudioReader(reader, thread, 1024 * 100);
  audioFormatReaderSource = new AudioFormatReaderSource(bufferedReader , true);
}

#2

If you call getNextAudioBlock from the BufferingAudioReader faster than filling the buffer takes, you get silence. If you use it to feed a real audio device callback, it should work fine, because the fetching of the next block takes only place, when the last one was played back.
But if you call getNextAudioBlock from a loop as fast as possible (e.g. for offline rendering), you get mostly silence.