Short audio file + looping + long buffer = garbage [Patch included]

AudioFormatReaderSource has a bug where reading very short files with a buffer longer than the file doesn’t work properly. The getNextAudioBlock function will naively assume it can handle all cases with one or two reads, and fails to read the right data. Please consider the attached patch.AudioFormatReaderSource.txt (2.2 KB)

Thanks for the patch. I’ll have a look tomorrow.

this will loop the file in the buffer if you use % for clamping the read position. would be better to just fill the buffer with the sample then fill with zeros the remaining samples

kraken: It’s within the if (looping) conditional, see the topic also :wink:

doh sorry i missed that.

Any news on this?