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. QAudioOutput notify() doesn't emit on set interval
Forum Updated to NodeBB v4.3 + New Features

QAudioOutput notify() doesn't emit on set interval

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 2 Posters 840 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.
  • T Offline
    T Offline
    Taytoo
    wrote on last edited by
    #1

    According to several examples online about using QAudioOutput in Push mode, I have to specify an interval e.g. 100ms, and then write some data. Now once 100ms worth of audio has been processed, notify() event will be emitted and I can can queue more audio.

    The logic I'm using is to initially queue 300ms audio/pcm data (being received over network) but set notify interval to 100ms. That way once first 100ms of audio has been processed and 200ms is left in buffer, notify() will be emitted, then I'll write another 100ms of data and so on. That way there is always 200ms of data in buffer - and audio should play smoothly.

    For some reason, and I've tried in debug & release mode. This approach works fine 50% of the time, remaining time, the first notify is emitted after ALL of the 300ms initial audio has been processed and the buffer is empty so when my code queues next 100ms worth of data, it results in laggy audio because the 200ms buffer is consumed already.

    Here's a screenshot. Notice after first 115200 bytes were written, program waited for almost 300ms before notify was called and audio buffer was consumed, resulting in output state also going into Idle. Am I doing something wrong here? whats the proper way to Push data to audio device?

    OS: Windows 10, Qt: 5.12.10

    3f3a296e-1071-4f54-b7e7-c985d6e30654-image.png

    T 1 Reply Last reply
    0
    • T Taytoo

      According to several examples online about using QAudioOutput in Push mode, I have to specify an interval e.g. 100ms, and then write some data. Now once 100ms worth of audio has been processed, notify() event will be emitted and I can can queue more audio.

      The logic I'm using is to initially queue 300ms audio/pcm data (being received over network) but set notify interval to 100ms. That way once first 100ms of audio has been processed and 200ms is left in buffer, notify() will be emitted, then I'll write another 100ms of data and so on. That way there is always 200ms of data in buffer - and audio should play smoothly.

      For some reason, and I've tried in debug & release mode. This approach works fine 50% of the time, remaining time, the first notify is emitted after ALL of the 300ms initial audio has been processed and the buffer is empty so when my code queues next 100ms worth of data, it results in laggy audio because the 200ms buffer is consumed already.

      Here's a screenshot. Notice after first 115200 bytes were written, program waited for almost 300ms before notify was called and audio buffer was consumed, resulting in output state also going into Idle. Am I doing something wrong here? whats the proper way to Push data to audio device?

      OS: Windows 10, Qt: 5.12.10

      3f3a296e-1071-4f54-b7e7-c985d6e30654-image.png

      T Offline
      T Offline
      Taytoo
      wrote on last edited by
      #2

      Anyone has experience using notify() signal?

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi,

        Did you check that you actually get the interval you asked for as suggested in the setNotifyInterval documentation ?

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

        T 1 Reply Last reply
        0
        • SGaistS SGaist

          Hi,

          Did you check that you actually get the interval you asked for as suggested in the setNotifyInterval documentation ?

          T Offline
          T Offline
          Taytoo
          wrote on last edited by
          #4

          @SGaist Yes it returns the correct interval

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #5

            Do you also handle the stateChanged signal in your code ?

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

            T 1 Reply Last reply
            0
            • SGaistS SGaist

              Do you also handle the stateChanged signal in your code ?

              T Offline
              T Offline
              Taytoo
              wrote on last edited by Taytoo
              #6

              @SGaist Yes, that's where I'm just outputting "State: IdleState" or "State: ActiveState" lines

              When it works fine i.e. initial notify() is emitted after 100ms and there is still 200ms of audio data in buffer and I queue additional 100ms of data (and so on), then the state never goes to Idle and audio plays smoothly.

              Also, the program either works completely fine or delays first notify() until entire initial 300ms audio is played in which case State goes back and forth between Idle and Active, resulting in breaks in audio.

              1 Reply Last reply
              0
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #7

                Can you share your code ?

                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

                • Login

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