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. Real time audio processing with Qt5, general concept
QtWS25 Last Chance

Real time audio processing with Qt5, general concept

Scheduled Pinned Locked Moved General and Desktop
12 Posts 4 Posters 6.3k 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.
  • SGaistS Offline
    SGaistS Offline
    SGaist
    Lifetime Qt Champion
    wrote on last edited by
    #2

    Hi and welcome to devnet,

    Can you elaborate on what you mean by "real time audio processing" ?

    Also which OS are you targeting ?

    By the way it's Qt, QT stands for Apple QuickTime which in this case could be confusing.

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

      "Qt": My bad! ;)

      I basicly want to program a little synthesizer. Like I said, what would be cool is if the program requests samples wich get processed by another libary. This part should be quite easy since there are multiple cool DSP libarys out there.

      I have to work out the details but the Synth should response quite quickly to User imput, I think of a buffer around 100-500 milliseconds for the start.

      So what I had in mind is something like this: (I neve did real time audio stuff before so this is what I came up with and propably totaly unefficient..)

      • the processing-function generates 1 sample at a time which get pushed into the buffer
      • this process is repeated until the buffer is full
      • when the buffer is half empty (for example), it sends a signal to a function which repeats the whole thing

      I am currently targeting windows, however the software I have in mind would work best on mobile devies. The project Is part of a curse in my studies and my prof would like to see the applications run on multiple platforms (esp one mobile)

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

        For such requirements you should rather use a dedicated library like portaudio. You can still to the GUI with Qt, but the Qt audio classes are not designed to do real time audio processing.

        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
        • R Offline
          R Offline
          RuhigBrauner
          wrote on last edited by
          #5

          Hi!

          Isn't Qt suitable for this because there is no "interface" for me to connect or is it more about performance? Not using Qt would realy limit me, I think...

          Thanks for your help. ;)

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

            You can use Qt without any problem, but the audi real time part will require additional libraries like port audio (really easy to integrate by the way)

            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
            • JKSHJ Offline
              JKSHJ Offline
              JKSH
              Moderators
              wrote on last edited by
              #7

              Hi,

              If you want to do real-time processing, you can use

              QAudioInput to acquire PCM samples, OR a 3rd-party decoder to convert your file into PCM samples

              A 3rd-party DSP library to process the samples

              QAudioOutput to play back the processed samples

              See the "Spectrum Example":http://qt-project.org/doc/qt-5/qtmultimedia-spectrum-example.html for some ideas.

              [quote author="RuhigBrauner" date="1396906352"]- the processing-function generates 1 sample at a time which get pushed into the buffer[/quote]You might find that 1 sample at a time is inefficient. Write the buffer in chunks instead (for example, process 512 samples and output 512 samples at a time). Your system's audio backend will have its own internal buffer that is separate from the QAudioOutput buffer.

              Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

              1 Reply Last reply
              0
              • R Offline
                R Offline
                RuhigBrauner
                wrote on last edited by
                #8

                Hi,

                JKSH, thats what I had in mind as well. But right now, I don't realy know how to actually push samples to AudioOutput. I mean, there is no realy way to playback samples other than using files, right? (QIODevice pointer)

                The example is a bit large to start with I think. But it looks like It uses AudioBuffer and AudioOutput in combination, right? But how?

                "1 sample at a time". I just wasn't sure where to collect them before sending them over to the Audio Device. ;)

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

                  QtMultimedia uses the OS audio system, which means on Windows it's not realtime (and depending on what you use, you don't get what you asked for). Maybe low-latency would be a better term for this part of the discussion. Thus using something like portaudio which as support of ASIO would be better for the acquisition-playback part.

                  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
                  • JKSHJ Offline
                    JKSHJ Offline
                    JKSH
                    Moderators
                    wrote on last edited by
                    #10

                    See the QAudioOutput documentation for a shorter example: http://qt-project.org/doc/qt-5/qaudiooutput.html

                    The QIODevice is your buffer. You write your samples into the QIODevice, and QAudioOutput will read from it.

                    Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                    1 Reply Last reply
                    0
                    • R Offline
                      R Offline
                      RuhigBrauner
                      wrote on last edited by
                      #11

                      Hi,

                      I noticed this way as well and I guess it would work. I decided to focus on windows for right now and add android support later on. So I am free to use portaudio now and it's way easier than working with QAudioOutput. (At least for my level of knowledge ;) )

                      But thanks for the help!

                      1 Reply Last reply
                      0
                      • C Offline
                        C Offline
                        Camillo
                        wrote on last edited by
                        #12

                        Hi,
                        I suggest you following library:
                        http://audiere.sourceforge.net/home.php
                        I already used that library for a synthesizer in a Qt application.
                        It is very small, fast and easy to use.

                        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