Qt Phonon open raw audio data file

家住魔仙堡 提交于 2019-12-08 08:32:19

问题


I have already asked a similar question here: Python open raw audio data file

Now I want to open, and play, raw audio files with QtPhonon. The main goal is to open the file and play a certain location in the file, for example from the 10th second to the 20th second. Is it possible using QtPhonon ?

I couldn't find anything useful about the subject.

Thanx in advance.


回答1:


The problem in trying to do this with Phonon is that Phonon::MediaSource does not expose any API with which you can specify the audio format - i.e. the sample rate, encoding and number of channels in your PCM data stream. Normally, this information is encoded in the file header (for PCM data files, typically a WAV header), but since you stated that you want to play "raw audio", I'm assuming you mean literally buffers of PCM samples.

Qt 4.6 introduces a new, lower level, suite of audio APIs in the QtMultimedia module. You can use QAudioOutput to play raw audio streams.

Note that support for the QtMultimedia APIs is not yet as widespread as Phonon, but there are already backends for Windows, Mac, and Linux (supporting PULSE and ALSA audio subsystems).




回答2:


You can probably use the seek() method after loading your MediaObject.

void MediaObject::seek ( qint64 time ) [slot]



来源:https://stackoverflow.com/questions/2132799/qt-phonon-open-raw-audio-data-file

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!