Integer division by zero in ResamplingAudioSource::getNextAudioBlock


#1

Hello everyone.

I’ve basically copied the example from AudioThumbnailTutorial into my app and trying to play a wave file when I get a division by zero in ResamplingAudioSource::getNextAudioBlock (buffer not valid).

I can get around this by manually calling transportSource.prepareToPlay() again, but how do I know what values I need to pass in?

File f(currentTrackInfo.filename);
AudioFormatReader* reader = formatManager.createReaderFor(f);

if (reader != nullptr)
{
	ScopedPointer<AudioFormatReaderSource> newSource = new AudioFormatReaderSource(reader, true);
	transportSource.setSource(newSource, 0, nullptr, reader->sampleRate);
	readerSource = newSource.release();
	//transportSource.prepareToPlay(448, 44100);
}

My component that does does inherits from AudioAppComponent.

I’ve probably just not quite understood how this works.

Thanks

// E


#2

Small update. If I move it to a subcomponent of the main GUI component, it works…


#3

Try calling your AudioTransportSource’s prepareToPlay method in the AudioAppComponent’s prepareToPlay method.

See this tutorial for a step by step example of playing a file: https://www.juce.com/doc/tutorial_playing_sound_files