Qt real time audio processing
-
Ok, so the signal is connected to the slot successfully.
[quote author="andrea993.93" date="1314450880"]
I have declare these objects:
@QAudioFormat audioformat;
QAudioInput *input;
QIODevice *intermediario;
QByteArray buffer;@
[/quote]
The only explanation I would have now is that these pointer are destroyed when you are exiting one of your methods. You might want to check this. Furthermore, you can check the "state":http://doc.qt.nokia.com/4.7/qaudio.html#State-enum of your audio input. -
these objects
@
QAudioFormat audioformat;
QAudioInput *input;
QIODevice *intermediario;
QByteArray buffer;
@
are declared out of methods; every method can access them -
Did you check the state of your audio stream ?
[quote author="koahnig" date="1314458762"]Furthermore, you can check the "state":http://doc.qt.nokia.com/4.7/qaudio.html#State-enum of your audio input. [/quote]
You can do with "state()":http://doc.qt.nokia.com/4.7/qaudioinput.html#state . Also you can use "bytesReady()":http://doc.qt.nokia.com/4.7/qaudioinput.html#bytesReady for checking.
Otherwise hopefully somebody with QAudio experience is picking up this thread.
-
I' ve looked the state.
Just I set intermediario->start the state is actived immediately after the state begins stopped and then never return active -
Sounds a bit that whatever you are opening to deliver the audio information does not provide any data. If you are reading a file, it may various reasons like file empty or wrong format.
If you are using a device supplying the data, it is probably stopped or disconnected for any reason. -
You might take a look at "this thread":http://developer.qt.nokia.com/forums/viewthread/7679/ , i posted an example for doing audio processing there.
-
I had already read that thread, thank you...
I tried to compile for windows and the connect work correctly but I need to compile for symbian.
The slot "cattura()" is called all times when "intermediario" is "readyread()"...is it right?
Then which is the correct value of "bytescatturati"?
@
qint64 bytescatturati=1000; //????
@ -
Well, let's take a look at the API Documentation of QIODevice ... ;-)
bq. void QIODevice::bytesWritten ( qint64 bytes ) [signal]
This signal is emitted every time a payload of data has been written to the device. The bytes argument is set to the number of bytes that were written in this payload.
bytesWritten() is not emitted recursively; if you reenter the event loop or call waitForBytesWritten() inside a slot connected to the bytesWritten() signal, the signal will not be reemitted (although waitForBytesWritten() may still return true).
See also readyRead().and
bq. qint64 QIODevice::bytesAvailable () const [virtual]
Returns the number of bytes that are available for reading. This function is commonly used with sequential devices to determine the number of bytes to allocate in a buffer before reading.
Subclasses that reimplement this function must call the base implementation in order to include the size of QIODevices' buffer. Example:
qint64 CustomDevice::bytesAvailable() const
{
return buffer.size() + QIODevice::bytesAvailable();
}
See also bytesToWrite(), readyRead(), and isSequential(). -
I've changed the cattura() function:
@void MainWindow::cattura()
{qint64 Nbytesletti; qint64 i; qint64 media=0; qint64 bytescatturati; bytescatturati=intermediario->bytesAvailable(); if (bytescatturati>0) { Nbytesletti= intermediario->read(buffer.data(),bytescatturati); for (i=0;i<Nbytesletti;i++) { media+=(qint64)buffer.at(i); } media/=Nbytesletti; ui->label->setText(QString("%1").arg(media)); }
}
@
But "intermediario->bytesAvailable()" return ever "0".
Why? -
I've try to monitor the QAudio::State and after "input->start()" the state is Idle.
Why?
-
have you read this?
bq. Symbian Platform Security Requirements
On Symbian, processes which use this class must have the UserEnvironment platform security capability. If the client process lacks this capability, calls to either overload of start() will fail. This failure is indicated by the QAudioInput object setting its error() value to QAudio::OpenError and then emitting a stateChanged(QAudio::StoppedState) signal.
Platform security capabilities are added via the TARGET.CAPABILITY qmake variable. -
thank you very much.
But it does'n work with windows :(
First I want it work with Windows -
nobody can help me?