When reading low level audio from QAudioInput
, the resulting data is a QByteArray
. When setting up QAudioInput
, you can tell it the Sample Type you want from the data. If you specify float there, does that mean the data in QByteArray
is already in this format? If it is, do you simply cast the output data to read the float array? If it isn't how is it being stored to get the expected floats out?
Asked
Active
Viewed 492 times
0

dtech
- 47,916
- 17
- 112
- 190

kevin-lisnr
- 43
- 7
1 Answers
0
All computer memory is individual bytes, but you can store in those bytes whatever you want. Do not mistake QByteArray
for a QVector<char>
, QByteArray
is Qt's "generic memory buffer" class.
If the recording format is a float, then simply read floats from the byte array, no need to convert, in fact it will give you more samples than you have since floats are bigger than a byte, and you will get garbage.
You can directly get access to the byte array data
pointer and read size() / sizeof(float)
floats from it.

dtech
- 47,916
- 17
- 112
- 190