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.
Thanks for any advice.
martin | 2021-05-07 07:49:29 UTC | #2
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.
You could do something similar, and just return the total amplitude instead -- Each
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.