I tried to play an audio file with AudioFormatReader created from MemoryBlock but the output sound is pretty grainy and even stop after a few seconds sometimes:
void AudioEngine::play(const juce::File &audioToPlay) {
MemoryBlock mb;
audioToPlay.createInputStream()->readIntoMemoryBlock (mb);
auto reader = rawToUniquePtr (formatManager.createReaderFor (std::make_unique<MemoryInputStream> (mb, false)));
// set the source and play the audio
}
While create the reader directly with the file doesn’t have any of those glitch sounds. Have i done it wrong? Appreciate any help
P/s: I have reason to not create the reader directly with audioToPlay file, pretty much a platform specific error
