c++ - Qt QAudioInput how to send a fixed number of samples -


i'm tryng send audio stream qt application other device udp protocol. problem target device wants fixed number of samples(in case 320) every packet receives. think must use setbuffersize function of qaudioinput object use catch sound, documentation odd , poor whole qaudioinput object. how can control number of samples send? thank you.

this how send stream:

qaudioformat format; format.setsamplerate(48000); format.setchannelcount(1); format.setsamplesize(16); format.setcodec("audio/pcm"); format.setbyteorder(qaudioformat::littleendian); format.setsampletype(qaudioformat::unsignedint);  //if format isn't supported find nearest supported qaudiodeviceinfo info(qaudiodeviceinfo::defaultinputdevice()); if (!info.isformatsupported(format))     format = info.nearestformat(format);  input = new qaudioinput(format);  socket = new qudpsocket();  socket->connecttohost(ip, port); input->start(socket); 

this way qbytearray:

qaudioformat format; format.setsamplerate(8000); format.setchannelcount(1); format.setsamplesize(16); format.setcodec("audio/pcm"); format.setbyteorder(qaudioformat::littleendian); format.setsampletype(qaudioformat::unsignedint);  //if format isn't supported find nearest supported qaudiodeviceinfo info(qaudiodeviceinfo::defaultinputdevice()); if (!info.isformatsupported(format))     format = info.nearestformat(format);  input = new qaudioinput(format); input->setnotifyinterval((int)20); connect(input, signal(notify()), this, slot(readmore())); socket = new qudpsocket();  socket->connecttohost(ip, port); array.clear(); input->start(socket);   void udpsender::readmore() { array.append(device->readall()); qdebug()<<"array size"<<array.length();  if(array.length()>=5120) \\ @ time, don't care exceeded data {     socket->write(array.mid(0,5120));     array.clear(); } } 


Comments

Popular posts from this blog

javascript - oscilloscope of speaker input stops rendering after a few seconds -

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -