Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

How to choose Output Channel to play sound with QAudioOutput



  • 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 !


  • Lifetime Qt Champion

    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.



  • 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 :)


  • Lifetime Qt Champion

    I mean using something like PortAudio.

    As for ALSA, something like described here.


Log in to reply