johnh100008948 | 2020-12-07 16:42:45 UTC | #1
From Martin Fitzpatrick's https://www.pythonguis.com/tutorials/failamp-multimedia-player/
He states that "QMediaPlayer does provide a stream of the audio data which is playing"
I have been trawling the docs all day, but can not find the stream. I intend to add a decibel meter to Martin's project.
Any ideas?
Thanks for any advice.
martin | 2021-05-07 07:49:29 UTC | #2
Create GUI Applications with Python & Qt5 by Martin Fitzpatrick — (PyQt5 Edition) The hands-on guide to making apps with Python — Over 10,000 copies sold!
Hi @johnh100008948 welcome to the forum.
This is a nice project, I mentioned it on the tutorial as it was something i was planning to do but not yet got around to. Looking at it now, I'm not sure how to go about it either.
- the "stream" I mentioned there might in fact be the stream that's available when loading from an audio stream -- I think you can see the current data/access the stream as a file device. But that doesn't really help for showing what is currently playing.
- there is an example of an equalizer on the Qt website (this is QML but comparable). This looks promising until you realise they actually pre-calculate the bars loading them in via a separate file.
But all is not lost. There is actually a very nice PyQt5 media player with graphic equalizer called Milkplayer. If you look at the visualizer code what they do there is open the same file in a separate thread using pydub. The QMediaPlayer current positions are used to extract regions of the audio, which is then processed to generate the equalizer.
Purchasing Power Parity
Developers in [[ country ]] get [[ discount.discount_pc ]]% OFF on all books & courses with code [[ discount.coupon_code ]]You could do something similar, and just return the total amplitude instead -- Each AudioSegment
in pydub
has a . dBFS
property which gives you the loudness.
Hope that helps? I'll update the tutorial when I'm back in the office next week.
Create GUI Applications with Python & Qt6 by Martin Fitzpatrick — (PyQt6 Edition) The hands-on guide to making apps with Python — Over 10,000 copies sold!