termusic icon indicating copy to clipboard operation
termusic copied to clipboard

[Feature Request] Speed control without changing pitch

Open TommyAmberson opened this issue 1 year ago • 10 comments

Currently we have a nice way to change the speed of the playback: https://github.com/tramhao/termusic/issues/47

However this doesn't work for a lot of use cases since it also changes the pitch. Some reasons I've encountered to change the playback speed without changing the pitch:

  • Practicing playing along to a song. You can start slow and change the speed as you get comfortable with the song.
  • Listening to a lecture or audiobook. (although it is quite entertaining to listen to it at 2x speed with the pitch change)

I know some people like to change the speed of songs along with the pitch so I think it would be nice if there was a setting that could toggle between changing the pitch along with the speed and keeping the pitch the same.

TommyAmberson avatar Nov 22 '23 19:11 TommyAmberson

I am currently using audacity to change the speed but I sometimes need to switch to VLC (https://www.reddit.com/r/Ubuntu/comments/uvjfjs/a_simple_audio_player_with_easy_to_adjust/) when I need to change the speed on the fly.

TommyAmberson avatar Nov 22 '23 19:11 TommyAmberson

This is also what I want to do. Recently I changed to a new job and have less time coding. I'll try to catch up.

tramhao avatar Nov 23 '23 00:11 tramhao

https://lib.rs/crates/tdpsola found this and check if it's possible.

tramhao avatar Nov 25 '23 16:11 tramhao

This is my number 1 feature request for podcasts specifically. Are you open to PR's?

ZioKli avatar Dec 21 '23 02:12 ZioKli

Sure! PR's are welcomed!

tramhao avatar Mar 18 '24 01:03 tramhao

Today I found several implementation for this. For mpv backend, there should be scaletempo by default. And we could add -af=rubberband for better results. For gstreamer backend, scaletempo and rubberband exists by plugin. I could try to use them and see the difference. For rusty backend, right now I haven't found any solution for it.

tramhao avatar Mar 18 '24 08:03 tramhao

I checked that mpv backend is using -af=scaletempo2 by default, so the pitch is preserved automatically. You can try

termusic -b mpv

The result is pretty good to me.

tramhao avatar Mar 18 '24 14:03 tramhao

I modified the gstreamer backend to use scale tempo as well. Please try it with

termusic -b gstreamer

tramhao avatar Mar 18 '24 15:03 tramhao

Now that soundtouch has been added (via d2b3386a6bd655fe2428134b2a2e6981d2e8bbff and before), the rusty backend now can change the speed without pitch (to my understanding).

This will be included in the next version with is either 0.10.0 or 0.9.1.

Downsides are that now rusty is not purely rust anymore.

hasezoey avatar Mar 30 '24 11:03 hasezoey

Downsides are that now rusty is not purely rust anymore.

This is driving me crazy. I'm trying to port a simple algorithm sonic.rs from c code, but is not successful. Working with the bindings to sonic.c, and the result is not as good as libsoundtouch. The best result is mpv backend scaletempo2 algorithm. To translate this algorithm into rust, will be a bigger task.

tramhao avatar Apr 04 '24 03:04 tramhao