Qt World Summit: Submit your Presentation

Reading an output audio device

  • Hello,

    Do you know if there is a way with Qt to play an audio device at the output. I want to duplicate the sound from one device to another device.

    Currently, if I use QAudioInput like that:

        // Get the device QAudioDeviceInfo from the given index
        q_deviceInput = list.value(index).first(); // <--- I get my QAudioDeviceInfo from a ComboBox that displays my output devices
        if (q_deviceInput.isNull())
            return false;
        if (!q_deviceInput.isFormatSupported(q_formatInput)) {
            q_formatInput = q_deviceInput.nearestFormat(q_formatInput);
        q_input = new QAudioInput(q_deviceInput, q_formatInput, this);
        // Get the device QAudioDeviceInfo from the given index
        q_deviceOutput = list.value(index).first(); // <--- I get my QAudioDeviceInfo from a ComboBox that displays my output devices
        // If device NULL
        if (q_deviceOutput.isNull())
            return false;
        q_output = new QAudioOutput(q_deviceOutput, q_formatOutput, this);

    Well it doesn't work, it takes my default input device and so I hear my microphone on my output....
    I tried replacing my QAudioInput with a QAudioOutput but I didn't get a better result, just the microphone that is no longer present.

    I can't find a way to read the data that enters my output audio device....

    I see a lot on the net that you can't read the data from an output device but what I don't understand is how Steam managed to create an audio mirror function?
    I am a user of the HTC Vive headset and, for the comfort of external users, the small Valve software (SteamVR) proposes to duplicate the sound from one device to another device so that it is not only the player with his headset that is the sound.....

    I just want to make this feature available to all my applications and not just for games.

    I hope you have all the necessary information. Thank you for your help!

  • Lifetime Qt Champion

    Hi and welcome to devnet,

    AFAIK, this is rather done at a lower level if you want that to happen for any and all application.

    See here for an example of ALSA configuration. If its for you own application, then you might consider opening several device and write your audio data to all.

  • If in Windows Vista and above:
    Capture Stream
    Loopback Recording

    Be aware that for some streams Windows applies DRM and may dynamically reduce the quality. The intent is to protect the stream from theft. Because everyone is out to steal IP... I used this a while back in a project to read currently playing audio to affect the objects in a game engine. This allowed a game to react to the music the user chose to play. I did some audio processing such as FFT:
    Actual Code
    Be aware that this was for Windows 7 so things may have changed. It might be a good starting place however.

  • Thank you very much for your answers!

    Thank you for your solution SGaist but I am under Windows and therefore the Fcarney solution is more suitable for my problem.

    It's really interesting, thank you for guiding me.

    I have always only used Qt libraries in my projects, the use of Windows libraries is possible in Qt? Is it integrated in Windows? Do I have to download the Windows 10 SDK and will my program work on Windows 7 with this SDK?

  • When I originally did this it was in Windows 7. The feature has been supported since Windows Vista. I would think if you wanted to support windows 7 you would need the Windows 7 sdk.

    At the very least you will probably need to be using MSVC. When I built my solution I was working solely in Visual Studio using a game engine. I believe you can develop windows specific features in Qt, but I have not done this yet.

    I don't know if using the Windows 10 SDK will allow development for Windows 7. I would use the Windows 7 SDK if targeting Windows 7.

  • Banned

    This post is deleted!

Log in to reply