breakfastquay / rubberband

Official mirror of Rubber Band Library, an audio time-stretching and pitch-shifting library.
http://breakfastquay.com/rubberband/
GNU General Public License v2.0
561 stars 89 forks source link

Changing sample rate on the fly? #91

Open Castor215 opened 11 months ago

Castor215 commented 11 months ago

I am trying to port some code from SoundTouch to rubberband. The SoundTouch object has the method setSampleRate to change the sample rate after construction. I was wondering if rubberband has an equivalent way to do this? Do I have to destroy the rubberband object and create a new one if the sample rate is to be changed?

cannam commented 11 months ago

There isn't any way to do this with Rubber Band - the sample rate is fundamental to the setup of the stretcher, so you have to destroy and recreate it.

(If you are switching only between 44100 and 48000 Hz, you might get away without doing this at all. The rate doesn't affect the amount of change to pitch and time, only the quality, and a change of rate within this limited range makes only a small difference to that. So in an emergency, you can use a stretcher constructed for 44100 at 48000 instead, or vice versa, and it should still sound ok. But with more divergent rates, that won't sound good.)