My goal is to save a QAudioRecorder
recording into memory. From my research it seems the best way to store the recording is to use a QByteArray
. My audio recorder is probed using a QAudioProbe
.
From the audioBufferProbed
signal I try to append the data to the byte array using this slot method.
QByteArray *byteArr;
void AudioRecorder::processBuffer(const QAudioBuffer &buffer)
{
byteArr->append(buffer.constData<char>());
qDebug() << buffer.byteCount();
qDebug() << byteArr->size();
}
However that doesn't seem to work considering buffer.byteCount();
returns 4092 constantly which seems normal but byteArr->size();
returns weird and irregular increments starting off usually with 2, 4, 6, 7, 189.
The data also usually only ends up being around 18kb in size which also leads me to believe that the data is not being appended into the byte array correctly.
According to the QByteArray::size() docs size()
should give how many bytes are in the array. Along with QAudioBuffer::byteCount() which also should give the amount of bytes in the current buffer, shouldn't the full 4092 from the buffer be copied to the array?
I am also open to another solution that doesn't use QByteArray
if there is a better way to store the data.