PDA

View Full Version : Do I get the idea of QAudioProbe?



Khaine
8th September 2015, 19:44
I currently have something like this. Player is supposed to be something like pseudo winamp, and everything is staged this way now.


player = new QMediaPlayer; //creating QMediaPlayer instance
probe = new QAudioProbe;
probe->setSource(player);

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

From what I understand - when probe has it's internal buffer full it emits it as signal which I catch with adequate slot function, which would look like that:


void qtplayer::processBuffer(QAudioBuffer buffer)
{

// do something with data in buffer
// I want for example copy insides of this buffer to Vector of Ints, how can I do that?

}

Am I right to this point? I assume that when I use QMediaPlayer, then it uses native system audio format (in my case 44100 Hz, 16 bit, 2 channel), so I assume that probe gets exaclty same format of audio. But what about buffer size? I want probe to get for example 44100 samples of audio, which would be 1 second, can I change that? How do I even know how big is it's internal buffer?

ChrisW67
11th September 2015, 22:12
QAudioBuffer is a wrapper around an array of integers in the specified format. It provides functions to tell you how many bytes in the buffer as well as the sample/frame count. Keep processing QAudioFrames accumulating samples in your own buffer until you have received your 1 second of audio.