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. Generating a waveform from an audio (or video) file?
Forum Updated to NodeBB v4.3 + New Features

Generating a waveform from an audio (or video) file?

Scheduled Pinned Locked Moved Solved General and Desktop
12 Posts 3 Posters 4.4k Views 3 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.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by A Former User
    #1

    I'm trying to understand how I can generate a waveform from an audio (or video) file to display to the user.

    I've been googling around for quite a while now and can't determine if this is even possible in Qt without using something like FFmpeg. I've seen all of these classes:QMediaPlayer, QMediaContent, QMediaResource, QAudioProbe and experimented with the Qt Media Player Example but am just not seeing where I can access the actual audio buffer.

    So I have 2 questions:

    1. Is what I want to do even possible without 3rd party libraries?
    2. If it is possible, can some kind soul outline what I need to read and understand in order to access the audio data

    I have tried the suggestions from this question Audio visualization with QMediaPlayer but the result of audioProbe->setSource(player) is always false and the method processBuffer never gets called.

    audioProbe = new QAudioProbe(this);
    bool success = audioProbe->setSource(player);
    qDebug() << success;
    
    connect(audioProbe, SIGNAL(audioBufferProbed(QAudioBuffer)), this, SLOT(processBuffer(QAudioBuffer)));
    
    kshegunovK 1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Are you by any chance running Windows ?

      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
      • SGaistS SGaist

        Hi,

        Are you by any chance running Windows ?

        ? Offline
        ? Offline
        A Former User
        wrote on last edited by
        #3

        @SGaist

        No – OSX, and I need it to run on WIndows too.

        Hard to believe this is not easy to do.

        1 Reply Last reply
        0
        • ? A Former User

          I'm trying to understand how I can generate a waveform from an audio (or video) file to display to the user.

          I've been googling around for quite a while now and can't determine if this is even possible in Qt without using something like FFmpeg. I've seen all of these classes:QMediaPlayer, QMediaContent, QMediaResource, QAudioProbe and experimented with the Qt Media Player Example but am just not seeing where I can access the actual audio buffer.

          So I have 2 questions:

          1. Is what I want to do even possible without 3rd party libraries?
          2. If it is possible, can some kind soul outline what I need to read and understand in order to access the audio data

          I have tried the suggestions from this question Audio visualization with QMediaPlayer but the result of audioProbe->setSource(player) is always false and the method processBuffer never gets called.

          audioProbe = new QAudioProbe(this);
          bool success = audioProbe->setSource(player);
          qDebug() << success;
          
          connect(audioProbe, SIGNAL(audioBufferProbed(QAudioBuffer)), this, SLOT(processBuffer(QAudioBuffer)));
          
          kshegunovK Offline
          kshegunovK Offline
          kshegunov
          Moderators
          wrote on last edited by
          #4

          @TOMATO_QT
          Hello,
          It would be helpful to check these things:

          • Have you made sure you have the Q_OBJECT macro on top of your class declaration (this is needed for signal-slot connections)?
          • Does player support probing for audio?
          • Do you have any debug output in your debug window relating to the QObject::connect you're invoking (connections are made in runtime)?
          • What does your media object return as availability, do you get QMultimedia::Available?

          Read and abide by the Qt Code of Conduct

          ? 1 Reply Last reply
          0
          • kshegunovK kshegunov

            @TOMATO_QT
            Hello,
            It would be helpful to check these things:

            • Have you made sure you have the Q_OBJECT macro on top of your class declaration (this is needed for signal-slot connections)?
            • Does player support probing for audio?
            • Do you have any debug output in your debug window relating to the QObject::connect you're invoking (connections are made in runtime)?
            • What does your media object return as availability, do you get QMultimedia::Available?
            ? Offline
            ? Offline
            A Former User
            wrote on last edited by A Former User
            #5

            @kshegunov

            Hi, thanks for the reply.

            • For testing/learning I am using the Media Player Example which ships with Qt, so it is set up correctly with Q_OBJECT etc.

            • For audio, I tested with both .mp3 and .wav files. FWIW, the player example won't play video for some reason (.mp4, .avi were tested)

            • The player in the code is QMediaPlayer – which inherits from QMediaObject. The example code for the Player class is here. I added my code (in original comment above) right after the player is instantiated. I also tried adding it once media is loaded.

            • I tried declaring my slot first as private, then as public – either way, it is never called.

            • Finally, I test for QMediaPlayer.availability() and it always reports "0": QMultimedia::Available 0 The service is operating correctly.

            Frustrating that such a simple thing is so hard.

            kshegunovK 1 Reply Last reply
            0
            • ? A Former User

              @kshegunov

              Hi, thanks for the reply.

              • For testing/learning I am using the Media Player Example which ships with Qt, so it is set up correctly with Q_OBJECT etc.

              • For audio, I tested with both .mp3 and .wav files. FWIW, the player example won't play video for some reason (.mp4, .avi were tested)

              • The player in the code is QMediaPlayer – which inherits from QMediaObject. The example code for the Player class is here. I added my code (in original comment above) right after the player is instantiated. I also tried adding it once media is loaded.

              • I tried declaring my slot first as private, then as public – either way, it is never called.

              • Finally, I test for QMediaPlayer.availability() and it always reports "0": QMultimedia::Available 0 The service is operating correctly.

              Frustrating that such a simple thing is so hard.

              kshegunovK Offline
              kshegunovK Offline
              kshegunov
              Moderators
              wrote on last edited by
              #6

              @TOMATO_QT
              Hello,
              I'd venture to guess you are missing a plugin or a codec, although I have not worked with the multimedia classes, so this is speculative. From what I can see here OS X's backend does not support audio probing.

              PS:

              I tried declaring my slot first as private, then as public – either way, it is never called.

              The access you declare for your slots is inconsequential when you connect them in the old style, because no compile time checks are done and calling each corresponding function is done through QMetaObject::invokeMethod.

              Read and abide by the Qt Code of Conduct

              ? 1 Reply Last reply
              0
              • kshegunovK kshegunov

                @TOMATO_QT
                Hello,
                I'd venture to guess you are missing a plugin or a codec, although I have not worked with the multimedia classes, so this is speculative. From what I can see here OS X's backend does not support audio probing.

                PS:

                I tried declaring my slot first as private, then as public – either way, it is never called.

                The access you declare for your slots is inconsequential when you connect them in the old style, because no compile time checks are done and calling each corresponding function is done through QMetaObject::invokeMethod.

                ? Offline
                ? Offline
                A Former User
                wrote on last edited by A Former User
                #7

                @kshegunov

                Thanks for digging that chart up. I tripped over that same info just now indirectly on another of my endless google searches on this issue

                http://comments.gmane.org/gmane.comp.lib.qt.user/10973

                Re: QAudioProbe and QMediaPlayer
                On Feb 3, 2014, at 5:40 PM, Ziggy Uszkurat wrote:

                I’m trying to attach a QAudioProbe to QMediaPlayer but I’m having no luck. When I setSource >>it returns false. Can anyone give me a clue where I might be going wrong?

                You are not doing anything wrong, not all multimedia APIs are supported on all platforms. QAudioProbe is currently supported only on Linux (with the GStreamer backend) and Windows (with the WMF backend, which is available only when Qt is built with MSVC)

                Yoann Lopes
                Senior Software Engineer - Digia, Qt
                Visit us on: http://qt.digia.com

                What a GD waste of my time. WHY doesn't the QAudioProbe class SAY it isn't supported on OSX.
                This is why I have ditched Qt in the past – it is NOT "Qt Everywhere" – it often ends up being a huge and pointless time sink.

                And I still have no way of accessing the audio data. Even GD HTML5 exposes it.

                1 Reply Last reply
                0
                • kshegunovK Offline
                  kshegunovK Offline
                  kshegunov
                  Moderators
                  wrote on last edited by
                  #8

                  @TOMATO_QT said:

                  WHY doesn't the QAudioProbe class SAY it isn't supported on OSX.
                  This is why I have ditched Qt in the past – it is NOT "Qt Everywhere" – it often ends up being a huge and pointless time sink.

                  It actually does, by returning false. Take a look at the documentation page I attached in one of my previous posts. Qt depends on the OS X's ability to provide the API needed for probing, it's a wrapper around the system functions, so you'll have to ask Apple why this is not implemented ... The same goes for many other components of Qt, by the way, you can't expect to have threads on a system that does not support them, right?

                  Read and abide by the Qt Code of Conduct

                  ? 1 Reply Last reply
                  0
                  • kshegunovK kshegunov

                    @TOMATO_QT said:

                    WHY doesn't the QAudioProbe class SAY it isn't supported on OSX.
                    This is why I have ditched Qt in the past – it is NOT "Qt Everywhere" – it often ends up being a huge and pointless time sink.

                    It actually does, by returning false. Take a look at the documentation page I attached in one of my previous posts. Qt depends on the OS X's ability to provide the API needed for probing, it's a wrapper around the system functions, so you'll have to ask Apple why this is not implemented ... The same goes for many other components of Qt, by the way, you can't expect to have threads on a system that does not support them, right?

                    ? Offline
                    ? Offline
                    A Former User
                    wrote on last edited by
                    #9

                    @kshegunov

                    It should say it in the documentation for QAudioProbe, as well as other classes where support varies by platform – same for the examples: what is the point or learning value of an "example" if it doesn't state what the limitations or differences are per platform.

                    OR – just include a link to that chart in the classes where support varies by platform – it's not a hard thing to do.

                    kshegunovK 1 Reply Last reply
                    0
                    • ? A Former User

                      @kshegunov

                      It should say it in the documentation for QAudioProbe, as well as other classes where support varies by platform – same for the examples: what is the point or learning value of an "example" if it doesn't state what the limitations or differences are per platform.

                      OR – just include a link to that chart in the classes where support varies by platform – it's not a hard thing to do.

                      kshegunovK Offline
                      kshegunovK Offline
                      kshegunov
                      Moderators
                      wrote on last edited by kshegunov
                      #10

                      @TOMATO_QT
                      That's my point, it is in the documentation of the QAudioProbe::setSource method. Also this is the second list item of my first post, the link is pointing right there. :)

                      If the media object does not support monitoring audio, this function will return false.

                      Read and abide by the Qt Code of Conduct

                      ? 1 Reply Last reply
                      0
                      • kshegunovK kshegunov

                        @TOMATO_QT
                        That's my point, it is in the documentation of the QAudioProbe::setSource method. Also this is the second list item of my first post, the link is pointing right there. :)

                        If the media object does not support monitoring audio, this function will return false.

                        ? Offline
                        ? Offline
                        A Former User
                        wrote on last edited by
                        #11

                        @kshegunov

                        Yes it is "there" – in a rather (cough) subtle way. I see no reason why the docs are not explicit: "Not supported on OSX" or whatever, within classes like QAudioProbe – rather than in some chart – then one could tell at a glance.

                        "oh well"

                        kshegunovK 1 Reply Last reply
                        0
                        • ? A Former User

                          @kshegunov

                          Yes it is "there" – in a rather (cough) subtle way. I see no reason why the docs are not explicit: "Not supported on OSX" or whatever, within classes like QAudioProbe – rather than in some chart – then one could tell at a glance.

                          "oh well"

                          kshegunovK Offline
                          kshegunovK Offline
                          kshegunov
                          Moderators
                          wrote on last edited by
                          #12

                          I don't write the documentation, but if I had to guess, probably because it depends on the OS and the backend used (some systems have multiple backends), which may change at any one time.

                          Read and abide by the Qt Code of Conduct

                          1 Reply Last reply
                          0

                          • Login

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