libsndfile / libsamplerate

An audio Sample Rate Conversion library
http://libsndfile.github.io/libsamplerate/
BSD 2-Clause "Simplified" License
600 stars 167 forks source link

src_process returns less samples than requested if the rate recently changed #171

Closed mbacarella closed 3 years ago

mbacarella commented 3 years ago

I noticed audio that I was filtering through libsamplerate would stutter a bit right after a sample rate change. It was because src_process was producing slightly fewer samples than requested, so my audio playback buffer wasn't being completely filled.

I looked around at toy programs that use libsamplerate and saw that some of them add 64 to the input_frames after computing the ratio of input_frames.

When I add 64 to input_frames in my program it stops stuttering as well. What behavior is this relying on?

evpobr commented 3 years ago

Hi @mbacarella . II think the clue is hiding here: http://libsndfile.github.io/libsamplerate/faq.html#Q006.

mbacarella commented 3 years ago

Well that indeed solves the mystery. I was not aware there was a FAQ. Thank you!

evpobr commented 3 years ago

You're welcome.