Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QAudioBufferOutput Class - audioBufferReceived (for music visualization)
Forum Updated to NodeBB v4.3 + New Features

QAudioBufferOutput Class - audioBufferReceived (for music visualization)

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 299 Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W Offline
    W Offline
    Wolfspirit
    wrote on last edited by
    #1

    Hi. I'm currently playing an mp3 via QMediaPlayer. Now I want to get access to the audiobuffer for drawing fancy bars etc while the music plays. So:
    header-file:

    class MainWindow : public QMainWindow {
       ...
       QMediaPlayer *my_playerB;
       QAudioOutput *my_audioOutputB;
       QAudioBufferOutput *audioBufferOutputB;
       ...
       private slots:
          void Oida(const QAudioBuffer &buffer);
          void Oida2();
    }
    

    Sourcecode:

    void MainWindow::Oida(const QAudioBuffer &buffer) {
        qDebug() << "Oida";
    }
    
    void MainWindow::Oida2() {
        qDebug() << "Oida2";
    }
    
    void MainWindow::on_pushButtonOpenGL_clicked()
    {
        my_playerB->setSource(QUrl::fromLocalFile("/home/thomas/Musik/coolmusic.mp3"));
        audioBufferOutputB = new QAudioBufferOutput();
        my_playerB->setAudioBufferOutput(audioBufferOutputB);
        connect(audioBufferOutputB, SIGNAL(audioBufferReceived(QAudioBuffer&)),
                this,       SLOT(Oida(QAudioBuffer&)));
        connect(my_playerB, SIGNAL(audioBufferOutputChanged()),
                 this,       SLOT(Oida2()));
        my_playerB->play();
    }
    

    I'm getting "QObject::connect: No such signal QAudioBufferOutput::audioBufferReceived(QAudioBuffer&)". Why?
    And both functions are not called. Again: Why?
    I hope someone can help me. Thx in advance.

    1 Reply Last reply
    0
    • W Offline
      W Offline
      Wolfspirit
      wrote on last edited by
      #2
      connect(audioBufferOutputB, SIGNAL(audioBufferReceived(QAudioBuffer)),
              this,       SLOT(Oida(QAudioBuffer)));
      

      Got it. All I had to do was removing '&' and it works!

      1 Reply Last reply
      0
      • W Wolfspirit has marked this topic as solved on
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi,

        An additional suggestion: adopt the new connect style using function address rather than the macro based version. You will have compile time error rather than run-time warnings printed in case of an error.

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        1

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved