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 choose Output Channel to play sound with QAudioOutput

How to choose Output Channel to play sound with QAudioOutput

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 1.8k 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.
  • P Offline
    P Offline
    Pierreko
    wrote on last edited by
    #1

    Hello,

    I make a tight multi-tracks audio player on Linux and I have troubles with the output selection.

    I use a wave decoder to generate the buffer and I send it to QAudioOutput :

    QFile track("./file.wav";
    QWaveDecoder decoder = new QWaveDecoder(&m_trackFile, this);
    
    QAudioDeviceInfo info(QAudioDeviceInfo::defaultOutputDevice());
    if (!info.isFormatSupported(decoder->audioFormat())) {
            qWarning() << "Raw audio format not supported by backend, cannot play audio."<<decoder->audioFormat();
    
    QAudioOutput output = new QAudioOutput(decoder->audioFormat());
        }
    

    But because I have an external sound card (Presonus Audiobox 1818VSL), I have to choose the channel at which my (stereo) 2 channels will be sent.

    I listed the devices :

    const QAudioDeviceInfo &defaultDeviceInfo = QAudioDeviceInfo::defaultOutputDevice();
        for (auto &deviceInfo: QAudioDeviceInfo::availableDevices(QAudio::AudioOutput)) {
            if (deviceInfo != defaultDeviceInfo)
                m_audiodevices.append(deviceInfo);
        }
    

    and it returned :

    PulseAudioService: pa_context_connect() failed
    0 - "sysdefault:CARD=ALSA" (1, 2, 4, 6, 8)
    1 - "dmix:CARD=ALSA,DEV=0" (1, 2, 4, 6, 8)
    2 - "dmix:CARD=ALSA,DEV=1" (1, 2, 4, 6, 8)
    ALSA lib pcm_dsnoop.c:557:(snd_pcm_dsnoop_open) The dsnoop plugin supports only capture stream
    3 - "dsnoop:CARD=ALSA,DEV=0" ()
    ALSA lib pcm_dsnoop.c:557:(snd_pcm_dsnoop_open) The dsnoop plugin supports only capture stream
    4 - "dsnoop:CARD=ALSA,DEV=1" ()
    5 - "hw:CARD=ALSA,DEV=0" (1, 2, 4, 6, 8)
    6 - "hw:CARD=ALSA,DEV=1" (1, 2, 4, 6, 8)
    7 - "plughw:CARD=ALSA,DEV=0" (1, 2, 4, 6, 8)
    8 - "plughw:CARD=ALSA,DEV=1" (1, 2, 4, 6, 8)
    9 - "front:CARD=VSL,DEV=0" (1, 2, 4, 6, 8)
    10 - "surround21:CARD=VSL,DEV=0" (1, 2, 4, 6, 8)
    11 - "surround40:CARD=VSL,DEV=0" (1, 2, 4, 6, 8)
    12 - "surround41:CARD=VSL,DEV=0" (1, 2, 4, 6, 8)
    13 - "surround50:CARD=VSL,DEV=0" (1, 2, 4, 6, 8)
    14 - "surround51:CARD=VSL,DEV=0" (1, 2, 4, 6, 8)
    15 - "surround71:CARD=VSL,DEV=0" (1, 2, 4, 6, 8)
    16 - "iec958:CARD=VSL,DEV=0" (1, 2, 4, 6, 8)
    

    I can't understand how I can for example send a stereo sound to Output channels 3 & 4 instead of 1&2 of device 10 (surround21...) which looks like to be a configuration of my external sound card.

    Do you have a idea ?

    Thanks !

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

      Hi and welcome to devnet,

      If you’d like to make more advanced audio stuff, you will have to use something other than QtMultimedia.

      As a first step, you might be able to configure your ALSA device to be seen by QtMultimedia.

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

        What are you meaning instead of using QtMultimedia ?

        I'm not sure I understand what you said about ALSA device. I'm searching for a solution to route my audio buffer (mono or stereo) to one or 2 channels of my external sound card (which is "VSL" in the list above) but I have some difficulties to interpret the result because I was waiting for a list of channels, in fact...

        thanks :)

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

          I mean using something like PortAudio.

          As for ALSA, something like described here.

          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