mpv-player / mpv

🎥 Command line video player
https://mpv.io
Other
28.63k stars 2.92k forks source link

Change Pitch with Scaletempo2 #8968

Open mysteryx93 opened 3 years ago

mysteryx93 commented 3 years ago

In MPV v0.33.1, there is now "scaletempo2" audio filter that seemingly achieves better quality than scaletempo or rubberband. Scaletempo has a bug preventing from changing the pitch without altering the speed. Rubberband works but causes audio distortions IMO.

Now, scaletempo2 would look interesting, but it's designed to "Scales audio tempo without altering pitch". Would there be a way to extend it to allow shifting the pitch without altering audio tempo?

cyph84 commented 3 years ago

This would be a great feature for https://github.com/marcan/blitzloop

marcan commented 3 years ago

In general, the way you do this with any tempo-shifting algorithm is to follow it with a resampler, which gets you pack to the original tempo and changes the pitch (or any arbitrary combination, depending on the parameters). That's what rubberband does internally, AIUI.

mysteryx93 commented 3 years ago

Also if this pitch-shifting is done in 48000hz instead of 41000hz, it produces better output. It would be nice if it could do that internally.

cyph84 commented 3 years ago

Does an algorithm that subjectively "sounds better" when time-stretching also translate to "sounding better" when used for pitch shifting?

From my unscientific sampling of karaoke friends, all seem to prefer Soundtouch over rubberband. Also, rubberband eats up an entire core on a RPI 2 when increasing pitch.

mysteryx93 commented 3 years ago

I prefer soundtouch over rubberband. Rubberband is inconsistent, alters bass, and causes artefacts with some audios. SoundTouch better respects the source audio.

mysteryx93 commented 2 years ago

There are now many methods to change speed in MPV; and still no feature to change pitch without altering speed besides Rubberband (that doesn't produce good output for all types of audios).

I found that changing pitch with BASS audio gives better quality than the algorithm used in scaletempo. The licensing terms of BASS however won't be suitable for this project.

That's wishful thinking, but I'd love to be able to shift pitch in MPV with the same algorithm that BASS is using.

kokoko3k commented 2 years ago

Also check the workaround posted here, it works with scaletempo: https://github.com/mpv-player/mpv/issues/9544

mysteryx93 commented 2 years ago

ah good to know it's actually possible to make it work!