Erik de Castro Lopo wrote:
In Jackbeat, I
want to include support for realtime pitch shifting. One
of the option is to use a quality resampler as libsamplerate's
SRC_SINC_BEST_QUALITY converter.
Err, the only think you can do with libsamplerate alone that even comes
close to pitch shifting is the vary speed effect (change the playback
speed and the pitch changes).
I know that changing the playback rate is not exactly pitch-shifting,
but it's what it's called in many drummachines and trackers : increasing
the "pitch" means playing the sample faster. It's a lightweight and
oldschool solution.
Secondly, for any real time operation,
SRC_SINC_BEST_QUALITY is complete
overkill. I would honestly suggest SRC_SINC_FASTEST.
Thanks for this tip. I've been wondering about this for weeks. However I
think the best is to include a user option for this.
Libsoundtouch can do constant pitch time stretching. If you combine
that with libsamplerate's vary speed capabilities then you get
pitch shifting.
If I use libsoundtouch, why should I need libsamplerate to perform
pitch-shifting ?
From the libsoundtouch's homepage :
*- Tempo* *(time-stretch)*: Changes the sound to play at faster or
slower speed than original, without affecting the sound pitch.
*- Pitch (key)* : Changes the sound pitch or key, without affecting the
sound tempo or speed.*
- Playback Rate* : Changes both the sound tempo and pitch, as if an LP
disc was played at wrong RPM rate.
The second feature seems to be able to perform what's properly called
"pitch-shifting".
About vary speed : I could use libsoundtouch instead of libsamplerate,
but I'm not sure the former can compare to the later's quality.
--
og