Thanks for reading my post .
I am developing a small project to process audio. The program allows both read an .mp3 file or record sound from the microphone .
While playing or recording shows the user the energy of the signal and the spectrum.
When I want to record sound I use QAudioRecorder and everything works properly. The problem is that if I want to read an .mp3 file does not work.I have a problem connecting QMediaPlayer and QAudioProbe.
mediaPlayer=new QMediaPlayer(this);
audioProbe = new QAudioProbe(this);
if (audioProbe->setSource(mediaPlayer)) {
// Probing succeeded, audioProbe->isValid() should be true.
connect(audioProbe, SIGNAL(audioBufferProbed(QAudioBuffer)),
this, SLOT(calculateLevel(QAudioBuffer)));
cout << "All work correctly" << endl;
}else{
cout << "Some problems" << endl;
}
mediaPlayer->setMedia(fileSelected);
mediaPlayer->setVolume(50);
mediaPlayer->play();
mediaPlayer=new QMediaPlayer(this);
audioProbe = new QAudioProbe(this);
if (audioProbe->setSource(mediaPlayer)) {
// Probing succeeded, audioProbe->isValid() should be true.
connect(audioProbe, SIGNAL(audioBufferProbed(QAudioBuffer)),
this, SLOT(calculateLevel(QAudioBuffer)));
cout << "All work correctly" << endl;
}else{
cout << "Some problems" << endl;
}
mediaPlayer->setMedia(fileSelected);
mediaPlayer->setVolume(50);
mediaPlayer->play();
To copy to clipboard, switch view to plain text mode
The sound is played correctly but I fail to connect with QAudioProbe . How I can connect it? Thanks.
Bookmarks