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. How to write audio data while playing sound?
Forum Updated to NodeBB v4.3 + New Features

How to write audio data while playing sound?

Scheduled Pinned Locked Moved Solved General and Desktop
7 Posts 3 Posters 1.1k Views 1 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.
  • N Offline
    N Offline
    name101
    wrote on last edited by
    #1

    I want to append data to the existing buffer so that the sound comes out continuously .
    so I tried QIODevice::ReadWrite of Qbuffer's openmode but I do not hear anything.(If QIODevice::ReadOnly is work well.)

    QByteArray part;
    inputFile.open(QIODevice::ReadWrite);
    part=inputFile.read(inputFile.size()/4);
    buffer.write(part);
    audioOutput->setNotifyInterval(4000);
    connect(audioOutput,SIGNAL(notify()),this,SLOT(appendData()));
    audioOutput->start(&buffer);

    void Widget::appendData()
    {
    part=inputFile.read(inputFile.size()/4);
    buffer.write(part);
    }

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

      Hi,

      What is that buffer ?
      Where do you create it ?
      What version of Qt are you using ?
      What platform are you running Qt on ?

      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
      • N Offline
        N Offline
        name101
        wrote on last edited by
        #3

        buffer is QBuffer. version 5.11.1 and windows10.
        I just want to append data in the sound buffer while the sound is playing. Like streaming.

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

          Are you checking the state of the audioOutput object for errors ?

          On a related note, why not pass inputFile to audioOutput->start rather than passing through a 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
          -1
          • N Offline
            N Offline
            name101
            wrote on last edited by name101
            #5

            Since audioOutput returns ActiveState, it seems to be no problem.
            The reason I do not use inputfile(QFile) is to decode and play the file directly using libav(ffmpeg).

            1 Reply Last reply
            0
            • N Offline
              N Offline
              name101
              wrote on last edited by name101
              #6

              I solve it by using QDataStream. Thanks.

              1 Reply Last reply
              1
              • aha_1980A Offline
                aha_1980A Offline
                aha_1980
                Lifetime Qt Champion
                wrote on last edited by
                #7

                HI @name101

                glad you solved it. So please mark this topic as SOLVED too. Thanks

                Qt has to stay free or it will die.

                1 Reply Last reply
                2

                • Login

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