Unsolved Render/Play Audio buffer data
-
Hi all,
I have an Audio buffer (PCM samples) and I need to render/play the buffer using the system speaker. How can I achieve this?
Any help would be appreciated. -
@sankar-110 What about http://doc.qt.io/qt-5/qaudiooutput.html ?
-
@jsulm ,
I have checked Qaudiooutput.
In the example mentioned they have given the source file as a "filepath".
But my buffer is not a file, rather it is continuous data given by the PCI device.
how do I render/play this? -
@sankar-110 How exactly do you get your audio data? In which format? It does not have to be a file - it is QIODevice: http://doc.qt.io/qt-5/qaudiooutput.html#start
-
@sankar-110
You can create a object of type buffer and set the data given by the PCI device (probably a char array)Simple example:
char *bufferArray; QBuffer buffer; buffer.setData(bufferArray, <replace by size of bufferarray>); // format has been declared before this line QAudioOutput* audio = new QAudioOutput(format); audio.start(&buffer);
References:
http://doc.qt.io/qt-5/qbuffer.html#setData-1
http://doc.qt.io/qt-5/qbuffer.html#QBuffer-1