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. Reading an output audio device

Reading an output audio device

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 4 Posters 1.6k 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.
  • M Offline
    M Offline
    Mick_1
    wrote on last edited by Mick_1
    #1

    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);
     
     
        q_output->start(q_input->start());
    

    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!

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

      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.

      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
      2
      • fcarneyF Offline
        fcarneyF Offline
        fcarney
        wrote on last edited by
        #3

        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.

        C++ is a perfectly valid school of magic.

        1 Reply Last reply
        3
        • M Offline
          M Offline
          Mick_1
          wrote on last edited by
          #4

          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?

          1 Reply Last reply
          0
          • fcarneyF Offline
            fcarneyF Offline
            fcarney
            wrote on last edited by
            #5

            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.

            C++ is a perfectly valid school of magic.

            1 Reply Last reply
            1
            • M Offline
              M Offline
              megan1
              Banned
              wrote on last edited by
              #6
              This post is deleted!
              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