Windows Audio Session (WASAPI) rendering sample
This sample demonstrates rendering audio data using the Windows Audio Session API (WASAPI).
The sample renders audio in shared mode using the event driven programming model.
The following additional features are demonstrated:
- Using
IAudioViewManagerService
to associate the audio stream with a window. If you do not explicitly associate the stream with a window, the system will try to guess which window to use. Use the-w
command line option to associate the audio stream with the console window.
Support for the IAudioViewManagerService
interface requires SDK version 10.0.22470.0 or higher.
Sample language
C++ with the C++/WinRT library
Sample structure
The main program is in WASAPIRendering.cpp
.
It parses the command line and uses a CWASAPIRenderer
object
to perform the rendering.
The CWASAPIRenderer
is implemented in WASAPIRenderer.cpp
.
It uses WASAPI to render a buffer containing audio data.
The audio samples are generated by ToneGen.h
.
The command line parser is in CmdLine.cpp
Related samples
More audio samples can be found in the Samples/Win7Samples/multimedia/audio
directory.
To build the sample using Visual Studio
- Load the .sln (solution) file into Visual Studio.
- In the Build menu, select Build Solution. The application will be built in the default \Debug or \Release directory
To run the sample
Go to the build output directory and type wasapirendering.exe
.
You can add the -?
flag to see command line options.