Capture audio of a single application on Windows 7 - c++

Is there a way to capture the audio outputted by only a single application, and not the system as a whole? With WASAPI I can capture the entire system audio, but I wish to only capture the audio from one application (there will be many applications, all playing audio at once.)

Detours is used for hooking. Using the lib to hook IAudioRenderClient interface, including GetBuffer and ReleaseBuffer, and read data from the buffer.

Depending on the APIs used by the application to play the audio, you could write an AppInit DLL that will wrap the built-in waveIn\waveOut functions and would pass along the audio data. I know this works with the waveIn\waveOut functions, but not sure what other audio playback interfaces there are on Windows 7 and whether they are compatible with the AppInit trick.

Related

How to capture audio on c++ UWP app with WASAPI?

I can not seem to find any tutorial on the internet for my question.
All the simple guide is not suitable for UWP.
For Example,
To use WASAPI there are these steps
enumerate devices
capture audio
play (render) audio back
But the enumerating step, The client must call CoCreateInstance. But from my understanding this function is not support in UWP. Also I failed at Line 30 when following this code.
So, I try to understand This, C++ UWP using WASAPI, But I can't find any Enumerate part and this project is very complicate for me.
It include a lot of other files (DeviceState.h, common.h)
And I failed to extract the code to create my own application.
My question is how can I capture audio on c++ UWP app with WASAPI?
If this question is too board, I will change my question to How to enumerate audio device in c++ UWP application?.
And the reason why I use WASAPI is because I want to access the data stored in the Buffer.
Edit:
For enumerating.
https://github.com/Microsoft/Windows-universal-samples/blob/7c7832e1f144e4fc836603fd70e1352024a5fe1a/Samples/WindowsAudioSession/cpp/Scenario1.xaml.cpp#L85
Yes, you can use WASAPI to do audio capturing in UWP and this is what is done in the sample you have referenced (https://github.com/Microsoft/Windows-universal-samples/tree/master/Samples/WindowsAudioSession).
For the enumeration, the main function is DeviceInformation::FindAllAsync with this selector MediaDevice::GetAudioCaptureSelector it will allow you to list the capture devices.
For the stream capturing, the main function you need is
ActivateAudioInterfaceAsync, it will allow you to create an IAudioClient from a device id (specific device) or a device class (render or capture) if you just need to use the default device.
Once you have this IAudioClient you can use it to get an IAudioClientCapture, basically the things that you have seen in the sample.

Recording audio output from application

I'm currently building a project on C++ using Visual Studio on Windows 8. This application captures video from camera and triggers some virtual animations in real-time, with some sounds being played along with the animations.
The user has the option to record the experience in video and sound. I already am able to record video, now I want to create a audio track of the sounds that are being played by the application, to later fuse both video and audio files.
So, which is the best way to record audio output from an application in windows?
Let me stress that I do NOT want to record audio from any input devices (such as a microphone), only from the application itself.
Best regards.
There is no recording of application output. If you generate audio on your own, you make a copy for the recording purposes, mix if you have multiple sources, and then use one of the APIs to produce a file depending on your preferences: directly writing a WAV file, Windows Media audio files (ASF/WMA), DriectShow, Media Foundation, third party libraries.
Real playback audio data is being mixed and sent for further playback. Sometimes you can enable loopback recording to capture fully mixed output (not just of specific application through) as if it is a capture from realtime audio input device.

How to stream raw synthesized PCM audio in C++/CX Windows 8 apps?

Simply put, I want my C++/CX XAML Windows 8 app to output continuous synthesized sound (not sound effects). However I've been looking all over the Web and I cannot figure out how to get the system feed it buffers of PCM samples (or better, have it ask me for them through callbacks) for them to be played. I would use the old waveOut* APIs, however they are banned in Store app development.
So, what is the simplest way to do this? Please note that I am not interested in playing media files (.wav, .mp3) or web audio streaming.
Thanks in advance.
You need to use WASAPI which is enabled in Windows Store apps. This article will get you started with how to use the API to render audio. One annoyance is that WASAPI devices generally don't resample for you so you'll have to be willing to go with what the device is using (probably 44.1kHz or 48kHz) or do the resampling yourself (for which you can make use of the Resampler Media Foundation transform).

Multichannel audio input using Qt/Phonon

My company is currently working on what could be called an audio analysis program which needs to process to multiple audio inputs (8 or so) in real time. This means that we need a framework that can handle multichannel audio interface devices that have up to 8 input channels. On top of this, the framework should be as portable as possible. We actually started our development using Java but it ran into issues with the sound API.
When looking for alternate ways to do what we need, I started thinking about using C++ and Qt. I have some experience with both, but I've never done anything remotely similar (in any language for that matter)
Now, the question is, can Qt/Phonon handle audio interfaces/sound cards with over 2 input channels (assuming that the OS can see the devices just fine)? Would it dependent on the backend being used?
Phonon as no input function. it's for playback only if i'm right. but if you want to process input audio you can use QAudioInput. I've used it with just one audio input but I think this constructor with the right QAudioDeviceInfo could do what you want.

Intercepting and postprocessing all audio streams on Windows

I would like to know is there any way I create an application which can intercept all the audio that is being played back on the computer, so I can process the audio (apply some effect) and then pass it further to the Windows audio subsystem?
I just had a glimpse in Vista/7 WASAPI, there is this sAPO:
http://www.microsoft.com/whdc/device/audio/sysfx.mspx
but it seems that I cannot create my sAPO and install it anywhere I like - I need a WHQL drivers for this.
Is there any universal way to do that?
I have an experience with DirectSound but I haven't seen any useful info about intercepting the audio streams.
If you're loading a custom sAPO, you're globally affecting the sound for a system. This is going to require signing. From this article:
The audio engine does not load
unsigned sAPOs into the audio
processing graph. So while you are
testing your sAPO, you must disable
the protected process for Audiodg.exe.
To disable the protected process, set
the value of the
DisableProtectedAudioDG registry key
to '1'.