Sample – playing silence via WASAPI event-driven (pull) mode

Be vewy vewy quiet – we’we hunting wabbits.
— Elmer Fudd

This is a mini-app I’ve written to play silence to any given playback device using WASAPI event-driven (pull) mode.

Browse source

Download silence.exe

Usage statement:

>silence -?
silence -?
silence --list-devices
silence --device "Device long name"

    With no arguments, plays silence to the default audio device.
    -? prints this message.
    --list-devices displays the long names of all active playback devices.
    --device plays silence to the specified device.

>silence --list-devices
Active render endpoints found: 2
    Speakers (USB Audio Device)
    Headphones (High Definition Audio Device)

>silence --device "Headphones (High Definition Audio Device)"
Press Enter to quit...
Received stop event after 488 passes

While it’s playing it shows up in the Volume Mixer:


Why would I write such a thing?

Well, there is the pedagogical exercise of writing a WASAPI event-driven render loop.

But there is also a practical application of an active silence stream, having to do with loopback capture.  More on this in a future post…

EDIT: 7/30/2009 – fixed bug where I was treating the GetCurrentPadding value as the amount of free space in the buffer when in fact it’s the amount of used space.

While I was at it, added an icon and exited immediately on errors rather than waiting for the caller to hit Enter.

EDIT: 9/28/2015 – moved source to

One thought on “Sample – playing silence via WASAPI event-driven (pull) mode

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s