I am also working on real-time audio processing using 3rd party libraries and Qt, and have run into a snag. Perhaps if I share what I have done I will help you, and then you or someone else can point out what I am doing wrong and help us both.
First, note that I used the Spectrum Analyser discussed "here":http://labs.qt.nokia.com/2010/05/18/qtmultimedia-in-action-a-spectrum-analyser/ and found on your computer at InstallPath\Qt\Demos\4.7\spectrum to come up with most of what I know.
I am using QAudioInput and QAudioOutput for recording and playback. Much like you, I have setup a circular buffer to store the recorded audio (I use a QByteArray as the data structure for my buffer). In theory, as each element in the circular buffer fills up, I can pass it to my audio processing (in my case CMU Sphinx for voice recognition) and then clear that buffer element. For debug purposes, I do not clear the buffer and can choose to play or process any of the individual buffer elements on demand to make sure I have recorded what I expect and can double check the processed output for each buffer. This results in perfect audio recording and playback, however I get inconsistent results from processing the buffer that eventually lead to seg faults after enough processing attempts.
A summary of the code I use is as follows:
@// Setup QAudioInput and QAudioOutput, not shown for brevity. See the Spectrum example for details
QIODevice *intermediateDevice; // This very temporarily stores recorded audio and then transfers it to the circular buffer
// Initialize the circular buffer, also shown in more detail in the Spectrum example
QByteArray byteArray[NUM_CIRCLE_BUFFER_ELEMENTS]; // Note that the spectrum example names this variable buffer despite it not being a QBuffer
qint64 byteArrayUsed[NUM_CIRCLE_BUFFER_ELEMENTS]; // This tracks how much of each buffer has been used
// Start recording audio
intermediateDevice = input->start();
connect(intermediateDevice, SIGNAL(readyRead()), this, SLOT(captureData())); // captureData is a function you define, and example is below
// Example captureData
void captureData(qint64 bytesToCapture)
qint64 bytesAvailable = byteArray[current].size() - byteArrayUsed[current];
qint64 bytesToRead = qMin(bytesToCapture, bytesAvailable);
// Transfer the audio from the intermediateDevice to the buffer
bytesActuallyRead = intermediateDevice->read(byteArray[current].data() + byteArrayUsed[current], bytesToRead);
byteArrayUsed[current] += bytesActuallyRead;
// Note that this is the simplified version, you would want to have the transferring in a loop and do this again in the next byteArray if bytesActuallyRead < bytesToRead
// How to play one of the byte arrays
The last piece is handing each of the QByteArrays to your processing libraries. I've tried several approaches but haven't had any consistent results.
Let me know if this is helpful and if you can figure out how to do this last part.