A tiny Windows command‑line tool to list, get, and set the default playback (output) audio device. It uses the Windows Core Audio APIs (MMDevice) and the commonly used, but undocumented, IPolicyConfig interface to switch the default endpoint for a given role.
- List all playback devices with friendly name and device ID
- Show the current default playback device
- Set the default playback device by partial friendly name match or by full device ID
- Support for Windows audio roles: Console, Multimedia, Communications
- Windows 10/11
- MSVC toolchain (Visual Studio 2019/2022 C++ Build Tools)
- CMake 3.20+ (4.x also works)
You can build with CMake from a Developer Command Prompt for VS (or any environment where cl.exe is available):
cd path\to\simple-audio-switch
cmake -S . -B build -G "Visual Studio 17 2022" -A x64
cmake --build build --config ReleaseThe executable will be produced as build\Release\SimpleAudioSwitch.exe (or under your IDE's build directory if using CLion).
Notes:
- The project is C++20 (
set(CMAKE_CXX_STANDARD 20)). - Links against system libs
ole32anduuid(handled by CMakeLists).
Run the built executable from a regular Command Prompt. Matching by name is a substring match against the device's friendly name.
SimpleAudioSwitch.exe --list
SimpleAudioSwitch.exe --get
SimpleAudioSwitch.exe --set "Headphones" 0--listprints all playback devices as pairs of[ID]and[Name].--getprints the current default playback device.--set <pattern> [role]sets the default device.<pattern>is either a substring of the friendly name or the full device ID.role(optional) chooses which role's default is set:0= Console1= Multimedia2= Communications
Examples:
:: Set Console default to the first device whose name contains "Speakers"
SimpleAudioSwitch.exe --set "Speakers" 0
:: Set Multimedia default by exact device ID (as shown by --list)
SimpleAudioSwitch.exe --set "{0.0.0.00000000}.{d1e5...}" 1Exit codes:
0on success1COM or enumerator initialization error2no device matched the provided pattern3failure when calling SetDefaultEndpoint
- Enumerates playback devices via
IMMDeviceEnumerator::EnumAudioEndpoints. - Reads friendly names via
IPropertyStoreandPKEY_Device_FriendlyName. - Switches the default endpoint using
IPolicyConfig::SetDefaultEndpointwith the selected Windows audio role.
- Device name matching is a simple case‑sensitive substring match.
- Uses the widely known but undocumented
IPolicyConfiginterface; behavior could change in future Windows releases. - This tool only manages playback (render) devices, not recording (capture) devices.
- If the executable runs but nothing changes, confirm you selected the correct role. Windows maintains separate defaults for Console, Multimedia, and Communications.
- Some OEM software may override or react to default device changes; try setting all three roles if needed.
- If compilation fails with missing
atlbase.h, ensure the "C++ ATL for latest v142/v143 build tools" component is installed with Visual Studio. The project usesCComPtrfrom ATL headers only (no ATL libs are linked).
Apache License 2.0. See the LICENSE file for the full text. If you distribute binaries or modifications, include a copy of the license and preserve attribution notices as required by the Apache-2.0 terms.
- Windows Core Audio (MMDevice) API documentation
- Community knowledge around
IPolicyConfigfor default endpoint switching