c++ - Fill QByteArray from QAudioBuffer -


my goal save qaudiorecorder recording memory. research seems best way store recording use qbytearray. audio recorder probed using qaudioprobe.

from audiobufferprobed signal try append data byte array using slot method.

qbytearray *bytearr;  void audiorecorder::processbuffer(const qaudiobuffer &buffer) {     bytearr->append(buffer.constdata<char>());     qdebug() << buffer.bytecount();     qdebug() << bytearr->size(); } 

however doesn't seem work considering buffer.bytecount(); returns 4092 seems normal bytearr->size(); returns weird , irregular increments starting off 2, 4, 6, 7, 189.

the data ends being around 18kb in size leads me believe data not being appended byte array correctly.

according qbytearray::size() docs size() should give how many bytes in array. along qaudiobuffer::bytecount() should give amount of bytes in current buffer, shouldn't full 4092 buffer copied array?

i open solution doesn't use qbytearray if there better way store data.

you have qbytearray pointer, have not set anything.

you need set qbytearray, in case can use qbytearray(const char * data, int size):

bytearr = new qbytearray(buffer.constdata<char>(), buffer.bytecount()); 

but honest, not sure why using pointer.

you do:

qbytearray bytearr; // global declaration     :    : bytearr.append(buffer.constdata<char>(), buffer.bytecount()); 

you might want try printing if using binary data...:

qdebug() << bytearr.tohex(); 

Popular posts from this blog

php - How should I create my API for mobile applications (Needs Authentication) -

5 Reasons to Blog Anonymously (and 5 Reasons Not To)

Google AdWords and AdSense - A Dynamic Small Business Marketing Duo