Getting peak meters and volume settings for all apps and audio devices on the system

A few previous posts have touched on how to get peak meter readings on the device, and per-app

Let’s put it all together and write a single command-line tool which enumerates:
  1. All active audio devices (both playback and recording)
  2. Dumps the peak meter and volume levels for each device
  3. All active audio applications (audio sessions) per device
  4. Dumps the peak meter and volume levels for each audio session
Note there is no API for enumerating individual streams within a session.
Pseudocode:
For each flow in (render, capture)
For each device in IMMDeviceEnumerator::EnumAudioEndpoints(flow)
Display the name of the device
Get and display IAudioMeterInformation::GetPeakValue for the device
Get and display IAudioEndpointVolume data for the device
For each session in IAudioSessionManager2::GetSessionEnumerator
Skip the session unless the state is “active”
Get and display IAudioMeterInformation::GetPeakValue for the session
Display session information
Get and display ISimpleAudioVolume information
Get and display IChannelAudioVolume information

Sample output:

>meters.exe
— Playback devices —
Line out (High Definition Audio Device)
Peak: 0.404736
Mute: 0
Volume range: 0% to 100% (-46.5 dB to 0 dB in steps of 1.5 dB)
Master: 74% (-4.32831 dB)
Channel 1 of 2: 74% (-4.32831 dB)
Channel 2 of 2: 74% (-4.32831 dB)

Active session #1
Peak value: 0.240089
Icon path:
Display name:
Grouping parameter: {98710e41-6535-4cf0-b9b3-4181a0b7103e}
Process ID: 3496 (single-process)
Session identifier: {0.0.0.00000000}.{b3d96927-adc1-4d0f-a83d-bda63ad41843}|\Device\HarddiskVolume1\Windows\System32\WWAHost.exe%b{00000000-0000-0000-0000-000000000000}
Session instance identifier: {0.0.0.00000000}.{b3d96927-adc1-4d0f-a83d-bda63ad41843}|\Device\HarddiskVolume1\Windows\System32\WWAHost.exe%b{00000000-0000-0000-0000-000000000000}|1%b3496
System sounds session: no
Package full name: Microsoft.ZuneMusic_2.2.41.0_x64__8wekyb3d8bbwe
Master volume: 1 (0 dB FS)
Not muted
Channel #1 volume: 1 (0 dB FS)
Channel #2 volume: 1 (0 dB FS)

Active session #2
Peak value: 0.329753
Icon path:
Display name:
Grouping parameter: {fc078096-d2fc-4883-8b0d-af4619266c02}
Process ID: 6720 (multi-process)
Session identifier: {0.0.0.00000000}.{b3d96927-adc1-4d0f-a83d-bda63ad41843}|#%b{726CF207-6167-47C4-A745-55691DBD84A1}
Session instance identifier: {0.0.0.00000000}.{b3d96927-adc1-4d0f-a83d-bda63ad41843}|#%b{726CF207-6167-47C4-A745-55691DBD84A1}|1%b#
System sounds session: no
HWND: 0x00000000000D1390 Windows Media Player
Master volume: 1 (0 dB FS)
Not muted
Channel #1 volume: 1 (0 dB FS)
Channel #2 volume: 1 (0 dB FS)

Internal speakers (High Definition Audio Device)
Peak: 0
Mute: 1
Volume range: 0% to 100% (-46.5 dB to 0 dB in steps of 1.5 dB)
Master: 65.7804% (-6 dB)
Channel 1 of 1: 65.7804% (-6 dB)

— Recording devices —
Microphone (High Definition Audio Device)
Peak: 0.000274658
Mute: 0
Volume range: 0% to 100% (-34.5 dB to 12 dB in steps of 1.5 dB)
Master: 84.7652% (6 dB)
Channel 1 of 2: 84.7652% (6 dB)
Channel 2 of 2: 84.7652% (6 dB)

Active session #1
Peak value: 0.000274658
Icon path:
Display name:
Grouping parameter: {cee77f5a-d651-4392-8ffc-232c6eecdf51}
Process ID: 8212 (single-process)
Session identifier: {0.0.1.00000000}.{878a0979-89d6-43ec-9cff-e3f70dac2618}|\Device\HarddiskVolume1\Program Files\WindowsApps\Microsoft.WindowsSoundRecorder_6.3.9600.16384_x64__8wekyb3d8bbwe\soundrec.exe%b{00000000-0000-0000-0000-000000000000}
Session instance identifier: {0.0.1.00000000}.{878a0979-89d6-43ec-9cff-e3f70dac2618}|\Device\HarddiskVolume1\Program Files\WindowsApps\Microsoft.WindowsSoundRecorder_6.3.9600.16384_x64__8wekyb3d8bbwe\soundrec.exe%b{00000000-0000-0000-0000-000000000000}|1%b8212
System sounds session: no
Package full name: Microsoft.WindowsSoundRecorder_6.3.9600.16384_x64__8wekyb3d8bbwe
Master volume: 0.847652 (-1.43565 dB FS)
Not muted
Channel #1 volume: 1 (0 dB FS)
Channel #2 volume: 1 (0 dB FS)

Active session #2
Peak value: 0.000274658
Icon path:
Display name:
Grouping parameter: {c346e9e3-a37e-427b-a2be-1feb2c81b469}
Process ID: 2608 (single-process)
Session identifier: {0.0.1.00000000}.{878a0979-89d6-43ec-9cff-e3f70dac2618}|\Device\HarddiskVolume1\Windows\System32\SoundRecorder.exe%b{00000000-0000-0000-0000-000000000000}
Session instance identifier: {0.0.1.00000000}.{878a0979-89d6-43ec-9cff-e3f70dac2618}|\Device\HarddiskVolume1\Windows\System32\SoundRecorder.exe%b{00000000-0000-0000-0000-000000000000}|1%b2608
System sounds session: no
HWND: 0x00000000004611FA Sound Recorder
Master volume: 0.847652 (-1.43565 dB FS)
Not muted
Channel #1 volume: 1 (0 dB FS)
Channel #2 volume: 1 (0 dB FS)

Browse source

Download meters.exe

One thought on “Getting peak meters and volume settings for all apps and audio devices on the system

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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