Hi everyone,
I’m trying to play and resample a BinaryData,
this is my code:
void prepareToPlay (double sampleRate, int samplesPerBlock) {
juce::MemoryInputStream inputStream{ BinaryData::sample_wav, BinaryData::sample_wavSize, false };
juce::WavAudioFormat wavFormat;
juce::AudioFormatReader* mFormatReader = wavFormat.createReaderFor(&inputStream, false);
audioFormatReaderSource = new juce::AudioFormatReaderSource(mFormatReader, true);
audioFormatReaderSource->setLooping(true);
resampler = new juce::ResamplingAudioSource{ audioFormatReaderSource, false, getNumOutputChannels() };
resampler->prepareToPlay(samplesPerBlock, sampleRate);
}
void processBlock (juce::AudioBuffer<float>& buffer, juce::MidiBuffer& midiMessages) {
juce::AudioSourceChannelInfo channelInfo(buffer);
resampler->getNextAudioBlock(channelInfo);
for (int i = 0; i < numSamples; i++) {
buffer.setSample(0, i, channelInfo.buffer->getSample(0, i));
buffer.setSample(1, i, channelInfo.buffer->getSample(1, i));
}
}
An exception is thrown at line 1488 of the juce_WavAudioFormat.cpp file
input->setPosition (dataChunkStart + startSampleInFile * bytesPerFrame);
Could anyone help me?