I'm looking for the current actual output levels, not what the volume is set to.
Ideally this would be a command-line tool, but if there's so way I could generate one myself with APIs, that would also be acceptable.
I'm looking for the current actual output levels, not what the volume is set to.
Ideally this would be a command-line tool, but if there's so way I could generate one myself with APIs, that would also be acceptable.
I kept searching and was able to cobble together a command-line app to do this myself:
using System; using System.Collections.Generic; using CSCore.CoreAudioAPI; using System.Diagnostics; using System.Web.Script.Serialization; namespace VolumeLevel { class Program { static void Main(string[] args) { using (var sessionManager = GetDefaultAudioSessionManager2(DataFlow.Render)) { using (var sessionEnumerator = sessionManager.GetSessionEnumerator()) { IDictionary<string, float> procs = new Dictionary<string, float>(); foreach (var session in sessionEnumerator) { using (var audioMeterInformation = session.QueryInterface<AudioMeterInformation>()) using (var session2 = session.QueryInterface<AudioSessionControl2>()) { if (session2.ProcessID > 0 && audioMeterInformation != null) procs[session2.Process.MainWindowTitle] = audioMeterInformation.GetPeakValue(); } } if (procs.Count > 0) { Console.WriteLine(new JavaScriptSerializer().Serialize(procs)); } else { Console.WriteLine("{}"); } Environment.Exit(0); } } } private static AudioSessionManager2 GetDefaultAudioSessionManager2(DataFlow dataFlow) { using (var enumerator = new MMDeviceEnumerator()) { using (var device = enumerator.GetDefaultAudioEndpoint(dataFlow, Role.Multimedia)) { Debug.WriteLine("DefaultDevice: " + device.FriendlyName); var sessionManager = AudioSessionManager2.FromMMDevice(device); return sessionManager; } } } } } The output will be something like this:
{"Spotify Premium":0.8345225} This requires the CSCore library, which you can get here, and you'll need to add a reference to System.Web.Extensions for the JSON output.
As there are no such programs for this task, I compiled a program written by ultimatebrent.
You can download it here: https://github.com/TheTitanrain/wov/releases