音频可视化QMediaPlayer [英] Audio visualization with QMediaPlayer
问题描述
我玩的音频, QMediaPlayer 并希望以可视化的音频电平(例如,像此影片)。结果
我已经找到了示例从Qt的4文档,但他们是手动生成的信号,我发现没有办法得到与QMediaPlayer音频输出缓冲器。结果
我应该如何解决这个问题/有其他的声音图书馆的(跨平台),可以做到这一点?
I am playing audio with the QMediaPlayer and want to visualize the audio levels (for example like in this video).
I already found a example from the Qt 4 documentation but they were manually generating the signal and I found no way to get the audio output buffer with the QMediaPlayer.
How should I solve this problem / are there other audio librarys (crossplatform) that can accomplish this?
感谢
推荐答案
您应该看看 QAudioProbe
。
You should look at QAudioProbe
.
该QAudioProbe类可以进行音频监听正在播放或录制。
The QAudioProbe class allows you to monitor audio being played or recorded.
由于 QMediaPlayer
是 QMediaObject
的子类,则附加 QAudioProbe
到 QMediaPlayer
与布尔QAudioProbe ::的SetSource(QMediaObject *源)
,然后连接到无效QAudioProbe :: audioBufferProbed(常量QAudioBuffer&安培;缓冲区)
信号。该文件提供了一个例子。
As the QMediaPlayer
is a subclass of QMediaObject
, you attach the QAudioProbe
to the QMediaPlayer
with bool QAudioProbe::setSource(QMediaObject* source)
, then connect to the void QAudioProbe::audioBufferProbed(const QAudioBuffer& buffer)
signal. The documentation provides an example.
在对 audioBufferProbed
信号可以处理原始音频数据通过计算的RMS~~V 样品。看看这个<一个href=\"http://www.embedded.com/design/configurable-systems/4006520/Improve-your-root-mean-calculations\">article在计算RMS有效的。
In the slot for the audioBufferProbed
signal you can process the raw audio data to calculate volume, for example by computing the RMS of the sample. Have a look at this article on calculating the RMS efficiently.
要显示你可以使用音量 QProgressBar
,但你可以使用 Qt的小部件库技术应用也可对数刻度这将工作获得更好的性能需要为一个体积显示。
To display the volume you could use QProgressBar
, but you may get better performance using the Qt Widgets for Technical Applications library which can also work on a logarithmic scale which will be needed for a volume display.
这篇关于音频可视化QMediaPlayer的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!