PDA

View Full Version : Change size of QAudioBuffer - Problems with QAudioProbe



mohabb
14th November 2014, 13:55
I’m doing a project for audio processing in real time. I used the library QAudioRecorder to record and QAudioProbe to process the data. Everything works properly. I plot the result with QWT.

10745


The problem is that the data buffer stores only 40ms,i change the sampleRate (Fs) and it continue to stores 40ms, 320 samples with 8000Hz or 640 samples with 16000Hz in a mono channel. The problem is that i have to process every 250 ms. I want to change the size of the buffer.. How I can change the buffer size?

I think I should change this line of code in question, it connect the buffer with the slot Processed.



connect (probe, SIGNAL (audioBufferProbed (QAudioBuffer)), this, SLOT (Processed (QAudioBuffer)));
probe-> setSource (Audiorecorder);
audioRecorder.record ();



I consulted the internet information. I can build a buffer size as desired:

QAudioBuffer (int numFrames, QAudioFormat const & format, qint64 startTime = -1)

I try to do this, define to variables


QAudioFormat FORMATO;
const QAudioBuffer Buffer;

and start it in constructor


FORMATO(),
Buffer(400, FORMATO, -1.0) //400 samples for example

After, i try:


connect(probe, SIGNAL(audioBufferProbed(QAudioBuffer)),this, SLOT(Procesado( Buffer)));

I define the slot like:


void Processed(const QAudioBuffer Buffer);

It compile correctly, but when i run the programe:


QObject::connect: No such slot MainWindow::Procesado(const Buffer) in ..\ComparadorAlgoritmosEstimadoresPitch\mainwindow .cpp:182
QObject::connect: (receiver name: 'MainWindow')

How do I set the buffer to the function of QAudioProbe, audioBufferProbed?

Thank you very much. Sorry but my english is not very good.

mohabb
14th November 2014, 14:05
I’m doing a project for audio processing in real time. I used the library QAudioRecorder to record and QAudioProbe to process the data. Everything works properly. I plot the result with QWT.

10745


The problem is that the data buffer stores only 40ms,i change the sampleRate (Fs) and it continue to stores 40ms, 320 samples with 8000Hz or 640 samples with 16000Hz in a mono channel. The problem is that i have to process every 250 ms. I want to change the size of the buffer.. How I can change the buffer size?

I think I should change this line of code in question, it connect the buffer with the slot Processed.



connect (probe, SIGNAL (audioBufferProbed (QAudioBuffer)), this, SLOT (Processed (QAudioBuffer)));
probe-> setSource (Audiorecorder);
audioRecorder.record ();



I consulted the internet information. I can build a buffer size as desired:

QAudioBuffer (int numFrames, QAudioFormat const & format, qint64 startTime = -1)

I try to do this, define to variables


QAudioFormat FORMATO;
const QAudioBuffer Buffer;

and start it in constructor


FORMATO(),
Buffer(400, FORMATO, -1.0) //400 samples for example

After, i try:


connect(probe, SIGNAL(audioBufferProbed(QAudioBuffer)),this, SLOT(Procesado( Buffer)));

I define the slot like:


void Processed(const QAudioBuffer Buffer);

It compile correctly, but when i run the programe:


QObject::connect: No such slot MainWindow::Procesado(const Buffer) in ..\ComparadorAlgoritmosEstimadoresPitch\mainwindow .cpp:182
QObject::connect: (receiver name: 'MainWindow')

How do I set the buffer to the function of QAudioProbe, audioBufferProbed?

Thank you very much. Sorry but my english is not very good.

StrikeByte
14th November 2014, 15:50
I don't know if you translated the slot name but you connect to SLOT(Procesado( Buffer)), but your define is called void Processed(const QAudioBuffer Buffer) and not Procesado

(Please don't double post)

anda_skoa
14th November 2014, 16:13
The type of the slot argument is QAudioBuffer. Buffer is the name of an instance of QAudioBuffer.
The SLOT macro needs the type of the argument, not its name.

Cheers,
_

StrikeByte
14th November 2014, 16:22
the connect should look like this :

connect(probe, SIGNAL(audioBufferProbed(QAudioBuffer)),this, SLOT(Processed(QAudioBuffer)));

a tip: http://qt-project.org/wiki/Qt_Coding_Style


anda_skoa: I didn't see that he was using Buffer

mohabb
14th November 2014, 22:18
I will try to explain my problem, when i use the code of the tutorial all work correctly:

connect (probe, SIGNAL (audioBufferProbed (QAudioBuffer)), this, SLOT (Processed (QAudioBuffer)));
probe-> setSource (Audiorecorder);
audioRecorder.record ();

The problem is that i want to change the size of the buffer, the buffer have only memory for 40ms. Someone could help me?

Thanks, It's an error, i translated the slot name!

StrikeByte
21st November 2014, 11:25
I think the size will depend on the amount of samples you have set.

do you want to dynamically change the sample size?