QMediaPlayer: How to keep the pitch of audio while changing playback rate (Windows 10)
-
I am using QMediaPlayer to playback video files. This class has the setPlaybackRate method which is cool, but it changes the pitch of the sound.
Is it possible to keep the pitch while changing the rate? I am on Windows 10.
-
Hi and welcome to devnet,
AFAIK, no. QtMultimedia is not made for advanced video manipulation like that.
Out of curiosity, what are you trying to achieve ?
-
Thanks for the answer and sorry for being a little late.
I've implemented a video files viewer using QMediaPlayer. This class has the member playbackRate which is really working, but changes the pitch. I just want to keep the pitch while adding or decreasing the playback speed.
I believe, this feature could be very useful for them who uses playbackRate property. E.g. Windows Media Player and some other players are keeping the pitch.
-
Thanks for the answer and sorry for being a little late.
I've implemented a video files viewer using QMediaPlayer. This class has the member playbackRate which is really working, but changes the pitch. I just want to keep the pitch while adding or decreasing the playback speed.
I believe, this feature could be very useful for them who uses playbackRate property. E.g. Windows Media Player and some other players are keeping the pitch.
-
Hearing does not work the same as seeing. It is quite simple to speed up a video: Just play the frames faster/skip some frames. It is quite simple. If you do the same with sound the pitch will change automatically. It is much harder to keep the pitch the same (I guess you'd have to use Fourier transform). It requires deep knowledge about sound/audio that you cannot expect someone at Qt to have. If you think Qt should have that, you can contribute it yourself. If you think it is too hard, well, you got the answer why it is not in Qt. (BTW, you will not get any features into Qt by mentioning it on the forum.)
-
Hearing does not work the same as seeing. It is quite simple to speed up a video: Just play the frames faster/skip some frames. It is quite simple. If you do the same with sound the pitch will change automatically. It is much harder to keep the pitch the same (I guess you'd have to use Fourier transform). It requires deep knowledge about sound/audio that you cannot expect someone at Qt to have. If you think Qt should have that, you can contribute it yourself. If you think it is too hard, well, you got the answer why it is not in Qt. (BTW, you will not get any features into Qt by mentioning it on the forum.)
@SimonSchroeder said in QMediaPlayer: How to keep the pitch of audio while changing playback rate (Windows 10):
It is much harder to keep the pitch the same (I guess you'd have to use Fourier transform). It requires deep knowledge about sound/audio that you cannot expect someone at Qt to have.
I agree with @SimonSchroeder . Nonetheless, I subscribed to this question as soon as I saw it posted, because I was curious whether someone would link to a "famous" algorithm or some other well-known solution.
Since nobody has, I did some "light Googling," and came up with:
Wikipedia then points to: "Pitch-corrected audio timestretch is found in every modern web browser as part of the HTML standard for media playback. Similar controls are ubiquitous in media applications and frameworks such as GStreamer and Unity. "
If you look at the "External Links" section of the Wikipedia page on timestretching, you also see:
- ZTX Time Stretching Library Free and commercial versions of a popular 3rd party time stretching library for iOS, Linux, Windows and Mac OS X
- TSM toolbox Free MATLAB implementations of various Time-Scale Modification procedures
(among others)
-
Thanks for the answer and sorry for being a little late.
I've implemented a video files viewer using QMediaPlayer. This class has the member playbackRate which is really working, but changes the pitch. I just want to keep the pitch while adding or decreasing the playback speed.
I believe, this feature could be very useful for them who uses playbackRate property. E.g. Windows Media Player and some other players are keeping the pitch.
@Shootah This may help if you try to use a customized pipeline.
https://gstreamer.freedesktop.org/documentation/soundtouch/pitch.html?gi-language=c
and
https://stackoverflow.com/questions/75456587/change-pitch-on-playback-with-gstreamer