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. Multichannel audio output with QAudioOutput Class

Multichannel audio output with QAudioOutput Class

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 835 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.
  • F Offline
    F Offline
    Franky01
    wrote on 20 Nov 2018, 15:49 last edited by
    #1

    Hi all,

    I am a student of electronics and mechatronics engineering and currently working on an audio project. I build a 8-channel linear speaker array as a demonstrator for speaker beamforming. I have a multichannel soundcard to handle the signal output and the input for the amplifiers.

    It's the first time I'm using Qt (on a windows system with Qt Creator), but I managed to write a working testcode. This small app outputs a simple sinewave via the QAudioOutput Class.

    As the next step, I want to output sinewaves on multiple channels at the same time.
    I red the documentation of the QAudioOutput Class, but there is just a section for setting the channel count. I didn't find any info on how to pass the multichannel buffer to the output device.

    Is it possible to use a multidimensional data array to store the data points of the sinewave in (e.g. first row of data is channel 1, second row is channel 2 and so on)?
    Or is it possible to concatenate multiple QByteArrays to one multidimensional buffer?

    Thank you.
    Kind regards, Markus.

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 20 Nov 2018, 21:35 last edited by
      #2

      Hi and welcome to devnet,

      What about writing to the QIODevice returned by the start method ?

      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
      • F Offline
        F Offline
        Franky01
        wrote on 11 Dec 2018, 17:11 last edited by
        #3

        Hi, I am back at the project again.

        What about writing to the QIODevice returned by the start method ?
        

        Yes thats how I do it. See reduced code below.

        //set audio output format unsing QAudioFormat
        //...
        //QBuffer with sine data (stored in ByteArray)
        QBuffer* input = new QBuffer(byteBuffer);
        input->open(QIODevice::ReadOnly);
        // Create an audio output with our QAudioFormat
        QAudioOutput* audio = new QAudioOutput(audioFormat, this);
        //play audio
        audio->start(input);

        The question is: if I use more than one channel, in which format do I have to send the data respectively how do I have to store multichannel data in a ByteArray?
        Is it possible to use a ByteArray for each audio channel or use a multidimensional array for the channels?
        Or do I have to concatenate the multichannel data like sample1_ch1 - sample1_ch2 - sample1_ch3 ....sample_n-ch_m in a single dimensional array?

        Thanks for your help.
        Kind regards.

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 11 Dec 2018, 20:32 last edited by
          #4

          You should interleave the audio data as required by the number of channels.

          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

          • Login

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