I’m quite new to JUCE (and C++), so apologies for the novice question. I am trying to create an audio plugin that essentially ignores incoming audio and instead plays sound from a pre-determined wav file (e.g. one that will be shipped with the plugin, not one that the user will choose). I gather from other forum posts that one way to do this is to make the wav file available as BinaryData. I’ve been looking at the looping audio tutorial as well (and the forum), but I’m struggling to get this working for an audio plugin rather than an audio app. I would greatly appreciate any advice or pointers.
Currently, I am reading the audio file by doing something like this in the AudioProcessor constructor (this may not be the right place for this – open to advice here):
input = new juce::MemoryInputStream (BinaryData::testaudio_wav, BinaryData::testaudio_wavSize, false); audioFormatReader = audioFormatManager.createReaderFor(std::unique_ptr <juce::InputStream> (input)); audioFormatReaderSource = new juce::AudioFormatReaderSource(audioFormatReader, true);
I’m now trying to figure out how to use the audioFormatReader or the audioFormatReaderSource in the processBlock function to get this test audio to play, but the examples I’m finding seem to be for audio applications rather than plugins (at least I think). I found one user who seemed to be taking this approach and then calling the audioFormatReaderSource->getNextAudioBlock in the processBlock function, but I’m not sure what to pass as an argument.
Am I at all on the right track? If not, does anyone know of any sample code that I could look at for reference?