Important: Please read the Qt Code of Conduct -

How to get QAudioBUffer from QMediaPlayer ?

  • Hi

    initialize player

    @ player =new QMediaPlayer(0, QMediaPlayer::StreamPlayback);
    // QMediaContent track=QUrl("");
    QMediaContent track=QUrl("");

    player =new QMediaPlayer(0, QMediaPlayer::StreamPlayback);
    probe = new QAudioProbe;
    connect(probe, SIGNAL(audioBufferProbed(QAudioBuffer)),   
            this, SLOT(processBuffer(QAudioBuffer)));    // this send signal with QAudioBuffer argument


    qbuffer me need for create peak meter
    this method is bad , signal emited onсe per second

    and my peak meter looks like it (on left)
    ! playing)!

    how to get mannualy QAudioBuffer from probe or mediaplayer or have any other way to get buffer?

    sorry for my bad english :/

  • update post

  • update post now

  • Moderators


    I couldn't find any way to do that, sorry.

    However, subscribe to the "Interest mailing list": and ask there. You can find Qt engineers on that mailing list.

    Yoann Lopes is the maintainer for Qt Multimedia. He will know for sure if you can get an QAudioBuffer in a different way, or if you can probe faster.

  • help!!!!!!!!!!!!!!!!

  • Moderators

    Have you emailed the Interest mailing list?

  • i no use email

  • .................................upupuupuupupupupupupup

  • Lifetime Qt Champion


    Like JKSH suggested, use the interest mailing list, if you really don't want to there's still the IRC channel. You can also dig through Qt's code.

    However low-level questions like this one are less likely to find an answer here since this forum is more user oriented and only very few Qt devs are on it.

  • This is the only way to get audio buffers from a QMediaPlayer.

    In your case, each QAudioBuffer you receive contains 1 second of audio, this why the signal is emitted only once per second.
    You could have a timer with a smaller interval and then for each tick you would get the appropriate sample from the last received QAudioBuffer.

    Something like this:
    void processBuffer(const QAudioBuffer &buffer)
    m_lastBuffer = buffer;
    m_lastBufferTime.restart(); // This is a QTime instance

    void onTimerTimeout()
    // This could be called every 100 ms for example
    qint64 timeSinceLastBuffer = m_lastBufferTimer.elapsed() * 1000; // converted to microseconds
    const void *audioData = m_lastBuffer.constData() + m_lastBuffer.format().bytesForDuration(timeSinceLastBuffer);



Log in to reply