Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Unsolved Render/Play Audio buffer data

    General and Desktop
    3
    5
    1286
    Loading More Posts
    • 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.
    • S
      sankar-110 last edited by

      Hi all,
      I have an Audio buffer (PCM samples) and I need to render/play the buffer using the system speaker. How can I achieve this?
      Any help would be appreciated.

      jsulm 1 Reply Last reply Reply Quote 0
      • jsulm
        jsulm Lifetime Qt Champion @sankar-110 last edited by

        @sankar-110 What about http://doc.qt.io/qt-5/qaudiooutput.html ?

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply Reply Quote 1
        • S
          sankar-110 last edited by

          @jsulm ,
          I have checked Qaudiooutput.
          In the example mentioned they have given the source file as a "filepath".
          But my buffer is not a file, rather it is continuous data given by the PCI device.
          how do I render/play this?

          jsulm 1 Reply Last reply Reply Quote 0
          • jsulm
            jsulm Lifetime Qt Champion @sankar-110 last edited by

            @sankar-110 How exactly do you get your audio data? In which format? It does not have to be a file - it is QIODevice: http://doc.qt.io/qt-5/qaudiooutput.html#start

            https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply Reply Quote 1
            • KillerSmath
              KillerSmath last edited by KillerSmath

              @sankar-110
              You can create a object of type buffer and set the data given by the PCI device (probably a char array)

              Simple example:

                 char *bufferArray;
              
                 QBuffer buffer;
              
                 buffer.setData(bufferArray, <replace by size of bufferarray>);
              
                 // format has been declared before this line
                 QAudioOutput* audio = new QAudioOutput(format);
                 audio.start(&buffer);
              

              References:

              http://doc.qt.io/qt-5/qbuffer.html#setData-1
              http://doc.qt.io/qt-5/qbuffer.html#QBuffer-1

              @Computer Science Student - Brazil
              Web Developer and Researcher
              “Sometimes it’s the people no one imagines anything of who do the things that no one can imagine.” - Alan Turing

              1 Reply Last reply Reply Quote 2
              • First post
                Last post