获取单个的Windows应用程序当前的音量输出电平为音频混音器可视化 [英] Getting individual windows application current volume output level as visualized in audio Mixer
问题描述
我试图写一个C#code(如图所示的音量调音台的不断变化的绿线)的输出从每个窗口应用程序访问声音输出的电流音频输出电平。
I am trying to write a C# code that outputs the current audio output level from each of the windows application accessing the sound output (as shown with constantly changing green bars of the Volume mixer).
该程序将检查每10毫秒,输出某事像这样:Windows媒体播放器:30,Mozilla Firefox浏览器:0的Adobe Flash Player 35(按图)
The program will check every 10 ms, and outputs sth like this: Windows Media Player: 30, Mozilla Firefox: 0, Adobe Flash Player: 35 (as per the figure)
我使用Windows 7,并在C#中尝试它(如Java无法做到这一点)。
I am using Windows 7, and trying it in C# (as Java cannot achieve this).
我已经找到了获取和设置主音量(车把,显示65%的Windows Media Player)的运行的应用程序,有没有办法让绿色波动级别的数据?
I have found ways to get and set the Master Volume (the handle bar which shows 65% for Windows Media Player) for a running application, is there a way to get the green fluctuating level data?
感谢您!
推荐答案
您可以使用 CSCore 。
没有为CoreAudioAPI-Audiosessions的包装。使用类似的东西(详情看一看的单元测试代码:<一href=\"http://cscore.$c$cplex.com/SourceControl/latest#CSCore.Test/CoreAudioAPI/AudioSessionTests.cs\">AudioSession-UnitTests):
private static void Main(string[] args)
{
using (var sessionManager = GetDefaultAudioSessionManager2(DataFlow.Render))
{
using (var sessionEnumerator = sessionManager.GetSessionEnumerator())
{
foreach (var session in sessionEnumerator)
{
using (var audioMeterInformation = session.QueryInterface<AudioMeterInformation>())
{
Console.WriteLine(audioMeterInformation.GetPeakValue());
}
}
}
}
Console.ReadKey();
}
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;
}
}
}
要控制的应用程序数量,看看这里的单元测试:<一href=\"http://cscore.$c$cplex.com/SourceControl/latest#CSCore.Test/CoreAudioAPI/AudioSessionTests.cs\">http://cscore.$c$cplex.com/SourceControl/latest#CSCore.Test/CoreAudioAPI/AudioSessionTests.cs
To control an applications volume, take a look at the unit-tests here: http://cscore.codeplex.com/SourceControl/latest#CSCore.Test/CoreAudioAPI/AudioSessionTests.cs
这篇关于获取单个的Windows应用程序当前的音量输出电平为音频混音器可视化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!