I’m relatively new to JUCE and C++ I was struggling for a little while loading in a file for use as a SamplerSound in a synth that I am creating until I realised I had to use an absolute path. This is a little bit of a pain as I can’t really predict where people will install my plugins and will have to change the path for every operating system I support.
So I was wondering if there was a way for me to load in all the wavs I will be using as assets and compile them into the plugin itself to bypass all of these issues?
Trying to get started with some simple playback of a short sample for a game sfx. I added a wav file via Projucer as a binary resource. The function playTestSound() works fine, but no sound is heard though my below simple example, so what am I doing wrong?
MemoryInputStream* file = new MemoryInputStream(BinaryData::BrickHit_wav, BinaryData::BrickHit_wavSize, false);
auto reader = formatManager.createReaderFor(file);
MemoryInputStream(BinaryData::BrickHit_wav, BinaryData::BrickHit_wavSize, false));
if (reader != nullptr)
{
std::unique_ptr<AudioFormatReaderSource> newSource(new AudioFormatReaderSource(reader, true));
transportSource.setSource(newSource.get(), 0, nullptr, reader->sampleRate);
transportSource.start();
}