Hi guys,
I’m updating an already released product to JUCE 6 and I’m facing an issue with the new Convolver class.
In this product, we load our IR as “custom” files, which are base64 encoded WAV files. The user can change the IR via a list.
The method I wrote to load the file is:
if(file.existsAsFile() && file.getFileExtension() == ".myIR")
{
MemoryBlock mb;
std::unique_ptr<FileInputStream> fis = file.createInputStream();
fis->readIntoMemoryBlock(mb);
MemoryOutputStream outStream;
bool result = juce::Base64::convertFromBase64(outStream, mb.toString());
const double maxSamples = 200.0 * 44100.0 * 0.001;
auto maxSize = static_cast<size_t> (roundToInt (sRate * (maxSamples / 44100.0))); //170ms
convolver.loadImpulseResponse(outStream.getData(), outStream.getDataSize(), dsp::Convolution::Stereo::yes, dsp::Convolution::Trim::no, maxSize);
}
The only difference between J5 and J6 is in the use of the enum classes for loadImpulseResponse. All the rest is identical: we pass the specs in prepareToPlay, reset the convolver in AudioProcessor::reset() and so on.
The assert is triggered by ResamplingAudioSource::setResamplingRatio, because samplesInPerOutputSample is 0. That method is called by resampleImpulseResponse in the convolver, which is called by makeEngine. What I noticed is that originalSampleRate gets a value of 0, while it should be the specs’ sample rate if it cannot get the correct SR from the file.
Maybe my method is wrong, since I can’t deduct the sample rate of the file, but I had no problems with the old convolver.
Thanks!