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. QT creator monitor audio input
QtWS25 Last Chance

QT creator monitor audio input

Scheduled Pinned Locked Moved Unsolved General and Desktop
qaudioprobeqaudioinputqmediaobjectmonitoringinputdevice
12 Posts 2 Posters 5.2k Views
  • 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.
  • P Offline
    P Offline
    Pajczur
    wrote on 2 May 2017, 11:03 last edited by
    #1

    Hello,
    I wonder is there any way to monitor audio input by using QAudioProbe with QAudioInput or QAudioDeviceInfo as a source?

    I know I can monitor by using by QAudioProbe with QAudioRecorder as a source, but in this case I also initialize recording to file and I want to prevent that.

    As I know QAudioProbe accept also QMediaObject as a source, but don't you know how to convert QAudioInput to QMediaObject?

    Yes I know there is documentation for QMediaObject and I can check, but I am totally begginer, and I am affraid that I would spend a lot of time to read whole documentation to understand and in the and I will fall with answer "No. It is not possible".

    So maybe some of you know the answer and be so kind to just inform me is it possible what I am asking or not? And If not, could you give any advice how to solve my issue?

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 2 May 2017, 21:41 last edited by
      #2

      Hi and welcome to devnet,

      What do you mean by monitor ?

      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
      0
      • P Offline
        P Offline
        Pajczur
        wrote on 3 May 2017, 16:50 last edited by Pajczur 5 Mar 2017, 16:50
        #3

        Hello,
        thanks for your reply.
        By "monitor" I mean something like on that video: https://www.youtube.com/watch?v=JYqQCP0yo2o

        I know how to make it easly when I use QAudioRecorder as a source for QAudioProbe, something like that:
        QAudioProbe->setSource(QAudioRecorder); // It works great

        but that:
        QAudioProbe->setSource(QAudioInput); // That doesn't work

        I know QAudioProbe accepts as a source QAudioRecorder or QMediaObject. So the goal is how to convert QAudioInput to be QMediaObject?

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 3 May 2017, 20:37 last edited by
          #4

          Then there's no real need for QAudioProbe in your case, you can process the audio data you get from QAudioInput.

          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
          0
          • P Offline
            P Offline
            Pajczur
            wrote on 5 May 2017, 11:09 last edited by
            #5

            Hello,
            great thanks for your reply, but could you give any advaice (not asking for solution but any advice) how to do that?

            And I still think I need QAudioProbe also because later I want also check and display the musical tone frequency of recorded audio. So don't you think it's good idea to use QAudioProbe? Or maybe for that case I don't need it also?

            1 Reply Last reply
            0
            • S Offline
              S Offline
              SGaist
              Lifetime Qt Champion
              wrote on 5 May 2017, 20:55 last edited by
              #6

              You likely going to get stereo data most of the time then check the buffer size and you'll known how many audio frame you have in one sample, then convert its content in DB so you can then paint your scale based on that.

              As for audio probe, just keep the common code in one place so you can re-use it with your probe.

              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
              0
              • P Offline
                P Offline
                Pajczur
                wrote on 6 May 2017, 01:11 last edited by
                #7

                Hello,
                great thanks for your reply. I trained a little bit with QAudioProbe and now I think I understand it a little bit more.

                But I am not sure what you mean, and how to understand your answer.
                To be clear my code is:

                QAudioRecorder * audioRecorder = new QAudioRecorder(this);
                        probe = new QAudioProbe;
                        connect(probe, SIGNAL(audioBufferProbed(QAudioBuffer)), this, SLOT(processBuffer(QAudioBuffer)));
                        probka->setSource(audioRecorder);
                

                And slot looks like that:

                void MainWindow::processBuffer(const QAudioBuffer& buffer)
                {
                    qDebug() << buffer.byteCount();
                    qDebug() << sizeof(buffer);
                    qDebug() << buffer.frameCount();
                }
                

                And my doubts to your answer are:

                1. "You likely going to get stereo data most of the time..." - actually I am going to record only mono microphone signal, so why you suppose I going to get stereo?

                2. What do you mean "check buffer size"? If I use just regular C++ sizeof(QAudioBuffer) I get just a lot of eights, like that: 888888888888....
                  But when I use QAudioBuffer.byteCount(); I get a lot of 4096.
                  When I use buffer.frameCount(); I get a lot of 2048.

                3. What do you mean DB? Are you talking about decibels? So then we are not talking about frequency but about loudness/volume? Actually now I know how to get and set audio volume. As you told: I don't even need QAudioProbe. QAudioRecorder::Volume, and setVolume do the job. But now my issue is to get frequency of recorded audio. Something like in guitar tuner. And I have no idea how to get that. Even don't know if QAudioProbe can provide me that solution? Maybe I should focus on something totally differen?

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on 6 May 2017, 21:08 last edited by
                  #8
                  1. Most of the times people listen in stereo

                  2. frameCount/byteCount

                  3. Decibel indeed. The video you showed is a VU-meter so it's not showing the volume you set but the loudness of the sound at the volume you set. So in fact you'd like to make a Spectrogram ?

                  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
                  0
                  • P Offline
                    P Offline
                    Pajczur
                    wrote on 6 May 2017, 23:14 last edited by
                    #9

                    Hello,
                    thanks for your reply.
                    But actually I'm not sure what is frameCount and byteCount. It gives me always the same value. For frameCount it is 2048, and for byteCount it is 4096. But I have no idea how to take advantage of it? How to use those values?

                    1 Reply Last reply
                    0
                    • S Offline
                      S Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on 7 May 2017, 20:58 last edited by
                      #10

                      Frame count is the number of audio frames available in the buffer. Its value will depend on the format of the audio input. The bye count is the number of bytes of data in the buffer.

                      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
                      0
                      • P Offline
                        P Offline
                        Pajczur
                        wrote on 7 May 2017, 21:13 last edited by
                        #11

                        Hello, thanks for your repy,
                        yes I think I understand what is frames count and byte count. But I have no idea how to use those valu to my issue. As you told they depend on the format of the audio input, and ones you set it they are always the same valu, so how I can take the advantage of it?

                        For any help thanks in advance.
                        Best Regards

                        1 Reply Last reply
                        0
                        • S Offline
                          S Offline
                          SGaist
                          Lifetime Qt Champion
                          wrote on 9 May 2017, 18:53 last edited by
                          #12

                          You then know how the data are arranged in your array as well as there range and the number of millisecond worth of them.

                          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
                          0

                          8/12

                          6 May 2017, 21:08

                          • Login

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